search

Custom UI SDK Integration - Optional Methods

This is the last part of Custom UI SDK integration where you will find the information about different optional methods available in the SDK. These can be optionally integrated based on your requirements and use cases.

 

  1.  
     
    1. 1

      Invoke Paytm app

      This method can be used to invoke and complete the transaction through Paytm app. The method can be used in below two cases:

      1. Integration - Type1: Merchants who receive SSO token of the Paytm users can invoke the Paytm app when the wallet balance is insufficient for the order amount. In order to complete the payment through wallet, the merchant can invoke the Paytm app where the user can AddnPay using available instruments.
      2. Integration - Type2: Merchants not receiving client id and user’s SSO token can invoke the Paytm app to enable users to complete the transaction using the wallet and other saved instruments of Paytm user.

        Note: With the version com.paytm.nativesdk:core-wr:1.2.0 the user shall be redirected automatically to the webview in case Paytm app is not present on the user device.

         

        Note: To support PSP Apps (UPI Intent) or to invoke Paytm app for Target SDK version 30 ( Android 11) and above. Please add below query in AndroidManifest.xml.
        <queries>
           <package android:name=“net.one97.paytm” />
            <intent>
               <action android:name=“android.intent.action.MAIN” />
            </intent>
        </queries>
openPaytmAppForAddMoneyToWallet
paytmSDK.openPaytmAppForAddMoneyToWallet(activity)

Method Params:

Parameter Description
Activity context SDK needs the context of activity

 

Note: To support PSP Apps (UPI Intent) or to invoke Paytm app for Target SDK version 30 ( Android 11) and above. Please add below query in AndroidManifest.xml.
<queries>
   <package android:name=“net.one97.paytm” />
    <intent>
       <action android:name=“android.intent.action.MAIN” />
    </intent>
</queries>
2

Customise the consent checkbox

You can perform the thematic customisations of the consent checkbox to make it relevant as per your App design. You can customise the theme such as color, font, etc. using the attributes in the XML.

Customise the consent checkbox

Use the attributes below in your XML to customize the consent checkbox:

Attribute Type Description
consentTextAppearance reference This attribute can be used to set text appearance of the consent text
consentCheckboxColorStateList reference This attribute can be used to set button tint list of the consent button
consentBackgroundColor color This attribute can be used to set the background color of consent button and text
consentButton reference This attribute can be used to set button drawable for the consent button

Usage Example:

<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"
   app:consentButton="@drawable/customised_checkbox"
   app:consentCheckboxColorStateList="@drawable/consent_colorstatelist"
   app:consentTextAppearance="@style/ConsentTextAppearance"
   app:consentBackgroundColor="@color/gray"/>
3

Check if the Paytm user has saved instruments

The method userHasSavedInstruments can use it to check if the user has any saved Payment instruments. You can invoke this method and see if any saved instruments are there before showing the consent checkbox to the user.

userHasSavedInstruments

Usage:

PaytmPaymentsUtilRepository paymentsUtilRepository =PaytmSDK.getPaymentsUtilRepository()
paymentsUtilRepository.userHasSavedInstruments(context, mid)

Method Parameters:

Parameter Type Description
context Context Context needed to make a query
mid String Merchant id needed to fetch saved instruments of user

Response:

This method will return a boolean parameter.

Value Description
True User is logged in and has saved instruments
False Either the user is not logged in or has no saved instruments
4

Check account balance and set MPIN - UPI Push flow

In case you are integrating the UPI Push flow i.e. you intend to show the Paytm user’s UPI linked bank accounts on your checkout page, you can use these optional methods to enable the user to check its account balance or set the UPI MPIN.

  1. Fetch account balance: The method fetchUpiBalance can be used to fetch the balance of the UPI linked bank account after entering the MPIN. UPI MPIN page will be opened when the merchant calls this method.
fetchUpiBalance
3

Model Name: UpiDataRequestModel

Creation of Object:

UpiDataRequestModel requestModel = new UpiDataRequestModel(vpa,bankAccount)

Constructor Parameters:

Parameter Type Description

vpa

