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.
openPaytmAppForAddMoneyToWallet
paytmSDK.openPaytmAppForAddMoneyToWallet(activity)

Method Params:

Parameter Description
Activity context SDK needs the context of activity
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 and is only required in case of tokenType as ACCESS. It should be similar to the value used in access 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":"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"
                }
            ]
        }
    }
}
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
  1. 10

    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.

11

Add the following pro-guard rules if needed:

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

Paytm Insufficient balance

A new condition is added in which if the wallet balance(received in the fetchPayOptions) is less then the transaction amount in that case merchant can invoke the Paytm app to Add and Pay to proceed with payment.

Paytm Insufficient balance

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

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"
}
4

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()
5

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()
6

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
7

Select the environment

SDK exposes a method to select the environment.

Select the environment
3

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

  • case .production
  • case .staging
8

PaytmConsentCheckBox Customization

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

PaytmConsentCheckBox Customization
3
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)