Accept payments on your Android app
Last updated: March 12, 2025
Information
We are not onboarding new merchants to Frames.
Upgrade to Flow instead, our pre-built, customizable payment user interface. Flow provides a more flexible, scalable, and feature-rich integration.
If you've integrated the Frames Android SDK to your Android app, you can tokenize a customer's payment details or Card Verification Value (CVV) to use in a payment request.
Create a callback for the payment flow:
1val paymentFlowHandler = object : PaymentFlowHandler {2override fun onSubmit() {3// form submit initiated; you can choose to display a loader here4}56override fun onSuccess(tokenDetails: TokenDetails) {7// your token is here8}910override fun onFailure(errorMessage: String) {11// token request error12}1314override fun onBackPressed() {15// the user decided to leave the payment page16}17}
Create a new configuration for the payment form:
1val paymentFormConfig = PaymentFormConfig(2publicKey = PUBLIC_KEY, // set your public key3context = context, // set context4environment = Environment.SANDBOX, // set the environment5paymentFlowHandler = paymentFlowHandler, // set the callback6style = PaymentFormStyle(), // set the style7supportedCardSchemeList = emptyList() // set supported card schemes, by default uses all schemes8)
Create a new PaymentFormMediator
object:
1val paymentFormMediator = PaymentFormMediator(paymentFormConfig)
Display the payment form with the PaymentForm()
method exposed by PaymentFormMediator
:
1paymentFormMediator.PaymentForm() // Compose function
Information
You can customize the forms used to collect customers' payment details.
Create a CheckoutApiServiceFactory
object:
1val checkoutApiClient = CheckoutApiServiceFactory.create(2publicKey = PUBLIC_KEY, // set your public key3environment = Environment.SANDBOX, // set context4context = context // set the environment5)
Create a token for Google Pay:
1val request = GooglePayTokenRequest(2tokenJsonPayload = tokenJsonPayload,3onSuccess = { tokenDetails ->4/* Handle success result */5tokenDetails.token6},7onFailure = { errorMessage ->8/* Handle failure result */9}10)11checkoutApiClient.createToken(request)
When the customer submits the required payment forms, the payment details are sent directly to Checkout.com's servers and tokenized. The tokenized payment details are then sent back to you, for you to use in a payment request.
Information
Checkout.com is fully compliant with the Payment Card Industry Data Security Standards (PCI DSS). If you use one of our UI-based solutions, you are subject to a lower level of PCI compliance (SAQ A).
To request a payment, call the following endpoint from your back end:
post
https://api.checkout.com/payments
For the full API specification, see the API reference.
1{2"source": {3"type": "token",4"token": "tok_4gzeau5o2uqubbk6fufs3m7p54"5},6"amount": 100,7"currency": "USD",8"processing_channel_id": "pc_ovo75iz4hdyudnx6tu74mum3fq",9"reference": "ORD-5023-4E89",10"metadata": {11"udf1": "TEST123",12"coupon_code": "NY2023",13"partner_id": 12398914}15}
1{2"id": "pay_mbabizu24mvu3mela5njyhpit4",3"action_id": "act_mbabizu24mvu3mela5njyhpit4",4"amount": 100,5"currency": "USD",6"approved": true,7"status": "Authorized",8"auth_code": "770687",9"response_code": "10000",10"response_summary": "Approved",11"3ds": {12"downgraded": true,13"enrolled": "N"14},15"risk": {16"flagged": true17},18"source": {19"type": "card",20"id": "src_nwd3m4in3hkuddfpjsaevunhdy",21"billing_address": {22"address_line1": "123 Anywhere St.",23"address_line2": "Apt. 456",24"city": "Anytown",25"state": "AL",26"zip": "123456",27"country": "US"28},29"phone": {30"country_code": "+1",31"number": "555 123 4567"32},33"last4": "4242",34"fingerprint": "F31828E2BDABAE63EB694903825CDD36041CC6ED461440B81415895855502832",35"bin": "424242"36},37"customer": {38"id": "cus_udst2tfldj6upmye2reztkmm4i",39"email": "[email protected]",40"name": "John Smith"41},42"processed_on": "2024-09-10T10:11:12Z",43"reference": "ORD-5023-4E89",44"processing": {45"retrieval_reference_number": "909913440644",46"acquirer_transaction_id": "440644309099499894406"47},48"eci": "06",49"scheme_id": "489341065491658",50"links": {51"self": {52"href": "https://api.sandbox.checkout.com/payments/pay_mbabizu24mvu3mela5njyhpit4"53},54"action": {55"href": "https://api.sandbox.checkout.com/payments/pay_mbabizu24mvu3mela5njyhpit4/actions"56},57"void": {58"href": "https://api.sandbox.checkout.com/payments/pay_mbabizu24mvu3mela5njyhpit4/voids"59},60"capture": {61"href": "https://api.sandbox.checkout.com/payments/pay_mbabizu24mvu3mela5njyhpit4/captures"62}63}64}
When you send a 3D Secure charge request from your server, you receive a 3D Secure URL in the response's _links.redirect.href
field. You can pass this URL to a PaymentFormMediator
in order to handle verification.
Information
You can use the 3D Secure mobile SDKs to handle 3DS challenges natively instead.
The redirect URLs, success_url
and failure_url
, are set in the Dashboard, but they can be overwritten in the charge request sent from your server. It's important that you provide the correct URLs to ensure a successful payment flow.
You can find an example of handling 3DS in DemoActivity.java
from the SDK's project files.
Create 3DS result handler:
1val threeDSResultHandler: ThreeDSResultHandler = { threeDSResult: ThreeDSResult ->2when (threeDSResult) {3is ThreeDSResult.Success -> {4/* Handle success result */5threeDSResult.token6}7is ThreeDSResult.Failure -> {8/* Handle failure result */9}10is ThreeDSResult.Error -> {11/* Handle error result */12threeDSResult.error13}14}15}
Configure the 3DS request:
1val request = ThreeDSRequest(2container = findViewById(android.R.id.content), // Provide a ViewGroup container for 3DS WebView3challengeUrl = redirectUrl, // Provide a 3D Secure URL4successUrl = "http://example.com/success",5failureUrl = "http://example.com/failure",6resultHandler = threeDSResultHandler7)8paymentFormMediator.handleThreeDS(request)
Some regions require you to send a Card Verification Value (CVV) when you perform a payment with a stored card.
To remain at PCI compliance level SAQ-A, you can use the SDK's CVV component to securely tokenize a CVV.
The CVV token is returned to your application layer, so that you can submit it when you perform a payment request from your back end.
To start, initialize the CVV component:
1// Create a one-time cvvComponentApi instance2val cvvComponentApi = CVVComponentApiFactory.create(3publicKey = "<PUBLIC_KEY>",4environment = Environment.SANDBOX,5context = context6)
Create an instance of CVVComponentConfig
. Use this object to configure the parameters for the CVV component.
You can set a card scheme for the component using the optional CardScheme
parameter. If you do so, the SDK can validate that the CVV submitted by the customer is in a valid format for the given card scheme via isEnteredCVVValid
.
If you do not explicitly set a card scheme, the scheme defaults to UNKNOWN
. You receive an error at the API level if the CVV is invalid.
If the user submits an empty field as the security code, the SDK throws a validation error when you call createToken()
, regardless of the card scheme you specified.
Information
For a list of valid scheme name string values, refer to your back end.
To customize the UI, specify a cvvComponentStyle
within CVVComponentConfig
. You can use any of the styling attributes exposed by the SDK.
1val cvvComponentConfig = CVVComponentConfig(2cardScheme = CardScheme.fromString(cardSchemeValue = "<CARD_SCHEME>"), // set an optional card scheme3onCVVValueChange = { isEnteredCVVValid -> // update your listener from the onCVVValueChange4enteredVisaCVVUpdated.value = isEnteredCVVValid5},6cvvInputFieldStyle = inputFieldStyle, // set your cvvInputFieldStyle7)
You can then instantiate the cvvComponentMediator
using your configuration:
1val cvvComponentMediator = cvvComponentApi.createComponentMediator(cvvComponentConfig)
Use the cvvComponentMediator
object to load the CVV component:
1cvvComponentMediator.CVVComponent()
Use the cvvComponentMediator
object to create a token:
1cvvComponentMediator.createToken { result ->2when (result) {3is CVVTokenizationResultHandler.Success -> {4result.tokenDetails // Handle success result5}6is CVVTokenizationResultHandler.Failure -> {7result.errorMessage // Handle failure result8}9}10}
You can then request a payment using the tokenized security code.