String Virtual Payment Address(eg.xyz@paytm)

bankAccount

String JSON string representing a bank account for UPI

Method Parameters:

Parameter Description
Activity context SDK needs the context of activity
UpiDataRequestModel upiDataRequestModel UPI request data

Usage:

paytmSDK.fetchUpiBalance(this, upiDataRequestModel)

Response:

Result will be received in PaytmSDKCallbackListener and can be obtained as shown:

{   // value of data
  "statusCode": 100,
  "statusMsg": "SUCCESS",
  "totalBalance": "12345.6"
}
  1. Set UPI MPIN: The method setUpiMpin can be used to enable users to set MPIN for their UPI account. UPI MPIN page will be opened when the merchant calls this method.
setUpiMpin
3

Model Name: UpiDataRequestModel

Creation of Object:

UpiDataRequestModel requestModel = new UpiDataRequestModel(vpa,bankAccount)

Constructor Params:

Parameter Type Description
vpa String Virtual Payment Adress(eg.xyz@paytm)
bankAccount String JSON string representing a bank account for UPI

Method Parameters:

Parameter Description
Activity context SDK needs the context of activity

UpiDataRequestModel upiDataRequestModel

UPI request data

Usage:

paytmSDK.setUpiPin(this, upiDataRequestModel) 

Response:

Result will be received in PaytmSDKCallbackListener and can be obtained as shown:
{"statusCode":100,"statusMsg":"SUCCESS"}
6

Get list of available NB payment mode

The method getNBList is available in the SDK for the Fetch NB Payment Channel API. The method can be used to get the list of Netbanking instruments along with their success rate and the icons available for your mid.

getNBList

Method Signature:

fun getNBList(callback: PaymentMethodDataSource.Callback<JSONObject>)

The returned result will be of NBResponse type. The bank's list can be fetched using the PayChannelOptions object that includes the list of banks.

Method Parameters:

Attribute Description
callback Callback to get the response received by the API request invoked by the above method

Usage:

PaytmSDK.getPaymentsHelper()
   getNBList(object:PaymentMethodDataSource.Callback<JSONObject> {
        override fun onResponse(response: JSONObject?,) {
            Toast.makeText(this@BaseInstrumentActivity, getMessage(response),
            Toast.LENGTH_LONG).show()
        }
        override fun onErrorResponse(error: VolleyError?, errorInfo: JSONObject?) {
             Toast.makeText(this@BaseInstrumentActivity, 
                getMessage(errorInfo) ?: "Error fetching NB List", 
                Toast.LENGTH_LONG).show()  
        }
})

The sample response of Fetch NB channel can be found below:

class="language-javascript">{
    "head":{
        "requestId":null,
        "responseTimestamp":"1591622928848",
        "version":"v1"
    },
    "body":{
        "extraParamsMap":null,
        "resultInfo":{
            "resultStatus":"S",
            "resultCode":"0000",
            "resultMsg":"Success"
        },
        "nbPayOption":{
            "displayName":"Net Banking",
            "isDisabled":{
                "status":"false",
                "msg":""
            },
            "payChannelOptions":[
                {
                "isDisabled":{
                    "status":"false",
                    "msg":null
                },
                "hasLowSuccess":{
                    "status":"false",
                    "msg":""
                },
                "iconUrl":"AXIS.png",
                "isHybridDisabled":false,
                "channelCode":"AXIS",
                "channelName":"Axis Bank"
                },
                {
                "isDisabled":{
                    "status":"false",
                    "msg":null
                },
                "hasLowSuccess":{
                    "status":"false",
                    "msg":""
                },
                "iconUrl":"HDFC.png",
                "isHybridDisabled":false,
                "channelCode":"HDFC",
                "channelName":"HDFC Bank"
                }
            ]
        }
    }
}

PayChannelOptions contains the items listed below:

  • String channelName - Bank Name

  • String channelCode - Bank Code

  • String iconUrl - Bank Logo URL

  • HasLowSuccess hasLowSuccess - Information about the bank’s success rate (HasLowSuccess contains Boolean status and String msg )

