Stripe
The Stripe:GooglePay provider renders a Google Pay button using the Stripe Express Checkout Element.
Note: Stripe uses a deferred-intent pattern — the
PaymentIntentis created server-side inside youronClickcallback when the buyer clicks the Google Pay button. No PaymentIntent exists before the click.
Options — StripeGooglePayOptions
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
publishableKey | string | Yes | — | Stripe publishable API key. Use pk_test_... for sandbox, pk_live_... for production |
totalAmount | number | Yes | — | Amount in minor units (e.g. 19300 = €193.00) |
currencyCode | string | Yes | — | ISO 4217 currency code in lowercase (e.g. 'eur', 'usd') |
captureMethod | 'automatic' | 'automatic_async' | 'manual' | Yes | — | When Stripe captures funds. 'manual' = authorize only |
stripeAccount | string | No | — | Stripe Connect account ID ('acct_...'). Required for Connect |
countryCode | string | No | 'DE' | ISO 3166-1 alpha-2 country code |
shippingAddressRequired | boolean | No | true | Collect shipping address |
billingAddressRequired | boolean | No | true | Collect billing address |
emailRequired | boolean | No | true | Collect buyer's email |
phoneNumberRequired | boolean | No | true | Collect buyer's phone number |
Example
html
<div id="stripe-googlepay-container"></div>js
import { ExpressButtons } from 'collana-pay-js';
const buttons = ExpressButtons({
providers: [
{
providerProtocolType: 'Stripe',
paymentMethodType: 'GooglePay',
container: '#stripe-googlepay-container',
options: {
publishableKey: 'pk_test_YOUR_PUBLISHABLE_KEY',
totalAmount: 19300, // €193.00
currencyCode: 'eur', // lowercase for Stripe
countryCode: 'DE',
captureMethod: 'automatic',
shippingAddressRequired: true,
billingAddressRequired: true,
emailRequired: true,
phoneNumberRequired: false,
},
},
],
onClick: async (identity, paymentMethodData) => {
// Create a PaymentIntent on your backend (deferred-intent pattern).
// Return checkoutData.id = clientSecret from the PaymentIntent.
const res = await fetch('/api/orders', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ provider: identity, paymentMethodData }),
});
const order = await res.json();
return {
orderId: order.id,
checkoutData: {
id: order.clientSecret, // Stripe PaymentIntent client_secret
},
};
},
onApprove: (data) => {
window.location.href = `/order/success?id=${data.orderId}`;
},
onCancel: (identity) => {
console.log('Stripe Google Pay cancelled', identity);
},
onError: (error) => {
console.error('Stripe Google Pay error', error);
},
});
buttons.render();