Android SDK
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
- 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.
- 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.
Demo (our pre-built UI)
Integrate with our Android SDK
Step 1: Add the dependence repository
// project gradle fileallprojects {repositories {...maven { url 'https://jitpack.io' }}}
Step 2: Add the SDK and its dependencies in gradle
// module gradle filedependencies {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
<com.checkout.android_sdk.PaymentFormandroid:id="@+id/checkout_card_form"android:layout_width="match_parent"android:layout_height="match_parent"/>
Step 2: Include the module in your class
private PaymentForm mPaymentForm; // include the payment form
Step 3: Create a callback for the payment form
PaymentFormCallback mFormListener = new PaymentFormCallback() {@Overridepublic void onFormSubmit() {// form submit initiated; you can potentially display a loader}@Overridepublic void onTokenGenerated(CardTokenisationResponse response) {// your token is heremPaymentForm.clearForm(); // this clears the Payment Form}@Overridepublic void onError(CardTokenisationFail response) {// token request error}@Overridepublic void onNetworkError(NetworkError error) {// network error}@Overridepublic void onBackPressed() {// the user decided to leave the payment pagemPaymentForm.clearForm(); // this clears the Payment Form}};
Step 4: Initialize the module
// initialize the payment frommPaymentForm = 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
private CheckoutAPIClient mCheckoutAPIClient; // include the module
Step 2: Create a callback
CheckoutAPIClient.OnTokenGenerated mTokenListener = new CheckoutAPIClient.OnTokenGenerated() {@Overridepublic void onTokenGenerated(CardTokenisationResponse token) {// your token}@Overridepublic void onError(CardTokenisationFail error) {// your error}@Overridepublic void onNetworkError(NetworkError error) {// your network error}};
Step 3: Initialize the module and pass the card details
mCheckoutAPIClient = new CheckoutAPIClient(this, // context"pk_XXXXX", // your public keyEnvironment.SANDBOX // the environment);mCheckoutAPIClient.setTokenListener(mTokenListener); // pass the callback// Pass the payload and generate the tokenmCheckoutAPIClient.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.