All-in-One SDK Integration in Unity App

Paytm All-in-One SDK provides a swift, secure, and seamless payment experience to your users by invoking the Paytm app (if installed on your user’s smartphone) to complete payment for your order. It enables payment acceptance via Paytm Wallet, Paytm Payments Bank, saved Debit/Credit Cards, Net Banking, BHIM UPI, and EMI as available in your customer’s Paytm account. If the Paytm app is not installed on a customer's device, the transaction will be processed via web view within the All-in-One SDK. This package helps you to be able to use native features of All-in-One SDK with your Unity application and supports both Android and iOS platforms.

Overview of payment processing using All-In-One SDK

  1. On your mobile app, the user adds goods/services into the shopping/order cart and proceeds to checkout. You call Initiate Transaction API from your backend to generate transaction tokens.
    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.
  2. Launch Paytm All-in-One SDK with the transaction token received in step 1.
  3. If Paytm app is installed on the user's phone, the payment will be completed on the Paytm app using the user's saved credentials else transaction will be processed via web view within the All-in-One SDK(Paytm hosted redirection flow).
  4. Paytm processes the transaction with the user’s bank and returns the transaction response to your app.
  5. You call the Transaction Status API to verify the transaction response.
  6. Notify the payment status to the user and proceed with the order/service fulfilment.


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

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

    Note: Save the MID and merchant key generated in the above step.
  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.

Installing All in One SDK

The package can be requested from the Paytm Merchant Support team and imported into the project.

Integration of All-in-One SDK with Unity package

