search
Your Paytm for business app is working and will keep working beyond March 15th, 2024. Click to know more

Non-SDK based Integration for Subscriptions

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 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

  1. On your mobile app, the user selects a plan and proceeds to pay.
  2. You call the Initiate Subscription API from your backend to generate the transaction token.Within the Initiate Subscription 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 user's phone.
  5. If Paytm app is installed, and the user has Paytm App version higher than 8.10.4, the invokes the app and the user completes the subscription creation on the Paytm app using his/her saved credentials.
  6. If Paytm app is not installed or the App version is less than 8.10.4, call the Show Payment Page API and redirect the user to Paytm’s hosted payment page.
  7. Paytm processes the transaction with the user’s bank and returns the subscription creation response.
  8. Use the Subscription S2S Callback or Fetch Subscription Status API to confirm the subscription and display the confirmation to the user on your app/website.

Flow diagram for payment processing via Non-SDK based integration

 

flow chart for non-sdk based integration

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

    • When a user clicks Pay with Paytm to checkout on your mobile app, create an order in your backend system and call Initiate Subscription 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 Subscription 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 Subscription 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 Subscription 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"]
      }]  
      
    • Paytm validates your details and return the TXN_Token
    • 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 Subscription API Yes
    mid This is a unique identifier provided to every merchant by Paytm Yes

     API based app Invoke on Android

    Paytm app invoke using API based integration will depend on the Paytm app version on 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.10.4 or higher invoke the Paytm App, else redirect the user to the Paytm Payment page (This is done because the app invoke flow for Subscription went live with App version 8.10.4 on the Paytm App)

    1. Create Intent to open Paytm Activity on your app. Check the app version on the User’s phone.copy icon
      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.10.4") < 0) {
      Full screen App Invoke flow
      }else{
      New App Invoke flow
      }
      1.  If the app version is less than 8.10.4, then use the code below:copy icon
        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.10.4 or greater, then use the code below for new App Invoke flow integration:copy icon
        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 onActivityResultcopy icon
      @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();
          }
      }

    Show Payment Page-


    This Should be managed by merchant by loading url and data in Webview of their own:
    For Ex:
    webView.postUrl(“https://securegw-stage.paytm.in/theia/api/v1/showPaymentPage?mid=YOUR_MID_HERE&orderId=YOUR_ORDERID_HERE”, formPost  payload in bytes* );
    *:https://developer.paytm.com/docs/show-payment-page/

    API based App Invoke on iOS

    1. Create and Call Paytm deeplink.copy icon
      ("paytm://subscriptionpayment?txnToken=(txnToken)&orderId=(orderId)&mid=(mid)&amount=(amount)")
      
      func invokePaytmApp(txnToken: String, orderId: String, mid: String, amount : String) -> Bool {
          if let paytmInvokeURL:URL = URL(string: "paytm://subscriptionpayment?txnToken=(txnToken)&orderId=(orderId)&mid=(mid)&amount=(amount)") {
              let application:UIApplication = UIApplication.shared
              if (application.canOpenURL(paytmInvokeURL)) {
                  application.open(paytmInvokeURL, options: [:]) { (finish) in}
                  return true
              }
              else{
                  //Paytm app Redirect the user to Paytm HTML payment page
                  return false
              }
          }
          return false
      }
    2. Check if Paytm app is installed by using the application delegate method "application.canOpenURL(paytmInvokeURL)". In case the Paytm app does not exist then go to STEP 4.
    3. Add an entry into Info.plist LSApplicationQueriesSchemes(Array) Item 0 (String)-> paytm.

    4. Add a URL Scheme “paytm”+”MID”.
    5. Define the app delegate method to handle Paytm response. Client will get the response in AppDelegate / SceneDelegate (iOS 13 and above) Method.copy icon
      func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
          let dict = separateDeeplinkParamsIn(url: url.absoluteString, byRemovingParams: nil)
          //get paytm params from dictionary 
          return true
      }
  4. In Case Paytm app is not installed, redirect 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 Subscription 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, 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. Fetching the latest subscription status

    Paytm will provide an S2S callback on your configured callback URL. Alternatively, you use a  Fetch Subscription Status API to fetch the latest status.