7

Get Bin details for a new Credit/Debit Card

The method fetchBinDetails is available in the SDK for the Fetch Bin details API. The method is used for the transaction using a payment source of a new Credit/Debit card. The method can be used to get the card details and get the last 15 minutes success rate of the bin. The method need to be called when user has entered the first 6 digits of the card..

fetchBinDetails

Method Signature:

PaymentsDataImpl.fetchBinDetails(cardSixDigit, 
    token value, token type, mid, reference id, object : 
    PaymentMethodDataSource.Callback {
        override fun onResponse(response: JSONObject?) {
        }
        override fun onErrorResponse(error: VolleyError?, errorInfo: JSONObject?) {
        }
    })

Method Parameters:

Attribute Description
cardSixDigits First six digits of the card
token Token value used(access/txntoken)
tokenType It can be "TXN_TOKEN", "ACCESS"
mid Merchant ID
referenceId Unique ID between 10 to 20 digits is required in case of tokenType as ACCESS. It should be similar to the value used in access token generation.
In case of tokenType as TXN_TOKEN, pass the orderId similar to value passed in transaction token generation.

Note: Paytm SDK builder is required to be created first in case using this method with transaction token.

The sample response to Fetch Bin can be found below:

{
    "head": {
        "requestId": null,
        "responseTimestamp": "1611036165656",
        "version": "v1"
    },
    "body": {
        "resultInfo": {
            "resultStatus": "S",
            "resultCode": "0000",
            "resultMsg": "Success"
        },
        "isEmiAvailable": false,
        "supportedCardSubTypes": [
            "CORPORATE_CARD"
        ],
        "binDetail": {
            "bin": "457262",
            "issuingBank": "HDFC Bank",
            "issuingBankCode": "HDFC",
            "paymentMode": "CREDIT_CARD",
            "channelName": "VISA",
            "channelCode": "VISA",
            "cnMin": "13",
            "cnMax": "16",
            "cvvR": "true",
            "cvvL": "3",
            "expR": "true",
            "isActive": "true",
            "isIndian": "true"
        },
        "authModes": [
            "otp"
        ],
        "hasLowSuccessRate": {
            "status": "false",
            "msg": ""
        },
        "iconUrl": "https://staticgw3.paytm.in/33.1.1/",
        "errorMessage": "EMI not available",
        "isHybridDisabled": false,
        "oneClickSupported": false,
        "oneClickMaxAmount": "2000",
        "prepaidCard": false,
        "prepaidCardMaxAmount": "100000"
    }
}
8

Get last NB used for the transaction

This method is used to fetch the bank code through which the last successful Netbanking transaction was done.

getLastNBSavedBank

Usage:

PaytmPaymentsUtilRepository paymentsUtilRepository =PaytmSDK.getPaymentsUtilRepository()
paymentsUtilRepository.getLastNBSavedBank()

Method:

This method will return a string parameter.

Value Description
"ICICI" If a user has used ICICI bank in his last net banking transaction
“” Empty if no such bank is saved

Note: This method will return the bank code using which successful transaction using NetBanking was done

9

Get last vpa used for the transaction

The method getLastSavedVPA is used to fetch the VPA used for the UPI collect transaction by the user. This can be used to show by the merchant on its checkout page as a preferred or last vpa used by the user for the successful transaction.

getLastSavedVPA

Usage:

PaytmPaymentsUtilRepository paymentsUtilRepository =PaytmSDK.getPaymentsUtilRepository()
paymentsUtilRepository.getLastSavedVPA()

Response:

This method will return a string parameter.

Value Description
"abc@xyz" If a user has used this VPA in his last UPI collect transaction
“” Empty if no such VPA is saved
10

Check if paytm user mobile number and merchant user mobile number match

The method checkIfLoggedInUserMobNoMatched can be used to check if the Paytm users mobile number matches with the mobile number passed in the parameters. Before passing the mobile number it has to be converted to it’s SHA256 hash value. You have to make sure that you are passing the hash value of a valid mobile number otherwise the method will return the number not matched.

checkIfLoggedInUserMobNoMatched

Method Signature:

PaytmSDK.getPaymentsUtilRepository().checkIfLoggedInUserMobNoMatched(context, userMobileHash ,object :
                    CheckLoggedInUserMatchListener{
                    override fun getIfUserMatched(case: Int) {
                       }
 
                })

Method Parameters:

Parameter Type Description
context Context SDK needs the context of activity as it might have to further launch new activities and few checks internally
userMobileHash String SHA256 hash value of the 10 digit mobile number

 

Response:
This method will return an integer value which has the following values.

Value Description
1 User Matched
2 User did not match
3 App version of paytm is not compatible (since only versions greater than or equal to 9.3.0 are compatible for this feature)
4 Paytm app not installed
5 Empty userMobileHash sent in the parameters
6 For any error occurred in the flow

 

Generate SHA256 Hash Of User’s Mobile

private String getSHA256HashString(String userMobileNumber) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
            md.reset();
            byte[] hashedBytes = md.digest(userMobileNumber.getBytes());
            return new String(hashedBytes);
}

 

  1. 11

    Optional Configurations

    Please change the following configurations based on your requirements.

     
    1. setServer (Server server) - Use this to test the APIs on the merchant Integration environment. Default value is Server.PRODUCTION

      PaytmSDK.Builder builder = 
          PaytmSDK.builder(context, mid, orderId, txn, amount, this);    
      if(isStaging) {
          PaytmSDK.setServer(Server.STAGING)
      }
      else{
          PaytmSDK.setServer(Server.PRODUCTION)
      }
      PaytmSDK paytmSdk = builder.build();
    2. setAssistEnabled (boolean enablePaytmAssist) - Use this to enable Paytm Auto Assist feature (Auto reading OTP). The default value is False. This method is only available in the sdk version com.paytm.nativesdk:core-ep:1.0.0. Should be used only in case merchant wants to use Paytm Assist.

    3. setLoggingEnabled (boolean enableLogging) - Use this to enable the logs in case required to debug any issue. By default, its value is set as False.

12

Validate VPA

This method is used to check if the provided vpa is valid or not.

validateVPA

Usage:

PaymentsDataImpl.validateVPA(vpa, mid, tokenType, txn, orderId, object : PaymentMethodDataSource.Callback<VPAValidateResponse> {
   override fun onResponse(response: VPAValidateResponse?) {
       if (response?.isValid == true) {
           Toast.makeText(applicationContext, "VPA Validated", Toast.LENGTH_SHORT).show()
       } else {
           Toast.makeText(applicationContext, "VPA Not Validated " + response?.resultMsg, Toast.LENGTH_SHORT).show()
       }
   }

   override fun onErrorResponse(error: VolleyError?, errorInfo: VPAValidateResponse?) {
       Toast.makeText(applicationContext, "Error in API", Toast.LENGTH_SHORT).show()
   }
},upiNumber)

Method Parameters:

This will return a VPAValidateResponse object which contains isValid (boolean) and is true if it is valid vpaId.

Attribute Description
vpaId VPA Id that needs to be checked
upiNumber Unique ID between 8-11 digits mapped to VPA. 10 digit is reserved for mobile number. 8 and 9 digit for custom numbers
Note: Subscription is not supported with upiNumber flow.
mid Merchant Id
tokenType It can be “TXN_TOKEN” or “ACCESS”
token Token value used (access/transactionToken)
refernceId Unique ID between 10 to 20 digits is required in case of tokenType as ACCESS. It should be similar to the value used in access token generation.
In case of tokenType as TXN_TOKEN, pass the orderId similar to value passed in transaction token generation.
  1. 13

    Add the following pro-guard rules if needed:

    - keep class net.one97.paytm.nativesdk.** { *; }
    - keep interface net.one97.paytm.nativesdk.** { *; }
1

Paytm Insufficient balance

