UPI QR Code Workflow
1
Step 1
Send a request to create a virtual account with
receiver.type as qr_code. A QR code is generated as a result of virtual account creation.2
Step 2
Display the QR code on your app used for collecting payments.
3
Step 3
Customers scan and pay using any of the UPI apps on their mobile devices.
4
Step 4
Verify the payment status either by polling Razorpay APIs or bysubscribing to Webhook events.
Prerequisites
-
Ensure that you have the API key required for integration.
- Log in to the Dashboard with appropriate credentials.
- Select the mode (Test or Live) for which you want to generate the API key.
Handy TipsYou have to generate separate API Keys for the test and live modes. No money is deducted from your account in the test mode.
- Navigate to Settings → API Keys → Generate Key to generate key for the selected mode.
Integration flow
Step 1: Creating a QR code
To start accepting payments using UPI QR Code, a virtual account should be created with areceiver, which defines the payment collection method associated with it. For UPI QR Code, the receiver type is qr_code, which allows your customers to make payments using UPI by scanning the QR code.
You need to create a virtual account by sending an API request to Razorpay for generating the QR code for each payment.
/virtual_accounts
Request Parameters
receivers mandatory
: object Object consisting of configured receivers types.
types mandatory
: array List of desired receiver types.
In this case, it will be qr_code.
qr_code mandatory
: array The payment method that should be used to make the payment.
card optional
: boolean Indicates whether card payment should be allowed with the QR Code or not.
By default, it is set to true. In case of UPI QR payments, set this value to false.
upi mandatory
: boolean Indicates whether UPI payment should be allowed with the QR Code or not.
By default, the value is set to true.
description optional
: string A brief description of the payment.
customer_id optional
: string Unique identifier of the customer for whom UPI QR Code is created. Know more about the Customers API.
close_byoptional
: integer Specifies the UNIX timestamp at which the virtual account is scheduled to be automatically closed. It should be set at least 15 minutes after the time of creation.
notes optional
: object Object consisting of key value pairs that allow you to store additional data.
Know more aboutNotes.
amount_expected mandatory
: integer The maximum amount you expect to receive in this virtual account. Pass 69999 = ₹699.99 (INR is the default currency).
Sample Request
Response Parameters
id
: string Unique identifier of the generated QR Code.
For example, qr_4lsdkfldlteskf
entity
: string Name of the entity in the response. In this case, it is qr_code.
short_url
: string URL of the QR code.
A sample short URL looks like this http://rzp.io/l6MS. Clicking on the link will download the code for offline use.
status
: string The status of the virtual account. Possible values:
-active
closed
closed_at
: integer Specifies the timestamp(in Unix format) at which the virtual account was closed.
Step 2: Verifying the Payment Status
To know if the customer has made the payment or not, you can track the payment status either by polling the Razorpay servers or subscribing to specific events generated in our system.Fetch All Virtual Accounts
To fetch all the payments received using the QR Code, send the following API request to Razorpay: /virtual_accountsSample Request
Fetching a Virtual Account
To fetch a specific payment, send the following request to Razorpay: /virtual_accounts/:idPath Parameters
id mandatory
: string Unique identifier of a specific virtual account whose details are to be retrieved.
Sample Request
Fetching all payments of a Virtual account
To fetch all the payments made to a virtual account, send the following request: /virtual_accounts/:id/paymentsPath Parameters
id mandatory
: string Unique identifier of a virtual account whose payments should be retrieved.
Sample Request
Closing a Virtual Account
After you have received the payment, you may choose to close the virtual account. /virtual_accounts/:id/closePath Parameter
id mandatory
: string Unique identifier of the virtual account that should be closed.
Sample Request