mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #2474 from woocommerce/PCP-3493-validation-on-classic-checkout-page-automatically-triggered-when-google-pay-is-enabled
Google Pay: Prevent field validation from being triggered on checkout page load (3493)
This commit is contained in:
commit
9fbeaf56be
2 changed files with 19 additions and 12 deletions
|
@ -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() {
|
||||
validateForm() {
|
||||
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 ) {
|
||||
|
|
|
@ -292,17 +292,24 @@ class GooglepayButton {
|
|||
onButtonClick() {
|
||||
this.log( 'onButtonClick', this.context );
|
||||
|
||||
const paymentDataRequest = this.paymentDataRequest();
|
||||
this.contextHandler.validateForm().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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue