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 c36a919e authored by Marcos Garcia's avatar Marcos Garcia Committed by GitHub

[PW-2096] Validate agreements before placing order for Google Pay (#808)

Currently, the Google Pay component does not respect additional validation in Checkout page. This commit attempts to fix this issue by making the Google Pay button disabled by default and enabling it only when the validation is successful.
parent b76762a6
...@@ -28,6 +28,7 @@ define( ...@@ -28,6 +28,7 @@ define(
'jquery', 'jquery',
'Magento_Checkout/js/view/payment/default', 'Magento_Checkout/js/view/payment/default',
'Magento_Checkout/js/action/place-order', 'Magento_Checkout/js/action/place-order',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder', 'Magento_Checkout/js/model/url-builder',
'Magento_Checkout/js/model/full-screen-loader', 'Magento_Checkout/js/model/full-screen-loader',
...@@ -35,7 +36,7 @@ define( ...@@ -35,7 +36,7 @@ define(
'Magento_Vault/js/view/payment/vault-enabler', 'Magento_Vault/js/view/payment/vault-enabler',
'adyenCheckout' 'adyenCheckout'
], ],
function (ko, $, Component, placeOrderAction, quote, urlBuilder, fullScreenLoader, url, VaultEnabler, AdyenCheckout) { function (ko, $, Component, placeOrderAction, additionalValidators, quote, urlBuilder, fullScreenLoader, url, VaultEnabler, AdyenCheckout) {
'use strict'; 'use strict';
/** /**
...@@ -78,16 +79,17 @@ define( ...@@ -78,16 +79,17 @@ define(
return this; return this;
}, initialize: function () { }, initialize: function () {
var self = this; var self = this;
this.additionalValidators = additionalValidators;
this.vaultEnabler = new VaultEnabler(); this.vaultEnabler = new VaultEnabler();
this.vaultEnabler.setPaymentCode(this.getVaultCode()); this.vaultEnabler.setPaymentCode(this.getVaultCode());
this.vaultEnabler.isActivePaymentTokenEnabler(false); this.vaultEnabler.isActivePaymentTokenEnabler(false);
this._super(); this._super();
}, },
renderGooglePay: function () { renderGooglePay: function () {
this.googlePayNode = document.getElementById('googlePay');
var self = this; var self = this;
var googlePayNode = document.getElementById('googlePay');
self.checkoutComponent = new AdyenCheckout({ self.checkoutComponent = new AdyenCheckout({
locale: self.getLocale(), locale: self.getLocale(),
originKey: self.getOriginKey(), originKey: self.getOriginKey(),
...@@ -137,12 +139,12 @@ define( ...@@ -137,12 +139,12 @@ define(
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(googlePayNode); googlepay.mount(self.googlePayNode);
$(self.googlePayNode).find('button').prop('disabled', true);
}, function (error) { }, function (error) {
console.log(error); console.log(error);
self.googlePayAllowed(false); self.googlePayAllowed(false);
...@@ -172,8 +174,8 @@ define( ...@@ -172,8 +174,8 @@ define(
context: function () { context: function () {
return this; return this;
}, },
validate: function () { validate: function (hideErrors) {
return true; 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()];
......
...@@ -38,14 +38,14 @@ ...@@ -38,14 +38,14 @@
</label> </label>
</div> </div>
<div class="payment-method-content"> <div class="payment-method-content" data-bind="event: { change: onPaymentMethodContentChange }">
<div class="payment-method-billing-address"> <div class="payment-method-billing-address">
<!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) --> <!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
<!-- ko template: getTemplate() --><!-- /ko --> <!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko--> <!--/ko-->
</div> </div>
<div class="checkout-agreements-block"> <div class="checkout-agreements-block" afterRender="bindDomEventListener">
<!-- ko foreach: $parent.getRegion('before-place-order') --> <!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko --> <!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko--> <!--/ko-->
......
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