docs
Sandbox
Live

Mobile » Android Kit » Overview

Overview

Please refer to the project on GitHub for the Android Kit section.

The CheckoutKit object

A demo application is available in the folder app

Import the CheckoutKit.java in your code as below:

import com.checkout.CheckoutKit;

You will need to specify at least the public key when creating an instance of CheckoutKit. We offer a wide range of constructors, the CheckoutKit instance is entirely customizable:

CheckoutKit.getInstance(String publicKey) throws CheckoutException
CheckoutKit.getInstance(String publicKey, boolean debug) throws CheckoutException
CheckoutKit.getInstance(String publicKey, Environment baseUrl, boolean debug) throws CheckoutException
CheckoutKit getInstance() throws CheckoutException // to use only once the CheckoutKit object has been instantiated, otherwise throws a CheckoutException

These functions can throw CheckoutException (when the public key specified is invalid). Here are more details about the parameters:

  • publicKey: String containing the public key. It is tested against the following regular expression: ^pk_(?:test_)?(?:\w{8})-(?:\w{4})-(?:\w{4})-(?:\w{4})-(?:\w{12})$. Mandatory otherwise the CheckoutKit object cannot be instantiated.
  • baseUrl: Environment object containing the information of the merchant's environment, default is SANDBOX. Optional.
  • debug: boolean, if the debug mode is activated or not, default is true. Optional.
  • logger: Log object printing information, warnings and errors to the console (for now). Optional.

If debug is set to true, many actions will be traced to the logging system.

More details and all the available functions of CheckoutKit can be found in the Reference.

GetCardProvider

The call to this function is made with checkoutkit.getCardProviders(). It returns an instance of Response<CardProviderResponse> that contains all the information received as JSON from the server. Inside this instance, there is one ResponseError instance if an error occurred, otherwise the CardProviderResponse object can be directly accessed. The array containing the information about the card providers can be accessed with cardProviderResponse.getData() which returns a List<CardProvider>.

CreateCardToken

The call to this function is made with checkoutkit.createCardToken(card), card being an instance of Card, containing the card information to be tokenized. It returns an instance of Response<CardTokenResponse> that contains all the information received as JSON from the server. Inside this instance, there is one ResponseError instance if an error occurred, otherwise the CardTokenResponse object can be directly accessed. This instance contains a CardToken instance, with the card information. The string containing the card token can be accessed with cardTokenResponse.getCardToken().

Logging

Most of the activity of the CheckoutKit is logged either as information, warning or error. All the logs are made to the console for now. Logging occurs only if the debug mode is activated (true as default, but can be explicitely set to false). The printing format is date (yyyy/MM/dd HH:mm:ss) **Subject/Class name** logged message. The logger can be modified via the functions setLogger or getInstance. The log entries are then added to the logger specified.

The CardValidator class

Another class is available and contains utility functions: CardValidator. It provides static functions for validating all the card related information before processing them. The list of the available functions is available in the Reference.