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( ...@@ -40,7 +40,8 @@ define(
'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',
'adyenCheckout' 'adyenCheckout',
'Adyen_Payment/js/bundle'
], ],
function ( function (
$, $,
...@@ -62,7 +63,8 @@ define( ...@@ -62,7 +63,8 @@ define(
threeds2, threeds2,
errorProcessor, errorProcessor,
adyenPaymentService, adyenPaymentService,
AdyenCheckout AdyenCheckout,
AdyenComponent
) { ) {
'use strict'; 'use strict';
......
...@@ -34,9 +34,23 @@ define( ...@@ -34,9 +34,23 @@ define(
'Magento_Checkout/js/model/full-screen-loader', 'Magento_Checkout/js/model/full-screen-loader',
'mage/url', 'mage/url',
'Magento_Vault/js/view/payment/vault-enabler', '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'; 'use strict';
/** /**
...@@ -50,34 +64,33 @@ define( ...@@ -50,34 +64,33 @@ define(
defaults: { defaults: {
template: 'Adyen_Payment/payment/google-pay-form', template: 'Adyen_Payment/payment/google-pay-form',
googlePayToken: null, googlePayToken: null,
googlePayAllowed: null googlePayAllowed: null,
}, },
/** /**
* @returns {Boolean} * @returns {Boolean}
*/ */
isShowLegend: function () { isShowLegend: function() {
return true; return true;
}, },
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_google_pay'; return 'adyen_google_pay';
}, },
isActive: function () { isActive: function() {
return true; return true;
}, },
initObservable: function () { initObservable: function() {
this._super() this._super().observe([
.observe([
'googlePayToken', 'googlePayToken',
'googlePayAllowed' 'googlePayAllowed',
]); ]);
return this; return this;
}, initialize: function () { }, initialize: function() {
var self = this; var self = this;
this.additionalValidators = additionalValidators; this.additionalValidators = additionalValidators;
this.vaultEnabler = new VaultEnabler(); this.vaultEnabler = new VaultEnabler();
...@@ -86,7 +99,7 @@ define( ...@@ -86,7 +99,7 @@ define(
this._super(); this._super();
}, },
renderGooglePay: function () { renderGooglePay: function() {
this.googlePayNode = document.getElementById('googlePay'); this.googlePayNode = document.getElementById('googlePay');
var self = this; var self = this;
...@@ -95,8 +108,8 @@ define( ...@@ -95,8 +108,8 @@ define(
originKey: self.getOriginKey(), originKey: self.getOriginKey(),
environment: self.getCheckoutEnvironment(), environment: self.getCheckoutEnvironment(),
risk: { risk: {
enabled: false enabled: false,
} },
}); });
var googlepay = self.checkoutComponent.create('paywithgoogle', { var googlepay = self.checkoutComponent.create('paywithgoogle', {
showPayButton: true, showPayButton: true,
...@@ -108,91 +121,92 @@ define( ...@@ -108,91 +121,92 @@ define(
// https://developers.google.com/pay/api/web/reference/object#MerchantInfo // https://developers.google.com/pay/api/web/reference/object#MerchantInfo
merchantIdentifier: self.getMerchantIdentifier(), merchantIdentifier: self.getMerchantIdentifier(),
merchantName: self.getMerchantAccount() merchantName: self.getMerchantAccount(),
}, },
// Payment // 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, currency: quote.totals().quote_currency_code,
totalPriceStatus: 'FINAL', totalPriceStatus: 'FINAL',
// empty onSubmit to resolve javascript issues. // empty onSubmit to resolve javascript issues.
onSubmit: function() {}, onSubmit: function() {},
onChange: function (state) { onChange: function(state) {
if (!!state.isValid) { if (!!state.isValid) {
self.googlePayToken(state.data.paymentMethod.googlePayToken); self.googlePayToken(state.data.paymentMethod.googlePayToken);
self.getPlaceOrderDeferredObject() self.getPlaceOrderDeferredObject().fail(
.fail( function() {
function () {
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
self.isPlaceOrderActionAllowed(true); self.isPlaceOrderActionAllowed(true);
} },
).done( ).done(
function () { function() {
self.afterPlaceOrder(); 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 buttonColor: 'black', // default/black/white
buttonType: 'long', // long/short 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(); var promise = googlepay.isAvailable();
promise.then(function (success) { promise.then(function(success) {
self.googlePayAllowed(true); self.googlePayAllowed(true);
googlepay.mount(self.googlePayNode); googlepay.mount(self.googlePayNode);
$(self.googlePayNode).find('button').prop('disabled', true); $(self.googlePayNode).find('button').prop('disabled', true);
}, function (error) { }, function(error) {
console.log(error); console.log(error);
self.googlePayAllowed(false); self.googlePayAllowed(false);
}); });
}, },
isGooglePayAllowed: function () { isGooglePayAllowed: function() {
if (this.googlePayAllowed()) { if (this.googlePayAllowed()) {
return true; return true;
} }
return false; return false;
}, },
getMerchantAccount: function () { getMerchantAccount: function() {
return window.checkoutConfig.payment.adyenGooglePay.merchantAccount; return window.checkoutConfig.payment.adyenGooglePay.merchantAccount;
}, },
showLogo: function () { showLogo: function() {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
getLocale: function () { getLocale: function() {
return window.checkoutConfig.payment.adyenGooglePay.locale; return window.checkoutConfig.payment.adyenGooglePay.locale;
}, },
getFormat: function () { getFormat: function() {
return window.checkoutConfig.payment.adyenGooglePay.format; return window.checkoutConfig.payment.adyenGooglePay.format;
}, },
getMerchantIdentifier: function () { getMerchantIdentifier: function() {
return window.checkoutConfig.payment.adyenGooglePay.merchantIdentifier; return window.checkoutConfig.payment.adyenGooglePay.merchantIdentifier;
}, },
context: function () { context: function() {
return this; return this;
}, },
validate: function (hideErrors) { validate: function(hideErrors) {
return this.additionalValidators.validate(hideErrors); return this.additionalValidators.validate(hideErrors);
}, },
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()];
}, },
/** /**
* Get data for place order * Get data for place order
* @returns {{method: *}} * @returns {{method: *}}
*/ */
getData: function () { getData: function() {
return { return {
'method': "adyen_google_pay", 'method': 'adyen_google_pay',
'additional_data': { 'additional_data': {
'token': this.googlePayToken() 'token': this.googlePayToken(),
} },
}; };
}, },
...@@ -202,21 +216,21 @@ define( ...@@ -202,21 +216,21 @@ define(
* @param $currency * @param $currency
* @return string * @return string
*/ */
formatAmount: function (amount, format) { formatAmount: function(amount, format) {
return Math.round(amount * (Math.pow(10, format))) return Math.round(amount * (Math.pow(10, format)));
}, },
isVaultEnabled: function () { isVaultEnabled: function() {
return this.vaultEnabler.isVaultEnabled(); return this.vaultEnabler.isVaultEnabled();
}, },
getVaultCode: function () { getVaultCode: function() {
return "adyen_google_pay_vault"; return 'adyen_google_pay_vault';
}, },
getOriginKey: function () { getOriginKey: function() {
return window.checkoutConfig.payment.adyen.originKey; return window.checkoutConfig.payment.adyen.originKey;
}, },
getCheckoutEnvironment: function () { getCheckoutEnvironment: function() {
return window.checkoutConfig.payment.adyen.checkoutEnvironment; 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