Android SDK
This documentation highlights the requirements for using the PointCheckout Android SDK. Throughout this document, we aassume that you are using Android Studio for your Android development.
MINIMUM REQUIREMENTS
The minimum supported Android API level for the SDK is 16 (KitKat), however, setting the minimum Android API level to 26 (Pie) is recommended.
note
The SDK uses Google's SafetyNet API for security, setting minimum Android API to lower than 26 will prevent it from functioning.
#
Setting up the SDK#
JitPack RepositoryInclude the JitPack.io repository to your Android project in your_project_home/build.gradle
allprojects { repositories { ... maven { url 'https://jitpack.io' } flatDir { dirs 'libs' } }}
#
PointCheckout SDK DependencyInclude the PointCheckout Android SDK dependency to your project in your_project_home/app/build.gradle
dependencies { implementation 'com.github.pointcheckout:android-sdk:v1.3'}
#
Required PermissionsThe PointCheckout SDK requires the following permissions. Please add them to your AndroidManifest.xml file if they are not already present:
<uses-permission android:name="android.permission.INTERNET"/>
#
Adding SafetyNet SupportYou must add Google's SafetyNet API to your app/build.gradle
. For details on how to add SafetyNet to your project, follow the instructions found in this guide.
#
SDK FlowThe PointCheckout Android SDK requires three distinct steps for you to accept card payments:
- Create a new mobile Checkout
- Initiate the PointCheckoutClient from the SDK using the provided checkout key
- Query the API for the payment status
This diagram shows the overall payment and data flow in order to accept payments using the PointCheckout mobile SDK
#
Using the SDK#
Create a new mobile checkout requestSend new checkout request to Create mobile checkout API. Check mobile payment integration guide for more details.
SERVER API CALL
API calls made to the PointCheckout API endpoints should be made from your server. You should NEVER include your API keys in your mobile application. A malicious user can gain access to your account if those keys are exposed.
#
Create a new the PointCheckoutClientCreate an object of PointCheckoutClient pointing to the required environment.
PointCheckoutClient pcoClient = new PointCheckoutClient(environment);
Environment | Description |
---|---|
Enviornment.PRODUCTION | Use this for accepting customer payments |
Enviornment.TEST | Use this during integration testing |
tip
Keep a reference of the created client to reuse the same instance
#
InitializeInitialize the created PointCheckoutClient
using:
pcoClient.initialize(context);
tip
Invoke the initialize
method when the app starts as it requires 2-3 seconds to initialize the SDK. If the client is not initialized and pay
is called, the client will call initialize internally before calling pay resulting in delay.
#
Start the Payment ProcessTo commence the payment process, you must call the static pay
method of the PointCheckoutClient
. This method accepts 3 parameters:
context
which refers to the current activity contextcheckoutKey
received in the Create mobile checkout API call.listener
that will be called on payment update or cancellation
pcClient.pay(context, checkoutKey, new PointCheckoutEventListener() { @Override public void onUpdate() { System.out.println("UPDATE CALLBACK"); }
@Override public void onDismiss() { System.out.println("USER CLOSED THE MODAL"); } });
Calling the pay
function will open a modal where the user will be able to complete the payment in a secure manner.
#
Listen to Payment EventsThe PointCheckoutEventListener
event listener has two callbacks:
onUpdate
which is called the checkout status is updated (paid, cancelled, failed .etc). You MUST call PointCheckout API to fetch the new status of the checkout to verify that its been successfully paid.onDismiss
which is called if the user closes the modal by clicking on close button.
#
Retrieve Checkout StatusRetrieve checkout status and details using the Get checkout API call. Check mobile payment integration guide for more details.
SERVER API CALL
API calls made to the PointCheckout API endpoints should be made from your server. You should NEVER include your API keys in your mobile application. A malicious user can gain access to your account if those keys are exposed.