Commit 86ce671a authored by alexandros's avatar alexandros

Add generic component

parent ea67f3ca
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -39,7 +39,8 @@ define( ...@@ -39,7 +39,8 @@ define(
'Adyen_Payment/js/threeds2-js-utils', 'Adyen_Payment/js/threeds2-js-utils',
'Adyen_Payment/js/model/threeds2', 'Adyen_Payment/js/model/threeds2',
'Magento_Checkout/js/model/error-processor', 'Magento_Checkout/js/model/error-processor',
'Adyen_Payment/js/model/adyen-payment-service' 'Adyen_Payment/js/model/adyen-payment-service',
'Adyen_Payment/js/bundle',
], ],
function ( function (
$, $,
...@@ -60,7 +61,8 @@ define( ...@@ -60,7 +61,8 @@ define(
threeDS2Utils, threeDS2Utils,
threeds2, threeds2,
errorProcessor, errorProcessor,
adyenPaymentService adyenPaymentService,
AdyenComponent
) { ) {
'use strict'; 'use strict';
...@@ -87,9 +89,11 @@ define( ...@@ -87,9 +89,11 @@ define(
this.vaultEnabler.isActivePaymentTokenEnabler(false); this.vaultEnabler.isActivePaymentTokenEnabler(false);
// initialize adyen component for general use // initialize adyen component for general use
this.checkout = new AdyenCheckout({ this.checkout = new AdyenCheckout({
locale: this.getLocale() locale: this.getLocale(),
}); originKey: this.getOriginKey(),
environment: this.getCheckoutEnvironment()
});
return this; return this;
}, },
...@@ -137,8 +141,6 @@ define( ...@@ -137,8 +141,6 @@ define(
var cardNode = document.getElementById('cardContainer'); var cardNode = document.getElementById('cardContainer');
self.cardComponent = self.checkout.create('card', { self.cardComponent = self.checkout.create('card', {
originKey: self.getOriginKey(),
environment: self.getCheckoutEnvironment(),
type: 'card', type: 'card',
hasHolderName: true, hasHolderName: true,
holderNameRequired: true, holderNameRequired: true,
......
...@@ -35,9 +35,10 @@ define( ...@@ -35,9 +35,10 @@ define(
'Magento_Checkout/js/model/full-screen-loader', 'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/action/place-order', 'Magento_Checkout/js/action/place-order',
'uiLayout', 'uiLayout',
'Magento_Ui/js/model/messages' 'Magento_Ui/js/model/messages',
'Adyen_Payment/js/bundle'
], ],
function (ko, $, Component, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader, placeOrderAction, layout, Messages) { function (ko, $, Component, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader, placeOrderAction, layout, Messages, AdyenComponent) {
'use strict'; 'use strict';
var brandCode = ko.observable(null); var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null); var paymentMethod = ko.observable(null);
...@@ -82,9 +83,7 @@ define( ...@@ -82,9 +83,7 @@ define(
* Create sherable checkout component * Create sherable checkout component
* @type {AdyenCheckout} * @type {AdyenCheckout}
*/ */
self.checkoutComponent = new AdyenCheckout({ self.checkoutComponent = new AdyenCheckout({ locale: self.getLocale()});
locale: self.getLocale()
});
// reset variable: // reset variable:
adyenPaymentService.setPaymentMethods(); adyenPaymentService.setPaymentMethods();
......
...@@ -41,7 +41,8 @@ define( ...@@ -41,7 +41,8 @@ define(
'Magento_Checkout/js/action/place-order', 'Magento_Checkout/js/action/place-order',
'Adyen_Payment/js/model/threeds2', 'Adyen_Payment/js/model/threeds2',
'Magento_Checkout/js/model/error-processor', 'Magento_Checkout/js/model/error-processor',
'Adyen_Payment/js/model/adyen-payment-service' 'Adyen_Payment/js/model/adyen-payment-service',
'Adyen_Payment/js/bundle'
], ],
function ( function (
ko, ko,
...@@ -64,7 +65,8 @@ define( ...@@ -64,7 +65,8 @@ define(
placeOrderAction, placeOrderAction,
threeds2, threeds2,
errorProcessor, errorProcessor,
adyenPaymentService adyenPaymentService,
AdyenComponent
) { ) {
'use strict'; 'use strict';
...@@ -135,9 +137,7 @@ define( ...@@ -135,9 +137,7 @@ define(
locale: self.getLocale(), locale: self.getLocale(),
originKey: self.getOriginKey(), originKey: self.getOriginKey(),
environment: self.getCheckoutEnvironment(), environment: self.getCheckoutEnvironment(),
risk: {
enabled: false
}
}); });
// convert to list so you can iterate // convert to list so you can iterate
...@@ -267,19 +267,56 @@ define( ...@@ -267,19 +267,56 @@ define(
hideCVC = true; hideCVC = true;
} }
const oneClickData = {
type: self.agreement_data.variant,
hideCVC: hideCVC,
details: self.getOneclickDetails(),
expiryMonth:self.agreement_data.card.expiryMonth,
expiryYear:self.agreement_data.card.expiryYear,
holderName:self.agreement_data.card.holderName,
number:self.agreement_data.card.number,
onChange: function (state, component) {
if (state.isValid) {
self.placeOrderAllowed(true);
isValid(true);
if (typeof state.data !== 'undefined' &&
typeof state.data.paymentMethod !== 'undefined' &&
typeof state.data.paymentMethod.encryptedSecurityCode !== 'undefined'
) {
self.encryptedCreditCardVerificationNumber = state.data.paymentMethod.encryptedSecurityCode;
}
} else {
self.encryptedCreditCardVerificationNumber = '';
if (self.agreement_data.variant != "maestro") {
self.placeOrderAllowed(false);
isValid(false);
}
}
}
};
console.log(oneClickData);
var oneClickCard = checkout var oneClickCard = checkout
.create('card', { .create('card',{
type: self.agreement_data.variant, type: self.agreement_data.variant,
hideCVC: hideCVC, hideCVC: hideCVC,
details: self.getOneclickDetails(), details: self.getOneclickDetails(),
storedDetails: { // storedDetails: {
"card": { // "card": {
"expiryMonth": self.agreement_data.card.expiryMonth, // "expiryMonth": self.agreement_data.card.expiryMonth,
"expiryYear": self.agreement_data.card.expiryYear, // "expiryYear": self.agreement_data.card.expiryYear,
"holderName": self.agreement_data.card.holderName, // "holderName": self.agreement_data.card.holderName,
"number": self.agreement_data.card.number // "number": self.agreement_data.card.number
} // }
}, // }
expiryMonth:self.agreement_data.card.expiryMonth,
expiryYear:self.agreement_data.card.expiryYear,
holderName:self.agreement_data.card.holderName,
number:self.agreement_data.card.number,
onChange: function (state, component) { onChange: function (state, component) {
if (state.isValid) { if (state.isValid) {
self.placeOrderAllowed(true); self.placeOrderAllowed(true);
......
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