Prerequisites
-
Contact our integrations team to get your mobile number, app, and GitHub account whitelisted to get access to the
https://github.com/upi-turbo/android-turbo-sample-app- sample app repository. In this repository, you will find the AAR files (libraries for Turbo). The AARs on the main branch are for the UAT environment, and the ones on the prod branch are for the production environment. These are the important files in the sample app repo:app/libs: All libraries (Bank, SecureComponent and Turbo) common for headless SDK.app/build.gradle: All transitive dependencies needed to integrate Turbo SDK.
- Integrate with Razorpay Flutter Custom Integration.
-
Import the following frameworks:
- Razorpay Turbo Wrapper Plugin SDK (maven)
- Razorpay Turbo Core SDK
- Razorpay SecureComponent SDK
- Bank SDK
-
Add the following lines to your Android project’s
gradle.propertiesfile:android.enableJetifier=trueandroid.useAndroidX=true
1. Integration Steps
-
Use the code given below to initialise the SDK.
Import Package
-
Use the following code to link the newly created UPI account with your app. This function can be called from anywhere in the application, providing multiple entry points for customers to link their UPI account with your app.
Link UPI Account
Request Parameter
Parameter | Description
mobileNumber | Mobile number of the customer.
- Initialise the instance to handle the event using the code given below:
Instantiate
- Handle dynamic responses to perform specific actions, including error handling and interactions with the integration, based on ‘type’ and ‘action’ properties.
Request Parameter
Parameter | Description
mobileNumber | Mobile number of the customer.
Response Parameters
Parameter | Description
onSuccess | This function is triggered if the list is fetched successfully. accList can be empty to indicate that no accounts have been linked yet.
onFailure | This function is triggered in case an error is thrown during the retrieval process, either by the Razorpay SDK or the Bank SDK.
-
To accept payments, call Custom Checkout’s
submitmethod with the following payload:Submit Payment Details
Request Parameter
Parameter | Description
turboPayload | Payload for initiating transaction.
Response Parameters
Parameter | Description
onSuccess | This function is triggered if the list is fetched successfully. accList can be empty to indicate that no accounts have been linked yet.
onFailure | This function is triggered in case an error is thrown during the retrieval process, either by the Razorpay SDK or the Bank SDK.
- Initialise the instance to handle the event, using the code given below:
Instantiate
- Print payment success and error responses by attaching event listeners to payment events as given below:
Attach Event Listeners
Non-Transactional Flow
You can directly interact with the exposed methods of the Turbo Framework to perform the non-transactional flows listed below.Fetch Balance
Fetch the customer’s account balance. CallgetBalance() on the bank account object received from upiAccount.
Fetch Balance
Parameter | Description
upiAccount | Provides a bank account.
Response Parameters
Parameter | Description
onSuccess | AccountBalance object received in the response.
onFailure | This function is triggered in case of an error. An Error object will be received.
Change UPI PIN
Provide the customer with the ability to change their UPI PIN. CallchangeUpiPin() on the bank account object received from UpiAccount.
Change UPI PIN
Parameter | Description
upiAccount | Provides a bank account.
Response Parameters
Parameter | Description
onSuccess | UpiAccount object received in the response.
onFailure | This function is triggered in case of an error. An Error object will be received.
Reset UPI
Let your customers reset the PIN for their account.Reset UPI
Parameter | Description
upiAccount | Provides a bank account.
card | Provides a card.
Response Parameters
Parameter | Description
onSuccess | UpiAccount object received in the response.
onFailure | This function is triggered in case of an error. An Error object will be received.
Delink
Let your customers delink, that is, remove a selected UPI account from your application.Delink
Parameter | Description
upiAccount | Provides a bank account.
Response Parameters
Parameter | Description
onSuccess | Empty object will be received.
onFailure | This function is triggered in case of an error. An Error object will be received.
Models Exposed from the SDKs
The SDKs given below provide access to exposed models for seamless integration.BankAccount
Fields | Return Type | Description
maskedAccountNumber | String | Masked account number.
beneficiaryName | String | Name of the account holder.
type | String | The account type. Possible values are savings and current.
bank | Bank | Bank Object.
Bank
Fields | Return Type | Description
ifsc | String | IFSC of bank.
name | String | Name of bank.
imageURL | String | Image URL of bank logo.
bankPlaceholderUrl | String | Image URL for bank logo placeholder.
AccountBalance
Method | Return Type | Description
id | long | Balance Account id.
balance | String | Balance amount in paise.
currency | String | Currency in INR.
Error
Error | Description
errorCode | Types of error codes - BAD_REQUEST_ERROR: Failure from the client’s end (SDK).
-
GATEWAY_ERROR: Failure either from the Secure Component or the Bank. -
SERVER_ERROR: Failure at PSP.
errorDescription| Brief description of the error.errorReason| Specifies the specific reason for the error.errorSource| Indicates the origin of the error.errorStep| Highlights the stage where the error occurred. Refer to the list of possible error reasons.
UpiAccount
Method | Return Type | Description
accountNumber | String | Masked account number.
ifsc | String | IFSC of the bank.
bankLogoUrl | String | Image URL of the bank logo.
bankName | String | Name of the bank.
bankPlaceholderUrl | String | Image URL for bank logo placeholder.
SIM
Method | Return Type | Description
id | String | SIM id used to target SIM card for binding.
provider | String | Network provider name.
slotNumber | Integer | SIM slot number. Possible values are 0 and 1.
number | String | Mobile number stored in SIM card.
Card
Method | Return Type | Description
lastSixDigits | String | Last six digits of the debit card number.
expiryYear | String | Expiry year. Format: YY.
expiryMonth | String | Expiry month.
AllBanks
Method | Return Type | Description
popularBanks | String | Returns the list of the top 8 banks.
banks | String | Returns a list of all banks.
2. Test Integration
We recommend the following:- Complete the integration on UAT before using the prod builds.
- Perform the UAT using the Razorpay-provided API keys.
3. Go-live Checklist
Complete these steps to take your integration live:- You should get your app id whitelisted by Razorpay to test on prod.
Handy Tips
-
Import the prod library from the GitHub repository →
https://github.com/upi-turbo/android-turbo-sample-app/tree/prod/app/libsprod branch. -
Add Proguard rules:
keepclassmembers,allowobfuscation class * { @com.google.gson.annotations.SerializedName ; }keepclassmembers enum * { *; }keepclassmembers class * { @android.webkit.JavascriptInterface ; }dontwarn com.razorpay.**keep class com.razorpay.** {*;}keep class com.olivelib.** {*;}keep class com.olive.** {*;}keep class org.apache.xml.security.** {*;}keep interface org.apache.xml.security.** {*;}keep class org.npci.** {*;}keep interface org.npci.** {*;}keep class retrofit2.** { *; }keep class okhttp3.** { *; }
- Replace the UAT credential with the Razorpay live keys for prod testing.