Enabling SDK Debug Logs
The SDK’s Logcat output is off by default — it produces no Logcat messages in production. To enable debug logging:The SDK also maintains an in-memory log buffer (last 500 entries) that stays active regardless of the Logcat setting. This buffer and the associated debug viewer are internal tooling used during SDK development and are not exposed as part of the public SDK surface. Logcat logging is the supported opt-in channel for merchant development and debugging.
SecurityThe SDK never logs raw card data, tokens, or PII. Log messages contain only operational information.
Build Issues
”Payrails session must be initialized”
Error:IllegalStateException: Payrails session must be initialized
Cause: You called createCardForm() or createCardPaymentButton() before Payrails.createSession().
Fix: Ensure createSession() completes successfully before creating any UI elements:
Dependency Resolution Fails
Error:Could not find com.payrails.android:checkout:<version>
Fixes:
- Verify the SDK is published to the repository you’re using (Maven Central or Maven Local)
- For local development, run
./gradlew publishSdkToMavenLocalfirst - Ensure
mavenLocal()is listed beforemavenCentral()in your settings if using local artifacts - Clear stale local artifacts:
Missing CSE Dependency
Error: Runtime crash orNoClassDefFoundError related to card encryption
Fix: Add both dependencies:
Card Form Issues
Card Form Not Validating
Symptom: User can submit without validation, or errors don’t show. Checks:- The
CardPaymentButtonvalidates the form automatically when clicked. You don’t need to callvalidate()manually. - Validation errors appear when a field loses focus (blur validation) or when the user taps “Pay Now”. For split expiry fields, the year field also validates the combined expiry date on blur — if the month/year are individually valid but the date is expired, the error appears on the year field.
- If you’re using
onChangeevents, checkevent.isValidfor real-time validation state. - Error messages only occupy vertical space when an error is present. Fields shift to fill the space when errors are cleared.
Card Network Not Detected
Symptom:cardNetwork stays UNKNOWN, card icon doesn’t update.
Checks:
- Network detection requires at least 1–2 digits. Enter a full card number to see detection.
- Supported networks: Visa, Mastercard, Amex, Discover. Other networks show as
UNKNOWN. - Ensure
showCardIcon = trueinCardFormConfigif you expect to see icons.
Layout Crashes at Creation
Error:IllegalArgumentException: CardForm layout contains unsupported fields or similar.
Fix: Check your layout configuration:
- Don’t mix
EXPIRATION_DATEwithEXPIRATION_MONTH/EXPIRATION_YEAR - Don’t duplicate fields across rows
- Supported fields:
CARDHOLDER_NAME,CARD_NUMBER,EXPIRATION_DATE,EXPIRATION_MONTH,EXPIRATION_YEAR,CVV
Google Pay Issues
Google Pay Button Not Appearing
Symptom:GooglePayButton.Render() is called but the button is never visible. onGooglePayAvailable is not called.
Explanation: The button is hidden by default and only becomes visible after isReadyToPay() succeeds. This check can fail for several reasons.
Checks:
- Emulator: Google Pay is not available on most emulators. Test on a physical device with the Google Pay app installed and a card added.
- Google Pay app: Ensure the Google Pay app is installed and set up on the device with at least one payment method.
- Merchant configuration: Verify that Google Pay is enabled as a payment method in your Payrails dashboard. The SDK reads Google Pay config from
paymentCompositionOptions— if the backend doesn’t include it,isReadyToPay()will fail. - Environment: In
Env.TESTmode, Google Pay uses the test environment which has different availability. Switch to a production-configured device for full testing.
Google Pay Payment Sheet Not Opening
Symptom: User taps the Google Pay button,onPaymentButtonClicked fires, but the payment sheet doesn’t appear.
Checks:
- Ensure the Activity is valid and not finishing when the button is tapped
- Check that the Google Pay API version in your backend config matches what’s expected (
apiVersion: 2,apiVersionMinor: 0) - Verify
merchantInfois configured in production (required by Google)
Google Pay Authorization Fails Immediately
Symptom:onAuthorizeFailed fires right after the user selects a payment method in the sheet.
Checks:
- Verify your Payrails dashboard has the correct gateway credentials for Google Pay
- Check the
PayrailsErrordetails in the delegate callback - If 3DS is triggered (
onThreeDSecureChallenge), follow the same 3DS troubleshooting as card payments below
Payment Issues
3DS Browser Doesn’t Open
Symptom: Payment hangs after authorization, no browser opens. Checks:- The SDK opens 3DS challenges automatically via Chrome Custom Tabs (or the system browser as fallback)
- Ensure
Render()has been composed beforepay()is called — the button creates its internal presenter during composition - The device must have a browser installed (Chrome Custom Tabs preferred)
- Check that the Activity reference is still valid (not destroyed)
3DS Succeeds But onAuthorizeSuccess Not Called
Symptom: User completes 3DS in browser, returns to app, but delegate isn’t called. Explanation: This is expected behavior. The SDK polls the execution status after the user returns. The delegate callback fires only when polling reaches a terminal state (success or failure). Possible causes for delay:- Without deep-link return, the SDK checks the payment status every 5 seconds while the bank page is open, for up to 15 minutes after the page opened. A slow challenge or approval doesn’t end the payment, and neither does a network error, a timeout or a server error during this time. An error that can’t go away, such as a
404or a response that the SDK can’t read, ends the payment right away withUNKNOWN_ERRORand session recovery. Your app comes back to the front within about 5 seconds after the payment completes. While your app is in the background, the SDK shows the status-check notification of its foreground service for this time, up to 15 minutes. - Without deep-link return, if the payment has no final status after 15 minutes, the SDK checks one last time. If that check finds no final status either,
onAuthorizeFailedfires withUNKNOWN_ERROR, and the SDK triggers session recovery ifonSessionExpiredis configured. The payment can still complete later, so check its status before the customer pays again. - When the customer closes the tab, the SDK checks the payment status 3 times, 2 seconds apart. If no check finds a final status,
onAuthorizeFailedfires withUSER_CANCELLED. If all 3 checks fail, for example because the device is offline, it fires withUNKNOWN_ERROR. In both cases, the payment can still complete later, so check its status before the customer pays again. - While the bank page is open, or after a deep-link return, the SDK doesn’t retry a
401or403response.onAuthorizeFailedfires right away, with session recovery. After the customer closes the tab, a401or403response counts as a failed check. - With deep-link return, the SDK doesn’t check while the bank page is open. It starts after the customer is back in your app and keeps checking for up to about 84 seconds. A network error or a request timeout during that time ends the payment with
onAuthorizeFailed.
Bank page stays open after the customer finishes 3DS
Symptom: The customer completes the challenge, but the browser tab stays on the bank page and your app doesn’t come back by itself. The payment resolves after the customer closes the tab. Cause: With deep-link return enabled for your account, the bank page sends the customer back to your app through a link that the SDK registers. Chrome blocks that link when it opens without a tap from the customer. This happens in some out-of-band 3DS flows, where the customer approves the payment in their banking app. Fix: No action is needed. When the customer closes the tab, the SDK checks the payment status and callsonAuthorizeSuccess or onAuthorizeFailed with the confirmed result. A blocked link never loses a payment.
Return page stays open on every payment
Symptom: With deep-link return enabled, every 3DS or redirect payment stops on the return page until the customer closes the tab. The payment then resolves as expected. Cause: Your account’s safe redirect URLs (safeRedirectUrls) don’t include payrailssdk://return/, so the backend never sends the customer to the link. If you set a custom-scheme Options.returnUrl, the list must include that URL instead.
Fix: Contact Payrails support. Payrails adds payrailssdk://return/ or your custom-scheme returnUrl to safeRedirectUrls in the Payrails portal for you. An https returnUrl doesn’t need an entry. Until then, payments still complete after the customer closes the tab.
Challenge tab closes when the customer taps the app icon
Symptom: During a 3DS or redirect challenge, the customer leaves the browser and comes back by tapping your app icon. The challenge tab is gone, and the payment ends as abandoned unless it was already complete. Cause: Your launcher activity usesandroid:launchMode="singleTask". Tapping the app icon brings that activity to the front and clears every activity above it in the task, including the challenge tab. The SDK treats this the same as the customer closing the tab: it checks the payment status, delivers the result if the payment is complete, and otherwise follows the session recovery path.
Fix: If your app doesn’t need singleTask, use the default standard launch mode for the launcher activity. Tapping the app icon then brings back the task with the challenge tab still open. Customers can also return through the recent apps screen, which keeps the tab.
handleRedirectReturn returns false
Symptom: Your return activity receives Options.returnUrl, but Payrails.handleRedirectReturn(intent) returns false.
Checks:
- The link must match
returnUrl: the same scheme, host, port and path. The SDK ignores the query and the fragment. A longer path doesn’t match. - Call the method on the main thread, from
onCreateandonNewIntent. On a different thread, the SDK logs a warning and returnsfalse. - Don’t call the method in
onResume. After a Custom Tab return, the SDK treats the resume as the return, and a later call returnsfalse. - Give the SDK the intent that Android sent. The action must be
ACTION_VIEW. - A payment must wait for a return. After process death, or after the SDK already handled the return, the method returns
false. This is expected. Show your own order status from your backend.
Checkout screen disappears after the customer returns
Symptom: The customer comes back to your app throughOptions.returnUrl, but the checkout screen is gone.
Cause: The activity that receives returnUrl is a singleTask launcher activity. Android clears the activities on top of it, which include the checkout activity, and the payment session ends.
Fix: Receive returnUrl in a separate translucent activity that calls handleRedirectReturn and then finish(). See Use your own return URL.
Browser stays on your website after the payment
Symptom: You set anhttps Options.returnUrl. After the payment, the Custom Tab shows your website and doesn’t open your app.
Cause: Chrome opened the https link in the tab. Chrome might do this when the redirect occurs without a tap from the customer, or when Android has not verified your App Link.
Fix: Use a custom-scheme returnUrl, such as shopapp://checkout/return. Contact Payrails support to add it to your safe redirect URLs. Until then, payments still complete after the customer closes the tab.
Payment Always Returns Failed
Checks:- Verify your init payload is correct (version and data from your backend)
- Check that your Payrails dashboard has the payment method configured
- Ensure your test card numbers are valid for your sandbox environment
- Check the
AuthorizationFailure(itscodeandmessage) passed to youronAuthorizeFaileddelegate callback for specific details (e.g.,AUTHORIZATION_ERROR,AUTHENTICATION_ERROR,UNKNOWN_ERROR)
Stored Instrument Payment Fails
Checks:- Ensure the stored instrument is still valid (not expired or deleted)
- Verify the instrument was retrieved from the current session:
session.getStoredInstruments()
Pre-Authorization Gate Issues
Payments are blocked and nothing reaches the backend
YouronRequestStart handler returned RequestStartDecision.Refuse, threw, or never returned. Confirm by checking
failure.code == AuthorizationFailureReason.VALIDATION_FAILED in onAuthorizeFailed — a block is
always reported with that code and never as AUTHORIZATION_ERROR.
The most common cause is a handler that only answers on the branch it cares about. The gate fires
for every payment method on the session, so any branch that does not return Proceed blocks
that method:
failure.message reads “The payment was blocked before authorization by the onRequestStart
handler” rather than your own text, the refusal came from a Refuse() with no message, a timeout,
or a throw — not from a Refuse(message) you wrote. That distinction is usually enough to tell an
intentional refusal from a broken handler.
A payment is blocked roughly ten seconds after tapping
The handler never returned. The SDK stops the attempt rather than leaving the element spinning, and logs:Thread.sleep, a blocking database read — runs to completion regardless, because coroutine
cancellation is cooperative. Use a suspending client, or wrap the blocking call so it can be
cancelled.
The handler throws and the payment is refused
That is intended. A handler that throws blocks the payment rather than letting it proceed, because a gate that fails open is not a gate. If you would rather allow payments when your own service is unreachable, catch the exception and returnRequestStartDecision.Proceed explicitly.
Note that the exception’s own message is not passed to the customer: failure.message gets the
SDK’s generic description instead, since a crash string can carry internals. To show your own text,
catch the exception and return RequestStartDecision.Refuse("…").
onPaymentButtonClicked does not stop the payment
It cannot. It returns Unit and the SDK does not wait for it — it is a notification for analytics
and observability. Move anything that decides whether a payment should happen into onRequestStart.
Lifecycle Issues
Session Lost After Configuration Change
Symptom: Payment fails after screen rotation or configuration change. Explanation: The SDK ties the session to the Activity lifecycle. When the Activity is destroyed (including for configuration changes), the session is cleaned up ifisFinishing is true.
Fix: For configuration changes (rotation), the standard Compose remember pattern preserves element references across recomposition. However, if the Activity is recreated, you’ll need to re-initialize the session.
Consider using a ViewModel to hold the session across configuration changes:
Memory Leak Warnings
Symptom: LeakCanary reports a leak fromPayrails or BrowserPaymentPresenterImpl.
Checks:
- The SDK holds a
WeakReferenceto the Activity — this should not cause leaks - Ensure you’re not holding strong references to
CardFormorCardPaymentButtonin long-lived scopes (e.g., a singleton) - The SDK registers
ActivityLifecycleCallbacksonce and cleans up when the bound Activity is destroyed
ProGuard / R8
If you’re using code shrinking, the SDK’s public API should work without additional rules. If you encounter issues with serialization or reflection:Getting Help
If your issue isn’t covered here:- Check the API Reference for specific error types and delegate behavior
- Review the SDK Concepts to verify your integration pattern
- Check the API Reference for correct method signatures
- Contact Payrails support with:
- SDK version
- Android API level
- The specific
PayrailsErrormessage (if applicable) - Steps to reproduce