***
title: Google Pay
subtitle: 'Accept Google Pay for fast, secure checkout on supported devices.'
-----------------------------------------------------------------------------
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):
```html
```
# Setup
```html
```
```typescript
import PaymentKit from '@payment-kit-js/vanilla';
import GooglePayPaymentMethod from '@payment-kit-js/vanilla/payment-methods/google-pay';
const paymentKit = PaymentKit({
environment: 'production',
secureToken: 'your_secure_token',
paymentMethods: [GooglePayPaymentMethod]
});
```
# Submit payment
```typescript
document.getElementById('google-pay-button').addEventListener('click', () => {
paymentKit.submit({
fields: {
customer_name: 'Jane Smith',
customer_email: 'jane@example.com',
customer_country: 'US',
customer_zip_code: '94102'
},
paymentMethod: 'google_pay',
options: {
processorId: 'proc_stripe_abc123',
customerInfo: {
first_name: 'Jane',
last_name: 'Smith'
}
},
onSuccess: (result) => {
console.log('Transaction ID:', result.id);
console.log('Checkout Session:', result.checkoutSessionId);
window.location.href = '/success';
},
onError: (errors) => {
if (errors.google_pay === 'Google Pay not available on this device') {
// Hide button, show card form instead
}
}
});
});
```
# Options
| Option | Type | Description |
| ------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------- |
| `processorId` | `string` | **Required.** Your processor ID with Google Pay enabled |
| `customerInfo.first_name` | `string` | **Required.** Customer's first name |
| `customerInfo.last_name` | `string` | **Required.** Customer's last name |
| `mockScenario` | `GooglePayMockScenario` | Testing 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
| Error | Cause |
| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `Processor ID is required` | Missing `processorId` in options |
| `Customer first and last name are required` | Missing `customerInfo.first_name` or `customerInfo.last_name` in options |
| `Stripe.js not loaded. Add to your page.` | Stripe.js script not loaded before initializing Google Pay |
| `Google Pay not available on this device` | Device doesn't support Google Pay or no cards saved |
| `Google Pay cancelled by user` | Customer closed the Google Pay sheet |
| `Failed to start Google Pay` | API call to start checkout failed |
| `Card setup failed` | Stripe card setup confirmation failed |
| `Payment failed` | Payment confirmation returned a failure status |
| `Google Pay error: {message}` | Unexpected error during the payment flow |