Google Pay

Accept Google Pay for fast, secure checkout on supported devices.
View as Markdown

Google Pay lets customers pay using cards saved to their Google account with a single tap.

Prerequisites

Add Stripe.js to your page (required for Google Pay):

1<script src="https://js.stripe.com/v3/"></script>

Setup

1<script src="https://unpkg.com/@payment-kit-js/vanilla/dist/cdn/paymentkit.min.js"></script>
2<script>
3 const paymentKit = PaymentKit.default({
4 environment: 'production',
5 secureToken: 'your_secure_token',
6 paymentMethods: [PaymentKit.PaymentMethods.googlePay]
7 });
8</script>

Submit payment

1document.getElementById('google-pay-button').addEventListener('click', () => {
2 paymentKit.submit({
3 fields: {
4 customer_name: 'Jane Smith',
5 customer_email: 'jane@example.com',
6 customer_country: 'US',
7 customer_zip_code: '94102'
8 },
9 paymentMethod: 'google_pay',
10 options: {
11 processorId: 'proc_stripe_abc123',
12 customerInfo: {
13 first_name: 'Jane',
14 last_name: 'Smith'
15 }
16 },
17 onSuccess: (result) => {
18 console.log('Transaction ID:', result.id);
19 console.log('Checkout Session:', result.checkoutSessionId);
20 window.location.href = '/success';
21 },
22 onError: (errors) => {
23 if (errors.google_pay === 'Google Pay not available on this device') {
24 // Hide button, show card form instead
25 }
26 }
27 });
28});

Options

OptionTypeDescription
processorIdstringRequired. Your processor ID with Google Pay enabled
customerInfo.first_namestringRequired. Customer’s first name
customerInfo.last_namestringRequired. Customer’s last name
mockScenarioGooglePayMockScenarioTesting only. Use "success" or "cancelled" to simulate Google Pay flows without a real device

Browser support

Google Pay works on:

  • Chrome 61+ on Android devices (with a card saved to Google Pay)
  • Chrome 61+ on desktop (with a card saved to Google Pay)
  • Microsoft Edge on desktop (with a card saved to Google Pay)

PaymentKit.js uses Stripe’s Payment Request API for Google Pay, which has specific browser requirements. Safari on iOS does not support Google Pay through this API—use Apple Pay instead.

Google Pay isn’t available on all devices. Always provide card payments as a fallback.

Error handling

ErrorCause
Processor ID is requiredMissing processorId in options
Customer first and last name are requiredMissing customerInfo.first_name or customerInfo.last_name in options
Stripe.js not loaded. Add <script src="https://js.stripe.com/v3/"></script> to your page.Stripe.js script not loaded before initializing Google Pay
Google Pay not available on this deviceDevice doesn’t support Google Pay or no cards saved
Google Pay cancelled by userCustomer closed the Google Pay sheet
Failed to start Google PayAPI call to start checkout failed
Card setup failedStripe card setup confirmation failed
Payment failedPayment confirmation returned a failure status
Google Pay error: {message}Unexpected error during the payment flow