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(
'Adyen_Payment/js/threeds2-js-utils',
'Adyen_Payment/js/model/threeds2',
'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 (
$,
......@@ -60,7 +61,8 @@ define(
threeDS2Utils,
threeds2,
errorProcessor,
adyenPaymentService
adyenPaymentService,
AdyenComponent
) {
'use strict';
......@@ -87,9 +89,11 @@ define(
this.vaultEnabler.isActivePaymentTokenEnabler(false);
// initialize adyen component for general use
this.checkout = new AdyenCheckout({
locale: this.getLocale()
});
this.checkout = new AdyenCheckout({
locale: this.getLocale(),
originKey: this.getOriginKey(),
environment: this.getCheckoutEnvironment()
});
return this;
},
......@@ -137,8 +141,6 @@ define(
var cardNode = document.getElementById('cardContainer');
self.cardComponent = self.checkout.create('card', {
originKey: self.getOriginKey(),
environment: self.getCheckoutEnvironment(),
type: 'card',
hasHolderName: true,
holderNameRequired: true,
......
......@@ -35,9 +35,10 @@ define(
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/action/place-order',
'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';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
......@@ -82,9 +83,7 @@ define(
* Create sherable checkout component
* @type {AdyenCheckout}
*/
self.checkoutComponent = new AdyenCheckout({
locale: self.getLocale()
});
self.checkoutComponent = new AdyenCheckout({ locale: self.getLocale()});
// reset variable:
adyenPaymentService.setPaymentMethods();
......
......@@ -41,7 +41,8 @@ define(
'Magento_Checkout/js/action/place-order',
'Adyen_Payment/js/model/threeds2',
'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 (
ko,
......@@ -64,7 +65,8 @@ define(
placeOrderAction,
threeds2,
errorProcessor,
adyenPaymentService
adyenPaymentService,
AdyenComponent
) {
'use strict';
......@@ -135,9 +137,7 @@ define(
locale: self.getLocale(),
originKey: self.getOriginKey(),
environment: self.getCheckoutEnvironment(),
risk: {
enabled: false
}
});
// convert to list so you can iterate
......@@ -267,19 +267,56 @@ define(
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
.create('card', {
.create('card',{
type: self.agreement_data.variant,
hideCVC: hideCVC,
details: self.getOneclickDetails(),
storedDetails: {
"card": {
"expiryMonth": self.agreement_data.card.expiryMonth,
"expiryYear": self.agreement_data.card.expiryYear,
"holderName": self.agreement_data.card.holderName,
"number": self.agreement_data.card.number
}
},
// storedDetails: {
// "card": {
// "expiryMonth": self.agreement_data.card.expiryMonth,
// "expiryYear": self.agreement_data.card.expiryYear,
// "holderName": self.agreement_data.card.holderName,
// "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) {
if (state.isValid) {
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