Skip to content

Stripe

The Stripe:GooglePay provider renders a Google Pay button using the Stripe Express Checkout Element.

Note: Stripe uses a deferred-intent pattern — the PaymentIntent is created server-side inside your onClick callback when the buyer clicks the Google Pay button. No PaymentIntent exists before the click.

Options — StripeGooglePayOptions

FieldTypeRequiredDefaultDescription
publishableKeystringYesStripe publishable API key. Use pk_test_... for sandbox, pk_live_... for production
totalAmountnumberYesAmount in minor units (e.g. 19300 = €193.00)
currencyCodestringYesISO 4217 currency code in lowercase (e.g. 'eur', 'usd')
captureMethod'automatic' | 'automatic_async' | 'manual'YesWhen Stripe captures funds. 'manual' = authorize only
stripeAccountstringNoStripe Connect account ID ('acct_...'). Required for Connect
countryCodestringNo'DE'ISO 3166-1 alpha-2 country code
shippingAddressRequiredbooleanNotrueCollect shipping address
billingAddressRequiredbooleanNotrueCollect billing address
emailRequiredbooleanNotrueCollect buyer's email
phoneNumberRequiredbooleanNotrueCollect 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();

CollanaPay SDK Documentation