OPEN Android SDK lets you seamlessly integrate OPEN Payment Gateway with your Android app and start collecting payments from your customers.

Create a payment_token

A payment token represents an order or a purchase. The first step to open up a Layer payment page on your website or checkout page is to create a payment_token

A payment_token can be created by referring to create payment token API. This API should be always called from your server. You will receive payment_token as a response from create payment token API.

Step 1 :

Add .aar in your Android Project lib folder

Step 2 :

Gradle Setup -
In build.gradle of app module, include the below dependency to import the OpenPayment library in the app.

    implementation files('libs/open-web-sdk-release.aar')

Step 3 :

App Setup -
In Android app, make activity where you want to implement payment integration. Here, we have created

Initializing OpenPayment :
You can see below code, these are minimum and mandatory calls to enable payment processing. If any of it is missed then an error will be generated.

For example, consider parameters as follows.

var openPayment: OpenPayment =
        .with([email protected])
        .setPaymentToken(body?.id!!) // Add your payment token here
        .setAccessKey(accessKey) // Add your Access Key here
        .setColor(colorHexCode)   // Add your Color Hex Code here
         .setErrorColor(errorColorHexCode).  // Add your Error Color Hex Code here
         .setLogoUrl(logoURL)  // Add your Logo URL here

Calls and Descriptions :

with() : Mandatory and this call take Activity as a parameter.

setPaymentToken() : Mandatory to create the token using Create Token API.

setEnvironment(): We have 2 environments.
Following ENUM can be passed to this method.

setAccessKey(): access_key is a unique key which you can generate from your Open dashboard.

setColor(): Main color of Layer will be changed to this . Example: #f8c5c5
Note : Only accepts hex code colors. Default color is applied if this key does not exist or proper value has not been passed.

setErrorColor(): Error color (icons/ error lines / error messages) of Layer will be changed to this . Example: #83025c
Note : Only accepts hex code colors. Optional key parameter. Default color is applied if this key does not exist or proper value has not been passed.

setLogoUrl(): Logo is changed to image source passed.
Note : If image source is not available, default Open logo will be used. Image might take time to
load depending on size of the image.

build() : It will build and returns the OpenPayment instance.

Step 4 :

Proceed to Payment -
To start the payment, just call startPayment() method of OpenPayment and after that transaction will get started.


Step 5 :

Event Callback Listeners -
To register for callback events, you will have to set PaymentStatusListener with OpenPayment as below.

openPayment.setPaymentStatusListener(mListener = [email protected])

Description :
onTransactionCompleted() - This method is invoked when a transaction is completed. It may either captured, failed , pending and cancelled

onError(): - Integration errors.

Getting Transaction Details

To get details of transactions, we have a callback method onTransactionCompleted() with a parameter of TransactionDetails.

To get details, below method of TransactionDetails are useful :


Call the webhook URL to get the complete response of the transactions.

Step 6 :

Remove Listener -
To remove listeners, you can invoke detachListener() after the transaction is completed or you haven’t to do with payment callbacks.