We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 10bcbf45 authored by rikterbeek's avatar rikterbeek

implemented notificaiton handler, cronjob and Adyen CC with CSE integration

parent a0baf50a
<?php
namespace Adyen\Payment\Api\Data;
interface NotificationInterface
{
/**#@+
* Constants for keys of data array. Identical to the name of the getter in snake case.
*/
/*
* Entity ID.
*/
const ENTITY_ID = 'entity_id';
/*
* Pspreference.
*/
const PSPREFRENCE = 'pspreference';
/*
* Merchantreference
*/
const MERCHANT_REFERENCE = 'merchant_reference';
/*
* Eventcode
*/
const EVENT_CODE = 'event_code';
/*
* Success
*/
const SUCCESS = 'success';
/*
* Paymentmethod
*/
const PAYMENT_METHOD = 'payment_method';
/*
* Amount value
*/
const AMOUNT_VALUE = 'amount_value';
/*
* Amount currency
*/
const AMOUNT_CURRENCY = 'amount_currency';
/*
* reason
*/
const REASON = 'reason';
/*
* Live
*/
const LIVE = 'live';
/*
* Additional data
*/
const ADDITIONAL_DATA = 'additional_data';
/*
* Created-at timestamp.
*/
const CREATED_AT = 'created_at';
/*
* Updated-at timestamp.
*/
const UPDATED_AT = 'updated_at';
/**
* Gets the ID for the notification.
*
* @return int|null Entity ID.
*/
public function getEntityId();
/**
* Sets entity ID.
*
* @param int $entityId
* @return $this
*/
public function setEntityId($entityId);
/**
* Gets the Pspreference for the notification.
*
* @return int|null Pspreference.
*/
public function getPspreference();
/**
* Sets Pspreference.
*
* @param string $pspreference
* @return $this
*/
public function setPspreference($pspreference);
/**
* Gets the Merchantreference for the notification.
*
* @return int|null MerchantReference.
*/
public function getMerchantReference();
/**
* Sets MerchantReference.
*
* @param string $merchantReference
* @return $this
*/
public function setMerchantReference($merchantReference);
/**
* Gets the Eventcode for the notification.
*
* @return int|null Eventcode.
*/
public function getEventCode();
/**
* Sets EventCode.
*
* @param string $eventCode
* @return $this
*/
public function setEventCode($eventCode);
/**
* Gets the success for the notification.
*
* @return int|null Success.
*/
public function getSucess();
/**
* Sets Success.
*
* @param boolean $success
* @return $this
*/
public function setSuccess($success);
/**
* Gets the Paymentmethod for the notification.
*
* @return int|null PaymentMethod.
*/
public function getPaymentMethod();
/**
* Sets PaymentMethod.
*
* @param string $paymentMethod
* @return $this
*/
public function setPaymentMethod($paymentMethod);
/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
public function getAmountValue();
/**
* Sets AmountValue.
*
* @param string $amountValue
* @return $this
*/
public function setAmountValue($amountValue);
/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
public function getAmountCurency();
/**
* Sets AmountCurrency.
*
* @param string $amountCurrency
* @return $this
*/
public function setAmountCurrency($amountCurrency);
/**
* Gets the Reason for the notification.
*
* @return int|null Reason.
*/
public function getReason();
/**
* Sets Reason.
*
* @param string $reason
* @return $this
*/
public function setReason($reason);
/**
* Gets the AdditionalData for the notification.
*
* @return int|null AdditionalData.
*/
public function getAdditionalData();
/**
* Sets AdditionalData.
*
* @param string $additionalData
* @return $this
*/
public function setAddtionalData($additionalData);
/**
* Gets the Done for the notification.
*
* @return int|null Done.
*/
public function getDone();
/**
* Sets Done.
*
* @param string $done
* @return $this
*/
public function setDone($done);
/**
* Gets the created-at timestamp for the notification.
*
* @return string|null Created-at timestamp.
*/
public function getCreatedAt();
/**
* Sets the created-at timestamp for the notification.
*
* @param string $createdAt timestamp
* @return $this
*/
public function setCreatedAt($createdAt);
/**
* Gets the updated-at timestamp for the notification.
*
* @return string|null Updated-at timestamp.
*/
public function getUpdatedAt();
/**
* Sets the updated-at timestamp for the notification.
*
* @param string $timestamp
* @return $this
*/
public function setUpdatedAt($timestamp);
}
\ No newline at end of file
<?php
/**
* Field renderer for PayPal merchant country selector
*/
namespace Adyen\Payment\Block\Adminhtml\System\Config\Field;
class Version extends \Magento\Config\Block\System\Config\Form\Field
{
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
// TODO: make dynamic
//$configVer = $this->moduleList->getOne($moduleName)['setup_version'];
return (string) "0.1.0";
}
}
\ No newline at end of file
......@@ -5,6 +5,14 @@ namespace Adyen\Payment\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action
{
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
{
$this->_objectManager = $objectManager;
}
public function execute()
{
echo 'test';die();
......
<?php
namespace Adyen\Payment\Controller\Process;
use Symfony\Component\Config\Definition\Exception\Exception;
/**
* Class Json
* @package Adyen\Payment\Controller\Process
*/
class Cron extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager;
/**
* @var \Magento\Framework\Controller\Result\RawFactory
*/
protected $_resultFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
*/
public function __construct(
\Magento\Framework\App\Action\Context $context
) {
parent::__construct($context);
$this->_objectManager = $context->getObjectManager();
$this->_resultFactory = $context->getResultFactory();
}
/**
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function execute()
{
$cron = $this->_objectManager->create('Adyen\Payment\Model\Cron');
$cron->processNotification();
die();
}
}
\ No newline at end of file
<?php
namespace Adyen\Payment\Controller\Process;
class Index extends \Magento\Framework\App\Action\Action
{
public function execute()
{
echo 'test';die();
$this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
}
}
\ No newline at end of file
<?php
namespace Adyen\Payment\Controller\Process;
use Symfony\Component\Config\Definition\Exception\Exception;
/**
* Class Json
* @package Adyen\Payment\Controller\Process
*/
class Json extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager;
/**
* @var \Magento\Framework\Controller\Result\RawFactory
*/
protected $_resultFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
*/
public function __construct(
\Magento\Framework\App\Action\Context $context
) {
parent::__construct($context);
$this->_objectManager = $context->getObjectManager();
$this->_resultFactory = $context->getResultFactory();
}
/**
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function execute()
{
//TODO validate the notification with authentication!!
// check duplicates
try {
// $notificationItems = json_decode(file_get_contents('php://input'), true);
$notificationItems = json_decode('{"live":"false","notificationItems":[{"NotificationRequestItem":{"additionalData":{"expiryDate":"12\/2012"," NAME1 ":"VALUE1","authCode":"1234","cardSummary":"7777","totalFraudScore":"10","hmacSignature":"yGnVWLP+UcpqjHTJbO5IUkG4ZdIk3uHCu62QAJvbbyg=","NAME2":" VALUE2 ","fraudCheck-6-ShopperIpUsage":"10"},"amount":{"currency":"EUR","value":10100},"eventCode":"AUTHORISATION","eventDate":"2015-09-11T13:53:21+02:00","merchantAccountCode":"MagentoMerchantByteShop1","merchantReference":"000000023","operations":["CANCEL","CAPTURE","REFUND"],"paymentMethod":"visa","pspReference":"test_AUTHORISATION_1","reason":"1234:7777:12\/2012","success":"true"}}]}', true);
$notificationMode = isset($notificationItems['live']) ? $notificationItems['live'] : "";
if($notificationMode != "" && $this->_validateNotificationMode($notificationMode))
{
foreach($notificationItems['notificationItems'] as $notificationItem)
{
$status = $this->_processNotification($notificationItem['NotificationRequestItem']);
if($status == "401"){
$this->_return401();
return;
}
}
$this->getResponse()
->clearHeader('Content-Type')
->setHeader('Content-Type', 'text/html')
->setBody("[accepted]");
return;
} else
{
if($notificationMode == "") {
$this->_return401();
return;
}
throw new \Magento\Framework\Exception\LocalizedException(__('Mismatch between Live/Test modes of Magento store and the Adyen platform'));
}
} catch (Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
}
}
/**
* @param $notificationMode
* @return bool
*/
protected function _validateNotificationMode($notificationMode)
{
// $mode = $this->_getConfigData('demoMode');
// if ($mode=='Y' && $notificationMode == "false" || $mode=='N' && $notificationMode == 'true') {
// return true;
// }
// return false;
return true;
}
/**
* $desc save notification into the database for cronjob to execute notificaiton
* @param $response
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _processNotification($response)
{
try {
$notification = $this->_objectManager->create('Adyen\Payment\Model\Notification');
if(isset($response['pspReference'])) {
$notification->setPspreference($response['pspReference']);
}
if(isset($response['merchantReference'])) {
$notification->setMerchantReference($response['merchantReference']);
}
if(isset($response['eventCode'])) {
$notification->setEventCode($response['eventCode']);
}
if(isset($response['success'])) {
$notification->setSuccess($response['success']);
}
if(isset($response['paymentMethod'])) {
$notification->setPaymentMethod($response['paymentMethod']);
}
if(isset($response['amount'])) {
$notification->setAmountValue($response['amount']['value']);
$notification->setAmountCurrency($response['amount']['currency']);
}
if(isset($response['reason'])) {
$notification->setReason($response['reason']);
}
if(isset($response['additionalData'])) {
$notification->setAddtionalData(serialize($response['additionalData']));
}
if(isset($response['done'])) {
$notification->setDone($response['done']);
}
$notification->save();
} catch(Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
}
}
/**
*
*/
protected function _return401()
{
$this->getResponse()->setHttpResponseCode(401);
}
}
\ No newline at end of file
......@@ -36,11 +36,11 @@ class Redirect extends \Magento\Framework\App\Action\Action
* @param \Magento\Customer\Model\Session $customerSession
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Customer\Model\Session $customerSession
\Magento\Framework\App\Action\Context $context
// \Magento\Customer\Model\Session $customerSession
) {
parent::__construct($context);
$this->_customerSession = $customerSession;
// $this->_customerSession = $customerSession;
}
......
......@@ -13,6 +13,27 @@ use Magento\Framework\App\Helper\AbstractHelper;
class Data extends AbstractHelper
{
/**
* Core store config
*
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $_scopeConfig;
/**
* @param Context $context
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
)
{
parent::__construct($context);
$this->_scopeConfig = $scopeConfig;
}
public function getRecurringTypes() {
return [
......@@ -22,4 +43,153 @@ class Data extends AbstractHelper
];
}
public function getModes() {
return [
'1' => 'Test Mode',
'0' => 'Production Mode'
];
}
public function getCaptureModes() {
return [
'auto' => 'immediate',
'manual' => 'manual'
];
}
/**
* Return the formatted currency. Adyen accepts the currency in multiple formats.
* @param $amount
* @param $currency
* @return string
*/
public function formatAmount($amount, $currency)
{
switch($currency) {
case "JPY":
case "IDR":
case "KRW":
case "BYR":
case "VND":
case "CVE":
case "DJF":
case "GNF":
case "PYG":
case "RWF":
case "UGX":
case "VUV":
case "XAF":
case "XOF":
case "XPF":
case "GHC":
case "KMF":
$format = 0;
break;
case "MRO":
$format = 1;
break;
case "BHD":
case "JOD":
case "KWD":
case "OMR":
case "LYD":
case "TND":
$format = 3;
break;
default:
$format = 2;
break;
}
return number_format($amount, $format, '', '');
}
/**
* Street format
* @param type $address
* @return array
*/
public function getStreet($address)
{
if (empty($address)) return false;
$street = self::formatStreet($address->getStreet());
$streetName = $street['0'];
unset($street['0']);
// $streetNr = implode('',$street);
$streetNr = implode(' ',$street);
return (array('name' => $streetName, 'house_number' => $streetNr));
}
/**
* Fix this one string street + number
* @example street + number
* @param type $street
* @return type $street
*/
static public function formatStreet($street)
{
if (count($street) != 1) {
return $street;
}
preg_match('/((\s\d{0,10})|(\s\d{0,10}\w{1,3}))$/i', $street['0'], $houseNumber, PREG_OFFSET_CAPTURE);
if(!empty($houseNumber['0'])) {
$_houseNumber = trim($houseNumber['0']['0']);
$position = $houseNumber['0']['1'];
$streeName = trim(substr($street['0'], 0, $position));
$street = array($streeName,$_houseNumber);
}
return $street;
}
public function getAdyenAbstractConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_abstract', $storeId);
}
public function getAdyenAbstractConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_abstract', $storeId, true);
}
public function getAdyenCcConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_cc', $storeId);
}
public function getAdyenCcConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_cc', $storeId, true);
}
public function getAdyenHppConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_hpp', $storeId);
}
public function getAdyenHppConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_hpp', $storeId, true);
}
/**
* Retrieve information from payment configuration
*
* @param string $field
* @param int|string|null|\Magento\Store\Model\Store $storeId
*
* @return mixed
*/
public function getConfigData($field, $paymentMethodCode, $storeId, $flag = false)
{
$path = 'payment/' . $paymentMethodCode . '/' . $field;
if(!$flag) {
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} else {
return $this->_scopeConfig->isSetFlag($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
}
}
\ No newline at end of file
<?php
namespace Adyen\Payment\Logger;
use Monolog\Logger;
class AdyenLogger extends Logger
{
/**
* Adds a log record.
*
* @param integer $level The logging level
* @param string $message The log message
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function addRecord($level, $message, array $context = [])
{
$context['is_exception'] = $message instanceof \Exception;
return parent::addRecord($level, $message, $context);
}
}
\ No newline at end of file
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Adyen\Payment\Logger\Handler;
use Magento\Framework\Filesystem\DriverInterface;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
class AdyenDebug extends StreamHandler
{
/**
* @var string
*/
protected $fileName = '/var/log/adyen/debug.log';
/**
* @var int
*/
protected $loggerType = Logger::DEBUG;
/**
* @var DriverInterface
*/
protected $filesystem;
/**
* @param DriverInterface $filesystem
* @param string $filePath
*/
public function __construct(
DriverInterface $filesystem,
$filePath = null
) {
$this->filesystem = $filesystem;
parent::__construct(
$filePath ? $filePath . $this->fileName : BP . $this->fileName,
$this->loggerType
);
$this->setFormatter(new LineFormatter(null, null, true));
}
/**
* @{inheritDoc}
*
* @param $record array
* @return void
*/
public function write(array $record)
{
$logDir = $this->filesystem->getParentDirectory($this->url);
if (!$this->filesystem->isDirectory($logDir)) {
$this->filesystem->createDirectory($logDir, 0777);
}
parent::write($record);
}
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Adyen\Payment\Model;
use Magento\Payment\Model\CcGenericConfigProvider;
use Magento\Payment\Helper\Data as PaymentHelper;
class AdyenCcConfigProvider extends CcGenericConfigProvider
{
/**
* @var Config
*/
protected $config;
/**
* @var string[]
*/
protected $methodCodes = [
\Adyen\Payment\Model\Method\Cc::METHOD_CODE
];
/**
* @var \Magento\Payment\Model\Method\AbstractMethod[]
*/
protected $methods = [];
/**
* @var PaymentHelper
*/
protected $paymentHelper;
protected $adyenHelper;
/**
* @param CcConfig $ccConfig
* @param PaymentHelper $paymentHelper
* @param array $methodCodes
*/
public function __construct(
\Magento\Payment\Model\CcConfig $ccConfig,
PaymentHelper $paymentHelper,
\Adyen\Payment\Helper\Data $adyenHelper
) {
parent::__construct($ccConfig, $paymentHelper, $this->methodCodes);
$this->adyenHelper = $adyenHelper;
}
public function getConfig()
{
$config = parent::getConfig();
$demoMode = $this->adyenHelper->getAdyenAbstractConfigDataFlag('demo_mode');
if($demoMode) {
$cseKey = $this->adyenHelper->getAdyenCcConfigData('cse_publickey_test');
} else {
$cseKey = $this->adyenHelper->getAdyenCcConfigData('cse_publickey_live');
}
$cseEnabled = $this->adyenHelper->getAdyenCcConfigDataFlag('cse_enabled');
$config['payment'] ['adyenCc']['cseKey'] = $cseKey;
$config['payment'] ['adyenCc']['cseEnabled'] = $cseEnabled;
$config['payment'] ['adyenCc']['cseEnabled'] = $cseEnabled;
$config['payment']['adyenCc']['generationTime'] = date("c");
return $config;
}
}
\ No newline at end of file
......@@ -12,17 +12,20 @@ class PaymentRequest extends \Magento\Framework\Object
protected $_code;
protected $_logger;
protected $_encryptor;
protected $_adyenHelper;
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
array $data = []
) {
$this->_scopeConfig = $scopeConfig;
$this->_logger = $logger;
$this->_encryptor = $encryptor;
$this->_code = "adyen_cc";
$this->_adyenHelper = $adyenHelper;
}
/**
......@@ -33,51 +36,85 @@ class PaymentRequest extends \Magento\Framework\Object
*
* @return mixed
*/
public function getConfigData($field, $storeId = null)
public function getConfigData($field, $paymentMethodCode = "adyen_abstract", $storeId = null)
{
if (null === $storeId) {
$storeId = $this->getStore();
}
$path = 'payment/' . $this->_code . '/' . $field;
// $this->_code to get current methodcode
$path = 'payment/' . $paymentMethodCode . '/' . $field;
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
public function fullApiRequest($merchantAccount, $payment)
public function fullApiRequest($payment)
{
$order = $payment->getOrder();
$amount = $order->getGrandTotal();
$customerEmail = $order->getCustomerEmail();
$shopperIp = $order->getRemoteIp();
$orderCurrencyCode = $order->getOrderCurrencyCode();
$merchantAccount = $this->getConfigData("merchant_account");
if($order) {
$this->_logger->critical("TEST5!!:" . print_r($order->getIncrementId(), true));
}
$this->_logger->critical("CLASS OBJECT:" . get_class($payment));
$this->_logger->critical("fullApiRequest1 ");
$request = array(
"action" => "Payment.authorise",
"paymentRequest.merchantAccount" => $merchantAccount,
"paymentRequest.amount.currency" => "EUR",
"paymentRequest.amount.value" => "199",
"paymentRequest.amount.currency" => $orderCurrencyCode,
"paymentRequest.amount.value" => $this->_adyenHelper->formatAmount($amount, $orderCurrencyCode),
"paymentRequest.reference" => $order->getIncrementId(),
"paymentRequest.shopperIP" => "ShopperIPAddress",
"paymentRequest.shopperEmail" => "TheShopperEmailAddress",
"paymentRequest.shopperReference" => "YourReference",
"paymentRequest.fraudOffset" => "0",
"paymentRequest.card.billingAddress.street" => "Simon Carmiggeltstraat",
"paymentRequest.card.billingAddress.postalCode" => "1011 DJ",
"paymentRequest.card.billingAddress.city" => "Amsterdam",
"paymentRequest.card.billingAddress.houseNumberOrName" => "6-50",
"paymentRequest.card.billingAddress.stateOrProvince" => "",
"paymentRequest.card.billingAddress.country" => "NL",
"paymentRequest.card.expiryMonth" => $payment->getCcExpMonth(),
"paymentRequest.card.expiryYear" => $payment->getCcExpYear(),
"paymentRequest.card.holderName" => $payment->getCcOwner(),
"paymentRequest.card.number" => $payment->getCcNumber(),
"paymentRequest.card.cvc" => $payment->getCcCid(),
"paymentRequest.shopperIP" => $shopperIp,
"paymentRequest.shopperEmail" => $customerEmail,
"paymentRequest.shopperReference" => $order->getIncrementId(),
"paymentRequest.fraudOffset" => "0"
);
$billingAddress = $order->getBillingAddress();
if($billingAddress)
{
$addressArray = $this->_adyenHelper->getStreet($billingAddress);
$requestBilling = array("paymentRequest.card.billingAddress.street" => $addressArray['name'],
"paymentRequest.card.billingAddress.postalCode" => $billingAddress->getPostcode(),
"paymentRequest.card.billingAddress.city" => $billingAddress->getCity(),
"paymentRequest.card.billingAddress.houseNumberOrName" => $addressArray['house_number'],
"paymentRequest.card.billingAddress.stateOrProvince" => $billingAddress->getRegionCode(),
"paymentRequest.card.billingAddress.country" => $billingAddress->getCountryId()
);
$request = array_merge($request, $requestBilling);
}
$deliveryAddress = $order->getDeliveryAddress();
if($deliveryAddress)
{
$addressArray = $this->_adyenHelper->getStreet($deliveryAddress);
$requestDelivery = array("paymentRequest.card.billingAddress.street" => $addressArray['name'],
"paymentRequest.card.billingAddress.postalCode" => $deliveryAddress->getPostcode(),
"paymentRequest.card.billingAddress.city" => $deliveryAddress->getCity(),
"paymentRequest.card.billingAddress.houseNumberOrName" => $addressArray['house_number'],
"paymentRequest.card.billingAddress.stateOrProvince" => $deliveryAddress->getRegionCode(),
"paymentRequest.card.billingAddress.country" => $deliveryAddress->getCountryId()
);
$request = array_merge($request, $requestDelivery);
}
// TODO get CSE setting
$cseEnabled = true;
if($cseEnabled) {
$request['paymentRequest.additionalData.card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data");
} else {
$requestCreditCardDetails = array("paymentRequest.card.expiryMonth" => $payment->getCcExpMonth(),
"paymentRequest.card.expiryYear" => $payment->getCcExpYear(),
"paymentRequest.card.holderName" => $payment->getCcOwner(),
"paymentRequest.card.number" => $payment->getCcNumber(),
"paymentRequest.card.cvc" => $payment->getCcCid(),
);
$request = array_merge($request, $requestCreditCardDetails);
}
$this->_logger->critical("fullApiRequest");
$this->_logger->critical(print_r($request, true));
......@@ -87,7 +124,8 @@ class PaymentRequest extends \Magento\Framework\Object
protected function _apiRequest($request) {
$webserviceUsername = $this->getConfigData("webservice_username");
// TODO make differents between test and live
$webserviceUsername = $this->getConfigData("ws_username_test");
$webservicePassword = $this->decryptPassword($this->getConfigData("webservice_password")); // DECODE!!
$ch = curl_init();
......
<?php
namespace Adyen\Payment\Model\Config\Source;
/**
* Order Statuses source model
*/
class Cancelled extends \Magento\Sales\Model\Config\Source\Order\Status
{
/**
* @var string[]
*/
protected $_stateStatuses = [
\Magento\Sales\Model\Order::STATE_CANCELED
];
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Order Statuses source model
*/
namespace Adyen\Payment\Model\Config\Source;
class CaptureMode implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Magento\Sales\Model\Order\Config
*/
protected $_orderConfig;
protected $_adyenHelper;
/**
* @param \Magento\Sales\Model\Order\Config $orderConfig
*/
public function __construct(
\Magento\Sales\Model\Order\Config $orderConfig,
\Adyen\Payment\Helper\Data $adyenHelper
)
{
$this->_orderConfig = $orderConfig;
$this->_adyenHelper = $adyenHelper;
}
/**
* @return array
*/
public function toOptionArray()
{
$recurringTypes = $this->_adyenHelper->getCaptureModes();
foreach ($recurringTypes as $code => $label) {
$options[] = ['value' => $code, 'label' => $label];
}
return $options;
}
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Order Statuses source model
*/
namespace Adyen\Payment\Model\Config\Source;
class DemoMode implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Magento\Sales\Model\Order\Config
*/
protected $_orderConfig;
protected $_adyenHelper;
/**
* @param \Magento\Sales\Model\Order\Config $orderConfig
*/
public function __construct(
\Magento\Sales\Model\Order\Config $orderConfig,
\Adyen\Payment\Helper\Data $adyenHelper
)
{
$this->_orderConfig = $orderConfig;
$this->_adyenHelper = $adyenHelper;
}
/**
* @return array
*/
public function toOptionArray()
{
$recurringTypes = $this->_adyenHelper->getModes();
foreach ($recurringTypes as $code => $label) {
$options[] = ['value' => $code, 'label' => $label];
}
return $options;
}
}
<?php
namespace Adyen\Payment\Model;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
class Cron
{
/**
* Logging instance
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected $_logger;
protected $_notificationFactory;
protected $_datetime;
protected $_localeDate;
/**
* @var \Magento\Sales\Model\OrderFactory
*/
protected $_orderFactory;
/**
* @var \Magento\Sales\Model\Order
*/
protected $_order;
/**
* Core store config
*
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $_scopeConfig;
protected $_adyenHelper;
/**
* @var OrderSender
*/
protected $_orderSender;
// notification attributes
protected $_pspReference;
protected $_merchantReference;
protected $_eventCode;
protected $_success;
protected $_paymentMethod;
protected $_reason;
protected $_value;
protected $_boletoOriginalAmount;
protected $_boletoPaidAmount;
protected $_modificationResult;
protected $_klarnaReservationNumber;
protected $_fraudManualReview;
/**
* Collected debug information
*
* @var array
*/
protected $_debugData = array();
/**
* Constructor
* @param \Adyen\Payment\Logger\Logger $logger
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Model\Resource\Notification\CollectionFactory $notificationFactory,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Adyen\Payment\Helper\Data $adyenHelper,
OrderSender $orderSender
)
{
$this->_scopeConfig = $scopeConfig;
$this->_logger = $adyenLogger;
$this->_notificationFactory = $notificationFactory;
$this->_orderFactory = $orderFactory;
$this->_datetime = $dateTime;
$this->_localeDate = $localeDate;
$this->_adyenHelper = $adyenHelper;
$this->_orderSender = $orderSender;
}
public function processNotification()
{
$this->_order = null;
$this->_logger->info("START OF THE CRONJOB");
//fixme somehow the created_at is saved in my timzone
// loop over notifications that are not processed and from 1 minute ago
$dateStart = new \DateTime();
$dateStart->modify('-1 day');
// excecute notifications from 2 minute or earlier because order could not yet been created by mangento
$dateEnd = new \DateTime();
$dateEnd->modify('-2 minute');
// TODO: format to right timezones db is now having my local time
$dateRange = ['from' => $dateStart, 'to' => $dateEnd, 'datetime' => true];
$notifications = $this->_notificationFactory->create();
$notifications->addFieldToFilter('done', 0);
$notifications->addFieldToFilter('created_at', $dateRange);
foreach($notifications as $notification) {
// get order
$incrementId = $notification->getMerchantReference();
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
if (!$this->_order->getId()) {
throw new Exception(sprintf('Wrong order ID: "%1".', $incrementId));
}
// declare all variables that are needed
$this->_declareVariables($notification);
// add notification to comment history status is current status
$this->_addStatusHistoryComment();
// $previousAdyenEventCode = $this->order->getAdyenNotificationEventCode();
$previousAdyenEventCode = $this->_order->getData('adyen_notification_event_code');
// check if success is true of false
if (strcmp($this->_success, 'false') == 0 || strcmp($this->_success, '0') == 0) {
// Only cancel the order when it is in state pending, payment review or if the ORDER_CLOSED is failed (means split payment has not be successful)
if($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT || $this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW || $this->_eventCode == \Magento\Sales\Model\Order::ADYEN_EVENT_ORDER_CLOSED) {
$this->_debugData['_updateOrder info'] = 'Going to cancel the order';
// if payment is API check, check if API result pspreference is the same as reference
if($this->_eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_AUTHORISATION && $this->_getPaymentMethodType($this->_order) == 'api') {
if($this->_pspReference == $this->_order->getPayment()->getAdyenPspReference()) {
// don't cancel the order if previous state is authorisation with success=true
if($previousAdyenEventCode != "AUTHORISATION : TRUE") {
$this->_holdCancelOrder(false);
} else {
//$this->_order->setAdyenEventCode($previousAdyenEventCode); // do not update the adyenEventCode
$this->_order->setData('adyen_notification_event_code', $previousAdyenEventCode);
$this->_debugData['_updateOrder warning'] = 'order is not cancelled because previous notification was a authorisation that succeeded';
}
} else {
$this->_debugData['_updateOrder warning'] = 'order is not cancelled because pspReference does not match with the order';
}
} else {
// don't cancel the order if previous state is authorisation with success=true
if($previousAdyenEventCode != "AUTHORISATION : TRUE") {
$this->_holdCancelOrder(false);
} else {
// $this->_order->setAdyenEventCode($previousAdyenEventCode); // do not update the adyenEventCode
$this->_order->setData('adyen_notification_event_code', $previousAdyenEventCode);
$this->_debugData['_updateOrder warning'] = 'order is not cancelled because previous notification was a authorisation that succeeded';
}
}
} else {
$this->_debugData['_updateOrder info'] = 'Order is already processed so ignore this notification state is:' . $this->_order->getState();
}
} else {
// Notification is successful
$this->_processNotification();
}
$id = $notification->getId();
// echo $id;
// $comment = "THIS IS A TEST";
// $status = \Magento\Sales\Model\Order::STATE_PROCESSING;
// $this->_order->setState($status);
// $this->_order->addStatusHistoryComment($comment, $status);
//
$this->_order->save();
foreach($this->_debugData as $debug) {
$this->_logger->info($debug);
}
print_R($this->_debugData);
echo $this->_order->getId();die();
$eventCode = $notification->getEventCode();
// TODO: set done to true!!
}
echo 'end';
// get currenttime
// $date = new date();
$this->_logger->info("END OF THE CRONJOB");
}
protected function _declareVariables($notification)
{
// declare the common parameters
$this->_pspReference = $notification->getPspreference();
$this->_merchantReference = $notification->getMerchantReference();
$this->_eventCode = $notification->getEventCode();
$this->_success = $notification->getSuccess();
$this->_paymentMethod = $notification->getPaymentMethod();
$this->_reason = $notification->getPaymentMethod();
$this->_value = $notification->getAmountValue();
$additionalData = unserialize($notification->getAdditionalData());
// boleto data
if($this->_paymentMethodCode() == "adyen_boleto") {
if($additionalData && is_array($additionalData)) {
$boletobancario = isset($additionalData['boletobancario']) ? $additionalData['boletobancario'] : null;
if($boletobancario && is_array($boletobancario)) {
$this->_boletoOriginalAmount = isset($boletobancario['originalAmount']) ? trim($boletobancario['originalAmount']) : "";
$this->_boletoPaidAmount = isset($boletobancario['paidAmount']) ? trim($boletobancario['paidAmount']) : "";
}
}
}
if($additionalData && is_array($additionalData)) {
// check if the payment is in status manual review
$fraudManualReview = isset($additionalData['fraudManualReview']) ? $additionalData['fraudManualReview'] : "";
if($fraudManualReview == "true") {
$this->_fraudManualReview = true;
} else {
$this->_fraudManualReview = false;
}
$modification = isset($additionalData['modification']) ? $additionalData['modification'] : null;
if($modification && is_array($modification)) {
$this->_modificationResult = isset($valueArray['action']) ? trim($modification['action']) : "";
}
$additionalData2 = isset($additionalData['additionalData']) ? $additionalData['additionalData'] : null;
if($additionalData2 && is_array($additionalData2)) {
$this->_klarnaReservationNumber = isset($additionalData2['acquirerReference']) ? trim($additionalData2['acquirerReference']) : "";
}
}
}
/**
* @return mixed
*/
protected function _paymentMethodCode()
{
return $this->_order->getPayment()->getMethod();
}
/**
* @desc order comments or history
* @param type $order
*/
protected function _addStatusHistoryComment()
{
$success_result = (strcmp($this->_success, 'true') == 0 || strcmp($this->_success, '1') == 0) ? 'true' : 'false';
$success = (!empty($this->_reason)) ? "$success_result <br />reason:$this->_reason" : $success_result;
if($this->_eventCode == Notification::REFUND || $this->_eventCode == Notification::CAPTURE) {
$currency = $this->_order->getOrderCurrencyCode();
// check if it is a full or partial refund
$amount = $this->_value;
$orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency);
$this->_debugData['_addStatusHistoryComment amount'] = 'amount notification:'.$amount . ' amount order:'.$orderAmount;
if($amount == $orderAmount) {
// $this->_order->setAdyenEventCode($this->_eventCode . " : " . strtoupper($success_result));
$this->_order->setData('adyen_notification_event_code', $this->_eventCode . " : " . strtoupper($success_result));
} else {
// $this->_order->setAdyenEventCode("(PARTIAL) " . $this->_eventCode . " : " . strtoupper($success_result));
$this->_order->setData('adyen_notification_event_code', "(PARTIAL) " . $this->_eventCode . " : " . strtoupper($success_result));
}
} else {
// $this->_order->setAdyenEventCode($this->_eventCode . " : " . strtoupper($success_result));
$this->_order->setData('adyen_notification_event_code', $this->_eventCode . " : " . strtoupper($success_result));
}
// if payment method is klarna or openinvoice/afterpay show the reservartion number
if(($this->_paymentMethod == "klarna" || $this->_paymentMethod == "afterpay_default" || $this->_paymentMethod == "openinvoice") && ($this->_klarnaReservationNumber != null && $this->_klarnaReservationNumber != "")) {
$klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber;
} else {
$klarnaReservationNumberText = "";
}
if($this->_boletoPaidAmount != null && $this->_boletoPaidAmount != "") {
$boletoPaidAmountText = "<br /> Paid amount: " . $this->_boletoPaidAmount;
} else {
$boletoPaidAmountText = "";
}
$type = 'Adyen HTTP Notification(s):';
$comment = __('%1 <br /> eventCode: %2 <br /> pspReference: %3 <br /> paymentMethod: %4 <br /> success: %5 %6 %7', $type, $this->_eventCode, $this->_pspReference, $this->_paymentMethod, $success, $klarnaReservationNumberText, $boletoPaidAmountText);
// If notification is pending status and pending status is set add the status change to the comment history
if($this->_eventCode == Notification::PENDING)
{
$pendingStatus = $this->_getConfigData('pending_status', 'adyen_abstract', $this->_order->getStoreId());
if($pendingStatus != "") {
$this->_order->addStatusHistoryComment($comment, $pendingStatus);
$this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification with status change to: ' . $pendingStatus;
return;
}
}
// if manual review is accepted and a status is selected. Change the status through this comment history item
if($this->_eventCode == Notification::MANUAL_REVIEW_ACCEPT
&& $this->_getFraudManualReviewAcceptStatus() != "")
{
$manualReviewAcceptStatus = $this->_getFraudManualReviewAcceptStatus();
$this->_order->addStatusHistoryComment($comment, $manualReviewAcceptStatus);
$this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification with status change to: ' . $manualReviewAcceptStatus;
return;
}
$this->_order->addStatusHistoryComment($comment);
$this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification';
}
/**
* @param $order
* @return bool
* @deprecate not needed already cancelled in ProcessController
*/
protected function _holdCancelOrder($ignoreHasInvoice)
{
$orderStatus = $this->_getConfigData('payment_cancelled', 'adyen_abstract', $this->_order->getStoreId());
$helper = Mage::helper('adyen');
// check if order has in invoice only cancel/hold if this is not the case
if ($ignoreHasInvoice || !$this->_order->hasInvoices()) {
$this->_order->setActionFlag($orderStatus, true);
if($orderStatus == Mage_Sales_Model_Order::STATE_HOLDED) {
if ($this->_order->canHold()) {
$this->_order->hold();
} else {
$this->_debugData['warning'] = 'Order can not hold or is already on Hold';
return;
}
} else {
if ($this->_order->canCancel()) {
$this->_order->cancel();
} else {
$this->_debugData['warning'] = 'Order can not be canceled';
return;
}
}
} else {
$this->_debugData['warning'] = 'Order has already an invoice so cannot be canceled';
}
}
/**
* @param $params
*/
protected function _processNotification()
{
$this->_debugData['_processNotification'] = 'Processing the notification';
$_paymentCode = $this->_paymentMethodCode();
switch ($this->_eventCode) {
case Notification::REFUND_FAILED:
// do nothing only inform the merchant with order comment history
break;
case Notification::REFUND:
$ignoreRefundNotification = $this->_getConfigData('ignore_refund_notification', 'adyen_abstract', $this->_order->getStoreId());
if($ignoreRefundNotification != true) {
$this->_refundOrder($this->_order);
//refund completed
$this->_setRefundAuthorized($this->_order);
} else {
$this->_debugData['_processNotification info'] = 'Setting to ignore refund notification is enabled so ignore this notification';
}
break;
case Notification::PENDING:
if($this->_getConfigData('send_email_bank_sepa_on_pending', 'adyen_abstract', $this->_order->getStoreId())) {
// Check if payment is banktransfer or sepa if true then send out order confirmation email
$isBankTransfer = $this->_isBankTransfer($this->_paymentMethod);
if($isBankTransfer || $this->_paymentMethod == 'sepadirectdebit') {
// $this->_order->sendNewOrderEmail(); // send order email
$this->_orderSender->send($this->_order);
$this->_debugData['_processNotification send email'] = 'Send orderconfirmation email to shopper';
}
}
break;
case Notification::HANDLED_EXTERNALLY:
case Notification::AUTHORISATION:
// for POS don't do anything on the AUTHORIZATION
if($_paymentCode != "adyen_pos") {
$this->_authorizePayment();
}
break;
case Notification::MANUAL_REVIEW_REJECT:
// don't do anything it will send a CANCEL_OR_REFUND notification when this payment is captured
break;
case Notification::MANUAL_REVIEW_ACCEPT:
// only process this if you are on auto capture. On manual capture you will always get Capture or CancelOrRefund notification
if ($this->_isAutoCapture()) {
$this->_setPaymentAuthorized($this->_order, false);
}
break;
case Notification::CAPTURE:
if($_paymentCode != "adyen_pos") {
// ignore capture if you are on auto capture (this could be called if manual review is enabled and you have a capture delay)
if (!$this->_isAutoCapture()) {
$this->_setPaymentAuthorized($this->_order, false, true);
}
} else {
// uncancel the order just to be sure that order is going trough
$this->_uncancelOrder($this->_order);
// FOR POS authorize the payment on the CAPTURE notification
$this->_authorizePayment($this->_order, $this->_paymentMethod);
}
break;
case Notification::CAPTURE_FAILED:
case Notification::CANCELLATION:
case Notification::CANCELLED:
$this->_holdCancelOrder(true);
break;
case Notification::CANCEL_OR_REFUND:
if(isset($this->_modificationResult) && $this->_modificationResult != "") {
if($this->_modificationResult == "cancel") {
$this->_holdCancelOrder(true);
} elseif($this->_modificationResult == "refund") {
$this->_refundOrder($this->_order);
//refund completed
$this->_setRefundAuthorized($this->_order);
}
} else {
$orderStatus = $this->_getConfigData('order_status', 'adyen_abstract', $this->_order->getStoreId());
if(($orderStatus != Mage_Sales_Model_Order::STATE_HOLDED && $this->_order->canCancel()) || ($orderStatus == Mage_Sales_Model_Order::STATE_HOLDED && $this->_order->canHold())) {
// cancel order
$this->_debugData['_processNotification info'] = 'try to cancel the order';
$this->_holdCancelOrder(true);
} else {
$this->_debugData['_processNotification info'] = 'try to refund the order';
// refund
$this->_refundOrder($this->_order);
//refund completed
$this->_setRefundAuthorized($this->_order);
}
}
break;
case Notification::RECURRING_CONTRACT:
// get payment object
$payment = $this->_order->getPayment();
// storedReferenceCode
$recurringDetailReference = $this->_pspReference;
// check if there is already a BillingAgreement
$agreement = Mage::getModel('adyen/billing_agreement')->load($recurringDetailReference, 'reference_id');
if ($agreement && $agreement->getAgreementId() > 0 && $agreement->isValid()) {
$agreement->addOrderRelation($this->_order);
$agreement->setStatus($agreement::STATUS_ACTIVE);
$agreement->setIsObjectChanged(true);
$this->_order->addRelatedObject($agreement);
$message = $this->_adyenHelper->__('Used existing billing agreement #%s.', $agreement->getReferenceId());
} else {
// set billing agreement data
$payment->setBillingAgreementData(array(
'billing_agreement_id' => $recurringDetailReference,
'method_code' => $payment->getMethodCode()
));
// create billing agreement for this order
$agreement = Mage::getModel('adyen/billing_agreement');
$agreement->setStoreId($this->_order->getStoreId());
$agreement->importOrderPayment($payment);
$listRecurringContracts = Mage::getSingleton('adyen/api')->listRecurringContracts($agreement->getCustomerReference(), $agreement->getStoreId());
$contractDetail = null;
// get currenct Contract details and get list of all current ones
$recurringReferencesList = array();
foreach ($listRecurringContracts as $rc) {
$recurringReferencesList[] = $rc['recurringDetailReference'];
if (isset($rc['recurringDetailReference']) && $rc['recurringDetailReference'] == $recurringDetailReference) {
$contractDetail = $rc;
}
}
if($contractDetail != null) {
// update status of the agreements in magento
$billingAgreements = Mage::getResourceModel('adyen/billing_agreement_collection')
->addFieldToFilter('customer_id', $agreement->getCustomerReference());
foreach($billingAgreements as $billingAgreement) {
if(!in_array($billingAgreement->getReferenceId(), $recurringReferencesList)) {
$billingAgreement->setStatus(Adyen_Payment_Model_Billing_Agreement::STATUS_CANCELED);
$billingAgreement->save();
} else {
$billingAgreement->setStatus(Adyen_Payment_Model_Billing_Agreement::STATUS_ACTIVE);
$billingAgreement->save();
}
}
$agreement->parseRecurringContractData($contractDetail);
if ($agreement->isValid()) {
$message = __('Created billing agreement #%s.', $agreement->getReferenceId());
// save into sales_billing_agreement_order
$agreement->addOrderRelation($this->_order);
// add to order to save agreement
$this->_order->addRelatedObject($agreement);
} else {
$message = __('Failed to create billing agreement for this order.');
}
} else {
$this->_debugData['_processNotification error'] = 'Failed to create billing agreement for this order (listRecurringCall did not contain contract)';
$this->_debugData['_processNotification ref'] = printf('recurringDetailReference in notification is %s', $recurringDetailReference) ;
$this->_debugData['_processNotification customer ref'] = printf('CustomerReference is: %s and storeId is %s', $agreement->getCustomerReference(), $agreement->getStoreId());
$this->_debugData['_processNotification customer result'] = $listRecurringContracts;
$message = __('Failed to create billing agreement for this order (listRecurringCall did not contain contract)');
}
}
$comment = $this->_order->addStatusHistoryComment($message);
$this->_order->addRelatedObject($comment);
break;
default:
$this->_order->getPayment()->getMethodInstance()->writeLog('notification event not supported!');
break;
}
}
/**
*
*/
protected function _authorizePayment()
{
$this->_debugData['_authorizePayment'] = 'Authorisation of the order';
// $this->_uncancelOrder($order); // not implemented in magento v2.0
$fraudManualReviewStatus = $this->_getFraudManualReviewStatus();
// If manual review is active and a seperate status is used then ignore the pre authorized status
if($this->_fraudManualReview != true || $fraudManualReviewStatus == "") {
$this->_setPrePaymentAuthorized();
} else {
$this->_debugData['_authorizePayment info'] = 'Ignore the pre authorized status because the order is under manual review and use the Manual review status';
}
$this->_prepareInvoice();
$_paymentCode = $this->_paymentMethodCode();
// for boleto confirmation mail is send on order creation
if($this->_paymentMethod != "adyen_boleto") {
// send order confirmation mail after invoice creation so merchant can add invoicePDF to this mail
// $this->_order->sendNewOrderEmail(); // send order email
$this->_orderSender->send($this->_order);
}
if(($this->_paymentMethod == "c_cash" && $this->_getConfigData('create_shipment', 'adyen_cash', $this->_order->getStoreId())) || ($this->_getConfigData('create_shipment', 'adyen_pos', $this->_order->getStoreId()) && $_paymentCode == "adyen_pos"))
{
$this->_createShipment($this->_order);
}
}
private function _setPrePaymentAuthorized()
{
$status = $this->_getConfigData('payment_pre_authorized', 'adyen_abstract', $this->_order->getStoreId());
// only do this if status in configuration is set
if(!empty($status)) {
$this->_order->addStatusHistoryComment(__('Payment is pre authorised waiting for capture'), $status);
$this->_debugData['_setPrePaymentAuthorized'] = 'Order status is changed to Pre-authorised status, status is ' . $status;
} else {
$this->_debugData['_setPrePaymentAuthorized'] = 'No pre-authorised status is used so ignore';
}
}
/**
* @param $order
*/
protected function _prepareInvoice()
{
$this->_debugData['_prepareInvoice'] = 'Prepare invoice for order';
$payment = $this->_order->getPayment()->getMethodInstance();
//Set order state to new because with order state payment_review it is not possible to create an invoice
if (strcmp($this->_order->getState(), \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW) == 0) {
$this->_order->setState(\Magento\Sales\Model\Order::STATE_NEW);
}
//capture mode
if (!$this->_isAutoCapture()) {
$this->_order->addStatusHistoryComment(__('Capture Mode set to Manual'));
$this->_debugData['_prepareInvoice capture mode'] = 'Capture mode is set to Manual';
// show message if order is in manual review
if($this->_fraudManualReview) {
// check if different status is selected
$fraudManualReviewStatus = $this->_getFraudManualReviewStatus();
if($fraudManualReviewStatus != "") {
$status = $fraudManualReviewStatus;
$comment = "Adyen Payment is in Manual Review check the Adyen platform";
$this->_order->addStatusHistoryComment(__($comment), $status);
}
}
$createPendingInvoice = (bool) $this->_getConfigData('create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId());
if(!$createPendingInvoice) {
$this->_debugData['_prepareInvoice done'] = 'Setting pending invoice is off so don\'t create an invoice wait for the capture notification';
return;
}
}
// validate if amount is total amount
$orderCurrencyCode = $this->_order->getOrderCurrencyCode();
$orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $orderCurrencyCode);
if($this->_isTotalAmount($orderAmount)) {
$this->_createInvoice($this->_order);
} else {
$this->_debugData['_prepareInvoice partial authorisation step1'] = 'This is a partial AUTHORISATION';
// Check if this is the first partial authorisation or if there is already been an authorisation
$paymentObj = $this->_order->getPayment();
$authorisationAmount = $paymentObj->getAdyenAuthorisationAmount();
if($authorisationAmount != "") {
$this->_debugData['_prepareInvoice partial authorisation step2'] = 'There is already a partial AUTHORISATION received check if this combined with the previous amounts match the total amount of the order';
$authorisationAmount = (int) $authorisationAmount;
$currentValue = (int) $this->_value;
$totalAuthorisationAmount = $authorisationAmount + $currentValue;
// update amount in column
$paymentObj->setAdyenAuthorisationAmount($totalAuthorisationAmount);
if($totalAuthorisationAmount == $orderAmount) {
$this->_debugData['_prepareInvoice partial authorisation step3'] = 'The full amount is paid. This is the latest AUTHORISATION notification. Create the invoice';
$this->_createInvoice($this->_order);
} else {
// this can be multiple times so use envenData as unique key
$this->_debugData['_prepareInvoice partial authorisation step3'] = 'The full amount is not reached. Wait for the next AUTHORISATION notification. The current amount that is authorized is:' . $totalAuthorisationAmount;
}
} else {
$this->_debugData['_prepareInvoice partial authorisation step2'] = 'This is the first partial AUTHORISATION save this into the adyen_authorisation_amount field';
$paymentObj->setAdyenAuthorisationAmount($this->_value);
}
}
}
/**
* @param $order
* @return bool
*/
protected function _isAutoCapture()
{
$captureMode = trim($this->_getConfigData('capture_mode', 'adyen_abstract', $this->_order->getStoreId()));
$sepaFlow = trim($this->_getConfigData('flow', 'adyen_sepa', $this->_order->getStoreId()));
$_paymentCode = $this->_paymentMethodCode();
$captureModeOpenInvoice = $this->_getConfigData('auto_capture_openinvoice', 'adyen_abstract', $this->_order->getStoreId());
$captureModePayPal = trim($this->_getConfigData('paypal_capture_mode', 'adyen_abstract', $this->_order->getStoreId()));
//check if it is a banktransfer. Banktransfer only a Authorize notification is send.
$isBankTransfer = $this->_isBankTransfer();
// if you are using authcap the payment method is manual. There will be a capture send to indicate if payment is succesfull
if($_paymentCode == "adyen_sepa" && $sepaFlow == "authcap") {
return false;
}
// payment method ideal, cash adyen_boleto or adyen_pos has direct capture
if (strcmp($this->_paymentMethod, 'ideal') === 0 || strcmp($this->_paymentMethod, 'c_cash' ) === 0 || $_paymentCode == "adyen_pos" || $isBankTransfer == true || ($_paymentCode == "adyen_sepa" && $sepaFlow != "authcap") || $_paymentCode == "adyen_boleto") {
return true;
}
// if auto capture mode for openinvoice is turned on then use auto capture
if ($captureModeOpenInvoice == true && (strcmp($this->_paymentMethod, 'openinvoice') === 0 || strcmp($this->_paymentMethod, 'afterpay_default') === 0 || strcmp($this->_paymentMethod, 'klarna') === 0)) {
return true;
}
// if PayPal capture modues is different from the default use this one
if(strcmp($this->_paymentMethod, 'paypal' ) === 0 && $captureModePayPal != "") {
if(strcmp($captureModePayPal, 'auto') === 0 ) {
return true;
} elseif(strcmp($captureModePayPal, 'manual') === 0 ) {
return false;
}
}
if (strcmp($captureMode, 'manual') === 0) {
return false;
}
//online capture after delivery, use Magento backend to online invoice (if the option auto capture mode for openinvoice is not set)
if (strcmp($this->_paymentMethod, 'openinvoice') === 0 || strcmp($this->_paymentMethod, 'afterpay_default') === 0 || strcmp($this->_paymentMethod, 'klarna') === 0) {
return false;
}
return true;
}
/**
* @param $paymentMethod
* @return bool
*/
protected function _isBankTransfer() {
if(strlen($this->_paymentMethod) >= 12 && substr($this->_paymentMethod, 0, 12) == "bankTransfer") {
$isBankTransfer = true;
} else {
$isBankTransfer = false;
}
return $isBankTransfer;
}
protected function _getFraudManualReviewStatus()
{
return $this->_getConfigData('fraud_manual_review_status', 'adyen_abstract', $this->_order->getStoreId());
}
protected function _getFraudManualReviewAcceptStatus()
{
return $this->_getConfigData('fraud_manual_review_accept_status', 'adyen_abstract', $this->_order->getStoreId());
}
protected function _isTotalAmount($orderAmount) {
$this->_debugData['_isTotalAmount'] = 'Validate if AUTHORISATION notification has the total amount of the order';
$value = (int)$this->_value;
if($value == $orderAmount) {
$this->_debugData['_isTotalAmount result'] = 'AUTHORISATION has the full amount';
return true;
} else {
$this->_debugData['_isTotalAmount result'] = 'This is a partial AUTHORISATION, the amount is ' . $this->_value;
return false;
}
}
/**
* Retrieve information from payment configuration
*
* @param string $field
* @param int|string|null|\Magento\Store\Model\Store $storeId
*
* @return mixed
*/
protected function _getConfigData($field, $paymentMethodCode = 'adyen_cc', $storeId)
{
// replace for now settings should moved from adyen_cc to adyen_abstract
if($paymentMethodCode == 'adyen_abstract') {
$paymentMethodCode = "adyen_cc";
}
$path = 'payment/' . $paymentMethodCode . '/' . $field;
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
}
\ No newline at end of file
......@@ -43,6 +43,8 @@ class Cc extends \Magento\Payment\Model\Method\Cc
protected $_paymentRequest;
protected $_adyenLogger;
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
......@@ -59,6 +61,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
*/
public function __construct(
\Adyen\Payment\Model\Api\PaymentRequest $paymentRequest,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
......@@ -87,6 +90,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
$data
);
$this->_paymentRequest = $paymentRequest;
$this->_adyenLogger = $adyenLogger;
}
......@@ -98,6 +102,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
public function isAvailable($quote = null)
{
$this->_logger->critical("CC IS AVAILABLE!! IS TRUE");
// $this->_adyenLogger->critical("TESTTT");
return true;
}
......@@ -110,10 +115,25 @@ class Cc extends \Magento\Payment\Model\Method\Cc
*/
public function assignData($data)
{
parent::assignData($data);
$infoInstance = $this->getInfoInstance();
$this->_logger->critical("Assign data!!:" . print_r($data, true));
return parent::assignData($data);
//// print_r($data);die();
// throw new \Magento\Framework\Exception\LocalizedException(__('The authorize action is not available.' . print_r($data, true)));
//// print_r($data);die();
// $this->_logger->critical("TEST in validate FUNTION !!:");
$infoInstance->setAdditionalInformation('encrypted_data', $data['encrypted_data']);
$this->_logger->critical("encrypted dat:" . $data['encrypted_data']);
return $this;
}
public function validate()
......@@ -125,6 +145,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount)
{
$this->_logger->critical("TEST in authorize FUNTION !!:");
if (!$this->canAuthorize()) {
throw new \Magento\Framework\Exception\LocalizedException(__('The authorize action is not available.'));
}
......@@ -150,16 +171,13 @@ class Cc extends \Magento\Payment\Model\Method\Cc
}
protected function _processRequest(\Magento\Framework\Object $payment, $amount, $request) {
$merchantAccount = $this->getConfigData('merchant_account');
$recurringType = $this->getConfigData('recurring_type');
$enableMoto = $this->getConfigData('enable_moto');
protected function _processRequest(\Magento\Framework\Object $payment, $amount, $request)
{
switch ($request) {
case "authorise":
$response = $this->_paymentRequest->fullApiRequest($merchantAccount, $payment);
$response = $this->_paymentRequest->fullApiRequest($payment);
break;
}
......@@ -167,9 +185,15 @@ class Cc extends \Magento\Payment\Model\Method\Cc
$this->_logger->critical("HIERRR result is " . print_r($response,true));
if (!empty($response)) {
$this->_logger->critical("NOT EMPTY ");
$this->_processResponse($payment, $response);
// print_r($response);die();
// $this->_processResponse($payment, $response, $request);
......@@ -181,6 +205,60 @@ class Cc extends \Magento\Payment\Model\Method\Cc
}
protected function _processResponse(\Magento\Payment\Model\InfoInterface $payment, $response)
{
switch ($response['paymentResult_resultCode']) {
case "Authorised":
//$this->_addStatusHistory($payment, $responseCode, $pspReference, $this->_getConfigData('order_status'));
break;
case "Refused":
// paymentResult_refusalReason
if($response['paymentResult_refusalReason']) {
$refusalReason = $response['paymentResult_refusalReason'];
switch($refusalReason) {
case "Transaction Not Permitted":
$errorMsg = __('The transaction is not permitted.');
break;
case "CVC Declined":
$errorMsg = __('Declined due to the Card Security Code(CVC) being incorrect. Please check your CVC code!');
break;
case "Restricted Card":
$errorMsg = __('The card is restricted.');
break;
case "803 PaymentDetail not found":
$errorMsg = __('The payment is REFUSED because the saved card is removed. Please try an other payment method.');
break;
case "Expiry month not set":
$errorMsg = __('The expiry month is not set. Please check your expiry month!');
break;
default:
$errorMsg = __('The payment is REFUSED by Adyen.');
break;
}
} else {
$errorMsg = Mage::helper('adyen')->__('The payment is REFUSED by Adyen.');
}
if ($errorMsg) {
$this->_logger->critical($errorMsg);
throw new \Magento\Framework\Exception\LocalizedException($errorMsg);
}
break;
}
if($response['paymentResult_resultCode'] == 'Refused') {
}
// print_R($response);die();
}
// does not seem to work.
public function hasVerification() {
return true;
......
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Adyen\Payment\Model;
use Adyen\Payment\Api\Data\NotificationInterface;
use Magento\Framework\Object\IdentityInterface;
class Notification extends \Magento\Framework\Model\AbstractModel
implements NotificationInterface
{
const AUTHORISATION = 'AUTHORISATION';
const PENDING = 'PENDING';
const AUTHORISED = 'AUTHORISED';
const CANCELLED = 'CANCELLED';
const REFUSED = 'REFUSED';
const ERROR = 'ERROR';
const REFUND = 'REFUND';
const REFUND_FAILED = 'REFUND_FAILED';
const CANCEL_OR_REFUND = 'CANCEL_OR_REFUND';
const CAPTURE = 'CAPTURE';
const CAPTURE_FAILED = 'CAPTURE_FAILED';
const CANCELLATION = 'CANCELLATION';
const POSAPPROVED = 'POS_APPROVED';
const HANDLED_EXTERNALLY = 'HANDLED_EXTERNALLY';
const MANUAL_REVIEW_ACCEPT = 'MANUAL_REVIEW_ACCEPT';
const MANUAL_REVIEW_REJECT = 'MANUAL_REVIEW_REJECT ';
const RECURRING_CONTRACT = "RECURRING_CONTRACT";
const REPORT_AVAILABLE = "REPORT_AVAILABLE";
const ORDER_CLOSED = "ORDER_CLOSED";
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
/**
* Initialize resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('Adyen\Payment\Model\Resource\Notification');
}
/**
* Gets the Pspreference for the notification.
*
* @return int|null Pspreference.
*/
public function getPspreference()
{
return $this->getData(self::PSPREFRENCE);
}
/**
* Sets Pspreference.
*
* @param string $pspreference
* @return $this
*/
public function setPspreference($pspreference)
{
return $this->setData(self::PSPREFRENCE, $pspreference);
}
/**
* Gets the Merchantreference for the notification.
*
* @return int|null MerchantReference.
*/
public function getMerchantReference()
{
return $this->getData(self::MERCHANT_REFERENCE);
}
/**
* Sets MerchantReference.
*
* @param string $merchantReference
* @return $this
*/
public function setMerchantReference($merchantReference)
{
return $this->setData(self::MERCHANT_REFERENCE, $merchantReference);
}
/**
* Gets the Eventcode for the notification.
*
* @return int|null Eventcode.
*/
public function getEventCode()
{
return $this->getData(self::EVENT_CODE);
}
/**
* Sets EventCode.
*
* @param string $eventCode
* @return $this
*/
public function setEventCode($eventCode)
{
return $this->setData(self::EVENT_CODE, $eventCode);
}
/**
* Gets the success for the notification.
*
* @return int|null Success.
*/
public function getSucess()
{
return $this->getData(self::SUCCESS);
}
/**
* Sets Success.
*
* @param boolean $success
* @return $this
*/
public function setSuccess($success)
{
return $this->setData(self::SUCCESS, $success);
}
/**
* Gets the Paymentmethod for the notification.
*
* @return int|null PaymentMethod.
*/
public function getPaymentMethod()
{
return $this->getData(self::PAYMENT_METHOD);
}
/**
* Sets PaymentMethod.
*
* @param string $paymentMethod
* @return $this
*/
public function setPaymentMethod($paymentMethod)
{
return $this->setData(self::PAYMENT_METHOD, $paymentMethod);
}
/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
public function getAmountValue()
{
return $this->getData(self::AMOUNT_VALUE);
}
/**
* Sets AmountValue.
*
* @param string $amountValue
* @return $this
*/
public function setAmountValue($amountValue)
{
return $this->setData(self::AMOUNT_VALUE, $amountValue);
}
/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
public function getAmountCurency()
{
return $this->getData(self::AMOUNT_CURRENCY);
}
/**
* Sets AmountCurrency.
*
* @param string $amountCurrency
* @return $this
*/
public function setAmountCurrency($amountCurrency)
{
return $this->setData(self::AMOUNT_CURRENCY, $amountCurrency);
}
/**
* Gets the Reason for the notification.
*
* @return int|null Reason.
*/
public function getReason()
{
return $this->getData(self::REASON);
}
/**
* Sets Reason.
*
* @param string $reason
* @return $this
*/
public function setReason($reason)
{
return $this->setData(self::REASON, $reason);
}
/**
* Gets the AdditionalData for the notification.
*
* @return int|null AdditionalData.
*/
public function getAdditionalData()
{
return $this->getData(self::ADDITIONAL_DATA);
}
/**
* Sets AdditionalData.
*
* @param string $additionalData
* @return $this
*/
public function setAddtionalData($additionalData)
{
return $this->setData(self::ADDITIONAL_DATA, $additionalData);
}
/**
* Gets the Done for the notification.
*
* @return int|null Done.
*/
public function getDone()
{
return $this->getData(self::DONE);
}
/**
* Sets Done.
*
* @param string $done
* @return $this
*/
public function setDone($done)
{
return $this->setData(self::DONE, $done);
}
/**
* Gets the created-at timestamp for the notification.
*
* @return string|null Created-at timestamp.
*/
public function getCreatedAt()
{
return $this->getData(self::CREATED_AT);
}
/**
* Sets the created-at timestamp for the notification.
*
* @param string $createdAt timestamp
* @return $this
*/
public function setCreatedAt($createdAt)
{
return $this->setData(self::CREATED_AT, $createdAt);
}
/**
* Gets the updated-at timestamp for the notification.
*
* @return string|null Updated-at timestamp.
*/
public function getUpdatedAt()
{
return $this->getData(self::UPDATED_AT);
}
/**
* Sets the updated-at timestamp for the notification.
*
* @param string $timestamp
* @return $this
*/
public function setUpdatedAt($timestamp)
{
return $this->setData(self::UPDATED_AT, $timestamp);
}
}
\ No newline at end of file
<?php
namespace Adyen\Payment\Model\Resource;
class Notification extends \Magento\Framework\Model\Resource\Db\AbstractDb
{
public function _construct()
{
$this->_init('adyen_notification', 'entity_id');
}
}
\ No newline at end of file
<?php
namespace Adyen\Payment\Model\Resource\Notification;
class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
{
public function _construct()
{
$this->_init('Adyen\Payment\Model\Notification', 'Adyen\Payment\Model\Resource\Notification');
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rikt
* Date: 9/15/15
* Time: 10:00 AM
*/
\ No newline at end of file
<?php
namespace Adyen\Payment\Setup;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\DB\Ddl\Table;
use \Magento\Framework\DB\Adapter\AdapterInterface;
class InstallSchema implements InstallSchemaInterface
{
/**
* Installs DB schema for a module
*
* @param SchemaSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
$table = $installer->getConnection()
->newTable($installer->getTable('adyen_notification'))
->addColumn('entity_id', Table::TYPE_SMALLINT, null,['identity' => true, 'nullable' => false, 'primary' => true],'Entity ID')
->addColumn('pspreference', Table::TYPE_TEXT, 255, ['nullable' => true], 'Pspreference')
->addColumn('merchant_reference', Table::TYPE_TEXT, 255, ['nullable' => true], 'Merchant Reference')
->addColumn('event_code', Table::TYPE_TEXT, 255, ['nullable' => true], 'Event Code')
->addColumn('success', Table::TYPE_TEXT, 255, ['nullable' => true], 'Success')
->addColumn('payment_method', Table::TYPE_TEXT, 255, ['nullable' => true], 'Payment Method')
->addColumn('amount_value', Table::TYPE_TEXT, 255, ['nullable' => true], 'Amount value')
->addColumn('amount_currency', Table::TYPE_TEXT, 255, ['nullable' => true], 'Amount currency')
->addColumn('reason', Table::TYPE_TEXT, 255, ['nullable' => true], 'reason')
->addColumn('live', Table::TYPE_TEXT, 255, ['nullable' => true], 'Send from Live platform of adyen?')
->addColumn('additional_data', Table::TYPE_TEXT, null, ['nullable' => true], 'AdditionalData')
->addColumn('done', Table::TYPE_BOOLEAN, null, ['nullable' => false, 'default' => 0], 'done')
->addColumn('created_at', Table::TYPE_TIMESTAMP, null, ['nullable' => false, 'default' => Table::TIMESTAMP_INIT], 'Created At')
->addColumn('updated_at', Table::TYPE_TIMESTAMP, null, ['nullable' => false, 'default' => Table::TIMESTAMP_INIT_UPDATE],'Updated At')
->addIndex($installer->getIdxName('adyen_notification', ['pspreference']), ['pspreference'])
->addIndex($installer->getIdxName('adyen_notification', ['event_code']), ['event_code'])
->addIndex(
$installer->getIdxName(
'adyen_notification',
['pspreference', 'event_code'],
AdapterInterface::INDEX_TYPE_INDEX
),
['pspreference', 'event_code'],
['type' => AdapterInterface::INDEX_TYPE_INDEX]
)
->addIndex(
$installer->getIdxName(
'adyen_notification',
['merchant_reference', 'event_code'],
AdapterInterface::INDEX_TYPE_INDEX
),
['merchant_reference', 'event_code'],
['type' => AdapterInterface::INDEX_TYPE_INDEX]
)
->setComment('Adyen Notifications');
$installer->getConnection()->createTable($table);
$orderTable = $installer->getTable('sales_order');
$columns = [
'adyen_resulturl_event_code' => [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 255,
'nullable' => true,
'comment' => 'Adyen resulturl event status',
],
'adyen_notification_event_code' => [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 255,
'nullable' => true,
'comment' => 'Adyen notification event status',
]
];
$connection = $installer->getConnection();
foreach ($columns as $name => $definition) {
$connection->addColumn($orderTable, $name, $definition);
}
$installer->endSetup();
}
}
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Magento/Config/etc/system_file.xsd">
<system>
<section id="payment" translate="label" type="text" sortOrder="400" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="adyen_cc" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Adyen</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
<field id="merchant_account" translate="label" type="text" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Merchant Account</label>
</field>
<field id="webservice_username" translate="label" type="text" sortOrder="16" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Webservice username</label>
</field>
<field id="webservice_password" translate="label" type="obscure" sortOrder="17" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Webservice Password</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
</field>
<field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
</field>
<field id="recurring_type" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Recurring Type</label>
<source_model>Adyen\Payment\Model\Config\Source\RecurringType</source_model>
</field>
<field id="enable_moto" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable MOTO for backend orders</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="190" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
</field>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="201" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
</field>
<field id="model"></field>
<group id="adyen_group_all_in_one" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Adyen All-in-One Payment Solutions</label>
<comment><![CDATA[Adyen All-in-One Payment Solutions]]></comment>
<attribute type="expanded">1</attribute>
<fieldset_css>complex</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Group</frontend_model>
<include path="Adyen_Payment::system/adyen_getting_started.xml"/>
<include path="Adyen_Payment::system/adyen_required_settings.xml"/>
<include path="Adyen_Payment::system/adyen_cc.xml"/>
<include path="Adyen_Payment::system/adyen_hpp.xml"/>
</group>
<group id="adyen_hpp" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Adyen</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
</group>
<group id="test" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
......
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Config/etc/system_include.xsd">
<group id="adyen_cc" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[CreditCard API integration]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment>Process creditcard payments inside your checkout.</comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_cc/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
<config_path>payment/adyen_cc/title</config_path>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_cc/sort_order</config_path>
</field>
<field id="cse_enabled" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable CSE</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_cc/cse_enabled</config_path>
</field>
<field id="cse_publickey_test" translate="label" type="textarea" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enter CSE Public Key of Test Adyen Web Service User</label>
<depends><field id="cse_enabled">1</field></depends>
<config_path>payment/adyen_cc/cse_publickey_test</config_path>
</field>
<field id="cse_publickey_live" translate="label" type="textarea" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enter CSE Public Key of Live Adyen Web Service User</label>
<depends><field id="cse_enabled">1</field></depends>
<config_path>payment/adyen_cc/cse_publickey_live</config_path>
</field>
<group id="adyen_cc_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200">
<label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<config_path>payment/adyen_cc/allowspecific</config_path>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
<config_path>payment/adyen_cc/specificcountry</config_path>
</field>
</group>
</group>
</include>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Config/etc/system_include.xsd">
<group id="adyen_getting_started" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Documentation & Support]]></label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<comment><![CDATA[
<ul>
<li><a target="_blank" href="http://vimeo.com/94005128">Instructional video on how to set up the Adyen Magento plugin</a></a>
<li><a target="_blank" href="https://www.adyen.com/dam/documentation/manuals/MagentoQuickIntegrationManual.pdf">Download the Quick Quick Integration Guide</a></li>
<li><a target="_blank" href="https://www.adyen.com/dam/documentation/manuals/AdyenMagentoExtension.pdf">Download the more advanced manual</a></li>
<li><a target="_blank" href="https://www.adyen.com/home/payment-services/plug-ins/magento#form"><strong>Sign</strong> up for a test account</a></li>
<li>The latest version of the <a target="_blank" href="https://github.com/adyenpayments/magento/releases">Adyen Magento module is also available through GitHub</a>.</li>
</ul>
<p> In the test modus you nee to use test cards. <a target="_blank" href="http://adyen.com/test-card-numbers">Test cards can be found here</a>
<p>You can find this in the Adyen back-office. The Adyen back-office can be found on <a target="_blank" href="https://ca-test.adyen.com">https://ca-test.adyen.com</a> for test or <a target="_blank" href="https://ca-live.adyen.com">https://ca-live.adyen.com</a> for live.</p>
<p>If you have any further questions, please visit the <a target="_blank" href="http://www.adyen.com">Adyen.com</a> website or email <a href="mailto:magento@adyen.com">magento@adyen.com</a>.</p>
]]></comment>
<field id="version" translate="label" type="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Extension version</label>
<frontend_model>\Adyen\Payment\Block\Adminhtml\System\Config\Field\Version</frontend_model>
</field>
</group>
</include>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Config/etc/system_include.xsd">
<group id="adyen_hpp" translate="label" type="text" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Hosted Payment Page (HPP) integration]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment>Process alternative payments methods</comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_hpp/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
<config_path>payment/adyen_hpp/title</config_path>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_hpp/sort_order</config_path>
</field>
<group id="adyen_cc_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="210">
<label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<config_path>payment/adyen_cc/allowspecific</config_path>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
<config_path>payment/adyen_cc/specificcountry</config_path>
</field>
</group>
</group>
</include>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Config/etc/system_include.xsd">
<group id="adyen_required_settings" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Required Settings]]></label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="merchant_account" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Merchant Account</label>
<config_path>payment/adyen_abstract/merchant_account</config_path>
</field>
<field id="demo_mode" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test/Production Mode</label>
<source_model>Adyen\Payment\Model\Config\Source\DemoMode</source_model>
<config_path>payment/adyen_abstract/demo_mode</config_path>
<tooltip><![CDATA[ In the test mode you must use test cards. See section Documentation & Support for the link to the test cards]]></tooltip>
</field>
<field id="notification_username" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Notification User Name</label>
<config_path>payment/adyen_abstract/notification_username</config_path>
<tooltip>Set a user name of your choice here and copy it over to Adyen Customer Area => Settings => Server Communication => Standard Notification => User Name.</tooltip>
</field>
<field id="notification_password" translate="label" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Notification Password</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/notification_password</config_path>
<tooltip>Set a password of your choice and copy it over to Adyen Customer Area => Settings => Server Communication => Standard Notification => Password.</tooltip>
</field>
<field id="ws_username_test" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice username</label>
<tooltip>Find this in your Test Adyen Customer Area => Settings => Users => System. Normally this will be ws@Company.YourCompanyAccount. Copy and Paste the exact ws user name here.</tooltip>
<config_path>payment/adyen_abstract/ws_username_test</config_path>
</field>
<field id="ws_password_test" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice Password</label>
<tooltip>Find this in your Test Adyen Customer Area => Settings => Users => System. Click on your web service user and generate a new password. Copy and Paste the exact password here.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/ws_password_test</config_path>
</field>
<field id="ws_username_live" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice username</label>
<tooltip>This is only applicable if you have a Live account. Find this in your Live Adyen Customer Area => Settings => Users => System. Normally this will be ws@Company.YourCompanyAccount. Copy and Paste the exact ws user name here.</tooltip>
<config_path>payment/adyen_abstract/ws_username_live</config_path>
</field>
<field id="ws_password_live" translate="label" type="obscure" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice Password</label>
<tooltip>This is only applicable if you have a Live account. Find this in your Live Adyen Customer Area => Settings => Users => System. Click on your web service user and generate a new password. Copy and Paste the exact password here.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/ws_password_live</config_path>
</field>
<field id="capture_mode" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Capture Delay</label>
<tooltip>Immediate is the default. Set to manual if you want to perform the capture of funds manually later (only affects credit cards and a few alternative payment methods). You need to change this setting as well in Adyen Customer Area => Settings => Merchant Settings => Capture Delay. If you have selected a capture delay of a couple of days in Adyen keep it here on immediate</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\CaptureMode</source_model>
<config_path>payment/adyen_abstract/capture_mode</config_path>
</field>
<field id="order_status" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Order status: order creation</label>
<tooltip>Status given to newly created orders before payment result confirmation via server notifications from Adyen.</tooltip>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
<config_path>payment/adyen_abstract/order_status</config_path>
</field>
<field id="payment_pre_authorized" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Order status: payment authorisation</label>
<tooltip>Status given to orders after authorisation confirmed by an AUTHORISATION notification from Adyen. Note: an authorisation status via the result URL does not yet trigger this status.</tooltip>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\Newprocessing</source_model>
<config_path>payment/adyen_abstract/payment_pre_authorized</config_path>
</field>
<field id="payment_authorized" translate="label" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Order status: payment confirmed</label>
<tooltip>Status given to orders after capture result is confirmed by an AUTHORISATION notification (if capture mode = immediate) or a CAPTURE notification (if capture mode = manual capture) from Adyen.</tooltip>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\Processing</source_model>
<config_path>payment/adyen_abstract/payment_authorized</config_path>
</field>
<field id="payment_cancelled" translate="label" type="select" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Order status: order cancellation</label>
<tooltip>Status given to orders after order cancellation is confirmed by a CANCEL_OR_REFUND notification from Adyen. If orders are already invoiced, they cannot be cancelled, but will be refunded instead.</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\Cancelled</source_model>
<config_path>payment/adyen_abstract/payment_cancelled</config_path>
</field>
<field id="debug" translate="label" type="select" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable debug logging</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/debug</config_path>
</field>
</group>
</include>
\ No newline at end of file
......@@ -8,16 +8,21 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Magento/Store/etc/config.xsd">
<default>
<payment>
<adyen_abstract>
<active>0</active>
<recurring_type>ONECLICK</recurring_type>
<order_status>pending</order_status>
<demo_mode>1</demo_mode>
</adyen_abstract>
<adyen_cc>
<active>1</active>
<model>Adyen\Payment\Model\Method\Cc</model>
<order_status>pending</order_status>
<title>Adyen</title>
<recurring_type>ONECLICK</recurring_type>
<title>Adyen CC</title>
<allowspecific>0</allowspecific>
<sort_order>1</sort_order>
<cctypes>AE,VI,MC,DI</cctypes>
<useccv>1</useccv>
<cse_enabled>1</cse_enabled>
<group>adyen</group>
</adyen_cc>
<adyen_hpp>
......
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Magento/Cron/etc/crontab.xsd">
<group id="index">
<job name="adyen_payment_process_notification" instance="Adyen\Payment\Model\Cron" method="processNotification">
<schedule>* * * * *</schedule>
</job>
</group>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<type name="Adyen\Payment\Logger\Handler\AdyenDebug">
<arguments>
<argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
</arguments>
</type>
<type name="Adyen\Payment\Logger\AdyenLogger">
<arguments>
<argument name="name" xsi:type="string">AdyenLoggerTest</argument>
<argument name="handlers" xsi:type="array">
<item name="adyenDebug" xsi:type="object">Adyen\Payment\Logger\Handler\AdyenDebug</item>
</argument>
</arguments>
</type>
</config>
\ No newline at end of file
......@@ -6,17 +6,10 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<virtualType name="AdyenCcConfigProvider" type="Magento\Payment\Model\CcGenericConfigProvider">
<arguments>
<argument name="methodCodes" xsi:type="array">
<item name="adyen_cc" xsi:type="const">Adyen\Payment\Model\Method\Cc::METHOD_CODE</item>
</argument>
</arguments>
</virtualType>
<type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments>
<argument name="configProviders" xsi:type="array">
<item name="adyen_cc_config_provider" xsi:type="object">AdyenCcConfigProvider</item>
<item name="adyen_cc_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenCcConfigProvider</item>
<item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenHppConfigProvider</item>
</argument>
</arguments>
......
......@@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="1.0.0">
<module name="Adyen_Payment" setup_version="0.1.0">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
......
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<css src="Adyen_Payment::styles.css"/>
</head>
</page>
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
.adyen-method-adyen-cc > .entry-edit-head > .config-heading .heading strong { padding-left:90px;background:url(images/adyen-logo.png) no-repeat 0 0; background-size: 83px 24px;line-height: 23px;}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -6,15 +6,21 @@
/*global define*/
define(
[
'underscore',
'jquery',
'Magento_Payment/js/view/payment/cc-form',
'Magento_Checkout/js/action/set-payment-information',
'Magento_Checkout/js/action/place-order',
'mage/translate',
'Adyen_Payment/js/view/payment/adyen-encrypt'
],
function (Component, setPaymentInformationAction) {
function (_, $, Component, setPaymentInformationAction, placeOrderAction, $t) {
'use strict';
return Component.extend({
defaults: {
template: 'Adyen_Payment/payment/cc-form',
creditCardOwner: ''
creditCardOwner: '',
encryptedData: ''
},
initObservable: function () {
this._super()
......@@ -27,10 +33,35 @@ define(
'creditCardSsStartMonth',
'creditCardSsStartYear',
'selectedCardType',
'creditCardOwner'
'creditCardOwner',
'encryptedData',
]);
return this;
},
initialize: function() {
var self = this;
this._super();
// when creditCarNumber change call encrypt function
this.creditCardNumber.subscribe(function(value) {
self.calculateCseKey();
});
this.creditCardOwner.subscribe(function(value) {
self.calculateCseKey();
});
//this.creditCardExpMonth.subscribe(function(value) {
// self.calculateCseKey();
//});
//this.creditCardExpYear.subscribe(function(value) {
// self.calculateCseKey();
//});
this.creditCardVerificationNumber.subscribe(function(value) {
self.calculateCseKey();
});
},
placeOrderHandler: null,
validateHandler: null,
setPlaceOrderHandler: function(handler) {
......@@ -53,13 +84,61 @@ define(
additional_data: {
'cc_cid': this.creditCardVerificationNumber(),
'cc_ss_start_month': this.creditCardSsStartMonth(),
'cc_ss_start_year': this.creditCardSsStartYear()
'cc_ss_start_year': this.creditCardSsStartYear(),
'encrypted_data': this.encryptedData()
}
};
},
isActive: function() {
return true;
},
placeOrder: function() {
var self = this;
//var cse_form = $("adyen-cc-form");
var cse_form = document.getElementById('adyen-cc-form');
var cse_key = this.getCSEKey();
var cse_options = {
name: 'payment[encrypted_data]',
enableValidations: true,
//submitButtonAlwaysEnabled: true
};
var cseInstance = adyen.encrypt.createEncryptedForm(cse_form, cse_key, cse_options);
// TODO needs to be done through php
var generation = new Date().toISOString();
var cardData = {
number : self.creditCardNumber,
cvc : self.creditCardVerificationNumber,
holderName : self.creditCardOwner,
expiryMonth : self.creditCardExpMonth,
expiryYear : self.creditCardExpYear,
generationtime : generation
};
var data = cseInstance.encrypt(cardData);
self.encryptedData(data);
var placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(){
self.isPlaceOrderActionAllowed(true);
});
//return true;
//
//if (this.validateHandler()) {
// this.isPlaceOrderActionAllowed(false);
// $.when(setPaymentInformationAction()).done(function() {
// self.placeOrderHandler();
// }).fail(function() {
// self.isPlaceOrderActionAllowed(true);
// });
//}
},
getTitle: function() {
return 'Adyen cc';
},
......@@ -72,6 +151,35 @@ define(
context: function() {
return this;
},
isCseEnabled: function() {
return window.checkoutConfig.payment.adyenCc.cseEnabled;
},
getCSEKey: function() {
return window.checkoutConfig.payment.adyenCc.cseKey;
},
getGenerationTime: function() {
return window.checkoutConfig.payment.adyenCc.generationTime;
},
isShowLegend: function() {
return true;
},
calculateCseKey: function() {
//
////var cse_form = $("adyen-cc-form");
//var cse_form = document.getElementById('adyen-cc-form');
//var cse_key = this.getCSEKey();
//var cse_options = {
// name: 'payment[encrypted_data]',
// enableValidations: true, // disable because month needs to be 01 isntead of 1
// //submitButtonAlwaysEnabled: true
//};
//
//var result = adyen.encrypt.createEncryptedForm(cse_form, cse_key, cse_options);
}
});
}
);
......
......@@ -22,7 +22,7 @@
<form class="form" id="co-transparent-form" action="#" method="post" data-bind="mageInit: {
<form class="form" id="adyen-cc-form" action="#" method="post" data-bind="mageInit: {
'transparent':{
'context': context(),
'controller': getControllerName(),
......@@ -37,6 +37,7 @@
<span><!-- ko i18n: 'Credit Card Information'--><!-- /ko --></span>
</legend><br />
<!-- /ko -->
<div class="field type required">
<label data-bind="attr: {for: getCode() + '_cc_type'}" class="label">
<span><!-- ko i18n: 'Credit Card Type'--><!-- /ko --></span>
......@@ -71,6 +72,7 @@
</label>
<div class="control">
<input type="number" name="payment[cc_number]" class="input-text" value=""
data-encrypted-name="number"
data-bind="attr: {
autocomplete: off,
id: getCode() + '_cc_number',
......@@ -91,6 +93,7 @@
name="payment[cc_owner]"
class="input-text"
value=""
data-encrypted-name="holderName"
data-bind="attr: {id: getCode() + '_cc_owner', 'data-container': getCode() + '-cc-owner'},
enable: isActive($parents),
value: creditCardOwner">
......@@ -106,6 +109,7 @@
<div class="control">
<select name="payment[cc_exp_month]"
class="select select-month"
data-encrypted-name="expiryMonth"
data-bind="attr: {id: getCode() + '_expiration', 'data-container': getCode() + '-cc-month', 'data-validate': JSON.stringify({required:true, 'validate-cc-exp':'#' + getCode() + '_expiration_yr'})},
enable: isActive($parents),
options: getCcMonthsValues(),
......@@ -120,6 +124,7 @@
<div class="control">
<select name="payment[cc_exp_year]"
class="select select-year"
data-encrypted-name="expiryYear"
data-bind="attr: {id: getCode() + '_expiration_yr', 'data-container': getCode() + '-cc-year', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents),
options: getCcYearsValues(),
......@@ -142,6 +147,7 @@
<input type="number"
autocomplete="off"
class="input-text cvv"
data-encrypted-name="cvc"
name="payment[cc_cid]"
value=""
data-bind="attr: {id: getCode() + '_cc_cid',
......@@ -226,6 +232,14 @@
</div>
</div>
<!-- /ko -->
<!-- ko if: (isCseEnabled())-->
<input type="hidden" id="adyen_encrypted_form_expiry_generationtime" data-bind="value: getGenerationTime()" data-encrypted-name="generationtime" />
<!-- /ko -->
</fieldset>
<div class="checkout-agreements-block">
......@@ -252,5 +266,3 @@
</div>
</div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment