All-in-One SDK Integration for Ionic platform

For merchants who have built their app on an ionic platform - Paytm provides a bridge for you to conveniently integrate All-in-One SDK for both Android and iOS. In this document, we will highlight the steps required to integrate All-in-One SDK with an ionic bridge for your app. This bridge helps you to build a seamless and responsive checkout experience for your iOS or Android application.

This integration will support the following two flows:

  • App Invoke Flow: In case the Paytm app is installed, it will be launched to complete the transaction and give the result back to your app.
  • Redirection Flow: In case the Paytm app is not installed, All-in-One SDK will open a web view to process transactions and give results to you.

Overview of payment processing via ionic bridge

  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 the Hybrid app bridge to invoke Paytm All-in-One SDK with the transaction token received in step 1.

  3. If Paytm app is installed on user's phone, the payment will be completed on 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. 


  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.

  5. Go through All-in-One SDK documentation before proceeding with integration.

  6. Call Initiate Transaction API from your backend to generate Transaction Token.

Integration on Ionic for All-in-One SDK

Please go through the following steps to integrate All-in-One SDK in your Ionic app:

Steps for Capacitor Project

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

    maven {
        url ""
  2. Add below line to 'dependencies' section of your app build.gradle.

    implementation 'com.paytm.appinvokesdk:appinvokesdk:1.5.3'
  3. Add AllInOneSDKPlugin class in project (see Appendix at the end of this document), and then in the MainActivity, use add function in OnCreate ( add(AllInOneSDKPlugin.class) ).

  4. Update setResult method in AllInOneSDKPlugin class as per your response requirement in the ionic app.

  5. Call startTransaction method from your Ionic app to invoke Paytm module.

For further queries visit the SDK based integration documentation.


Steps for Ionic Project

  1. Using plugin from ‘@capacitor/core’ fetch AllInOneSDKPlugin class.
    import { Plugins } from "@capacitor/core";
    const { AllInOneSDKPlugin } = Plugins;
  2. Start the process by calling AllInOneSDKPlugin.startTransaction with the appropriate parameters.
    let response = await AllInOneSDKPlugin.startTransaction({
        mid: mid, orderId: orderId, txnToken: txnToken, amount: amount,
        isStaging: isStaging, callbackUrl: callbackUrl 
    Attributes Description Mandatory



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



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



    Transaction token received from calling Initiate Transaction API (Note - pass same order id in SDK which was used for initiateTransaction). 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



    IsStaging is to define staging or production server (True for staging and False for production) Yes



    On completion of transaction, Paytm payment gateway will send the response on this URL. This can be a static response URL as mentioned below:
    Staging Environment: "<order_id>"
    Production Environment: "<order_id>"
  3. Callback will be received in the above “response” object in JSObject format. 
    Sample Response:
        ORDERID="Order Id",
        TXNDATE=2020-07-21 19:00:05.0,
        MID="Merchant Id",
        TXNID="Transaction Value",
        BANKTXNID="Bank transaction Id",
        RESPMSG=Txn Success
  4. Verifying Payment

    1. You should validate the transaction response via a server-side request using the 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.



AllInOneSDKPlugin class

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.getcapacitor.JSObject;
import com.getcapacitor.NativePlugin;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
import com.paytm.pgsdk.PaytmOrder;
import com.paytm.pgsdk.PaytmPaymentTransactionCallback;
import com.paytm.pgsdk.TransactionManager;

@NativePlugin(requestCodes = {AllInOneSDKPlugin.REQ_CODE})

public class AllInOneSDKPlugin extends Plugin {
    protected static final int REQ_CODE = 0;

    public void startTransaction(PluginCall call) {
        String orderId = call.getString("orderId");
        String mid = call.getString("mid");
        String txnToken = call.getString("txnToken");
        String amount = call.getString("amount");
        String callbackUrl = call.getString("callbackUrl");
        boolean isStaging = call.getBoolean("isStaging");
        if (orderId == null || mid == null || txnToken == null || amount == null ||
        orderId.isEmpty() || mid.isEmpty() || txnToken.isEmpty() || amount.isEmpty()) {
            if (txnToken == null || txnToken.isEmpty()) {
                Toast.makeText(getContext(), "txnToken error", Toast.LENGTH_LONG).show();
            else {
                Toast.makeText(getContext(), "Please enter all field", Toast.LENGTH_LONG).show();
        String host = "";
        if (isStaging) {
                host = "";
        if(callbackUrl == null || callbackUrl.trim().isEmpty()) {
                callbackUrl = host + "theia/paytmCallback?ORDER_ID=" + orderId;

        PaytmOrder paytmOrder = new PaytmOrder(orderId, mid, txnToken, amount, callbackUrl);
        TransactionManager transactionManager = new TransactionManager(  paytmOrder, new PaytmPaymentTransactionCallback() {

            public void onTransactionResponse(Bundle bundle) {
                Log.d("LOG", "Payment Transaction is successful " + bundle);
                setResult("Payment Transaction response " + bundle.toString(), call);

            public void networkNotAvailable() {
                setResult("networkNotAvailable", call);

            public void onErrorProceed>(String s) {
                setResult(s, call);

            public void clientAuthenticationFailed(String s) {
                setResult(s, call);

            public void someUIErrorOccurred(String s) {
                setResult(s, call);

            public void onErrorLoadingWebPageString inFailingUrl) {
                setResult(inErrorMessage, call);

            public void onBackPressedCancelTransaction() {
                setResult("onBackPressedCancelTransaction", call);

            public void onTransactionCancel(String s, Bundle bundle) {
                setResult(s + " " + bundle, call);
        transactionManager.setShowPaymentUrl(host + "theia/api/v1/showPaymentPage");
        transactionManager.startTransaction(getActivity(), REQ_CODE);

    protected void handleOnActivityResult(int requestCode, int resultCode, Intent data) {
        super.handleOnActivityResult(requestCode, resultCode, data);
        if (requestCode == REQ_CODE && data != null) {
            PluginCall call = getSavedCall();
            setResult(data.getStringExtra("nativeSdkForMerchantMessage") + 
            data.getStringExtra("response"), call);

    private void setResult(String message, PluginCall call) {
        if (call != null) {
            JSObject result = new JSObject();
            result.put("result", message);
        else {
            Toast.makeText(getContext(), "call is null", Toast.LENGTH_LONG).show();