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.
Non-SDK based Integration for Subscriptions
Overview of payment processing via Non-SDK based integration
- On your mobile app, the user selects a plan and proceeds to pay.
- 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.
- Paytm shares a transaction token with you.
- Check if Paytm app is installed on user's phone.
- 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.
- 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.
- Paytm processes the transaction with the user’s bank and returns the subscription creation response.
- 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
Integration Steps for Non-SDK based integration
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.
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", }]
"enablePaymentMode" : [{ "mode":"UPI", "channelse":["UPIPUSH"] }]
- Paytm validates your details and return the TXN_Token
- Send this TXN_Token to your website or mobile app
- 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.
Invoke Paytm app
Use the following steps to invoke Paytm app as per your platform:
Input ParametersATTRIBUTES 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)- 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.10.4") < 0) { Full screen App Invoke flow }else{ New App Invoke flow }
- If the app version is less than 8.10.4, 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);
- Else, if the app version is 8.10.4 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);
- If the app version is less than 8.10.4, then use the code below:
- 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(); } }
Show Payment Page-
This Should be managed by merchant by loading url and data in Webview of their own:
For Ex:
webView.postUrl(“https://securestage.paytmpayments.com/theia/api/v1/showPaymentPage?mid=YOUR_MID_HERE&orderId=YOUR_ORDERID_HERE”, formPost payload in bytes* );
*:https://paytmpayments.com/docs/show-payment-page/- Create Intent to open Paytm Activity on your app. Check the app version on the User’s phone.
In Case Paytm app is not installed, redirect user to Paytm hosted Checkout Page
- As of now, an order is created in your order system and transaction token is also generated using Initiate Subscription API.
- 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.
- 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.
- Verify checksum hash received in response to ensure that it has not been tampered with.
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.