Available in🇮🇳 India
The steps required to integrate tokens in the payment flow are as follows:
Step 1: Create a Customer
Create a customer whose VPAs should be saved. You can skip this step if you have already created customers in your account.POST /customers
Request Parameters
Set of key-value pairs that can be associated with an entity. This can be useful for storing additional information about the entity. A maximum of 15 key-value pairs, each of 256 characters
(maximum), are supported.
Response
Theid obtained in the response should be sent as customer_id while creating the token.
Step 2: Create an Order
You should create an order before initiating a payment at your end.POST /orders
Request Parameters
The amount for which the order was created, in currency subunits.
For example, for an amount of ₹295, enter
For example, for an amount of ₹295, enter
29500.ISO code for the currency in which you want to accept the payment. Only
INR is supported.Receipt number that corresponds to this order, set for your internal reference. Maximum length of 40 characters.
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”.Step 3: Create Tokens for a Customer
While making the UPI collect payment, the customer enters the VPA on your UI. To store the VPA as a token, pass additional attributes in the create payment request:Request Parameters
Unique identifier of the customer. This can be obtained from the response of Step 1.
The amount for which the order was created, in currency subunits.
For example, for an amount of ₹295, enter
For example, for an amount of ₹295, enter
29500.ISO code for the currency in which you want to accept the payment. Only
INR is supported.Order ID generated via Razorpay Orders API.
Value of
referer header passed by the client’s browser. For example, https://merchansite.com/example/paybillValue of
For example, Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
user_agent header passed by the client’s browser. For example, Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
Specifies if the VPA should be stored as a token. Possible values are:
true: Saves the VPA details.false(default): Does not save the VPA details.
Response
The response contains an HTML page that is rendered in the customer’s browser. The customer can now complete the payment by logging in to the respective UPI app.Step 4: Fetch all Tokens of the Customer
All the card (if saved earlier) and VPA tokens of a customer can be retrieved.GET /customers/:customer_id/tokens
Response
Pass the token that contains the VPA details of the customer,token_EeO65VIv8BXZg5 in the above example, to the payment create request.
Step 5: Create Payments using Tokens
After VPA tokenisation, customers can complete their UPI payments without having to enter their VPAs again for repeat transactions on your site. You should pass the following attributes in each payment create request, instead of thevpa field:
Request Parameters
The amount for which the order was created, in currency subunits.
For example, for an amount of ₹295, enter
For example, for an amount of ₹295, enter
29500.ISO code for the currency in which you want to accept the payment. Only
INR is supported.Order ID generated via Razorpay Orders API.
Token of the saved VPA, obtained in the previous step.
Response
The response contains an HTML page that is rendered in the customer’s browser. The customer can now complete the payment by logging in to the respective UPI app.Next Steps
You can check the status of the payments using any of the following methods:- Poll the Razorpay servers to fetch a payment or fetch the payments made for an order.
- Subscribe to payments and orders Webhook events that are generated in Razorpay when the customer completes the payment on your website.