Commit 935f8042 authored by Attila Kiss's avatar Attila Kiss Committed by GitHub

Add bundle.js with checkout component version 3.12.1 (#828)

Add the AdyenComponent var in the requireJS paramas
parent 52839256
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -40,7 +40,8 @@ define(
'Adyen_Payment/js/model/threeds2',
'Magento_Checkout/js/model/error-processor',
'Adyen_Payment/js/model/adyen-payment-service',
'adyenCheckout'
'adyenCheckout',
'Adyen_Payment/js/bundle'
],
function (
$,
......@@ -62,7 +63,8 @@ define(
threeds2,
errorProcessor,
adyenPaymentService,
AdyenCheckout
AdyenCheckout,
AdyenComponent
) {
'use strict';
......
......@@ -34,9 +34,23 @@ define(
'Magento_Checkout/js/model/full-screen-loader',
'mage/url',
'Magento_Vault/js/view/payment/vault-enabler',
'adyenCheckout'
'adyenCheckout',
'Adyen_Payment/js/bundle',
],
function (ko, $, Component, placeOrderAction, additionalValidators, quote, urlBuilder, fullScreenLoader, url, VaultEnabler, AdyenCheckout) {
function(
ko,
$,
Component,
placeOrderAction,
additionalValidators,
quote,
urlBuilder,
fullScreenLoader,
url,
VaultEnabler,
AdyenCheckout,
AdyenComponent,
) {
'use strict';
/**
......@@ -50,34 +64,33 @@ define(
defaults: {
template: 'Adyen_Payment/payment/google-pay-form',
googlePayToken: null,
googlePayAllowed: null
googlePayAllowed: null,
},
/**
* @returns {Boolean}
*/
isShowLegend: function () {
isShowLegend: function() {
return true;
},
setPlaceOrderHandler: function (handler) {
setPlaceOrderHandler: function(handler) {
this.placeOrderHandler = handler;
},
setValidateHandler: function (handler) {
setValidateHandler: function(handler) {
this.validateHandler = handler;
},
getCode: function () {
getCode: function() {
return 'adyen_google_pay';
},
isActive: function () {
isActive: function() {
return true;
},
initObservable: function () {
this._super()
.observe([
initObservable: function() {
this._super().observe([
'googlePayToken',
'googlePayAllowed'
'googlePayAllowed',
]);
return this;
}, initialize: function () {
}, initialize: function() {
var self = this;
this.additionalValidators = additionalValidators;
this.vaultEnabler = new VaultEnabler();
......@@ -86,7 +99,7 @@ define(
this._super();
},
renderGooglePay: function () {
renderGooglePay: function() {
this.googlePayNode = document.getElementById('googlePay');
var self = this;
......@@ -95,8 +108,8 @@ define(
originKey: self.getOriginKey(),
environment: self.getCheckoutEnvironment(),
risk: {
enabled: false
}
enabled: false,
},
});
var googlepay = self.checkoutComponent.create('paywithgoogle', {
showPayButton: true,
......@@ -108,91 +121,92 @@ define(
// https://developers.google.com/pay/api/web/reference/object#MerchantInfo
merchantIdentifier: self.getMerchantIdentifier(),
merchantName: self.getMerchantAccount()
merchantName: self.getMerchantAccount(),
},
// Payment
amount: self.formatAmount(quote.totals().grand_total, self.getFormat()),
amount: self.formatAmount(quote.totals().grand_total,
self.getFormat()),
currency: quote.totals().quote_currency_code,
totalPriceStatus: 'FINAL',
// empty onSubmit to resolve javascript issues.
onSubmit: function() {},
onChange: function (state) {
onChange: function(state) {
if (!!state.isValid) {
self.googlePayToken(state.data.paymentMethod.googlePayToken);
self.getPlaceOrderDeferredObject()
.fail(
function () {
self.getPlaceOrderDeferredObject().fail(
function() {
fullScreenLoader.stopLoader();
self.isPlaceOrderActionAllowed(true);
}
},
).done(
function () {
function() {
self.afterPlaceOrder();
window.location.replace(url.build(window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl));
window.location.replace(url.build(
window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl));
}
},
);
}
},
buttonColor: 'black', // default/black/white
buttonType: 'long', // long/short
showButton: true // show or hide the Google Pay button
showButton: true, // show or hide the Google Pay button
});
var promise = googlepay.isAvailable();
promise.then(function (success) {
promise.then(function(success) {
self.googlePayAllowed(true);
googlepay.mount(self.googlePayNode);
$(self.googlePayNode).find('button').prop('disabled', true);
}, function (error) {
}, function(error) {
console.log(error);
self.googlePayAllowed(false);
});
},
isGooglePayAllowed: function () {
isGooglePayAllowed: function() {
if (this.googlePayAllowed()) {
return true;
}
return false;
},
getMerchantAccount: function () {
getMerchantAccount: function() {
return window.checkoutConfig.payment.adyenGooglePay.merchantAccount;
},
showLogo: function () {
showLogo: function() {
return window.checkoutConfig.payment.adyen.showLogo;
},
getLocale: function () {
getLocale: function() {
return window.checkoutConfig.payment.adyenGooglePay.locale;
},
getFormat: function () {
getFormat: function() {
return window.checkoutConfig.payment.adyenGooglePay.format;
},
getMerchantIdentifier: function () {
getMerchantIdentifier: function() {
return window.checkoutConfig.payment.adyenGooglePay.merchantIdentifier;
},
context: function () {
context: function() {
return this;
},
validate: function (hideErrors) {
validate: function(hideErrors) {
return this.additionalValidators.validate(hideErrors);
},
getControllerName: function () {
getControllerName: function() {
return window.checkoutConfig.payment.iframe.controllerName[this.getCode()];
},
getPlaceOrderUrl: function () {
getPlaceOrderUrl: function() {
return window.checkoutConfig.payment.iframe.placeOrderUrl[this.getCode()];
},
/**
* Get data for place order
* @returns {{method: *}}
*/
getData: function () {
getData: function() {
return {
'method': "adyen_google_pay",
'method': 'adyen_google_pay',
'additional_data': {
'token': this.googlePayToken()
}
'token': this.googlePayToken(),
},
};
},
......@@ -202,21 +216,21 @@ define(
* @param $currency
* @return string
*/
formatAmount: function (amount, format) {
return Math.round(amount * (Math.pow(10, format)))
formatAmount: function(amount, format) {
return Math.round(amount * (Math.pow(10, format)));
},
isVaultEnabled: function () {
isVaultEnabled: function() {
return this.vaultEnabler.isVaultEnabled();
},
getVaultCode: function () {
return "adyen_google_pay_vault";
getVaultCode: function() {
return 'adyen_google_pay_vault';
},
getOriginKey: function () {
getOriginKey: function() {
return window.checkoutConfig.payment.adyen.originKey;
},
getCheckoutEnvironment: function () {
getCheckoutEnvironment: function() {
return window.checkoutConfig.payment.adyen.checkoutEnvironment;
}
},
});
}
},
);
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