Android SDK reference
Our Frames for Android reference is here to help you find those hard-to-find bits of information all in one place.
You can only create charges in currencies that have been enabled for your account. Please contact your Customer Success manager if you need to process payments in additional currencies.
Required when using our pre-built UI
First, you need to make sure you declare the form in XML.
<com.checkout.android_sdk.PaymentFormandroid:id="@+id/checkout_card_form"android:layout_width="match_parent"android:layout_height="match_parent"/>
Method name | Description |
---|---|
| The callback for the payment form's interaction outcomes. |
| Your public key. Make sure you use the correct key for your environment. |
| The setter used to decide which environment will be used. Possible values: |
Required when using your own UI
Parameter/setter | Description |
---|---|
| Your activity context. |
| The setter used to decide which environment will be used.Possible values: |
| Your public key. Make sure you use the correct key for your environment. |
| Your callback used to handle the tokenization outcome. |
Handling 3D Secure
The module allows you to handle 3D Secure URLs within your mobile app.
When you send a 3D Secure charge request from your server, you will get back a 3D Secure URL. You can then pass the 3D Secure URL to the module to handle the verification.
Step 1: Create a callback
PaymentForm.On3DSFinished m3DSecureListener =new PaymentForm.On3DSFinished() {@Overridepublic void onSuccess(String token) {// success}@Overridepublic void onError(String errorMessage) {// fail}};
Step 2: Pass the callback to the module and handle 3D Secure
mPaymentForm = findViewById(R.id.checkout_card_form);mPaymentForm.set3DSListener(m3DSecureListener); // pass the callbackmPaymentForm.handle3DS('https://sandbox.checkout.com/api2/v2/3ds/acs/687805', // the 3D Secure URL'https://example.com/success', // the Redirection URL'https://example.com/fail', // the Redirection Fail URL);
Handling Google Pay
The module allows you to handle a Google Pay token payload and retrieve a token which can be used to create a charge from your backend.
Step 1: Create a callback
CheckoutAPIClient.OnGooglePayTokenGenerated mGooglePayListener =new CheckoutAPIClient.OnGooglePayTokenGenerated() {@Overridepublic void onTokenGenerated(GooglePayTokenisationResponse response) {// success}@Overridepublic void onError(GooglePayTokenisationFail error) {// fail}@Overridepublic void onNetworkError(VolleyError error) {// your network error}};
Step 2: Pass the callback to the module and generate the token
mCheckoutAPIClient = new CheckoutAPIClient(context, // activity context'pk_XXXXX', // your public keyEnvironment.SANDBOX, // the environment);mCheckoutAPIClient.setGooglePayListener(mGooglePayListener); // pass the callbackmCheckoutAPIClient.generateGooglePayToken(payload); // the payload is the JSON string generated by GooglePay
Payment form methods
Method name | Description |
---|---|
| Set the callback for the payment form. |
| Set the environment to be used. |
| Set the public key to be used in the tokenization process. |
| Set all the card schemes that you want to accept. This will determine which logos to display. |
| This will automatically set the country drop-down to be your desired locale. |
| Used to handle 3DS URLs. |
| Set the 3DS handler. |
| In case you already collected the customer's billing details, you can inject them here so they don't have to enter them again. |
| In case you already collected the customer's phone details, you can inject them here so they don't have to enter them again. |
| In case you already collected the customer's name, you can inject it here so they don't have to enter it again. |
| Clears the payment form. |
| Sets a callback for when the form is submitted. |
CardTokenisationResponse Object
All the properties have getters.
Property | Type |
---|---|
| String |
| String |
| String |
| Integer |
| Integer |
| String |
| String |
| String |
| String |
| String |
| String |
| String |
| String |
| String |
| BillingModel |
| PhoneModel |
| String |
CardTokenisationFail Object
All the properties have getters.
Property | Type |
---|---|
| String |
| String |
| String[] |