Skip to main content

Prerequisites

  • Create a Razorpay account.
  • Generate the API Keys from the Dashboard. To go live with the integration and start accepting real payments, generate Live Mode API Keys and replace them in the integration.
  • Ensure the Third-Party Validation feature is activated on your account.

Sample Code

After creating an order using the Orders API, use the following API call to generate a UPI intent deep link and convert the returned link into a QR code:
Request

Request Parameters

amount mandatory : integer Payment amount in the smallest currency subunit. For example, if the amount to be charged is ₹2.00, enter 200 in this field. currency mandatory : string The currency in which the payment should be made by the customer. For TPV QR codes, this should be INR. order_id mandatory : string Order ID generated via Orders API. email mandatory : string Email address of the customer. contact mandatory : string Phone number of the customer. The expected format is without country code for Indian numbers. Example: 9090909090. method mandatory : string Payment method. For this integration, set this to upi. ip optional : string IP address of the customer. referer optional : string Referer header value. user_agent optional : string User agent of the customer’s browser. description optional : string Description of the payment. notes optional : object Set of key-value pairs that can be used to store additional information about the payment. It can hold a maximum of 15 key-value pairs, each 256 characters long (maximum). upi mandatory : object UPI specific parameters. flow mandatory : string UPI flow type. Set this to intent to generate a deep link for QR code creation.

Response Parameters

razorpay_payment_id : string Unique identifier for the payment. link : string UPI intent deep link that can be converted to a QR code using third-party libraries.

Implementation Steps

Follow these steps to implement TPV QR code payments:
1

Step 1

Call the UPI payment creation API with "flow": "intent".
2

Step 2

Extract the link from the response.
3

Step 3

Use any QR code generation library to convert this link into a QR code.
4

Step 4

Display the QR code to your customers.
5

Step 5

Poll Payment APIs to check the payment status.
Watch Out!
  • Expiry Management: QR codes generated through this method require expiry handling on your application side.
  • Payment Monitoring: Continue monitoring payment status even after your intended QR expiry time, as users may complete payments later.
  • Reconciliation: Implement appropriate reconciliation processes to handle payments completed after your QR display period
Use widely available open-source libraries across all major programming languages to generate QR codes from any UPI Intent URL or Deep Link.

Node.js

Use the qrcode library:
Given below is a sample code to generate QR code:
Node.js
Supports: PNG, SVG, Terminal output.

Python

Use the qrcode library:
Given below is a sample code to generate QR code:
Python

Java

Use the ZXing (Zebra Crossing) library, the most widely used QR generator in Java-based applications. Given below is a sample code to generate QR code:
Java

Go

Use the skip2/go-qrcode library:
Given below is a sample code to generate QR code:
Go

PHP

Use the endroid/qr-code library:
Given below is a sample code to generate QR code:
PHP

Android/iOS

Use the ZXing Android embedded library. Use Native CoreImage (no external dependency required). Given below is a sample code to generate QR code:
iOS Swift
Handy TipsAny UPI Intent URL (for example, upi://pay?...) can be passed as a string to any of the above libraries to generate a QR code. These are public, open-source, stable and suitable for your integrations across web, backend and mobile applications.