The SDK uses Google's SafetyNet API for security, setting minimum Android API to lower than 26 will prevent it from functioning.
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
...
implementation(name:'pc-android-sdk', ext:'aar')
}
The 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"/>
Add Google's SafetyNet API to your app/build.gradle, follow this guid.
After these steps, rebuild your app and you are good to go!
First you will need a checkoutKey which can be obtained via PointCheckout's API.
Create an object of PointCheckoutClient:
Production environment with auto dismiss |
PointCheckoutClient pcClient = new PointCheckoutClient(); |
Production environment without auto dismiss |
PointCheckoutClient pcClient = new PointCheckoutClient(false); |
Test environment without auto dismiss |
PointCheckoutClient pcClient = new PointCheckoutClient(Environment.TEST, true); |
Parameter | Default | Description |
Environment | Environment.PRODUCTION | Specifies the environment of the app, use Environment.TEST for testing purposes. |
autoDismiss | true | Closes the modal on payment success or failure. Regardless of autoDismiss value, the onDismiss method of PointCheckoutEventListener will be called on payment success or failure. |
Create a single instance of PointCheckoutClient and re-use that instance each time you want to checkout.
Initialize PointCheckoutClient using:
PointCheckoutClient pcClient = new PointCheckoutClient();
pcClient.initialize(context);
Invoke initialize when the app starts because it needs 2-3 seconds. If the client is not initialized and checkout is performed, the client will call initialize internally before checking out.
To submit a payment call the pay method of the PointCheckoutClient:
pcClient.pay(context, checkoutKey, new PointCheckoutEventListener() {
@Override
public void onPaymentCancel() {
// payment was cancelled
}
@Override
public void onPaymentUpdate() {
// check the status of the payment and act accordingly
}
});
Calling the pay method will open a modal and the user will be able to login and complete the payment.