Skip to Content
Docs

Pay with Apple Pay or Google Pay

Turn on the drop-in's Apple Pay button on iOS and its Google Pay button on Android, and set up what each wallet needs.

The drop-in shows the Apple Pay button on iOS, and the Google Pay button on Android, above the other methods. Turn them on with the applePay and googlePay options of checkout.presentDropIn(). Each platform reads only its own option, so pass both and each platform shows its wallet. The customer pays in the wallet's own sheet, which opens with the session's current total, and presentDropIn() resolves with the result as for any other method. Pay.com decrypts the wallet's token, so the app never handles card data.

const result = await checkout.presentDropIn({
  applePay: { merchantIdentifier: 'merchant.com.myshop' },
  googlePay: {},
})

Parameters

ParameterTypeRequiredDescription
applePayPayApplePayOptionsNoShows the Apple Pay button on iOS.
applePay.merchantIdentifierstringYesA merchant ID from your app's Apple Pay entitlement, for example merchant.com.myshop.
applePay.merchantCountryCodestringNoYour country, as an ISO 3166 alpha-2 code such as US. Default: your Pay.com account's country.
applePay.merchantDisplayNamestringNoThe total's label in the Apple Pay sheet. Default: your account's statement name.
applePay.buttonType'plain' | 'buy' | 'checkout' | 'book' | 'subscribe' | 'donate' | 'order' | 'continue' | 'inStore' | 'setUp'NoThe button's label. Default: 'plain', the Apple Pay mark alone.
googlePayPayGooglePayOptionsNoShows the Google Pay button on Android. {} turns it on with the defaults.
googlePay.merchantIdstringNoYour Google merchant ID. Default: the one set up with Pay.com for your account.
googlePay.merchantNamestringNoThe merchant name in the Google Pay sheet. Default: your account's statement name.
googlePay.environment'test' | 'production'NoGoogle Pay's environment. Default: 'production' for live sessions, 'test' for sandbox ones.
googlePay.buttonType'plain' | 'buy' | 'pay' | 'checkout' | 'order' | 'subscribe' | 'book' | 'donate'NoThe button's label. Default: 'plain', the Google Pay mark alone.
googlePay.buttonTheme'dark' | 'light'NoThe button's theme. Default: dark on a light sheet, light on a dark one.

On iOS, appearance.applePayButtonStyle sets the Apple Pay button's colors. strings.orSeparator is the text between the wallet's button and the other methods.

When the button shows

The drop-in shows the wallet's button when all of these hold:

  • You passed the platform's option (applePay on iOS or googlePay on Android).
  • The session offers the wallet, which means checkout.paymentMethods() lists applepay or googlepay. If you pass the drop-in's paymentMethods option, the wallet is in that list too.
  • The session takes a payment. It's a sale or authorization session with an amount and a currency, not a setup session.
  • Your Pay.com account has a country. On iOS, merchantCountryCode can set it instead.
  • The device can pay with the wallet, with a card network the session accepts.

Otherwise, the sheet opens without the button.

Set up the wallets

Apple Pay needs the Apple Pay capability in your app, with the merchant ID you pass as merchantIdentifier. Pay.com must also hold that merchant ID's payment processing certificate for your account, because Pay.com decrypts the Apple Pay token.

Google Pay runs in Google's test environment for sandbox sessions. Live payments need Google's production access for your app, with your Google merchant ID, from the Google Pay & Wallet Console. The SDK already turns on the Google Pay API in the app's manifest.

Errors

presentDropIn() rejects as described in its errors. It rejects with a TypeError before the sheet opens when an option has an invalid value, such as an applePay without a non-empty merchantIdentifier, a merchantCountryCode that isn't two letters, a googlePay that isn't an object, or a buttonType, environment, or buttonTheme outside the allowed values. This validation runs on both platforms, even for the option the current platform doesn't use.

Example

import { PayCheckout, type PayResult } from '@pay-com/react-native'

export async function payWithWallets(clientSecret: string): Promise<PayResult> {
  const checkout = await PayCheckout.create(clientSecret, { returnUrl: 'myshop://pay' })
  try {
    return await checkout.presentDropIn({
      merchantDisplayName: 'My Shop',
      applePay: {
        merchantIdentifier: 'merchant.com.myshop',
        merchantCountryCode: 'US',
        buttonType: 'buy',
      },
      googlePay: { buttonType: 'buy' },
      appearance: { applePayButtonStyle: 'black' },
    })
  } finally {
    checkout.release()
  }
}

Next steps

Was this page helpful?