search

Custom UI SDK Integration - Account Linking

This part of Custom UI SDK integration is applicable for Integration Type1 merchants i.e. who have received the client id and client secret-key and will display Paytm saved instruments on their checkout page itself.

In this part, you will find the steps to link the Paytm account without any OTP. Before integrating these methods, please make sure that the SDK initialisation is done and all the pre-requisites mentioned are fulfilled.

Note: For the merchants (Integration Type2) invoking Paytm app for saved instruments, this part is not applicable. You can proceed  with "Transaction processing" to continue with the integration.

Perform the steps below to link a Paytm account without any OTP:

  1. 1

    Link Paytm user account and fetch secured tokens

    Implement the following methods in case you want to show Paytm user’s saved payment instruments including a wallet. You need to check if the Paytm App is installed on the user’s phone and it supports the feature of getting the authToken for the logged-in Paytm user.
    These methods can be accessed using an instance of PaytmPaymentsUtilRepository. This instance can be obtained as below:

     PaytmPaymentsUtilRepository paymentsUtilRepository = PaytmSDK.getPaymentsUtilRepository()

After having the instance methods in this class you can call the following methods:

  1. Check if Paytm app is installed on user's phone

    Call the method isPaytmAppInstalled to check if the Paytm App is installed on the user’s phone.

isPaytmAppInstalled

Method Usage:

paymentsUtilRepository.isPaytmAppInstalled(context)

Method Parameters:

Context context: The current application Context

Response: Boolean

Attribute Description
True In case, Paytm App is installed and supports the feature to extract authcode
False In case, Paytm App is not there or does not support the feature to extract authcode
  1. Include the SDK’s consent checkbox on your UI.

    Use the below line to include the custom checkbox in your xml, you can customize it as a normal checkbox.

    <net.one97.paytm.nativesdk.common.widget.PaytmConsentCheckBox
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="Allow <Merchant> to fetch Paytm instruments" />
  1. Fetch authCode for the logged in user

    Call the method fetchAuthCode on the background thread in order to get the authcode for the currently logged in user inside Paytm App The authCode will be fetched only if the user has given the consent on the above checkbox.

fetchAuthCode

Method Usage:

paymentsUtilRepository.fetchAuthCode(context,clientId, mid)

Method Parameters:

Attribute Type Description

context

Context The current application Context

clientId

String The clientId issued from Paytm identifying a merchant

mid

String Merchant Id identifying a merchant

Response:

Attribute Description
String Alphanumeric authCode string e.g. ‘Apfdf-2234-nhdjshj-wers’ in case auth code fetched
Null In case authCode could not be fetched.
  1. Fetch Paytm user's secured tokens

    Use the authorization code received above and call the OAuth token API to receive the refresh token and SSO token associated with Paytm user.

    Note:

    1. In case paytm app not installed or user doesn't give the consent, merchant can process the transactions for payment modes other than wallet and saved instruments.
    2. SSO token will be used to fetch saved instruments of paytm user and refresh token will be used to get a new SSO token of paytm user after its expiry.

Perform the steps below to link a Paytm account without any OTP:

  1. 1

    Link Paytm user account and fetch secured tokens

  2. Implement the following methods in case you want to show Paytm user’s saved payment instruments including a wallet. You need to check if the Paytm App is installed on the user’s phone and it supports the feature of getting the authToken for the logged-in Paytm user. These methods can be accessed using an instance of AIHandler class. This instance can be obtained as below.

    let appInvoke = AIHandler() 

After having the instance methods in this class you can call the following methods:

  1. Check if Paytm app is installed on user's phone

    You need to call the method isPaytmAppInstall to check if the Paytm App is installed on the user’s phone.

isPaytmAppInstall

Method Signature:

appInvoke.isPaytmAppInstall 

Response: Boolean

Attribute Description
True In case Paytm App is found
False In case Paytm App not found on user's device
  1. Include the SDK’s consent checkbox on your UI.

    You need to call the method fetchAuthCode on the background thread in order to get the authcode for the currently logged in user inside Paytm App. For fetching authCode using Paytm SDK, include Paytm’s custom checkbox on your UI. The authCode will be fetched only if the user has checked the checkbox. Set custom class AINativeConsentView for the consent view.
AINativeConsentView

Method Signature:

func getAuthToken(clientId, mid, completion : MerchantPaymentCompletionBlock) 

Method Params:

Attribute Type Description
clientId String Unique Id given by Paytm app.
mid String Unique Identifier given by Paytm app.
MerchantPaymentCompletionBlock   It will return an enum of type.

Response: AINativeTokenFlowStatus with possible values.

Attribute Description
.appNotInstall In case the Paytm app is not installed on the user's device.
.error In case the request parameters passed are not valid.
.inProcess AppInvoke process initiated by SDK.

You will get the authcode in the callback using the URL schema.


URL format shall be
paytm\(self.mid)://payment?response=\(responseInFormOfString)&status=\(merchantPaymentStatus.rawValue)

Example: 'Apfdf-2234-nhdjshj-wers' in case auth code is fetched and 'Null' in case authCode could not be fetched.

  1. Add an entry into Info.plist

LSApplicationQueriesSchemes(Array) Item 0 (String)-> paytm

Define the app delegate method to handle Paytm response. The client will get the response in the Appdelegate Method.

func application(_ app: UIApplication, open url: URL, 
options: [UIApplicationOpenURLOptionsKey : Any] = [:]) ->Bool{
    let dict = separateDeeplinkParamsIn(url: url.absoluteString, byRemovingParams: nil)
     //get paytm params from dictionary
    return true
}
  1. Fetch Paytm user's secured tokens

    Use the authorization code received above and call the OAuth token API to receive the refresh token and SSO token associated with Paytm user.

    Note:

    1. In case paytm app not installed or user doesn't give the consent, merchant can process the transactions for payment modes other than wallet and saved instruments.
    2. SSO token will be used to fetch saved instruments of paytm user and refresh token will be used to get a new SSO token of paytm user after its expiry.
     

 

To continue with the integration, please move to the next step of transaction processing through SDK.