This method can be used to invoke and complete the transaction through Paytm app. The method can be used in below two cases:

  1. Integration - Type1: Merchants who receive SSO token of the Paytm users can invoke the Paytm app when the wallet balance is insufficient for the order amount. In order to complete the payment through wallet, the merchant can invoke the Paytm app where the user can AddnPay using available instruments.
  2. Integration - Type2: Merchants not receiving client id and user’s SSO token can invoke the Paytm app to enable users to complete the transaction using the wallet and other saved instruments of Paytm user.

Paytm Insufficient balance
  1. To invoke the Paytm app, add the following entry into Info.plist.
    1. LSApplicationQueriesSchemes(Array) Item 0 (String)->paytm

    2. LSApplicationQueriesSchemes(Array) Item 1 (String)->paytmmp

    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
    }

     

  2. Use the method mentioned below to invoke Paytm:

    public func openPaytm(selectedPayModel: PaytmNativeSDK.AINativeInhouseParameterModel, 
             merchantId: String, 
             orderId: String, 
             txnToken: String, 
             amount: String, 
             callbackUrl: String?, 
             delegate: PaytmNativeSDK.AIDelegate, 
             environment: PaytmNativeSDK.AIEnvironment)

    Sample Response:

    {
        "nameValuePairs": {
            "ORDERID": "PARCEL16105282330",
            "MID": "AliSub58582630351896",
            "TXNID": "20210113111212800110168877474890508",
            "TXNAMOUNT": "1.00",
            "PAYMENTMODE": "PPI",
            "CURRENCY": "INR",
            "TXNDATE": "2021-01-13 14:27:12.0",
            "STATUS": "TXN_SUCCESS",
            "RESPCODE": "01",
            "RESPMSG": "Txn Success",
            "MERC_UNQ_REF": "test4",
            "UDF_1": "test1",
            "UDF_2": "test2",
            "UDF_3": "test3",
            "ADDITIONAL_INFO": "test5",
            "GATEWAYNAME": "WALLET",
            "BANKTXNID": "151096542207",
            "BANKNAME": "WALLET"
        }
    }
2

convertStringToJSON

Convert string to JSON format using convertStringToJSON method.

convertStringToJSON
func convertStringToJSON(jsonString : String) -> [String : Any]? {
    if let jsonString1 = jsonString.removingPercentEncoding {
        let jsonData = jsonString1.data(using: .utf8)!
        if let dictionary = try? JSONSerialization.jsonObject(with: jsonData, 
             options: .mutableLeaves) as? [String : Any]{
            return dictionary
        }
    }
    return nil
}
3

fetchBin

Get bin details for a new card entered by the user.

fetchBin
func fetchBin(selectedPayModel : AINativeSavedCardParameterModel, delegate: AIDelegate)

Method Params:

Parameter Description
AINativeSavedCardParameterModel

An instance of class AINativeSavedCardParameterModel with initializer.

