Android SDK Integration

Install SDK

  1. Add the authToken for the repository access to your project’s gradle.properties file :
authToken=jp_nvgg9iebmirqko7uo25n0ssc9b
  1. Add the Jitpack repository url along with the authToken to your project level build.gradle file :
allprojects{
  repositories{
    maven{
      url"https://jitpack.io"
      credentials{
        usernameauthToken
      }
    }
  }
}
  1. Add the SDK dependency to your app level build.gradle file :
implementation 'com.github.Mobikwik:Android-SDK:4.3'

Sync your gradle files after adding the dependencies and you should now be able to use the SDK in your application.

Initiate Payment

For initiating a payment through the SDK in your application, please undertake the following steps:

  1. Create an instance of TransactionData by using TransactionDataBuilder :
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
/***** 
 application logic 
 ****/
        TransactionData transactionDataInstance = getTransactionDataInstance();
    }

    private TransactionData getTransactionDataInstance() {
        TransactionDataBuilder transactionDataBuilder = TransactionDataBuilder()
                .withAmount(amount) // BigInteger
                .withChecksum(checksum) // String
                .withChecksumPO(checksumPO) // String
                .withCurrency("INR") // String
                .withOrderId(orderId) // String
                .withUserEmail(userEmail) // String
                .withReturnUrl(returnUrl) // Url on which the txn response will be posted (String)
                .withMerchantIconUrl(iconUrl) // Merchant Icon to be displayed in the SDK (String)
                .withMerchantName(merchantName) // String
                .withMerchantId(merchantIdentifier) // String
                .withUserPhoneNumber() //String
                .withEnvironment(Enums.Environment.STAGING); // Enum to configure the server environment

The checksum and checksumPO values used here must be calculated and fetched from the merchant’s server. Details on how to create the checksum and checksumPO on the merchant server can be found here :

The return url is the url on which the response of the transaction will be posted. Details on the construction of the return url response can be found here :

The above example shows the mandatory params needed for the SDK transaction. You can check the full list of params supported by the TransactionData object here : https://github.com/Mobikwik/Integration-Documents/blob/master/PG-Integration-Document/TransactD-V8%20Flow.pdf

  1. The TransactionData object created above should then be passed in the startPayment of the PaymentCheckout class :
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
/***** 
 application logic 
 *****/
        TransactionData transactionDataInstance = getTransactionDataInstance();
        PaymentCheckout paymentCheckout = new PaymentCheckout(this);
        paymentCheckout.startPayment(transactionDataInstance);
    }

This will trigger the SDK flow inside your application and present a list of payment options to the user.

Register Callback Listener

To be able to receive the final transaction response from the SDK, you must implement the PaymentCheckout.ZaakPayPaymentListener inside your activity/fragment from which you initiated the payment :

public class PaymentActivity extends AppCompatActivity implements PaymentCheckout.ZaakPayPaymentListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /* application checkout flow logic */
        TransactionData transactionDataInstance = getTransactionDataInstance();
        PaymentCheckout paymentCheckout = new PaymentCheckout(this);
        paymentCheckout.startPayment(transactionDataInstance);
    }

    @Override
    public void onPaymentSuccess(TransactionResponse response) {
// extract the checksum from the response using response.getChecksum() and verify it on your server before further processing the success response
    }

    @Override
    public void onPaymentFailure(String responseCode, String responseDescription) {
        //handle payment failure 
    }
}

To verify the authenticity of the response received in case of payment success it is recommended to extract the checksum from the response and verify it on your server before any further processing. This helps fight against MITM attacks or network fiddling. The specifics on verifying the response checksum on the merchant server is available in next section.

Following sample response should be returned in response of return url. You will get the values of these parameters in the request parameters of return url hit.

Sample Response:

{
  "orderId": "1601294679223",
  "responseCode": "100",
  "responseDescription": "The transaction was completed successfully. ",
  "checksum": "1b6f38fca8ceb319218d806f79f7e163de595eb8b3753c976441733028f186b8",
  "amount": "100",
  "doRedirect": "false",
  "paymentMode": "UPI",
  "cardId": "NA",
  "cardScheme": "NA",
  "cardToken": "NA",
  "bank": "ICICIUPI",
  "bankid": "ICIUPI",
  "paymentMethod": "N1064",
  "cardhashid": "NA",
  "product1Description": "NA",
  "product2Description": "NA",
  "product3Description": "NA",
  "product4Description": "NA",
  "pgTransId": "ZP5b05e7c3666b8",
  "pgTransTime": "09/28/2020 17:35:54"
}

👍

Note

In case you face Manifest merger failed : Attribute [email protected] error while building your application with the SDK, please add tools:replace="android:theme" in the application tag inside your application’s AndroidManifest.xml file.

Checksum Validation For Request Parameters

If you want to validate the checksum on the request string. Please follow below required steps:

  1. Use SHA -256 algorithm to generate the correct checksum for JSON string
  2. we need to calculate on all the parameters of the string
  3. Use merchant's secret key for the same

Consedering staging Credentials:
• Merchant Identifier : b19e8f103bce406cbd3476431b6b7973
• Secret key : 0678056d96914a8583fb518caf42828a

String on which checksumPO generated, consists of merchantIdentifier and emailId.

ChecksumPO String format:

merchantIdentifier=b19e8f103bce406cbd3476431b6b7973&email=a
560575e94d22adc3ed1eac42f8e4f1d070b5eb2feb5f80bace7385119d5bc295

String for checksum would consist of below parameters in the same order:
merchant Identifier, orderid, mode, currency, amount, IP, date.

Checksum String format:

'b19e8f103bce406cbd3476431b6b7973''1551264623988gjgkgf''0''INR''200''ip''date'

Checksum Validation For JSON Response

If you want to validate the checksum on the above JSON response string. Please follow below required setps:

  1. Use SHA -256 algorithm to generate the correct checksum for JSON string
  2. we need to calculate on all the parameters of the JSON string
  3. Use merchant's secret key for the same
Sample Input Parameters: 

amount=100&bank=ICICIUPI&bankid=ICIUPI&cardId=NA&cardScheme=NA&cardToken=NA&cardhashid=NA&doRedirect=false&orderId=1601294679223&paymentMethod=N1064&paymentMode=UPI&responseCode=100&responseDescription=The transaction was completed successfully. &product1Description=NA&product2Description=NA&product3Description=NA&product4Description=NA&pgTransId=ZP5b05e7c3666b8&pgTransTime=09/28/2020 17:35:54&is 1b6f38fca8ceb319218d806f79f7e163de595eb8b3753c976441733028f186b8

Secret Key: Please user merchant's secret Key

👍

Have you generated the key?

Please follow steps below to Generate encryption and public keys:

  1. Login to the Zaakpay dashboard.
  2. Go to URL: https://zaakpay.com/manageKeys
  3. Click on 'Generate Keys' to generate your encryption keys.
  4. Click on 'Show Key' to get your public Keys.

📘

Want to see our Android SDK payment flow?

Demo Video

Changelog

V 4.3

Added UPI intent flow


Did this page help you?