Available in🇮🇳 India
Use Razorpay Turbo UPI to make UPI payments faster. Follow these steps to integrate with the Razorpay Turbo UPI UI SDK.
Prerequisites
Prerequisites
- Integrate with the Razorpay Android Custom SDK.
-
Contact our Integrations team and provide the following details to get allowlisted:
- Mobile numbers of your internal users.
- App id of your debug, staging and production apps.
-
Contact our Integrations team to get the access to the Sample App Repository
https://github.com/upi-turbo/android-turbo-sample-app. Once you have access, please read the readme section of the repository to learn how to locate the library files and integrate them into your project. -
Add the following lines to your Android project’s
gradle.propertiesfile:android.enableJetifier=trueandroid.useAndroidX=true
-
The
minSDKversionfor using Turbo UPI is currently 23 and cannot be over written.
- In the root settings.gradle file, use:
Kotlin
- In the library module’s build.gradle, use:
Kotlin
Integrate Steps
1.1 Create a Session Token
To enhance security, you must create a session token via a server-to-server (S2S) call between your backend and Razorpay’s backend. This session token ensures secure communication between the Turbo SDK and Razorpay’s systems.How to Create a Session Token
-
Trigger the S2S API from your Backend. Use the following API to generate a session token:
Environment based URLs:
-
UAT:
https://api-web-turbo-upi.ext.dev.razorpay.in -
Production:
https://api.razorpay.com
-
UAT:
Base64.encode(${public_key}:${secret})
Request Parameters
Request Parameters
customer_reference mandatory
: string A unique identifier for the customer provided by the business. The recommended value is mobile number. For example, 9000090000.Response Parameters
Response Parameters
token
: string A session token to be used in subsequent session-protected APIs.expire_at
: long Expiry time (in seconds) for the session token, used to optimise session handling and reduce unnecessary reinitialisations.error
: object The request failure due to business or technical failure.- Pass the Generated Token to Turbo SDK. Use the session token in the initialisation step, ensuring that it is refreshed upon expiry.
1.2 Initialise Turbo SDK
Initialise theTurboSessionDelegate object anonymously and pass it through the initialize method. The SDK will call fetchToken whenever required and use the provided callback to handle the new/updated token. In the fetchToken function, retrieve a new token from your server (see 1.1 Create a Session Token) and once available, pass it to the completion object. This mechanism allows you to seamlessly refresh the session by retrieving a new token via a server-to-server (S2S) call whenever the SDK requests it.
1.3 Getting Linked UPI Accounts
After initialising the Turbo SDK, proceed to securely link UPI accounts and complete the payment flow.- Get already linked accounts. If your customer has already linked accounts, use the following code to fetch them. If there are no linked UPI accounts, an empty list is returned.
Handy Tips
- When the user arrives at your checkout screen, use the
getLinkedUpiAccountsfunction to fetch the updated list of UPI accounts. - A mobile number is required in the
linkNewUpiAccountfunction for an enhanced user experience. Otherwise, feel free to use either your mobile number or customer id.
Request Parameters
Request Parameters
customerMobile mandatory
: string The customer’s mobile number.listener
: object The listener to be sent should be of type UpiTurboResultListener.Response Parameters
Response Parameters
onSuccess
: This function is triggered if the list is fetched successfully. accList can be empty to indicate that no accounts have been linked yet.onError
: This function is triggered in case an error is thrown during the retrieval process, either by the Razorpay SDK or the Bank SDK.1.4 Onboarding Flow
Invoke the below function for these use cases:- To initiate new onboarding, in case you get a DEVICE_BINDING_INCOMPLETE error in the above section,
- To link additional bank accounts for already onboarded users.
Handy TipsA mobile number is required in the
linkNewUpiAccount function for an enhanced user experience. Otherwise, feel free to use either your mobile number or customer id.Transactional Flow
- To process the payments, call the
submit methodof custom checkout with the provided payload.
- Pass the
vpaandpayloadobjects as shown in the code below.
Non-Transactional Flow
You can directly interact with the exposed methods of the Turbo Framework to perform the non-transactional flows listed below.Manage UPI Accounts
Manage UPI Accounts
Let Razorpay SDK manage the linked
UpiAccount on the applications by triggering manageUpiAccounts().Handy TipsA mobile number is required in the
linkNewUpiAccount function for an enhanced user experience. Otherwise, feel free to use either your mobile number or customer id.- Code
- Customer Interaction Walkthrough Video
Manage UPI Accounts
Additional Features
- To get the device binding status, please use the method
isDeviceOnboarded()which returns a boolean. It indicates whether the device binding, which is a prerequisite for adding UPI accounts, is done with the user’s mobile number.
Kotlin
- Users can now link their credit cards alongside bank accounts during onboarding. You can seamlessly retrieve both credit and bank accounts for transactions, thereby simplifying payments, expanding options, and ensuring security.
- Charges will be levied for payments made using CC on UPI. Contact the support team for further information.
Models Exposed from the SDKs
The SDKs given below provide access to exposed models for seamless integration.UpiAccount
UpiAccount
BankAccount
BankAccount
BankAccountState
BankAccountState
Bank
Bank
PaymentData
PaymentData
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 allowlisted by Razorpay to test on prod.
- As a compliance requirement, you need to get approval from Google for READ_SMS permission. Refer to the Google article for more details.
-
Add Proguard rules:
keepclassmembers,allowobfuscation class * { @com.google.gson.annotations.SerializedName <fields>; }keepclassmembers enum * { *; }keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; }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.