search

Non-SDK based Integration

Integrate All-in-One payment solution by checking and invoking the Paytm app if it is installed on the user’s device. You will then invoke invoke the Paytm app using a deeplink in case it is installed on user device. In case Paytm app not installed, you can redirect the user to Paytm’s hosted payment page.

Overview of payment processing via Non-SDK based integration

Note: This page describes the integration steps for integrating All-in-One payment solution for one time payment. In case you want to integrate the same for recurring payments, please refer to the https://developer.paytm.com//docs/subscription/

  1. On your mobile app, the user adds goods/services into the shopping/order cart and proceeds to checkout.

  2. You call the Initiate Transaction API from your backend to generate transaction token.

    Within the Initiate Transaction API, you also get an option to include single or multiple payment sources for the users, thus, allowing you to make your own payment page with multiple payment sources.

  3. Paytm shares a transaction token with you.

  4. Check if Paytm app is installed on the user's phone.

  5. If the Paytm app is installed, invoke the app.

  6. User completes payment on the Paytm app using his/her saved credentials.

  7. If Paytm app is not installed, call the Show Payment Page API and redirect the user to Paytm’s hosted payment page.

  8. Paytm processes the transaction with the user’s bank and returns a transaction response.

  9. You call the Transaction Status API from your backend to verify the transaction response.

  10. Notify the payment status to user and proceed with the order/service fulfilment.

 

Flow diagram for payment processing via Non-SDK based integration

 

Pre-requisites

Before starting the integration make sure, you follow the following steps:

  1. Create an account on Paytm as a merchant. Click how to create an account.

  2. Get the merchant Id and merchant Key for the integration environment after creating the account.

  3. Go through the checksum logic to understand how to generate and validate the checksum.

  4. Get the staging android or iOS Paytm app for integration testing on the merchant staging environment.

Integration Steps for Non-SDK based integration

1. Get your authentication keys

  • MID: A unique merchant identifier issued by Paytm for your account

  • Merchant Key: This is a unique secret key used to secure encryption of every request. This needs to be kept on server-side and should not be shared with anyone.

2. Get Transaction Token

  1. When a user clicks Pay with Paytm to checkout on your mobile app, create an order in your backend system and call Initiate Transaction API from your backend to generate transaction token.
    In case you want to allow/show specific payment sources, pass the enablePaymode param in the Initiate Transaction API as depicted below. This feature will enable you to create your own cart payment page with multiple payment sources. Please refer to the Initiate Transaction API documentation for all possible payment sources that can be enabled.


    For Example, if you want to enable UPI as the only paymode, then pass the below parameters within Initiate Transaction API.

    "enablePaymentMode" : [{
        "mode":"UPI",
    }]

    If you want to use only UPI Intent within All-in-One SDK, pass the below params:

    "enablePaymentMode" : [{
        "mode":"UPI",
        "channelse":["UPIPUSH"]
    }]
  2. Paytm validates your details and return the TXN_Token.
  3. Send this TXN_Token to your website or mobile app.
     

3. Invoke Paytm app

Use the following steps to invoke Paytm app as per your platform:

Input Parameters

ATTRIBUTES DETAILS MANDATORY
amount Total amount of Transaction Yes
orderID Unique reference ID for a transaction which is generated by merchant and sent in the request. No special character allowed except ("@" "-","_") Yes
txnToken Transaction Token received in the response of Initiate Transaction API Yes
mid This is a unique identifier provided to every merchant by Paytm Yes

 API based app Invoke on Android

 

