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

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

    This integration will support following two flows:

    App Invoke Flow: In case Paytm app is installed, it will be launched to complete the transaction and give the response back to your app.

    Redirection Flow : In case Paytm app is not installed, All-in-One SDK will open a webview 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 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 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 fulfillment.

    Pre-requisites

    1. Create an account on Paytm as a merchant. Click on 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 enviornment.
    5. Go through All-in-One SDK documentation before proceeding with integration.
    6. Call Initiate Transaction API from your backend to generate Transaction Token.

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

    1. Easy Pay Library (All in one sdk is using this)

      Download .aar file from below URL :
      "https://artifactory.paytm.in/libs-release-local/com/paytm/easypay/easypay/8.7.3-appinvoke/"
      1. Add New Android Bindings Library Project that supports .aar and .jar file
      2. Add easy pay .aar file in jar directory of created library project

        Add easy pay .aar file
      3. Replace file in EasyPay Library Project/Transforms/Metadata.xml with given attached Metadata.xml (see Appendix at the end of this document)

        Replace file
      4. Rebuild your project
    2. All In One SDK Library

      Download .aar file from below URL :
      "https://artifactory.paytm.in/libs-release-local/com/paytm/appinvokesdk/appinvokesdk/1.5/"
      1. Add New Android Bindings Library Project that supports .aar and .jar file
      2. Add all in one sdk .aar file in jar directory of created library project
      3. Now add reference of EasyPay Library Project in All In one sdk Library project

        References
      4. Rebuild your project
    3. Main Xamarin Project

      1. Add reference of All In One SDK library in Main project

        References
      2. Import library in class by - using Com.Paytm.Pgsdk;
      3. Add below NuGet Package for All in one sdk in Main Xamarin Project:

        NuGet Package
      4. Rebuild your Project.
    4. Paytm provides payment response on both Callback URL and Webhook URL. Please refer to the sample response for different payment sources here.
    Note:
    1. Set minSDKVersion to API - 18 or above.
    2. In case of AppInvoke flow callback will be received in OnActivityResult method.
    3. In case of Redireaction flow callback will be received in PaytmPaymentTransactionCallback.
    4. Below is the sample of PaytmPaymentTransactionCallback class.
    Implement SDK methods using below link
    https://developer.paytm.com/docs/all-in-one-sdk/
    Like - PaytmOrder, TransactionManager

    Start the transaction by passing parameters (as shown below) to invoke All-in-One SDK flow:
    PaytmOrder paytm = new PaytmOrder(orderId, merchantId, txnToken, amount, callbackUrl);
    TransactionManager manager = new TransactionManager(paytm, new PaytmPaymentTransactionCallback(this));
    // For Staging
    manager.SetShowPaymentUrl( "https://securegw-stage.paytm.in/theia/api/v1/showPaymentPage");
    // For Production
    // manager.SetShowPaymentUrl( "https://securegw.paytm.in/theia/api/v1/showPaymentPage");
    manager.StartTransaction(this, REQ_CODE);
    Create a class of PaytmPaymentTransactionCallback to receive callbacks and modify methods as per requirements.
    class PaytmPaymentTransactionCallback : Java.Lang.Object, IPaytmPaymentTransactionCallback
        {
            private Context mContext;
            public PaytmPaymentTransactionCallback(Context context)
            {
                mContext = context;
            }
            public void ClientAuthenticationFailed(string p0)
            {
                Toast.MakeText(mContext, "ClientAuthenticationFailed", ToastLength.Long).Show();
            }
            public void NetworkNotAvailable()
            {
                Toast.MakeText(mContext, "NetworkNotAvailable", ToastLength.Long).Show();
            }
            public void OnBackPressedCancelTransaction()
            {
                Toast.MakeText(mContext, "OnBackPressedCancelTransaction", ToastLength.Long).Show();
            }
            public void OnErrorLoadingWebPage(int p0, string p1, string p2)
            {
                Toast.MakeText(mContext, "OnErrorLoadingWebPage", ToastLength.Long).Show();
            }
            public void OnErrorProceed(string p0)
            {
                Toast.MakeText(mContext, "OnErrorProceed", ToastLength.Long).Show();
            }
            public void OnTransactionCancel(string p0, Bundle p1)
            {
                Toast.MakeText(mContext, $"{p0} and {p1}", ToastLength.Long).Show();
            }
            public void OnTransactionResponse(Bundle p0)
            {
                Toast.MakeText(mContext, $"Payment Transaction : {p0}", ToastLength.Long).Show();
            }
            public void SomeUIErrorOccurred(string p0)
            {
                Toast.MakeText(mContext, "SomeUIErrorOccurred", ToastLength.Long).Show();
            }
        }

    Appendix

    Replace EasyPay Library Project/Transforms/Metadata.xml with below file

    Metadata.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <metadata>
        <!--
        This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
        <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
        This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
        <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
        -->
        <attr
            path="/api/package[@name='easypay.utils']/class[@name='EasyPaySecureSharedPref']/method[@name='edit' and count(parameter)=0]"
            name="managedReturn">Android.Content.ISharedPreferencesEditor
        </attr>
        <attr
            path="/api/package[@name='easypay.utils']/class[@name='EasyPaySecureSharedPref.Editor']/method[@name='clear' and count(parameter)=0]"
            name="managedReturn">Android.Content.ISharedPreferencesEditor
        </attr>
        <attr
            path="/api/package[@name='easypay.utils']/class[@name='EasyPaySecureSharedPref.Editor']/method[@name='putBoolean' and count(parameter)=2 and parameter[1][@type='java.lang.String'] and parameter[2][@type='boolean']]"
            name="managedReturn">Android.Content.ISharedPreferencesEditor
        </attr>
        <attr
            path="/api/package[@name='easypay.utils']/class[@name='EasyPaySecureSharedPref.Editor']/method[@name='putFloat' and count(parameter)=2 and parameter[1][@type='java.lang.String'] and parameter[2][@type='float']]"
            name="managedReturn">Android.Content.ISharedPreferencesEditor
        </attr>
        <attr
            path="/api/package[@name='easypay.utils']/class[@name='EasyPaySecureSharedPref.Editor']/method[@name='putInt' and count(parameter)=2 and parameter[1][@type='java.lang.String'] and parameter[2][@type='int']]"
            name="managedReturn">Android.Content.ISharedPreferencesEditor
        </attr>    
        <attr
            path="/api/package[@name='easypay.utils']/class[@name='EasyPaySecureSharedPref.Editor']/method[@name='putLong' and count(parameter)=2 and parameter[1][@type='java.lang.String'] and parameter[2][@type='long']]"
            name="managedReturn">Android.Content.ISharedPreferencesEditor
        </attr>
        <attr
            path="/api/package[@name='easypay.utils']/class[@name='EasyPaySecureSharedPref.Editor']/method[@name='putString' and count(parameter)=2 and parameter[1][@type='java.lang.String'] and parameter[2][@type='java.lang.String']]"
            name="managedReturn">Android.Content.ISharedPreferencesEditor
        </attr>
        <attr
            path="/api/package[@name='easypay.utils']/class[@name='EasyPaySecureSharedPref.Editor']/method[@name='remove' and count(parameter)=1 and parameter[1][@type='java.lang.String']]"
            name="managedReturn">Android.Content.ISharedPreferencesEditor
        </attr>
    </metadata>