Prerequisites
- An active Payrails session (see Quick Start)
- A session init payload with redirect-capable payment methods configured in the Payrails backend
- Kotlin + Jetpack Compose for rendering the redirect buttons
Steps
1. Initialize a session
2. Discover available redirect methods
Ask the session for redirect payment methods configured by the backend:
Returns an empty list if no redirect methods are configured.
Each PayrailsPaymentOption contains:
paymentMethodCode — the identifier used to create the button (e.g., "ideal", "bancontact")
displayName — a human-readable label from the backend (nullable)
4. Handle the redirect flow
When the user taps the button, the SDK:
- Opens the payment provider’s page in a Custom Tab (or system browser as fallback)
- Polls the execution status in the background. For a payment that uses deep-link return, it checks the status after the customer returns, or after 15 minutes if the customer doesn’t return. See Deep-link return.
- Returns the result through the delegate callbacks
No additional handling is needed — the SDK manages the redirect lifecycle, polling, and result delivery automatically.
To return the customer to your app through your own URL, see Use your own return URL.
Use your own return URL
When Payrails has enabled deep-link return for your account, the bank or payment page returns the customer to your app through a link that the SDK registers. To use your own URL instead, set Options.returnUrl and give the return to the SDK from your activity.
Before you start, make sure that you have the following:
- Payrails has enabled deep-link return for your account. Without it, the SDK ignores
returnUrl.
- A custom-scheme
returnUrl is in your safe redirect URLs in the Payrails portal. To add it, contact Payrails support. An https URL doesn’t need an entry.
Chrome might keep the https page in the tab and not open your app.
To use your own return URL, do the following:
-
In
Options, set returnUrl:
Write the scheme in lowercase, for example shopapp://, not ShopApp://. Browsers change the scheme to lowercase, and intent filters compare it case-sensitively. If the URL is not valid, createSession fails with PayrailsError.unknown. For the rules, see Options.returnUrl.
-
In
AndroidManifest.xml, add a translucent activity that receives the URL:
The scheme, host and path must match your returnUrl. If returnUrl doesn’t open an activity in your app, the SDK logs a warning and uses the Payrails return pages.
Use a separate activity for the URL. Don’t point the URL at these activities:
- A
singleTask launcher activity. Android clears the checkout activity, and the payment session ends.
- A checkout activity with the
standard launch mode. Android opens a second copy of the checkout screen.
-
Create the activity. It gives the link to the SDK and then closes:
Call
handleRedirectReturn in onCreate and onNewIntent, not in onResume. After a Custom Tab return, the SDK treats the resume as the return, and a later call returns false.
Extend Activity, not AppCompatActivity. AppCompatActivity needs an AppCompat theme, and it fails to start with Theme.Translucent.NoTitleBar.
When handleRedirectReturn returns true, the SDK brings your checkout screen to the front and calls onAuthorizeSuccess or onAuthorizeFailed. When it returns false, no payment took the link, for example after process death. In that case, show your own order status from your backend.
Session recovery
If the redirect flow is abandoned or remains non-terminal, the SDK follows the same session recovery path as card 3DS redirects. Configure onSessionExpired in Options.redirectSessionLifecycle to enable automatic recovery:
Last modified on November 20, 2026