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 703b5e20 authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

PW-300 Hosted CSE solution, change from CSE key to library token (#230)

* PW-300 Hosted CSE solution, change from CSE key to library token

* use test or live url depending if running on test or live. adyen is already loaded through adyen_cc payment method so can be ignored for adyen_oneclick methdo

* add storeId into call
parent 279ee778
...@@ -67,7 +67,8 @@ class Cc extends \Magento\Payment\Block\Form\Cc ...@@ -67,7 +67,8 @@ class Cc extends \Magento\Payment\Block\Form\Cc
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Checkout\Model\Session $checkoutSession, \Magento\Checkout\Model\Session $checkoutSession,
array $data = [] array $data = []
) { )
{
parent::__construct($context, $paymentConfig); parent::__construct($context, $paymentConfig);
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_appState = $context->getAppState(); $this->_appState = $context->getAppState();
...@@ -79,7 +80,7 @@ class Cc extends \Magento\Payment\Block\Form\Cc ...@@ -79,7 +80,7 @@ class Cc extends \Magento\Payment\Block\Form\Cc
* @return mixed * @return mixed
* @throws \Magento\Framework\Exception\LocalizedException * @throws \Magento\Framework\Exception\LocalizedException
*/ */
public function getCsePublicKey() public function getLibrarySource()
{ {
// get storeId for admin // get storeId for admin
if (!$this->_appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { if (!$this->_appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
...@@ -88,15 +89,7 @@ class Cc extends \Magento\Payment\Block\Form\Cc ...@@ -88,15 +89,7 @@ class Cc extends \Magento\Payment\Block\Form\Cc
$storeId = null; $storeId = null;
} }
$demoMode = $this->_adyenHelper->getAdyenAbstractConfigDataFlag('demo_mode', $storeId); return $this->_adyenHelper->getLibrarySource($storeId);
if($demoMode) {
$cseKey = $this->_adyenHelper->getAdyenCcConfigData('cse_publickey_test', $storeId);
} else {
$cseKey = $this->_adyenHelper->getAdyenCcConfigData('cse_publickey_live', $storeId);
}
return $cseKey;
} }
/** /**
...@@ -111,7 +104,7 @@ class Cc extends \Magento\Payment\Block\Form\Cc ...@@ -111,7 +104,7 @@ class Cc extends \Magento\Payment\Block\Form\Cc
$this->getCheckoutSession(); $this->getCheckoutSession();
$store = $this->_checkoutSession->getQuote()->getStore(); $store = $this->_checkoutSession->getQuote()->getStore();
$enableMoto = $this->_adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $store->getId()); $enableMoto = $this->_adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $store->getId());
if($enableMoto) { if ($enableMoto) {
return false; return false;
} }
} }
......
...@@ -47,7 +47,8 @@ class CcAuthorizationDataBuilder implements BuilderInterface ...@@ -47,7 +47,8 @@ class CcAuthorizationDataBuilder implements BuilderInterface
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Model\Context $context \Magento\Framework\Model\Context $context
) { )
{
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->appState = $context->getAppState(); $this->appState = $context->getAppState();
} }
...@@ -65,38 +66,30 @@ class CcAuthorizationDataBuilder implements BuilderInterface ...@@ -65,38 +66,30 @@ class CcAuthorizationDataBuilder implements BuilderInterface
$storeId = $order->getStoreId(); $storeId = $order->getStoreId();
$request = []; $request = [];
if ($this->adyenHelper->getAdyenCcConfigDataFlag('cse_enabled', $storeId)) {
$request['additionalData']['card.encrypted.json'] =
$payment->getAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_DATA);
// Remove from additional data $request['additionalData']['card.encrypted.json'] =
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_DATA); $payment->getAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_DATA);
} else {
$requestCreditCardDetails = [ // Remove from additional data
"expiryMonth" => $payment->getCcExpMonth(), $payment->unsAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_DATA);
"expiryYear" => $payment->getCcExpYear(),
"holderName" => $payment->getCcOwner(),
"number" => $payment->getCcNumber(),
"cvc" => $payment->getCcCid(),
];
$cardDetails['card'] = $requestCreditCardDetails;
$request = array_merge($request, $cardDetails);
}
/** /**
* if MOTO for backend is enabled use MOTO as shopper interaction type * if MOTO for backend is enabled use MOTO as shopper interaction type
*/ */
$enableMoto = $this->adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId); $enableMoto = $this->adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE && if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE &&
$enableMoto) { $enableMoto
) {
$request['shopperInteraction'] = "Moto"; $request['shopperInteraction'] = "Moto";
} }
// if installments is set add it into the request // if installments is set add it into the request
if ($payment->getAdditionalInformation('number_of_installments') && if ($payment->getAdditionalInformation('number_of_installments') &&
$payment->getAdditionalInformation('number_of_installments') > 0) { $payment->getAdditionalInformation('number_of_installments') > 0
) {
$request['installments']['value'] = $payment->getAdditionalInformation('number_of_installments'); $request['installments']['value'] = $payment->getAdditionalInformation('number_of_installments');
} }
return $request; return $request;
} }
} }
\ No newline at end of file
...@@ -31,6 +31,9 @@ use Magento\Framework\App\Helper\AbstractHelper; ...@@ -31,6 +31,9 @@ use Magento\Framework\App\Helper\AbstractHelper;
class Data extends AbstractHelper class Data extends AbstractHelper
{ {
const TEST = 'test';
const LIVE = 'live';
/** /**
* @var \Magento\Framework\Encryption\EncryptorInterface * @var \Magento\Framework\Encryption\EncryptorInterface
*/ */
...@@ -88,7 +91,8 @@ class Data extends AbstractHelper ...@@ -88,7 +91,8 @@ class Data extends AbstractHelper
\Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\View\Asset\Source $assetSource, \Magento\Framework\View\Asset\Source $assetSource,
\Adyen\Payment\Model\Resource\Notification\CollectionFactory $notificationFactory \Adyen\Payment\Model\Resource\Notification\CollectionFactory $notificationFactory
) { )
{
parent::__construct($context); parent::__construct($context);
$this->_encryptor = $encryptor; $this->_encryptor = $encryptor;
$this->_dataStorage = $dataStorage; $this->_dataStorage = $dataStorage;
...@@ -873,4 +877,33 @@ class Data extends AbstractHelper ...@@ -873,4 +877,33 @@ class Data extends AbstractHelper
return count($notifications); return count($notifications);
} }
/**
* @param $storeId
* @return mixed
*/
public function getLibraryToken($storeId = null)
{
if ($this->isDemoMode($storeId)) {
$libraryToken = $this->getAdyenCcConfigData('cse_library_token_test', $storeId);
} else {
$libraryToken = $this->getAdyenCcConfigData('cse_library_token_live', $storeId);
}
return $libraryToken;
}
/**
* Returns the hosted location of the client side encryption file
*
* @param null $storeId
* @return string
*/
public function getLibrarySource($storeId = null)
{
$environment = self::LIVE;
if ($this->isDemoMode($storeId)) {
$environment = self::TEST;
}
return "https://" . $environment . ".adyen.com/hpp/cse/js/" . $this->getLibraryToken($storeId) . ".shtml";
}
} }
\ No newline at end of file
...@@ -64,7 +64,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -64,7 +64,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
* @var \Magento\Payment\Model\CcConfig * @var \Magento\Payment\Model\CcConfig
*/ */
private $ccConfig; private $ccConfig;
/** /**
* AdyenCcConfigProvider constructor. * AdyenCcConfigProvider constructor.
...@@ -84,7 +84,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -84,7 +84,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
\Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\UrlInterface $urlBuilder,
Source $assetSource, Source $assetSource,
\Magento\Payment\Model\CcConfig $ccConfig \Magento\Payment\Model\CcConfig $ccConfig
) { )
{
$this->_paymentHelper = $paymentHelper; $this->_paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_request = $request; $this->_request = $request;
...@@ -123,25 +124,13 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -123,25 +124,13 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
] ]
]); ]);
$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');
$recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type'); $recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type');
$canCreateBillingAgreement = false; $canCreateBillingAgreement = false;
if ($recurringType == "ONECLICK" || $recurringType == "ONECLICK,RECURRING") { if ($recurringType == "ONECLICK" || $recurringType == "ONECLICK,RECURRING") {
$canCreateBillingAgreement = true; $canCreateBillingAgreement = true;
} }
$config['payment'] ['adyenCc']['cseKey'] = $cseKey; $config['payment'] ['adyenCc']['librarySource'] = $this->_adyenHelper->getLibrarySource();
$config['payment'] ['adyenCc']['cseEnabled'] = $cseEnabled;
$config['payment'] ['adyenCc']['cseEnabled'] = $cseEnabled;
$config['payment']['adyenCc']['generationTime'] = date("c"); $config['payment']['adyenCc']['generationTime'] = date("c");
$config['payment']['adyenCc']['canCreateBillingAgreement'] = $canCreateBillingAgreement; $config['payment']['adyenCc']['canCreateBillingAgreement'] = $canCreateBillingAgreement;
$config['payment']['adyenCc']['icons'] = $this->getIcons(); $config['payment']['adyenCc']['icons'] = $this->getIcons();
...@@ -250,7 +239,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface ...@@ -250,7 +239,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
{ {
return $this->ccConfig->getCvvImageUrl(); return $this->ccConfig->getCvvImageUrl();
} }
/** /**
* Retrieve request object * Retrieve request object
* *
......
...@@ -90,7 +90,8 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -90,7 +90,8 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\UrlInterface $urlBuilder,
\Magento\Payment\Model\CcConfig $ccConfig \Magento\Payment\Model\CcConfig $ccConfig
) { )
{
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_request = $request; $this->_request = $request;
$this->_customerSession = $customerSession; $this->_customerSession = $customerSession;
...@@ -130,25 +131,13 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -130,25 +131,13 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
] ]
]); ]);
$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');
$recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type'); $recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type');
$canCreateBillingAgreement = false; $canCreateBillingAgreement = false;
if ($recurringType == "ONECLICK" || $recurringType == "ONECLICK,RECURRING") { if ($recurringType == "ONECLICK" || $recurringType == "ONECLICK,RECURRING") {
$canCreateBillingAgreement = true; $canCreateBillingAgreement = true;
} }
$config['payment'] ['adyenOneclick']['cseKey'] = $cseKey; $config['payment'] ['adyenOneclick']['librarySource'] = $this->_adyenHelper->getLibrarySource();
$config['payment'] ['adyenOneclick']['cseEnabled'] = $cseEnabled;
$config['payment'] ['adyenOneclick']['cseEnabled'] = $cseEnabled;
$config['payment']['adyenOneclick']['generationTime'] = date("c"); $config['payment']['adyenOneclick']['generationTime'] = date("c");
$config['payment']['adyenOneclick']['canCreateBillingAgreement'] = $canCreateBillingAgreement; $config['payment']['adyenOneclick']['canCreateBillingAgreement'] = $canCreateBillingAgreement;
...@@ -178,9 +167,9 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -178,9 +167,9 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
$recurringType = $this->_getRecurringContractType(); $recurringType = $this->_getRecurringContractType();
$billingAgreements = $this->_adyenHelper->getOneClickPaymentMethods( $billingAgreements = $this->_adyenHelper->getOneClickPaymentMethods(
$customerId, $customerId,
$storeId, $storeId,
$grandTotal, $grandTotal,
$recurringType $recurringType
); );
} }
...@@ -227,7 +216,6 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface ...@@ -227,7 +216,6 @@ class AdyenOneclickConfigProvider implements ConfigProviderInterface
} }
/** /**
* Retrieve credit card expire months * Retrieve credit card expire months
* *
......
...@@ -47,20 +47,15 @@ ...@@ -47,20 +47,15 @@
<source_model>Adyen\Payment\Model\Config\Source\CcType</source_model> <source_model>Adyen\Payment\Model\Config\Source\CcType</source_model>
<config_path>payment/adyen_cc/cctypes</config_path> <config_path>payment/adyen_cc/cctypes</config_path>
</field> </field>
<!--<field id="cse_enabled" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">--> <field id="cse_library_token_test" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<!--<label>Enable CSE</label>--> <label>Library token of Test Adyen Web Service User</label>
<!--<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>--> <tooltip>Copy this from the Test Adyen Customer Area => Settings => Users => System => [web service user]=> Library token.</tooltip>
<!--<config_path>payment/adyen_cc/cse_enabled</config_path>--> <config_path>payment/adyen_cc/cse_library_token_test</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>
<field id="cse_publickey_live" translate="label" type="textarea" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="cse_library_token_live" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enter CSE Public Key of Live Adyen Web Service User</label> <label>Library token of Live Adyen Web Service User</label>
<depends><field id="cse_enabled">1</field></depends> <tooltip>Copy this from the Live Adyen Customer Area => Settings => Users => System => [web service user]=> Library token.</tooltip>
<config_path>payment/adyen_cc/cse_publickey_live</config_path> <config_path>payment/adyen_cc/cse_library_token_live</config_path>
</field> </field>
<group id="adyen_cc_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" sortOrder="150"> <group id="adyen_cc_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" sortOrder="150">
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
<sort_order>2</sort_order> <sort_order>2</sort_order>
<cctypes>AE,VI,MC,DI</cctypes> <cctypes>AE,VI,MC,DI</cctypes>
<useccv>1</useccv> <useccv>1</useccv>
<cse_enabled>1</cse_enabled>
<enable_moto>0</enable_moto> <enable_moto>0</enable_moto>
<payment_action>authorize</payment_action> <payment_action>authorize</payment_action>
<is_gateway>1</is_gateway> <is_gateway>1</is_gateway>
...@@ -71,7 +70,6 @@ ...@@ -71,7 +70,6 @@
<recurring_payment_type>ONECLICK</recurring_payment_type> <recurring_payment_type>ONECLICK</recurring_payment_type>
<payment_action>authorize</payment_action> <payment_action>authorize</payment_action>
<useccv>1</useccv> <useccv>1</useccv>
<cse_enabled>1</cse_enabled>
<enable_moto>0</enable_moto> <enable_moto>0</enable_moto>
<payment_action>authorize</payment_action> <payment_action>authorize</payment_action>
<is_gateway>1</is_gateway> <is_gateway>1</is_gateway>
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5,9 +5,6 @@ ...@@ -5,9 +5,6 @@
/*jshint browser:true jquery:true*/ /*jshint browser:true jquery:true*/
/*global alert*/ /*global alert*/
var config = { var config = {
paths: {
'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min'
},
config: { config: {
mixins: { mixins: {
'Adyen_Payment/js/action/place-order': { 'Adyen_Payment/js/action/place-order': {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -34,9 +34,8 @@ define( ...@@ -34,9 +34,8 @@ define(
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'ko', 'ko',
'Adyen_Payment/js/model/installments', 'Adyen_Payment/js/model/installments',
'adyen/encrypt'
], ],
function (_, $, Component, placeOrderAction, $t, additionalValidators, customer, creditCardData, quote, ko, installments, adyenEncrypt) { function (_, $, Component, placeOrderAction, $t, additionalValidators, customer, creditCardData, quote, ko, installments) {
'use strict'; 'use strict';
var cvcLength = ko.observable(4); var cvcLength = ko.observable(4);
...@@ -69,21 +68,27 @@ define( ...@@ -69,21 +68,27 @@ define(
return this; return this;
}, },
getInstallments: installments.getInstallments(), getInstallments: installments.getInstallments(),
initialize: function() { initialize: function () {
var self = this; var self = this;
this._super(); this._super();
// include dynamic cse javascript
var dfScriptTag = document.createElement('script');
dfScriptTag.src = this.getLibrarySource();
dfScriptTag.type = "text/javascript";
document.body.appendChild(dfScriptTag);
//Set credit card number to credit card data object //Set credit card number to credit card data object
this.creditCardNumber.subscribe(function(value) { this.creditCardNumber.subscribe(function (value) {
// installments enabled ?? // installments enabled ??
var allInstallments = self.getAllInstallments(); var allInstallments = self.getAllInstallments();
// what card is this ?? // what card is this ??
var creditcardType = creditCardData.creditCard.type; var creditcardType = creditCardData.creditCard.type;
if(creditcardType) { if (creditcardType) {
cvcLength(4); cvcLength(4);
if (creditcardType != "AE"){ if (creditcardType != "AE") {
cvcLength(3); cvcLength(3);
} }
if (creditcardType in allInstallments) { if (creditcardType in allInstallments) {
...@@ -93,13 +98,13 @@ define( ...@@ -93,13 +98,13 @@ define(
var numberOfInstallments = 0; var numberOfInstallments = 0;
$.each(installmentCreditcard, function (amount, installment) { $.each(installmentCreditcard, function (amount, installment) {
if(grandTotal <= amount) { if (grandTotal <= amount) {
numberOfInstallments = installment; numberOfInstallments = installment;
return false; return false;
} }
}); });
if(numberOfInstallments > 0) { if (numberOfInstallments > 0) {
installments.setInstallments(numberOfInstallments); installments.setInstallments(numberOfInstallments);
} }
} else { } else {
...@@ -108,16 +113,16 @@ define( ...@@ -108,16 +113,16 @@ define(
} }
}); });
}, },
setPlaceOrderHandler: function(handler) { setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler; this.placeOrderHandler = handler;
}, },
setValidateHandler: function(handler) { setValidateHandler: function (handler) {
this.validateHandler = handler; this.validateHandler = handler;
}, },
getCode: function() { getCode: function () {
return 'adyen_cc'; return 'adyen_cc';
}, },
getData: function() { getData: function () {
return { return {
'method': this.item.method, 'method': this.item.method,
additional_data: { additional_data: {
...@@ -129,16 +134,16 @@ define( ...@@ -129,16 +134,16 @@ define(
} }
}; };
}, },
getCvcLength: function() { getCvcLength: function () {
return cvcLength(); return cvcLength();
}, },
isActive: function() { isActive: function () {
return true; return true;
}, },
/** /**
* @override * @override
*/ */
placeOrder: function(data, event) { placeOrder: function (data, event) {
var self = this, var self = this,
placeOrder; placeOrder;
...@@ -146,19 +151,18 @@ define( ...@@ -146,19 +151,18 @@ define(
event.preventDefault(); event.preventDefault();
} }
var cse_key = this.getCSEKey();
var options = {};
var cseInstance = adyenEncrypt.createEncryption(cse_key, options); var options = {};
var cseInstance = adyen.createEncryption(options);
var generationtime = self.getGenerationTime(); var generationtime = self.getGenerationTime();
var cardData = { var cardData = {
number : self.creditCardNumber(), number: self.creditCardNumber(),
cvc : self.creditCardVerificationNumber(), cvc: self.creditCardVerificationNumber(),
holderName : self.creditCardOwner(), holderName: self.creditCardOwner(),
expiryMonth : self.creditCardExpMonth(), expiryMonth: self.creditCardExpMonth(),
expiryYear : self.creditCardExpYear(), expiryYear: self.creditCardExpYear(),
generationtime : generationtime generationtime: generationtime
}; };
var data = cseInstance.encrypt(cardData); var data = cseInstance.encrypt(cardData);
...@@ -168,44 +172,41 @@ define( ...@@ -168,44 +172,41 @@ define(
this.isPlaceOrderActionAllowed(false); this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder); placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(response) { $.when(placeOrder).fail(function (response) {
self.isPlaceOrderActionAllowed(true); self.isPlaceOrderActionAllowed(true);
}); });
return true; return true;
} }
return false; return false;
}, },
getControllerName: function() { getControllerName: function () {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()]; return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
}, },
getPlaceOrderUrl: function() { getPlaceOrderUrl: function () {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()]; return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
}, },
context: function() { context: function () {
return this; return this;
}, },
isCseEnabled: function() { getLibrarySource: function () {
return window.checkoutConfig.payment.adyenCc.cseEnabled; return window.checkoutConfig.payment.adyenCc.librarySource;
},
getCSEKey: function() {
return window.checkoutConfig.payment.adyenCc.cseKey;
}, },
getGenerationTime: function() { getGenerationTime: function () {
return window.checkoutConfig.payment.adyenCc.generationTime; return window.checkoutConfig.payment.adyenCc.generationTime;
}, },
canCreateBillingAgreement: function() { canCreateBillingAgreement: function () {
if(customer.isLoggedIn()) { if (customer.isLoggedIn()) {
return window.checkoutConfig.payment.adyenCc.canCreateBillingAgreement; return window.checkoutConfig.payment.adyenCc.canCreateBillingAgreement;
} }
return false; return false;
}, },
isShowLegend: function() { isShowLegend: function () {
return true; return true;
}, },
validate: function () { validate: function () {
var form = 'form[data-role=adyen-cc-form]'; var form = 'form[data-role=adyen-cc-form]';
var validate = $(form).validation() && $(form).validation('isValid'); var validate = $(form).validation() && $(form).validation('isValid');
// add extra validation because jqeury validation will not work on non name attributes // add extra validation because jqeury validation will not work on non name attributes
var ccNumber = Boolean($(form + ' #creditCardNumber').valid()); var ccNumber = Boolean($(form + ' #creditCardNumber').valid());
var owner = Boolean($(form + ' #creditCardHolderName').valid()); var owner = Boolean($(form + ' #creditCardHolderName').valid());
...@@ -213,13 +214,13 @@ define( ...@@ -213,13 +214,13 @@ define(
var expiration_yr = Boolean($(form + ' #adyen_cc_expiration_yr').valid()); var expiration_yr = Boolean($(form + ' #adyen_cc_expiration_yr').valid());
var cid = Boolean($(form + ' #adyen_cc_cc_cid').valid()); var cid = Boolean($(form + ' #adyen_cc_cc_cid').valid());
if(!validate || !ccNumber || !owner || !expiration || !expiration_yr || !cid) { if (!validate || !ccNumber || !owner || !expiration || !expiration_yr || !cid) {
return false; return false;
} }
return true; return true;
}, },
showLogo: function() { showLogo: function () {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
getIcons: function (type) { getIcons: function (type) {
...@@ -227,10 +228,10 @@ define( ...@@ -227,10 +228,10 @@ define(
? window.checkoutConfig.payment.adyenCc.icons[type] ? window.checkoutConfig.payment.adyenCc.icons[type]
: false : false
}, },
hasInstallments: function() { hasInstallments: function () {
return window.checkoutConfig.payment.adyenCc.hasInstallments; return window.checkoutConfig.payment.adyenCc.hasInstallments;
}, },
getAllInstallments: function() { getAllInstallments: function () {
return window.checkoutConfig.payment.adyenCc.installments; return window.checkoutConfig.payment.adyenCc.installments;
} }
}); });
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
</div> </div>
<form class="form" id="adyen-cc-form" data-role="adyen-cc-form" action="#" method="post" data-bind="mageInit: { <form class="form" id="adyen-cc-form" data-role="adyen-cc-form" action="#" method="post" data-bind="mageInit: {
'transparent':{ 'transparent':{
'context': context(), 'context': context(),
...@@ -54,13 +53,15 @@ ...@@ -54,13 +53,15 @@
}, 'validation':[]}"> }, 'validation':[]}">
<fieldset data-bind="attr: {class: 'fieldset payment items ccard ' + getCode(), id: 'payment_form_' + getCode()}"> <fieldset
data-bind="attr: {class: 'fieldset payment items ccard ' + getCode(), id: 'payment_form_' + getCode()}">
<!-- ko if: (isShowLegend())--> <!-- ko if: (isShowLegend())-->
<legend class="legend"> <legend class="legend">
<span><!-- ko text: $t('Credit Card Information')--><!-- /ko --></span> <span><!-- ko text: $t('Credit Card Information')--><!-- /ko --></span>
</legend><br /> </legend>
<br/>
<!-- /ko --> <!-- /ko -->
<div class="field type required"> <div class="field type required">
<label data-bind="attr: {for: getCode() + '_cc_type'}" class="label"> <label data-bind="attr: {for: getCode() + '_cc_type'}" class="label">
<span><!-- ko text: $t('Credit Card Type')--><!-- /ko --></span> <span><!-- ko text: $t('Credit Card Type')--><!-- /ko --></span>
...@@ -125,7 +126,7 @@ ...@@ -125,7 +126,7 @@
value: creditCardOwner, value: creditCardOwner,
valueUpdate: 'keyup' " valueUpdate: 'keyup' "
data-validate="{required:true}" data-validate="{required:true}"
/> />
</div> </div>
</div> </div>
<div class="field date required" data-bind="attr: {id: getCode() + '_cc_type_exp_div'}"> <div class="field date required" data-bind="attr: {id: getCode() + '_cc_type_exp_div'}">
...@@ -136,9 +137,9 @@ ...@@ -136,9 +137,9 @@
<div class="fields group group-2"> <div class="fields group group-2">
<div class="field no-label month"> <div class="field no-label month">
<div class="control"> <div class="control">
<select class="select select-month" <select class="select select-month"
data-encrypted-name="expiryMonth" 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'})}, 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), enable: isActive($parents),
options: getCcMonthsValues(), options: getCcMonthsValues(),
optionsValue: 'value', optionsValue: 'value',
...@@ -187,9 +188,9 @@ ...@@ -187,9 +188,9 @@
oninput:'javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);' oninput:'javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);'
}, },
enable: isActive($parents), enable: isActive($parents),
value: creditCardVerificationNumber", value: creditCardVerificationNumber" ,
data-validate="{required:true}" data-validate="{required:true}"
/> />
<div class="field-tooltip toggle"> <div class="field-tooltip toggle">
<span class="field-tooltip-action action-cvv" <span class="field-tooltip-action action-cvv"
tabindex="0" tabindex="0"
...@@ -208,21 +209,22 @@ ...@@ -208,21 +209,22 @@
<!-- ko if: (hasInstallments())--> <!-- ko if: (hasInstallments())-->
<div class="field required" data-bind="attr: {id: getCode() + '_installments_div'}, visible: getInstallments().length > 0"> <div class="field required"
data-bind="attr: {id: getCode() + '_installments_div'}, visible: getInstallments().length > 0">
<label data-bind="attr: {for: getCode() + '_installments'}" class="label"> <label data-bind="attr: {for: getCode() + '_installments'}" class="label">
<span><!-- ko text: $t('Installments')--><!-- /ko --></span> <span><!-- ko text: $t('Installments')--><!-- /ko --></span>
</label> </label>
<div class="control"> <div class="control">
<select class="select" <select class="select"
name="payment[number_of_installments]" name="payment[number_of_installments]"
data-bind="attr: {id: getCode() + '_installments', 'data-container': getCode() + '-installments', 'data-validate': JSON.stringify({required:true})}, data-bind="attr: {id: getCode() + '_installments', 'data-container': getCode() + '-installments', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents), enable: isActive($parents),
options: getInstallments, options: getInstallments,
optionsValue: 'value', optionsValue: 'value',
optionsText: 'key', optionsText: 'key',
optionsCaption: $t('Installments'), optionsCaption: $t('Installments'),
value: installment" value: installment"
data-validate="{required:true}"> data-validate="{required:true}">
</select> </select>
</div> </div>
</div> </div>
...@@ -239,7 +241,7 @@ ...@@ -239,7 +241,7 @@
autocomplete="off" autocomplete="off"
class="checkbox" class="checkbox"
data-bind="attr: {title: $t('Remember Me')}, checked: setStoreCc" data-bind="attr: {title: $t('Remember Me')}, checked: setStoreCc"
/> />
<label data-bind="attr: {for: getCode() + '_remember_details'}" class="label"> <label data-bind="attr: {for: getCode() + '_remember_details'}" class="label">
<span><!-- ko text: $t('Remember these details')--><!-- /ko --></span> <span><!-- ko text: $t('Remember these details')--><!-- /ko --></span>
</label> </label>
...@@ -248,19 +250,14 @@ ...@@ -248,19 +250,14 @@
<!-- /ko --> <!-- /ko -->
<!-- ko if: (isCseEnabled())--> <input type="hidden"
name="payment[generationtime]"
<input type="hidden" class="input-text"
name="payment[generationtime]" value=""
class="input-text" data-encrypted-name="generationtime"
value="" data-bind="attr: {id: getCode() + '_generationtime', 'data-container': getCode() + '-generationtime'},
data-encrypted-name="generationtime" value: getGenerationTime()"
data-bind="attr: {id: getCode() + '_generationtime', 'data-container': getCode() + '-generationtime'}, />
value: getGenerationTime()
">
<!-- /ko -->
</fieldset> </fieldset>
</form> </form>
......
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