Google Pay: Prevent field validation from being triggered on checkout page load

This commit is contained in:
Daniel Dudzic 2024-07-30 10:24:26 +02:00
parent f52b01b275
commit 5ad73cf5f0
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
2 changed files with 19 additions and 12 deletions

View file

@ -4,7 +4,7 @@ import CheckoutActionHandler from '../../../../ppcp-button/resources/js/modules/
import FormValidator from '../../../../ppcp-button/resources/js/modules/Helper/FormValidator';
class CheckoutHandler extends BaseHandler {
transactionInfo() {
formValidator() {
return new Promise( async ( resolve, reject ) => {
try {
const spinner = new Spinner();
@ -23,7 +23,7 @@ class CheckoutHandler extends BaseHandler {
: null;
if ( ! formValidator ) {
resolve( super.transactionInfo() );
resolve();
return;
}
@ -42,7 +42,7 @@ class CheckoutHandler extends BaseHandler {
reject();
} else {
resolve( super.transactionInfo() );
resolve();
}
} );
} catch ( error ) {

View file

@ -292,17 +292,24 @@ class GooglepayButton {
onButtonClick() {
this.log( 'onButtonClick', this.context );
const paymentDataRequest = this.paymentDataRequest();
this.contextHandler.formValidator().then(
() => {
window.ppcpFundingSource = 'googlepay';
this.log(
'onButtonClick: paymentDataRequest',
paymentDataRequest,
this.context
const paymentDataRequest = this.paymentDataRequest();
this.log(
'onButtonClick: paymentDataRequest',
paymentDataRequest,
this.context
);
this.paymentsClient.loadPaymentData( paymentDataRequest );
},
() => {
console.error( '[GooglePayButton] Form validation failed.' );
}
);
window.ppcpFundingSource = 'googlepay'; // Do this on another place like on create order endpoint handler.
this.paymentsClient.loadPaymentData( paymentDataRequest );
}
paymentDataRequest() {