Skip to content

Google Pay

Google Pay is triggered via a wallet button component: shift4.js renders the official Google Pay button. There is no continue() call — the payment flow starts when the customer taps the button, and the customer's email (and, when the Checkout Session collects them, billing/shipping addresses) is extracted from the wallet response automatically.

Requirements

Business eligibility

Google restricts certain business categories — see the Google Pay Acceptable Use Policy. If your merchant category code falls into one, the wallet is suppressed and no button is shown.

Content Security Policy

In addition to the baseline Payment components policy, Google Pay needs Google's script and frame allowed:

script-src https://pay.google.com
frame-src  https://pay.google.com

3D Secure

3D Secure runs automatically whenever it is needed. If the token returned by the wallet already carries strong authentication data, no additional verification takes place; otherwise the verification step happens automatically after the wallet returns its token. Either way, there is nothing for you to trigger or handle.

Example

<script src="https://js.shift4.com/v1/shift4.js"></script>

<div id="google-pay-button"></div>
<div id="result"></div>
<div id="error"></div>

<script>
  (async function () {
    var shift4 = Shift4('pk_sandbox_XXXXXXXXXXXXXXXXXXXX');
    var checkout = await shift4.createCheckout('{{clientSecret}}');

    checkout.addEventListener('checkout_session.succeeded', function () {
      document.getElementById('result').textContent = 'Payment successful';
    });
    checkout.addEventListener('payment.failed', function (event) {
      document.getElementById('error').textContent = event.error.message;
    });

    checkout.createComponent('google-pay-button').mount('#google-pay-button');
  })();
</script>

If the customer dismisses the sheet

The wallet SDK manages its own confirmation sheet. If the customer dismisses it without authorising, no payment is initiated and no event fires — the checkout stays mounted and they can try again. See Events & error handling for the full interruption matrix.

Next steps