Paytm app invokes using API based integration will depend on the Paytm app version on the user's mobile device. First, check the version of Paytm app installed on the user's device using the code below. If the Paytm app version is 8.6.0 or above, App Invoke will have user experience as the GIF provided above. If the Paytm app version is below 8.6.0 then full screen Paytm app will invoke as shown in the flow diagram below:

 
  1. Create Intent to open Paytm Activity on your app. Check the app version on the User’s phone.
    Check current Paytm app version
    privateString getPaytmVersion(Context context) {
        PackageManager pm = context.getPackageManager();
        try{
          PackageInfo pkgInfo = pm.getPackageInfo(PAYTM_APP_PACKAGE, PackageManager.GET_ACTIVITIES);
          returnpkgInfo.versionName;
        }catch (PackageManager.NameNotFoundException e) {
               PaytmUtility.debugLog("Paytm app not installed");
        } 
        return null;
    }
    Compares two version strings.
    <p>
    Use this instead of String.compareTo() for a non-lexicographical
    
    comparison that works for versiorn strings. e.g. "1.10".compareTo("1.6")
     @param str1 a string of ordinal numbers separated by decimal points.
    
    @param str2 a string of ordinal numbers separated by decimal points
    @return The result is a negative integer if str1 is _numerically_ less than str2.
    
    The result is a positive integer if str1 is _numerically_ greater than str2.
    
    The result is zero if the strings are _numerically_ equal.
    
     @note It does not work if "1.10" is supposed to be equal to "1.10.0".
    private int versionCompare(String str1, String str2) {
    if (TextUtils.isEmpty(str1) || TextUtils.isEmpty(str2)) {
           return 1;
       }
       String[] vals1 = str1.split("\\.");
       String[] vals2 = str2.split("\\.");
       int i = 0;
       set index to first non-equal ordinal or length of shortest version string
       while (i < vals1.length && i < vals2.length && vals1[i].equalsIgnoreCase(vals2[i])) {
           i++;
       }
       compare first non-equal ordinal number
       if (i < vals1.length && i < vals2.length) {
           int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
           return Integer.signum(diff);
       }
       the strings are equal or one string is a substring of the other
       e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4"
       return Integer.signum(vals1.length - vals2.length);
    }
    if (versionCompare(currentAppVersion, "8.6.0") < 0) {
    Full screen App Invoke flow
    }else{
    New App Invoke flow
    }
    1.  If the app version is less than 8.6.0, then use the code below:
      Intent paytmIntent = new Intent();
          Bundle bundle = new Bundle();gues
          bundle.putDouble("nativeSdkForMerchantAmount", Amount);
          bundle.putString("orderid", OrderID);
          bundle.putString("txnToken", txnToken);
          bundle.putString("mid", MID);
          paytmIntent.setComponent(new ComponentName("net.one97.paytm", "net.one97.paytm.AJRJarvisSplash"));
          paytmIntent.putExtra("paymentmode", 2); // You must have to pass hard coded 2 here, Else your transaction would not proceed. 
          paytmIntent.putExtra("bill", bundle); 
          startActivityForResult(paytmIntent, ActivityRequestCode);
    2. Else, if the app version is 8.6.0 or greater, then use the code below for new App Invoke flow integration:
      Intent paytmIntent = new Intent();
          paytmIntent.setComponent(new ComponentName("net.one97.paytm", "net.one97.paytm.AJRRechargePaymentActivity"))
          paytmIntent.putExtra("paymentmode", 2);
          paytmIntent.putExtra("enable_paytm_invoke", true);
          paytmIntent.putExtra("paytm_invoke", true);
          paytmIntent.putExtra("price", Amount); //this is string amount
          paytmIntent.putExtra("nativeSdkEnabled", true);
          paytmIntent.putExtra("orderid", OrderID);
          paytmIntent.putExtra("txnToken", txnToken);
          paytmIntent.putExtra("mid", MID);
          context.startActivityForResult(paytmIntent, requestCode);
  2. Receive output parameters in onActivityResult
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == ActivityRequestCode && data != null) {
        Toast.makeText(this, data.getStringExtra("nativeSdkForMerchantMessage") + data.getStringExtra("response"), Toast.LENGTH_SHORT).show();
        }
    }

4.  In Case Paytm app is not installed, redirect the user to Paytm hosted Checkout Page

  1. As of now, an order is created in your order system and transaction token is also generated using Initiate Transaction API.

  2. Post the payload and transaction token in an HTML form. This redirects the user to Paytm's payment page. The payload details are mentioned here.

  3. User fills payment details and completes the payment authentication. Once the payment is complete, the response is posted in HTML form POST on your app/website's callback URL.

  4. Verify checksum hash received in response to ensure that it has not been tampered with.
     

5.  Verifying Payment

  1. You should validate transaction response via a server-side request using Transaction Status API. This API requires checksumhash in request and response. You must verify the Order ID and Amount with your data. The status should be treated as the final status of the transaction in all cases.
  2. Paytm provides payment response on both Callback URL and Webhook URL. Please refer to the sample response for different payment sources here.

On completion of your integration

Post completion of integration on your staging environment, do a complete transaction from order summary page on your website or mobile app.

  1. Attempt a test transaction using the test paymodes credentials.

  2. Ensure you re-verify transaction response with Transaction Status API (OR Fetch Subscription Status API in case of subscription payments) via server to server call in payment flow and not separately as a one-time activity.

  3. See the transaction details in the "Test Data” mode on your dashboard.

Once the test transaction is complete, move your code to live environment with production account details. Note that production accounts details are available after you have activated your account on the dashboard. Lastly, it's recommended that you read about Managing Refunds and late payment notifications In case of any issues with integration, please Get in touch.