Android SDK
Take card, redirect, and Google Pay payments in an Android app, with SDK-owned card fields, 3DS in a WebView, a headless checkout API, and a drop-in.
The Pay.com Android SDK is a headless checkout for native apps, with the same API shape as the iOS SDK, and a ready-made drop-in. Your server creates a session, the app starts a checkout with the session's client_secret, and the SDK takes the payment:
- Card fields the SDK owns. Compose fields, with View versions, driven by a
PayCardController. The app never reads the card number. It sees only validation state, the card brand, and the first 8 digits. - 3DS handled for you. When the issuer asks for a challenge, the SDK shows it in a full-screen WebView dialog over your activity, then reads the outcome.
- Redirect payment methods. Alternative payment methods open in a Custom Tab and come back to your app through a return URL.
- Google Pay. Google's sheet over your activity, with Pay.com decrypting the token.
- A drop-in. A Material 3 payment sheet with the session's methods, the card form, Google Pay, and the Pay button.
- Saved methods and payout methods. At checkout, the customer can pay with one of their saved methods, such as a card, a PayPal account, or a bank account. In a payout setup session, the customer being paid picks a saved payout method or adds one.
- Coroutines.
create,pay,payWithGooglePay, and the drop-in'spresentaresuspendfunctions.
The drop-in for a new customer, and for a returning one:
Requirements
The SDK needs these platform versions and libraries.
| Requirement | Version |
|---|---|
| Android | minSdk 24 (Android 7.0), with the libraries compiled against SDK 35 |
| Kotlin | 2.2 |
| Java bytecode | 11 |
| UI | Jetpack Compose and Material 3 for the card fields and the drop-in, with View versions of the card fields for apps that don't use Compose |
| Google Pay | Google Play services Wallet 19.4, which pay-googlepay brings in |
Install
The SDK is split into seven modules, with the Maven coordinates com.pay.sdk:<module>:0.1.0.
| Module | Type | What it contains |
|---|---|---|
pay-core | Kotlin/JVM | PayCheckout, the models, PayError, PayResult, card validation, and the payment flow. |
pay-elements | Android library | The card fields (PayCardNumberField, PayExpiryField, PayCvcField, PayNameField) driven by a PayCardController, a saved card's CVV field driven by a PayCvcController, and their View versions. Brings in pay-core. |
pay-threeds | Android library | checkout.pay(request, activity), the 3DS challenge WebView, and the Custom Tabs redirects. Brings in pay-core. |
pay-googlepay | Android library | Google Pay (PayGooglePay.isReadyToPay() and checkout.payWithGooglePay()). Brings in pay-threeds and Google's play-services-wallet. |
pay-dropin | Android library | PayDropIn, a ready-made payment sheet with the session's methods, a returning customer's saved methods, the card form, Google Pay, the save-card switch, the Pay button, errors, and retries. Brings in pay-elements, pay-threeds, and pay-googlepay. |
pay-cse | Kotlin/JVM | Client-side encryption (PayCSE) of a card or a CVV. pay-core uses it for clientSideEncryption. Depend on it to encrypt cards from your own form. See Client-side encryption on mobile. |
pay-linkout | Android library | PayLinkOut opens a checkout your server created in the browser when the store's rules allow it and reports how the customer came back. Standalone module with no SDK dependencies. |
For the drop-in, depend on pay-dropin:
dependencies {
implementation("com.pay.sdk:pay-dropin:0.1.0")
}For your own UI, most apps depend on pay-elements and pay-threeds, and add pay-googlepay for Google Pay:
dependencies {
implementation("com.pay.sdk:pay-elements:0.1.0")
implementation("com.pay.sdk:pay-threeds:0.1.0")
}How a payment works
A payment runs in four steps across your server and the app.
- Your server creates a payment session with Create a payment session and sends only its
client_secretto the app. - The app calls
PayCheckout.create()with thatclient_secret. - The app shows the session's payment methods and the card fields, and calls
checkout.pay()when the customer pays. Or it presents the drop-in, which does both. The SDK sends the card to Pay.com, runs 3DS when the session asks for it, and shows any challenge or redirect. - The app gets a
PayResult. Treat it as a hint for your UI. Your server confirms the payment with Retrieve a payment session or thepayment_session.completedwebhook before it fulfills the order. For a setup session, it uses Retrieve a setup session or thesetup_session.completedwebhook.
Accept payments in your Android app
Take a first payment, with the drop-in or your own screen.
Start a checkout
Load a session from its client_secret.
Pay
Pay with a card, a redirect method, or Google Pay.
Card fields
SDK-owned card inputs, in Compose or Views.
Present the drop-in
A ready-made Material 3 payment sheet.
Pay with Google Pay
Google's sheet, with Pay.com decrypting the token.