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.
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.
This method can be used to invoke and complete the transaction through Paytm app. The method can be used in below two cases:
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>
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>
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.
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"/>
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.
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 |
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.
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"
}
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:
PaytmSDKCallbackListener
and can be obtained as shown:
{"statusCode":100,"statusMsg":"SUCCESS"}
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.
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 )
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..
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.paytmpayments.com/33.1.1/",
"errorMessage": "EMI not available",
"isHybridDisabled": false,
"oneClickSupported": false,
"oneClickMaxAmount": "2000",
"prepaidCard": false,
"prepaidCardMaxAmount": "100000"
}
}
This method is used to fetch the bank code through which the last successful Netbanking transaction was done.
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
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.
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 |
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.
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);
}
Please change the following configurations based on your requirements.
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();
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.
setLoggingEnabled (boolean enableLogging) - Use this to enable the logs in case required to debug any issue. By default, its value is set as False.
This method is used to check if the provided vpa is valid or not.
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)
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. |
- keep class net.one97.paytm.nativesdk.** { *; }
- keep interface net.one97.paytm.nativesdk.** { *; }