Skip to main content
Drive checkout from your own button and method selector while the SDK handles the post-tap work — the Google Pay sheet, the 3DS / PayPal / redirect Custom Tab, and polling. Use this when you want full control of styling, placement, and state but don’t want to reimplement payment orchestration. The handle that makes this possible is PayrailsPaymentLauncher.

Prerequisites

  • An active Payrails session (see Quick Start)
  • The Session reference returned by Payrails.createSession(...)
  • The com.payrails.android:checkout dependency (see Quick Start)
  • For the encrypted-card path: a card payload already encrypted by your client-side encryption library (the SDK exposes no encryption API — see Why no encryption API)

Steps

1. Create the launcher early

The launcher registers a Google Pay Activity Result contract, so it must be created before the host reaches the STARTED state. In Compose, call the factory during composition:
From a View / Activity, create it in onCreate:

2. Draw your own method selector and Pay button

This is your UI — style it however you like. Track the selected method in your own state:

3. Trigger the payment

Call the matching authorize(...) overload from your button. The SDK opens whatever UI the method needs:

4. Handle the result

Each authorize(...) resolves to exactly one ActionResult, delivered to the callback you supplied in step 1:

Full example — custom dropdown + single Pay button

Troubleshooting

Problem: The launcher throws when created Solution: Payrails.createPaymentLauncher(...) must be called from Activity.onCreate. Registering the Google Pay Activity Result contract after the activity is STARTED is not allowed by the Android Activity Result API. Problem: A card that needs 3DS does not complete Solution: 3DS is handled automatically by the launcher (it owns the Custom Tab) — you do not branch on it. The terminal ActionResult arrives after the challenge resolves. There is no separate “headless” card call to choose; launcher.authorize(encryptedCardData = …) covers both frictionless and 3DS. Problem: ActionResult.Failed with code == UNKNOWN_ERROR (rawError unsupportedPayment) Solution: The selected method is not configured on the session. Confirm availability with session.getPaymentMethodConfig() before calling authorize(...). Problem: Google Pay never opens Solution: Check device capability with session.isGooglePayAvailable(context) and confirm Google Pay is configured on the session.

See also

PayrailsPaymentLauncher API Reference — every method and factory
Last modified on September 30, 2026