Import the All in One SDK package to your unity project. This will import all the required files for Android and iOS platforms.


  1. Android Gradle dependency

    1. Customize the following gradle file from the Player settings:
      File > Build Settings > Android > Player Settings > Player.

    2. Add the below line to the ‘repositories’ section of your project level baseProjectTemplate.gradle file.

      maven {
         url ""
    3. Add below line to ‘dependencies’ section of your App launcherTemplate.gradle file.

      implementation 'com.paytm.appinvokesdk:appinvokesdk:1.6.0'
  2. Create a new class that will be responsible for communicating with the All in One SDK package. Add the following code as per your requirement. This class is also available in the Demo folder of the package for reference. This file is responsible for calling the functions present in the All in One package and getting a callback from the package.
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using System.Runtime.InteropServices;
    using AOT;
    public class DemoAppInvokePlugin
    #if UNITY_IOS
    private static extern void _startPaymentForPaytm(string orderId, string merchantId, string amount, string transactionToken, string callbackUrl, bool isStaging, bool isAppInvokeRestricted); 
    public static void startPaymentForPaytm(string orderId, string merchantId, string amount, string transactionToken, string callbackUrl, bool isStaging, bool isAppInvokeRestricted) { 
    _startPaymentForPaytm(orderId, merchantId, amount, transactionToken, callbackUrl, isStaging, isAppInvokeRestricted);
        private static extern void _setDelegate(DelegateMessage callback);
        private delegate void DelegateMessage(string response);
        private static void delegateMessageReceived(string response) {
          Debug.Log("Message received in AppInvokePlugin : " + response);
          DemoTransactionBtn.setResponse("response: " + response);
        public static void startTransactionCall(string orderId, string mid, string amount, string txnToken, string callbackUrl, bool isStaging, bool isAppInvokeRestricted)
            const string pluginName = "com.paytm.unityaioplugin.AIOSdkPluginHelper";
            AndroidJavaClass pluginClass = new AndroidJavaClass(pluginName);
            AndroidJavaObject pluginInstance = null;
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject mCurrentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            Debug.Log("Current activity " + mCurrentActivity);
            if (mCurrentActivity != null && pluginClass != null)
                Debug.Log("Android pluginClass created");
                pluginClass.SetStatic<AndroidJavaObject>("mainActivity", mCurrentActivity);
            if (pluginClass != null)
                pluginInstance = pluginClass.CallStatic<AndroidJavaObject>("getInstance");
                Debug.Log("Android pluginInstance created");
            pluginInstance.Call("startTransactionApi", new object[] { mid, orderId, amount, txnToken, callbackUrl, isStaging, isAppInvokeRestricted, new TransactionCallback() });
    Please refer to the following for the parameters required for creating a transaction.
    Attributes Description Mandatory



    Unique reference ID for a transaction which is generated by merchant Special characters allowed in Order ID are: "@" "-" "_" ".".

    Note - Pass same order Id in SDK which was used for initiateTransaction




    This is a unique identifier provided to every merchant by Paytm. MID is part of your account credentials and is different in staging and production environment. Yes



    Transaction token in response to the Initiate Transaction API request. Yes



    Amount in INR payable by the customer. Should contain digits up to two decimal points. The amount should not include any separator like (",") Yes



    On completion of the transaction, Paytm Payment Gateway will send the response on this URL. This URL should be the same as passed in callbackURL of Initiate Transaction API. It can be a dynamic or static response URL as mentioned below:
    • Staging Environment: "<order_id>"
    • Production Environment: "<order_id>"
    If true, the Paytm application is not invoked even if it is available in the device and the transaction is carried out on web view. If false, the Paytm application is invoked when it is available in the device for a transaction.  
    IsStaging is to define staging or production server (True for staging and False for production)  
  3. Handling of the callback from the Paytm application after the transaction is completed:
    Add a class to handle the callback received and implement onTransactionSuccess and onTransactionError method. The success or error response is a stringified JSON and can be used as per the requirement.
    using System;
    using UnityEngine;
    public class DemoTransactionCallback : AndroidJavaProxy
        private const string pluginName = "com.paytm.unityaioplugin.AIOSdkPluginHelper";
        public DemoTransactionCallback() : base(pluginName + "$onTransactionCallback")
        public void onTransactionSuccess(string msg, string data)
            Debug.Log("TransactionCallback: onTransactionSuccess:" + msg);
            Debug.Log("TransactionCallback: Data:" + data);
            DemoTransactionBtn.setResponse("Message: " + msg +"\nResponse:"+data);
        public void onTransactionError(string msg)
            Debug.Log("TransactionCallback: onTransactionError" + msg);
            DemoTransactionBtn.setResponse("Message: " + msg);
  4. The functions from the above class can be consumed by the unity scenes as per the requirement.
    #if UNITY_IOS
         DemoAppInvokePlugin.startPaymentForPaytm(getOrderId(), getMerchantId(), getAmount(), getTransactionToken(), getCallBackURL(), !isProductionEnvironment(), isAppInvokeRestricted());
        DemoAppInvokePlugin.startTransactionCall(getOrderId(), getMerchantId(), getAmount(), getTransactionToken(), getCallBackURL(), !isProductionEnvironment(), isAppInvokeRestricted());
  1. Handling of the callback from the Paytm application after the transaction is completed:
    The callback is received in delegateMessageReceived which is added in the file added in the above step. The response is a stringified JSON and can be used as per the requirement.
  2. When implementing the All-in-One SDK for iOS platform, ensure some of the steps that are required for the application to invoke paytm application and receive the callback for the same.
    1. Add an entry into Info.plist LSApplicationQueriesSchemes(Array) Item 0 (String)-> paytm. To add the entry, create a class and implement the method ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
      using UnityEngine;
      using UnityEditor;
      using UnityEditor.Callbacks;
      using System.Collections;
      #if UNITY_IOS
        using UnityEditor.iOS.Xcode;
      using System.IO;
      public class ChangeIOSBuildNumber {
        #if UNITY_IOS
        public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject) {
            if (buildTarget == BuildTarget.iOS) {
                // Get plist
                string plistPath = pathToBuiltProject + "/Info.plist";
                PlistDocument plist = new PlistDocument();
                // Get root
                PlistElementDict rootDict = plist.root;
                //Adding the LSApplicationQueriesScheme to open Paytm application
                var queryScheme = rootDict.CreateArray("LSApplicationQueriesSchemes");
                // Write to file
                File.WriteAllText(plistPath, plist.WriteToString());
      The above class needs to be added in the Editor folder of the scripts. Refer to the Demo included in the package.
    2. Add a URL Scheme “paytm”+”MID”. To add the scheme, open Player settings (File => Build Settings => Player Settings => Player => Other Settings => Supported URL Schemes) Add the URL scheme as per the format to enable the unity application to receive the callback from Paytm.

    3. If you face an error while archiving the build for App Store, add the script available in Plugins folder “” in your application’s build phases.

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 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 "Test Data” mode on your dashboard.

Once the test transaction is complete, move your code to the 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.