Skip to content

Google Pay express payment fails to reinit after it passes checkout validation via registerPaymentMethodExtensionCallbacks #3937

@xristos3490

Description

@xristos3490

Describe the Bug

When using conditional visibility for express payment buttons, the GooglePay option fails to reinit.
Not entirely sure if related but I also see some console errors:

Image

The issue was identified after some testing we did with the Conditional Shipping and Payments extension, but I simplified the replication steps into a snippet. Let me know if this helps!

Important: I'm working on dev mode.

To Reproduce

Prerequisites

Install the following JS code and ensure it loads on the Checkout page:

import { registerPaymentMethodExtensionCallbacks } from '@woocommerce/blocks-registry';
// ...
registerPaymentMethodExtensionCallbacks(
	'woocommerce-ppcp-googlepay-test',
	(() => {

		const callbacksConfig = {};
		callbacksConfig['ppcp-googlepay'] = (args) => {
			const currentPostCode = args?.billingData?.postcode;
			if ( currentPostCode === '92440' ) {
				return false;
			}

			return true;
		};
		return callbacksConfig;
	})()
);
  1. Set up the snippet above.
  2. Make sure you've enabled Google Pay.
  3. Visit the checkout and change your address using the restricted postcode provided in the snippet above, e.g., 92440.
  4. Observe that the Google Pay button gets hidden as expected.
  5. Change the postcode to a valid one.
  6. Notice that the Google Pay button fails to appear again.

Screenshots

pp-googlepay-issue.mov

Expected Behavior

Google Pay express payment method should revalidate and appear once the conditions are met.

Actual Behavior

Environment

  • WordPress Version
  • WooCommerce Version
  • Plugin Version
  • Browser [e.g. Chrome, Safari] and Version
  • Any other plugins installed

Additional Details

System status
<!--If applicable, paste the system status here. Please ensure you redact or remove any identifying information. -->

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions