mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #2495 from woocommerce/PCP-3493-validation-on-classic-checkout-page-automatically-triggered-when-google-pay-is-enabled-rc2
Fix Google Pay button on non-checkout pages (#3493)
This commit is contained in:
commit
f96293542a
1 changed files with 24 additions and 15 deletions
|
@ -292,24 +292,33 @@ class GooglepayButton {
|
|||
onButtonClick() {
|
||||
this.log( 'onButtonClick', this.context );
|
||||
|
||||
this.contextHandler.validateForm().then(
|
||||
() => {
|
||||
window.ppcpFundingSource = 'googlepay';
|
||||
const initiatePaymentRequest = () => {
|
||||
window.ppcpFundingSource = 'googlepay';
|
||||
|
||||
const paymentDataRequest = this.paymentDataRequest();
|
||||
const paymentDataRequest = this.paymentDataRequest();
|
||||
|
||||
this.log(
|
||||
'onButtonClick: paymentDataRequest',
|
||||
paymentDataRequest,
|
||||
this.context
|
||||
);
|
||||
this.log(
|
||||
'onButtonClick: paymentDataRequest',
|
||||
paymentDataRequest,
|
||||
this.context
|
||||
);
|
||||
|
||||
this.paymentsClient.loadPaymentData( paymentDataRequest );
|
||||
},
|
||||
() => {
|
||||
console.error( '[GooglePayButton] Form validation failed.' );
|
||||
}
|
||||
);
|
||||
this.paymentsClient.loadPaymentData( paymentDataRequest );
|
||||
};
|
||||
|
||||
if ( 'function' === typeof this.contextHandler.validateForm ) {
|
||||
// During regular checkout, validate the checkout form before initiating the payment.
|
||||
this.contextHandler
|
||||
.validateForm()
|
||||
.then( initiatePaymentRequest, () => {
|
||||
console.error(
|
||||
'[GooglePayButton] Form validation failed.'
|
||||
);
|
||||
} );
|
||||
} else {
|
||||
// This is the flow on product page, cart, and other non-checkout pages.
|
||||
initiatePaymentRequest();
|
||||
}
|
||||
}
|
||||
|
||||
paymentDataRequest() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue