Android SDK

To integrate the PayKun Payment Gateway in your mobile app which can enable you to receive payments from your customers using the Android Devices you need to follow a few easy steps.

For the video tutorial to Integrate PayKun Payment Gateway in your Android App you may click here

Get the demo app from here - Paykun Demo Android App

Checkout Android SDK requires

  1. A registered PayKun Merchant Account

How to install SDK in your app?

We have distributed our SDK via Maven Central Repositery. You can add our latest PayKun SDK directly to your build.gradle file in the dependency section using the below given line:

implementation 'com.paykun.sdk:paykun-checkout-lib:1.1.13'

How to implement SDK into your Android APP?

For testing purpose you need to login to the PayKun Dashboard using Sandbox Mode and also get your Merchant ID and Access Token from there.

Note: To get Merchant ID, go to the top-right corner “Profile drop-down”. Access Token and Encryption Key can be generated from Settings > Security > Generate API Key

You need to pass merchant id, access token, customer name, customer email, customer phone, product name, order no and amount to SDK. Remember that order number should always be unique, duplicate order number will cause invalid request.

  • Create Json object with following key and values.

JSONObject object = new JSONObject();
try {
object.put("customer_name","Bhavik Makvana");
object.put("order_no",System.currentTimeMillis()); // order no. should have 10 to 30 character in numeric format
object.put("amount","10"); // minimum amount should be 10
object.put("isLive",false); // need to send false if you are in sandbox mode
} catch (JSONException e) {
  • Send Json object to Paykun API

new PaykunApiCall.Builder(MainActivity.this).sendJsonObject(object);
// Paykun api to initialize your payment and send info.
  • After sending your data to Paykun, you will get the result in getResults() Method. But to get result, you have to register GlobalBus in your activity’s onStart() Method.

protected void onStart() {
// Register this activity to listen to event.
  • Then, don’t forget to unregister GlobalBus in OnStop() method of activity.

protected void onStop() {
// Unregister from activity
  • Implementation of getResults() method – get your success or failed result in getResults() method.

@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void getResults(Events.PaymentMessage message) {
// do your stuff here
// message.getTransactionId() will return your failed or succeed transaction id
/* if you want to get your transaction detail call message.getTransactionDetail()
* getTransactionDetail return all the field from server and you can use it here as per your need
* For Example you want to get Order id from detail use message.getTransactionDetail().order.orderId */
if(!TextUtils.isEmpty(message.getTransactionId())) {
Toast.makeText(MainActivity.this, "Your Transaction is succeed with transaction id : "+message.getTransactionId() , Toast.LENGTH_SHORT).show();
Log.v(" order id "," getting order id value : "+message.getTransactionDetail().order.orderId);
else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_FAILED)){
// do your stuff here
Toast.makeText(MainActivity.this,"Your Transaction is failed",Toast.LENGTH_SHORT).show();
else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_SERVER_ISSUE)){
// do your stuff here
}else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_ACCESS_TOKEN_MISSING)){
// do your stuff here
Toast.makeText(MainActivity.this,"Access Token missing",Toast.LENGTH_SHORT).show();
else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_MERCHANT_ID_MISSING)){
// do your stuff here
Toast.makeText(MainActivity.this,"Merchant Id is missing",Toast.LENGTH_SHORT).show();
else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_INVALID_REQUEST)){
Toast.makeText(MainActivity.this,"Invalid Request",Toast.LENGTH_SHORT).show();
else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_NETWORK_NOT_AVAILABLE)){
Toast.makeText(MainActivity.this,"Network is not available",Toast.LENGTH_SHORT).show();
  • Proguard rules

-keepattributes *Annotation*
-keepclassmembers class * {
@org.greenrobot.eventbus.Subscribe <methods>;
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {

For any Assistance :

In case of any query, please contact to