Skip to content

Android SDK

Last updated: 14th July 2022

Start accepting online payments in just a few minutes with our Android SDK. It's quick and easy to integrate, accepts online payments from all major credit cards, and is customizable to your brand.

Minimum requirements

In order to use our Android SDK, you must be on at least version 5.0 (API 21).

Our Android SDK is released under the MIT license.


How it works

  1. You either embed our own customizable UI in your mobile app or, if you want full flexibility, you can build your own payment form and use our Android SDK in a headless mode.
  2. Our Android SDK is then used to take your customer's sensitive information and exchange them for a secure token. This process is called tokenization. Once you have the card token, you're ready to make the payment request.
android

Demo (our pre-built UI)

android demo

Integrate with our Android SDK

Step 1: Add the dependence repository

1
2
3
4
5
6
7
// project gradle file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

Step 2: Add the SDK and its dependencies in gradle

1
2
3
4
5
// module gradle file
dependencies {
implementation 'com.github.checkout:frames-android:<latest_version>'
}

You can find more about the installation and available versions on JitPack

If you're using the Android SDK with the deprecated Android Support Library, follow these steps.

Learn more about gradle files.

Step 3: Decide whether or not to use our pre-built UI

The usage guidelines vary slightly depending on your choice:


Usage (with the module's UI)

Step 1: Add the module to your XML layout

1
2
3
4
5
<com.checkout.android_sdk.PaymentForm
android:id="@+id/checkout_card_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

Step 2: Include the module in your class

1
private PaymentForm mPaymentForm; // include the payment form

Step 3: Create a callback for the payment form

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
PaymentFormCallback mFormListener = new PaymentFormCallback() {
@Override
public void onFormSubmit() {
// form submit initiated; you can potentially display a loader
}
@Override
public void onTokenGenerated(CardTokenisationResponse response) {
// your token is here
mPaymentForm.clearForm(); // this clears the Payment Form
}
@Override
public void onError(CardTokenisationFail response) {
// token request error
}
@Override
public void onNetworkError(NetworkError error) {
// network error
}
@Override
public void onBackPressed() {
// the user decided to leave the payment page
mPaymentForm.clearForm(); // this clears the Payment Form
}
};

Step 4: Initialize the module

1
2
3
4
5
6
// initialize the payment from
mPaymentForm = findViewById(R.id.checkout_card_form);
mPaymentForm
.setSubmitListener(mSubmitListener) // set the callback
.setEnvironment(Environment.SANDBOX) // set the environment
.setKey("pk_xxx"); // set your public key

Usage (without the module's UI)

Step 1: Include the module in your class

1
private CheckoutAPIClient mCheckoutAPIClient; // include the module

Step 2: Create a callback

1
2
3
4
5
6
7
8
9
10
11
12
13
14
CheckoutAPIClient.OnTokenGenerated mTokenListener = new CheckoutAPIClient.OnTokenGenerated() {
@Override
public void onTokenGenerated(CardTokenisationResponse token) {
// your token
}
@Override
public void onError(CardTokenisationFail error) {
// your error
}
@Override
public void onNetworkError(NetworkError error) {
// your network error
}
};

Step 3: Initialize the module and pass the card details

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
mCheckoutAPIClient = new CheckoutAPIClient(
this, // context
"pk_XXXXX", // your public key
Environment.SANDBOX // the environment
);
mCheckoutAPIClient.setTokenListener(mTokenListener); // pass the callback
// Pass the payload and generate the token
mCheckoutAPIClient.generateToken(
new CardTokenisationRequest(
"4242424242424242",
"name",
"06",
"25",
"100",
new BillingModel(
"address line 1",
"address line 2",
"postcode",
"UK",
"city",
"state",
new PhoneModel(
"+44",
"07123456789"
)
)
)
);

Make our Android SDK your own

Customization

Although we kept our demo simple, you have a lot of control over the appearance of your form—from the colors and styling, to whether you want to display one input field or several. Check out our Customization guide for more details and examples.

Configuration options

You'll find a list of all the possible configuration options in our Android SDK reference.


Next steps

Now that you've got your card token, you're ready to request a card payment.