This guide shows you how to start Apple Pay, Google Pay or Revolut Pay from a pay button you render yourself, instead of the SDK’s wallet buttons. Use it when your checkout needs one pay button for every wallet, or a button with your own wording, such as Jetzt kaufen for § 312j BGB in Germany. It needs SDK 6.14.0 or later, and assumes you have already initialized the SDK and hold a payrails client instance. If you haven’t, start with the quick start.
The shopper still sees the wallet’s own payment sheet, and the payment runs the same flow as the SDK’s wallet buttons. Follow Apple’s and Google’s brand guidelines when you show the wallet as a payment option.
1. Check availability
Run the availability check before you show your button. The check also loads the wallet’s script, which has to be ready before the shopper clicks.
Pass { headless: true } to the Google Pay check. In some sessions Google Pay opens in a hidden frame, and the check keeps that frame ready for authorize(). Running the check again replaces the frame.
Revolut Pay needs no check.
2. Call authorize() in the click handler
Call authorize() directly in your button’s click handler. Don’t await anything before it: browsers only open a wallet sheet from a direct click.
storeInstrument replaces the SDK’s save checkbox. It applies only when the payment method supports saving. Revolut Pay ignores it.
3. Run your own checks
authorize() doesn’t fire buttonClicked, because the click is yours. If you stop payments from a buttonClicked handler with the SDK’s buttons, move that check when you switch to authorize(). A buttonClicked handler never runs here, so a check left there stops nothing.
Run a quick check in your click handler before you call authorize(), or keep your button disabled until the check passes. Don’t make a network call there: the browser only opens the wallet sheet shortly after the click.
Put a check that needs a network call in requestStart. It runs after the shopper approves in the wallet sheet and before the payment request is sent. Call preventDefault() to stop the payment.
4. Handle the result
authorize() returns nothing. Show your own loading state, and end it when the payment ends:
failed also fires when the shopper closes the wallet sheet. If a requestStart handler stops the payment, failed fires with a validation error. actionRequired arrives through payrails.on(...), the same as with the SDK’s buttons. For the event payloads, refer to the events reference.
Setup errors
authorize() throws a PayrailsError with the code payrails:validation:failed when:
- the payment method isn’t
googlePay, applePay or revolutPay
- the payment method isn’t enabled for the session
- Google Pay or Apple Pay has no passed availability check
- in some sessions, the Google Pay check ran without
{ headless: true }
- an earlier
authorize() for the same payment method is still running
- the session is a merchant-of-record session
Limits
- In sessions where Google Pay opens from a hidden frame, Firefox blocks the Google Pay popup by default, because the shopper clicked your page and not the frame.
failed fires with OTHER, and the shopper can pay once they allow popups for your site. Chrome and Safari open it normally.
- The Apple Pay sheet label,
clientDomain and Revolut Pay’s openInNewTab use their defaults. Use the SDK’s wallet buttons if you need them.
returnInfo and redirectFor3DS come from Payrails.init(...).
- Cards aren’t supported yet. Until then, to give the card pay button your own wording, set
translations.label on paymentButton(). For a card form with your own button, use Secure Fields.
authorize() starts a new payment. To pay with a saved card, use cardList() with paymentButton().
For every option, refer to authorize() in the payrails reference. Last modified on December 4, 2026