Pass card and order details in this initializer: init(withTransactionToken txnToken : String, tokenType: TokenType = .txntoken, orderId : String,  shouldOpenNativePlusFlow : Bool, mid : String, flowType : AINativePaymentFlow, paymentModes : AINativePaymentModes, authMode: AuthMode, cardId : String?, cardNumber : String?, cvv : String?, expiryDate : String?, newCard isNewCard : Bool, saveInstrument: String, redirectionUrl : String =”", reference_Id: String  = "")

AIDelegate

It is the Paytm SDK Callback listener, used to get callback of Process Transaction API

Sample Method:

self.appInvoke.fetchBin(selectedPayModel: self.selectedModel!, delegate: self)
4

isVpaValidated

isVpaValidated
4

You can verify the VPA by access token and Transaction token.

  1. Verify VPA by use of access token

    Method Signature: isVpaValidated
    public func isVpaValidated(vpa: String?, upiNumber: String?, mid: String, tokenType: TokenType, token: String, referenceId: String, completionHandler: ValidateVPA) {

    Method Params:

    Parameter Description
    vpa Virtual Payment Address(eg.xyz@paytm)
    upiNumber Unique ID between 8-11 digits mapped to VPA. 10 digit is reserved for mobile number. 8 and 9 digit for custom numbers
    mid Merchant id identifying a merchant
    tokenType Transaction token to identify the current transaction
    token Authorization string corresponding to the tokenType used.
    referenceId In case of access token pass the referenceId and in case of txnToken pass the orderId.
    completionHandler Getting the response UPI VPA valid or not.

    Sample Method:

    self.appInvoke.isVpaValidated(vpa: vpaAddress, mid: merchantId, tokenType: .acccess, token: accessToken, referenceId: self.referenceId) { (response, error) in    } 
    self.appInvoke.isVpaValidated(upiNumber: upiNumber, mid: merchantId, tokenType: .acccess, token: accessToken, referenceId: self.referenceId) { (response, error) in    } 
  1. Verify VPA by use of transaction token

    Sample Method:
    self.appInvoke.isVpaValidated(vpa: vpaAddress, mid: merchantId, tokenType: .txntoken, token: txnToken, referenceId: orderId) { (response, error) in    }  
    self.appInvoke.isVpaValidated(upiNumber: upiNumber, mid: merchantId, tokenType: .txntoken, token: txnToken, referenceId: orderId) { (response, error) in    }  
5

Save and fetch last used Netbanking instrument

Save and fetch last used Netbanking instrument

Use the method mentioned below to save the channel code of the last used net banking instrument in the cache:

self.appInvoke.saveNetBankingMethod(channelCode: channelCode)

Use the method mentioned below to fetch the channel code of the last used net banking instrument from the cache:

self.appInvoke.getSavedNetBankingMethod()
6

merchantPaymentStatus

merchantPaymentStatus

Below are the possible values:

enum MerchantPaymentStatus:String {
    case none = "PYTM_100"
    case initiated = "PYTM_101"
    case paymentMode = "PYTM_102"
    case paymentDeduction = "PYTM_103"
    case errorInParameter = "PYTM_104"
    case error = "PYTM_105"
    case cancel = "PYTM_106"
}
7

Save and fetch last used VPA address

Save and fetch last used VPA address

Use the method mentioned below to save the VPA used by the customer in the last UPI collect transaction:

self.appInvoke.saveVPA(vpa: vpaAddress)

Use the method mentioned below to fetch and show the VPA used by the customer in the last UPI collect transaction:

self.appInvoke.getSavedVPA()
8

fetchNetBankingChannels

Use this method to retrieve all net banking channels along with their success rate.

fetchNetBankingChannels

Method Signature:

fun fetchNetBankingChannels(selectedPayModel : AINativeNBParameterModel,
    delegate: AIDelegate)

Method Parameters:

Parameter Description
selectedPayModel An instance of class AINativeNBParameterModel with initializer: init(withTransactionToken txnToken, orderId, shouldOpenNativePlusFlow, mid, flowType, paymentModes, channelCode, ssoToken, redirectionUrl)
AIDelegate
It is Paytm SDK Callback listener, used to get callback of ProcessTransaction API
9

Select the environment

SDK exposes a method to select the environment.

Select the environment
9

Merchants can use setEnvironment() method to select between the available environments:

  • case .production
  • case .staging
10

PaytmConsentCheckBox Customization

Use this method to customize the consent checkbox as per your theme and requirement.

PaytmConsentCheckBox Customization
8
Note:
  1. Check box is by default - true
  2. View should be once visible to users to fetch authcode

Create a view outlet as an object of AINativeConsentView.

For Example: @IBOutlet weak var consentView: AINativeConsentView!)
final public func setBackgroundColor(_ color: UIColor)
final public func setFontFamily(_ family: String)
final public func setFontSize(_ size: CGFloat)
final public func setFont(_ font: UIFont)
final public func setTextColor(_ color: UIColor)
final public func setSelectedCheckmarkImage(_ image: UIImage?)
final public func setSelectedCheckmarkTint(_ tintColor: UIColor)
final public func setUnselectedCheckmarkImage(_ image: UIImage?)
final public func setUnselectedCheckmarkTint(_ tintColor: UIColor)
final public func applyTheme(_ theme: PaytmNativeSDK.AINativeConsentView.Theme)

Usage Example:

consentView.applyTheme(theme)
consentView.setFontSize(12)