Prerequisites
Prerequisites
-
Contact our integrations team for
- Whitelisting mobile numbers and app id whitelisted for testing on UAT.
- Getting access to our sample app
https://github.com/upi-turbo/ios-sample-apprepository.
-
In this repository, you will find the UAT frameworks and the sample app source code to help you with the integration. Use branches inside
ui/tpv/to access sample app and frameworks for Turbo UPI with UI TPV.
- Integrate with the Razorpay iOS Custom SDK.
- Add the following lines to your Podfile for Turbo pod installation:
- Import the Turbo plugin as given below:
1. Integration Steps
Environment based URLs:-
UAT:
https://api-web-turbo-upi.ext.dev.razorpay.in -
Production:
https://api.razorpay.com
Step 1: Whitelist Customer Bank Accounts *(Optional)*
Step 1: Whitelist Customer Bank Accounts *(Optional)*
1: Create a Customer
1: Create a Customer
Request Parameters
Request Parameters
name optional
: string Customer’s name. Alphanumeric value with period (.), apostrophe (’), forward slash (/), at (@) and parentheses are allowed. The name must be between 3-50 characters in length. For example, Gaurav Kumar.contact optional
: string The customer’s phone number. A maximum length of 15 characters including country code. For example, +919876543210.email optional
: string The customer’s email address. A maximum length of 64 characters. For example, gaurav.kumar@example.com.fail_existing optional
: string Possible values:1(default): If a customer with the same details already exists, throws an error.0: If a customer with the same details already exists, fetches details of the existing customer.
gstin optional
: string Customer’s GST number, if available. For example, 29XAbbA4369J1PA.notes optional
: object This is a key-value pair that can be used to store additional information about the entity. It can hold a maximum of 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.Response Parameters
Response Parameters
id
: string Unique identifier of the customer. For example, cust_1Aa00000000004.name
: string Customer’s name. Alphanumeric, with period (.), apostrophe (’), forward slash (/), at (@) and parentheses allowed. The name must be between 3-50 characters in length. For example, Gaurav Kumar.contact
: string The customer’s phone number. A maximum length of 15 characters including country code. For example, +919876543210.email
: string The customer’s email address. A maximum length of 64 characters. For example, gaurav.kumar@example.com.gstin
: string GST number linked to the customer. For example, 29XAbbA4369J1PA.notes
: json object This is a key-value pair that can be used to store additional information about the entity. It can hold a maximum of 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.created_at
: integer UNIX timestamp, when the customer was created. For example, 1234567890.2: Add Customer's Bank Account
2: Add Customer's Bank Account
POST customers/:customer_id/bank_accountPath Parameter
Path Parameter
customer_id mandatory
: string Customer id of the customer whose bank account is to be added.Request Parameters
Request Parameters
account_number mandatory
: string Customer’s bank account number. For example, 11214311215411.beneficiary_name mandatory
: string The name of the beneficiary associated with the bank account.beneficiary_address1 optional
: string The virtual payment address.beneficiary_email optional
: string Email address of the beneficiary. For example, gaurav.kumar@example.com.beneficiary_mobile optional
: string Mobile number of the beneficiary.beneficiary_city optional
: string The city of the beneficiary.beneficiary_state optional
: string The state of the beneficiary.beneficiary_country optional
: string The country of the beneficiary.beneficiary_pin optional
: integer The pin code of the beneficiary’s address.ifsc_code mandatory
: string The IFSC of the bank branch associated with the account.Response Parameters
Response Parameters
bank_accounts
: array An array containing bank account details.id
: string Unique identifier of the bank account.entity
: string The type of entity, which in this case is bank_account.ifsc
: string The IFSC of the bank branch associated with the account.bank_name
: string The name of the bank.name
: string The name associated with the bank account.notes
: object Set of key-value pairs that can be used to store additional information about the payment.account_number
: integer Customer’s bank account number. For example, 0002020000304030434.Step 2: Create an Order *(Mandatory)*
Step 2: Create an Order *(Mandatory)*
bank_account array of the Orders API. Given below is the sample code when the method is upi.Request Parameters
Request Parameters
amount mandatory
: integer The transaction amount expressed in paise (currency supported is INR). For example, for an actual amount of ₹1, the value of this field should be 100.currency mandatory
: string The currency in which the transaction should be made. You can create orders in INR only.receipt optional
: string Receipt number that corresponds to this order, set for your internal reference. Maximum length is 40 characters.notes optional
: json object Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.method mandatory
: string The payment method used to make the payment. If this parameter is not passed, investors will be able to make payments using both netbanking and UPI payment methods. Possible values:netbanking: Investors can make payments only using netbanking.card: Investors can make payments using debit card.upi: Investors can make payments only using UPI.
bank_account mandatory
: object Details of the bank account that the investor has provided at the time of registration.account_number mandatory
: string The bank account number from which the investor should make the payment. For example, 765432123456789 Payments will not be processed for an incorrect account number.name mandatory
: string The name linked to the bank account. For example, Gaurav Kumar.ifsc mandatory
: string The bank IFSC. For example, HDFC0000053.Response Parameters
Response Parameters
id
: string Unique identifier of the order.entity
: string Indicates the type of entity. Here, it is order.amount
: integer The order amount represented in the smallest unit of the currency passed. For example, amount = 100 translates to 100 paise, that is ₹1 (default currency is INR).amount_paid
: integer The amount that has been paid.amount_due
: integer The amount that is yet to be paid.currency
: string The 3-letter ISO currency code for the payment. Currently, we support INR only.receipt
: string A unique identifier of the order entered by the user. For example, BILL13375649.status
: string The status of the order.notes
: object Key-value pair you can use to store additional information about the entity. Maximum of 15 key-value pairs, 256 characters each. For example, “note_key”: “Beam me up Scotty”.created_at
: integer The Unix timestamp at which the order was created.offer_id
: string Unique identifier of the offer.attempts
: integer The number of payment attempts, successful and failed, that have been made against this order.Step 3: Turbo UPI with UI SDK Action
Step 3: Turbo UPI with UI SDK Action
1 Initialise the SDK
1 Initialise the SDK
2 Create a Session Token
2 Create a Session Token
How to Create a Session Token
- Trigger the S2S API from your Backend. Use the following API to generate a session token:
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, 9000090000Response 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.- Create/Retry Session Token Mechanism
To ensure a smooth experience during token expiry, the Turbo SDK provides the
TurboSessionDelegate interface with a fetchToken method. This method dynamically fetches and updates the session token without reinitialising the session.Initialise the TurboSessionDelegate object anonymously and pass it through the initialize method.fetchToken as needed and use the provided callback to handle the updated token. This allows you to seamlessly refresh the session by retrieving a new token via a server-to-server (S2S) call.Below is an example of creating an instance of the TurboSessionDelegate interface using an anonymous object expression:3 Link New UPI Account
3 Link New UPI Account
Parameter Combinations
Using Order ID
When calling thelinkNewUpiAccount function with an OrderId, the TPV process is initiated for linking whitelisted accounts. Ensure that TPV bank account details are not provided in this case.Using Customer ID with TPV Bank Account
When calling thelinkNewUpiAccount function with a CustomerId, you must also include TPV bank account details. This links the specific whitelisted account associated with that user.Restrictions
- Order ID and Customer ID: Do not pass both
OrderIdandCustomerIdsimultaneously in thelinkNewUpiAccountfunction. Choose one based on your use case. - Order ID and TPV Bank Account: Do not pass
OrderIdandTPV bank accountdetails together. Use either one. - TPV Bank Account without Customer ID or Order ID: TPV bank account details cannot be provided without a
CustomerId.
- Using Order Id and Mobile Number
- Using Customer Id and TPV Bank Account
Request Parameters
Request Parameters
customerMobile mandatory
: string A unique identifier for the customer provided by the business. The recommended value is mobile number. For example, 9000090000customer_id
: string The CustomerId will be used for fetching the TPV whitelisted bank accounts when the OrderId is not provided.order_id
: string The OrderId to be used for fetching the TPV whitelisted bank account for the order.tpvBankAccount
: object This object type TurboTPVBankAccount will contain the bank account that the user selected in the onboard flow.Steps 4: Store Fields in Your Server
Steps 4: Store Fields in Your Server
- You need to store these fields in your server.
- You can confirm the authenticity of these details by verifying the signature in the next step.
Response Parameters
Response Parameters
razorpay_payment_id
: string Unique identifier for the payment returned by Checkout only for successful payments.razorpay_order_id
: string Unique identifier for the order returned by Checkout.razorpay_signature
: string Signature returned by the Checkout. This is used to verify the payment.Step 5: Verify Signature
Step 5: Verify Signature
To verify the `razorpay_signature` returned to you by the Checkout form:
To verify the `razorpay_signature` returned to you by the Checkout form:
-
Create a signature in your server using the following attributes:
order_id: Retrieve theorder_idfrom your server. Do not use therazorpay_order_idreturned by Checkout.razorpay_payment_id: Returned by Checkout.key_secret: Available in your server. Thekey_secretthat was generated from the Dashboard.
-
Use the SHA256 algorithm, the
razorpay_payment_idand theorder_idto construct a HMAC hex digest as shown below:
- If the signature you generate on your server matches the
razorpay_signaturereturned to you by the Checkout form, the payment received is from an authentic source.
Generate Signature on Your Server
Generate Signature on Your Server
Post Signature Verification
Post Signature Verification
Get Linked Accounts
If your customer has already linked the UPI account, use the following code to fetch it. If there are no linked UPI accounts, an empty list is returned- You can retrieve the list of UPI accounts linked to a customer’s mobile number using the following code. This function can be invoked from any part of the application, offering multiple entry points for customers to manage their UPI accounts.
- Implement the delegate methods to handle the response for fetching linked UPI accounts. Below is an example:
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
manageUpiAccounts().Additional Features
To get the device binding status, please use the variablerazorpay.upiTurbo.deviceBindingDone of type boolean. It indicates whether the device binding, which is a prerequisite for adding UPI accounts, is done with the user’s mobile number.
Models Exposed from the SDKs
The SDKs provide access to exposed models for seamless integration.UpiAccount
UpiAccount
UpiBankAccount
UpiBankAccount
UpiBank
UpiBank
TurboError
TurboError
TurboTPVBankAccount
TurboTPVBankAccount
2. Test Integration
We recommend the following:- Complete the integration on UAT before using the prod builds.
- Perform the UAT testing 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.
- Replace the UAT credential with the Razorpay live keys for prod testing.