Skip to content

Google Pay

The Google:GooglePay provider renders a native Google Pay button using the Google Pay JS API directly (no PSP intermediary).

Options — GooglePayOptions

FieldTypeRequiredDefaultDescription
totalAmountnumberYesAmount in minor units (e.g. 19300 = €193.00)
currencyCodestringYesISO 4217 uppercase currency code (e.g. 'EUR')
gatewaystringYesPSP gateway identifier (e.g. 'stripe', 'adyen')
gatewayMerchantIdstringYesMerchant ID at the PSP/gateway
countryCodestringNoISO 3166-1 alpha-2 merchant country code
merchantIdstringNoGoogle Pay merchant ID (required in PRODUCTION environment)
merchantNamestringNoMerchant name shown in the payment sheet
allowedCardNetworksstring[]No['AMEX','DISCOVER','INTERAC','JCB','MASTERCARD','VISA']Accepted card networks
allowedCardAuthMethodsstring[]No['PAN_ONLY','CRYPTOGRAM_3DS']Accepted auth methods
emailRequiredbooleanNofalseRequest buyer's email address
shippingAddressRequiredbooleanNofalseRequest shipping address
billingAddressRequiredbooleanNofalseRequest billing address
billingAddressParametersobjectNo{ format?: 'FULL' | 'MIN'; phoneNumberRequired?: boolean }
callbackIntentsstring[]No['PAYMENT_AUTHORIZATION']Google Pay callback intents

Environment note: Google Pay uses its own environment field inside the options object — it does not read the SDK-level environment. Pass environment: 'TEST' (via the provider SDK defaults) for sandbox or 'PRODUCTION' for live. For the native Google Pay provider, switch to TEST by omitting merchantId and using 'TEST' when initializing the PaymentsClient (handled internally by the SDK). Obtain a production merchantId from the Google Pay Business Console.

Style — GooglePayStyle

FieldTypeDescription
buttonColor'default' | 'black' | 'white'Button color theme. 'default' follows user preference
buttonType'buy' | 'plain' | 'checkout'Label variant
buttonSizeMode'fill' | 'static''fill' stretches to container width

Example

html
<div id="googlepay-container"></div>
js
import { ExpressButtons } from 'collana-pay-js';

const buttons = ExpressButtons({
  providers: [
    {
      providerProtocolType: 'Google',
      paymentMethodType: 'GooglePay',
      container: '#googlepay-container',
      style: {
        buttonColor: 'black',
        buttonType: 'buy',
        buttonSizeMode: 'fill',
      },
      options: {
        totalAmount: 19300,       // €193.00
        currencyCode: 'EUR',
        countryCode: 'DE',
        gateway: 'example',
        gatewayMerchantId: 'exampleMerchantId',
        merchantName: 'My Shop',
        emailRequired: true,
        billingAddressRequired: true,
        billingAddressParameters: { format: 'FULL' },
      },
    },
  ],

  onClick: async (identity, paymentMethodData) => {
    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 };
  },

  onApprove: (data) => {
    window.location.href = `/order/success?id=${data.orderId}`;
  },

  onCancel: (identity) => {
    console.log('Google Pay cancelled', identity);
  },

  onError: (error) => {
    console.error('Google Pay error', error);
  },
});

buttons.render();

CollanaPay SDK Documentation