Upgrade from Frames for Android
Last updated: March 12, 2025
Follow this guide to upgrade your Frames for Android integration to Flow for mobile.
Create a public key and a secret key from the Dashboard, with the following key scopes:
- Public key –
payment-sessions:pay
andvault-tokenization
- Secret key –
payment-sessions
To receive notifications for the payment events that may be triggered throughout the steps, configure your webhook receiver.
To prepare for the upgrade to Flow, remove all Frames code from your client-side and server-side integrations.
Remove Frames from the Gradle file of the app.
1// app gradle file2implementation("com.github.checkout:frames-android:<latest_version>")
Remove any Kotlin code where you initialize Frames. For example:
1val paymentFlowHandler = PaymentFlowHandler()2val paymentFormConfig = PaymentFormConfig(3publicKey = PUBLIC_KEY,4context = context,5environment = Environment.Production,6paymentFlowHandler = paymentFlowHandler,7style = PaymentFormStyle(),8)9val paymentFormMediator = PaymentFormMediator(paymentFormConfig())1011// in Activity12paymentFormMediator.setActivityContent(activity)1314// in Compose15paymentFormMediator.PaymentForm()
Remove all server-side API calls to the following endpoints:
post
https://api.checkout.com/payments
Update your server to create a PaymentSession
for the Flow integration:
1const createPaymentSession = async (req, res) => {2const response = await fetch("https://api.checkout.com/payment-sessions", {3method: "POST",4headers: {5Authorization: `Bearer ${secretKey}`,6"Content-Type": "application/json",7},8body: JSON.stringify({9amount: 1000,10currency: "GBP",11reference: "ORD-123A",12display_name: "Online Shop",13billing: {14address: { country: "GB" },15},16customer: {17name: "Jia Tsang",18email: "[email protected]",19},20success_url: "https://example.com/payments/success",21failure_url: "https://example.com/payments/failure",22}),23});2425const paymentSession = await response.json();26res.json(paymentSession);27};
Include the Flow dependency in your app:
1// app gradle file2implementation("com.checkout:checkout-android-components:<latest_version>")34// project gradle file5repositories {6mavenCentral()7}
Configure Flow with your public key and the payment session data returned from the server:
1val config = CheckoutComponentConfiguration(2context = context,3paymentSession = PaymentSessionResponse(4id = paymentSessionId,5paymentSessionToken = paymentSessionToken,6paymentSessionSecret = paymentSessionSecret,78),9publicKey = PUBLIC_KEY,10environment = Environment.PRODUCTION,11)1213// Create CheckoutComponents14CoroutineScope(Dispatchers.IO).launch {15try {16val checkoutComponents = CheckoutComponentsFactory(config).create()17} catch (checkoutError: CheckoutError) {18handleError(checkoutError)19}20}
Use CheckoutComponents
to create a flow
component that displays a list of all available payment methods for the current payment session:
1val flow = checkoutComponents.create(ComponentName.Flow)
Add the Flow component to a container View or render Flow in a Composable function:
1// in Compose2if (flow.isAvailable) {3flow.Render()4}56// in View7if (flow.isAvailable) {8flow.provideView(containerView)9}
You can use Flow to handle payment methods that require a redirect (asynchronous payments) and those that do not (synchronous payments).
Depending on the payment outcome, customers are redirected to the success_url
or failure_url
you specified when you created the PaymentSession
.
We send a webhook to your server notifying you of changes to the payment's status. Wait for the webhook callback before you trigger your order fulfillment process.
For payments submitted with Flow, the PaymentSession
ID is returned in the webhook payload's data.metadata.cko_payment_session_id
field.
Optionally, you can retrieve the payment result using the callbacks provided by Flow:
onSuccess
for successful paymentsonError
for unsuccessful payments
For payment methods that do not require a redirect, use the onSuccess
callback to handle payments. You can use this to notify the customer of the payment status.
1val config = CheckoutComponentConfiguration(2context = context,3paymentSession = paymentSessionResponse,4publicKey = PUBLIC_KEY,5environment = Environment.PRODUCTION,6componentCallback = ComponentCallback(7onSuccess = { component, paymentId ->8// Complete order in server side9completeOrder(paymentId);10}11)12)
A webhook is sent to your server notifying you of changes to the payment's status. Wait for the webhook callback before you trigger your order fulfillment process.
Use our test cards to simulate different payment flows, to ensure your integration is set up correctly and behaving as expected.
Information
Ensure that you test each payment method that you plan to offer to your customers.
You can check the status of a payment from the Payments > Processing > All payments screen in the Dashboard.
You can use Flow for mobile to natively offer Google Pay payments.
To upgrade from your Google Pay Frames integration:
- Contact your account manager and provide your Google Pay Merchant ID.
- Remove the Google Pay SDK integration from your Gradle files.
- Remove any Google Pay SDK code from your app.
- Remove any
GooglePayTokenRequest
related code from your Frames implementation. For Example:
1val checkoutApiClient = CheckoutApiServiceFactory.create(2publicKey = PUBLIC_KEY,3environment = Environment.PRODUCTION,4context = context,5)67val request = GooglePayTokenRequest(8tokenJsonPayload = tokenJsonPayload,9onSuccess = { tokenDetails ->10/* Handle success result */11tokenDetails.token12},13onFailure = { errorMessage ->14/* Handle failure result */15},16)17checkoutApiClient.createToken(request)
- Follow the Flow for mobile instructions to accept Google Pay payments.