• Callback Response
  • Getting Started
    • Mobile Integration (Android/IOS)
      Enterprise Solutions
      Retail Solutions
      Accept Payments
      Process Payments
      Disbursals
      API References
      Refunds
      Guides
      Other links
      Mini Program Platform
  • Features for Investments PG
  • Subscription activation - All-in-One SDK

    The All-in-One SDK is intended to make payments seamless with Paytm irrespective of whether the Paytm app is installed on a device or not. This SDK handles the following 2 flows:

    1. App Invoke Flow: If the Paytm App is installed on a mobile device, it gets launched to complete the subscription activation and sends back the result to the merchant app.
    2. Redirection Flow: If the Paytm App is not installed on a mobile device, a webview opens to complete the subscription activation and sends back the result to the merchant.

    Demo


    All-in-one SDK

    Overview


    1. This flow starts when after the user has selected the plan and you have obtained the transaction token using the Initiate Subscription API
    2. Launch Paytm All-in-One SDK with the Transaction Token. If the Paytm app is installed on the user's mobile device, the subscription will be completed on the Paytm app, else it will be processed via web view within the All-in-One SDK (Paytm hosted redirection flow).
    3. The customer enters the payment details to complete the authorization. Post completing the authorization & the first payment, the SDK would confirm the status on your app.
    4. 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 to show the subscription activation via All-in-one-SDK

    All-in-one SDK

    Integration Steps


    1. Include Dependency

      1. Add the below line to ‘repositories’ section of your project level build.gradle file
        maven {
            url "https://artifactory.paytm.in/libs-release-local"
        }
        
      2. Add below line to ‘dependencies’ section of your App build.gradle
        implementation 'com.paytm.appinvokesdk:appinvokesdk:1.2
    2. Creation of Order object

      Create an order object as follows, passing the mandatory parameters.
      PaytmOrder paytmOrder = new PaytmOrder (orderid, mid, txnToken, amount, callbackurl)
      ATTRIBUTESDESCRIPTIONMANDATORY
      orderid
      String(50)
      A unique reference ID generated by a merchant for the transaction. The special characters allowed in Order ID are "@" "-" "_" ".".Yes
      mid
      String(20)
      Unique identifier provided to every merchant as a part of their account credentials by Paytm. It is different in the staging and production environment.Yes
      txnToken
      String
      Transaction Token received by calling the Initiate Transaction API.
      (Note - Pass the same Order ID in the SDK that was used to initiate the transaction).
      Yes
      amount
      String
      Amount in INR payable by customer. It must contain digits up to two decimal points without any separator like (",").Yes
      callbackurl
      String(255)
      On completion of a transaction, Paytm payment gateway sends the response on this URL. This can be a static response URL as mentioned below:
      Staging Environment: "https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID={order_id}"
      Production Environment: "https://securegw.paytm.in/theia/paytmCallback?ORDER_ID={order_id}"
      Yes
    3. Creation of TransactionManager object

      Create an object of TransactionManager className and pass PaytmOrder object created in step 1 along with the callback interface to receive results for redirection (webview flow)
      TransactionManager transactionManager = new TransactionManager(paytmOrder, 
      new PaytmPaymentTransactionCallback() // code statement);
      transactionManager.setSubscriptionFlow(true);
    4. Starting a Transaction

      Start a transaction passing requestCode to listen for All-in-One SDK flow in onActivityResult.
      transactionManager.startTransaction(this, 01); 01=sample requestcode
    5. Retrieval of payment status result

      1. App Invoke flow (If the transaction is processed via Paytm App)
        For app invoke flow, the result will be delivered via onActivityResult in your activity.
        Merchant has to pass the same request code which is used while calling TransactionManager.startTransaction.
        In our example above we have used 01 as requestCode.
        @Override
                    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                        if (requestCode == 01 && data != null) {
                            Toast.makeText(this, data.getStringExtra("nativeSdkForMerchantMessage") 
                            + data.getStringExtra("response"), Toast.LENGTH_SHORT).show();
                        }
                    }
      2. Redirection Flow (Paytm App is not installed on user’s device) For redirection flow, the payment status will be delivered via PaytmPaymentTransactionCallback. This interface has multiple methods to get error or completion status of the transaction as shown below.
        public void onTransactionResponse(Bundle inResponse) {
                        /*Display the message as below */
                        Toast.makeText(getApplicationContext(), "Payment Transaction response"  + 
                        inResponse.toString(), Toast.LENGTH_LONG).show();
                    }
                    
    6. 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.