Prerequisites: Android project with Jetpack Compose, JDK 17,
minSdk 21, compileSdk 35
Step 1: Add Dependencies
The SDK is distributed via Maven Central. In your app-levelbuild.gradle.kts:
settings.gradle.kts:
Step 2: Fetch an Init Payload From Your Backend
The SDK requires an initialization payload from the Payrails API. Your backend should call the Payrails client-init endpoint and return theversion and data fields.
Kotlin
Step 3: Initialize the SDK Session
Create a session before rendering any payment UI. This is typically done in your Activity or ViewModel. KotlinStep 4: Build the Card Payment Screen
Kotlin/Compose onlyThe payment UI elements use Jetpack Compose and require Kotlin. There is no Java equivalent for this step. Session initialization (Step 3) and delegate callbacks are Java-compatible.
Step 5: Handle Payment Results
The delegate callbacks tell you what happened:Step 6: Test It
Use your Payrails sandbox environment and test card numbers to verify the integration. The card form validates input automatically — you’ll see inline error messages for invalid card numbers, expiry dates, and CVV codes.What’s Next?
Now that you have a basic card payment working:- How to Tokenize a Card — Save a card to vault without charging it (for wallets, subscriptions, and save-for-later flows)
- How to Let Shoppers Choose a Card Network — Co-branded (co-badged) cards: surface the brand selector and submit the preferred scheme
- How to Build a Custom Pay Button (Your Own UI) — Use your own button and method selector while the SDK runs the payment flow
- How to Run a Payment Without an SDK Button (Headless) — Drive checkout from your own UI /
ViewModelwithPayrailsPaymentLauncher - Styling Guide — Customize colors, fonts, and layout to match your brand
- Troubleshooting — Diagnose integration and runtime issues
- SDK Concepts — Understand the architecture and mental model
- API Reference — Complete reference for all public APIs