search

All In One SDK integration in Xamarin

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

This integration will support the following flows:

  • App Invoke Flow: In case the Paytm app is installed, it will be launched to complete the transaction and give the response 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 transaction and give the response back to your app.

Overview of payment processing in Xamarin App

  1. On your mobile app, the user adds goods/services into the shopping/order cart and proceeds to checkout. You call the Initiate Transaction API from your backend to generate transaction token.
    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.

Pre-requisites

  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 the Initiate Transaction API from your backend to generate Transaction Token.

Follow the steps below to integrate All-in-One SDK in your Xamarin app:

Project

  1. Add below Nuget package to your project Dependencies/NuGet:
    Paytm.AllInOneSdk

    Note: Please ignore the warning message

    Warning Message

  2. Call plugin method as below
    using AllInOneSDK;
    …
     public partial class MainPage : ContentPage, PaymentCallback
    {
            public void error(string errorMessage)
            {
                ...
                AllInOnePlugin.DestroyInstance();
            }
    
            public void success(Dictionary<string, object> dictionary)
            {
                ...
                AllInOnePlugin.DestroyInstance();
            }
    
           public void startTransaction()
           {
             AllInOnePlugin.startTransaction(orderId, mid, txnToken, amount, callbackurl, isStaging, restrictAppInvoke, this); // this -> PaymentCallback
           }
    }

Follow the steps below to integrate All-in-One SDK in your Xamarin app:

  1. Add below nuget package in android packages
    Android packages
  2. Add below OnActivityResult method in MainAcivity.cs
    using AllInOneSDK;
    ...
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        ...
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
            {
                base.OnActivityResult(requestCode, resultCode, data);
                AllInOnePlugin.OnActivityResult(requestCode, resultCode, data);
            }
    }
    

Note:Please remove fast assembly Deployment check from Android Build of Android.Project Option

android build

Note: To help you with the integration, we have provided a sample merchant app integrated with this SDK. To get the sample app, please click here.