This page covers the Android checkout SDK,
com.github.dodopayments:dodopayments-mobile-sdk, which opens Dodo Payments hosted checkout inside your app. To call the Dodo Payments API from your server, use the backend Kotlin SDK instead.Checkout Sessions API
Create the
checkout_url that this SDK opens.Mobile Integration Guide
Best practices for mobile checkout flows.
androidx.browser.customtabs) and returns a typed CheckoutResult when the customer finishes or leaves checkout. Your backend creates the checkout session and sends its checkout_url to the app. The SDK contains no networking code and holds no API key, so it never calls the Dodo Payments API.
Requirements: minSdk 23, Kotlin, and Java 17. The SDK depends only on androidx.activity, androidx.browser, and kotlinx-coroutines-android.
Installation
1
Add the Dependency
JitPack distributes the SDK. Add the JitPack repository in Then add the dependency to your app module’s Appearance customization requires version 1.1.0 or later.
settings.gradle.kts:settings.gradle.kts
build.gradle.kts:build.gradle.kts
From version 1.1.2, the SDK is on JitPack, and the version is the release tag, such as
kotlin-v1.1.2. Versions 1.1.0 and earlier stay on Maven Central as com.dodopayments.api:checkout-android. The package names in your code do not change. JitPack builds a new version on the first request, so the first download can be slow.2
Register a Callback URL Scheme
Set your callback scheme as a Gradle manifest placeholder. The SDK’s own manifest declares the redirect activity’s intent filter with the Use the same scheme in
${dodoCallbackScheme} placeholder, so this property is the only setup step. You don’t add any manifest XML:build.gradle.kts
CheckoutParams.returnUrl, for example myapp://checkout/return, and set the same URL as the checkout session’s return_url when your backend creates the session. The SDK matches the return URL on scheme, host, and path, and ignores the query string. The URL doesn’t need to load a real page.If you omit the placeholder, the build fails with an unresolved-placeholder error. If the placeholder doesn’t match the scheme of
returnUrl, the SDK throws PLATFORM_ERROR before it opens checkout.Usage
The SDK has two ways to start checkout: an activity result launcher and a suspend function. Both return the sameCheckoutResult.
- Launcher (Recommended)
- Suspend Function
Register the contract with
registerForActivityResult, then launch it:What the Result Means
The SDK buildsCheckoutResult from the query parameters on the return URL.
One of five values:
SUCCEEDED: the return URL hasstatus=succeeded(one-time payment) orstatus=active(subscription).FAILED: the payment was declined (status=failed).CANCELLED: the customer closed the Custom Tab before the return URL arrived. The SDK doesn’t know the outcome, and the payment may have succeeded, so don’t show a failure screen. Reconcile the abandoned session instead.PENDING: the payment settles later (status=processingor anyrequires_*value), or thestatusparameter was missing or unrecognized. Reconcile it likeCANCELLED.EXPIRED: the checkout session expired (status=expired).
The
payment_id query parameter, when the return URL includes one. Show it in your UI, but don’t use it to grant access. See Verify the Payment.Verify the Payment
Webhooks
Listen for payment events in real time.
Get Payment Detail
Query the payment status on demand.
payment.succeeded or subscription.active webhook. Don’t rely on CheckoutResult.status alone.
Appearance Customization
To change the Custom Tab’s toolbar, buttons, and color scheme, pass aBrowserCustomization as customization on CheckoutParams. Every field is optional and defaults to null. For a null field, the SDK doesn’t set that option, so the browser that hosts the Custom Tab applies its own default.
Navigation bar color, as an ARGB
Color int.Color of the divider above the navigation bar, as an ARGB
Color int.Shows the toolbar’s share icon.
false hides it.LIGHT or DARK forces that appearance regardless of the device’s system setting. SYSTEM follows the system setting.checkoutLauncher from Usage:
Errors
DodoCheckout.start throws CheckoutError only for misuse or a platform failure. Read the reason from CheckoutError.code:
INVALID_CHECKOUT_URL:checkoutUrlisn’t anhttpscheckout URL oncheckout.dodopayments.comortest.checkout.dodopayments.com. The path must start with/session/, or be the 8-character payment link ID that aconfirm: truesession returns. Payment link URLs need version 1.1.2 or later.INVALID_RETURN_URL:returnUrlisn’t an absolute URL with a scheme and a host.ALREADY_IN_PROGRESS: another checkout is running. Only one checkout can run at a time.PLATFORM_ERROR: an unexpected platform failure, including areturnUrlscheme that doesn’t match yourdodoCallbackSchemeplaceholder.
CANCELLED or FAILED), never a thrown error. With the launcher, validation errors throw from launcher.launch(...). A platform failure after the launch can’t be thrown through the activity result callback, so the launcher returns CANCELLED with the error code in raw["error"].
Abandoned Sessions
The SDK records the checkout session when checkout starts, and clears the record only when checkout ends withSUCCEEDED, FAILED, or EXPIRED. The record stays when the app is killed during checkout, and after a CANCELLED or PENDING result, because in those cases the SDK doesn’t know the outcome. Check for it on the next app launch and after every CANCELLED or PENDING result:
abandoned.sessionId is the checkout session ID, which starts with cks_. abandoned.createdAt is the time checkout started, as an epoch timestamp in milliseconds. Your backend can look up the session with Get Checkout Session, which returns its payment_id and payment_status. Until the payment reaches a final status, treat it as pending, not failed. A confirm: true session opens a payment link URL with no session ID in it, so the SDK keeps no record for it and getAbandonedSession() returns null. Use the session_id or payment_id from the create response instead.
Related
Mobile Integration Guide
Best practices for mobile checkout flows.
Kotlin SDK
Backend SDK for server-side operations.