> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# UPI QR

> Accept UPI payments on desktop and web checkout in your server-to-server integration by showing the UPI intent link as a QR code.

Available in
🇮🇳 India

With UPI QR, you show a QR code on your checkout and the customer scans it with any UPI app to pay. Use it on desktop and web checkouts, where you cannot open a UPI app on the same device.

UPI QR uses the same payment API as [UPI Intent](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/payment-methods/upi/intent.md). You create an intent payment, take the intent link from the response and convert it into a QR code yourself. There is no separate QR payment flow.

> [!NOTE]
>
> **Handy Tips**
>
> Razorpay also has a [QR Codes API](https://razorpay.com/docs/api/qr-codes) that creates a separate QR code entity. For an S2S checkout, we recommend converting the intent link into a QR code as described on this page. You work with a single payment and reconciliation is simpler.

## Prerequisites

* Generate the [API keys](https://razorpay.com/docs/payments/dashboard/account-settings/api-keys.md#generate-api-keys) from the Dashboard.
* Set up [webhooks](https://razorpay.com/docs/webhooks/setup-edit-payments.md) to know the result of the payment.
* If you are an international business looking to collect payments from Indian customers, refer to our [import payment flow documentation](https://razorpay.com/docs/payments/international-payments/accept-international-payments-from-indian-customers/s2s-integration/build-integration/saas.md).

## Integration Steps

1. [Create an order](#step-1-create-an-order) for the amount you want to collect.
2. [Initiate the payment](#step-2-initiate-a-payment) with `upi.flow` set to `intent` and take the `link` from the response.
3. [Convert the link into a QR code](#step-3-convert-the-link-into-a-qr-code) and show it on your checkout.
4. [Verify the payment status](#step-4-verify-the-payment-status) after the customer scans the QR code and approves the payment.

### Step 1: Create an Order

Create an order the same way as for UPI Intent. Refer to [Create an Order](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/payment-methods/upi/intent.md#step-1-create-an-order) for the request and its parameters.

### Step 2: Initiate a Payment

Initiate a payment with the `intent` flow. This is the same call as UPI Intent.

`POST /payments/create/upi`

```bash Request theme={null}
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
-X POST https://api.razorpay.com/v1/payments/create/upi \
-H "Content-Type: application/json" \
-d '{
  "amount": 50000,
  "currency": "INR",
  "order_id": "order_IluGWxBm9U8zJ8",
  "email": "gaurav.kumar@example.com",
  "contact": "9090909090",
  "method": "upi",
  "ip": "192.168.0.103",
  "referer": "http",
  "user_agent": "Mozilla/5.0",
  "description": "Test flow",
  "upi": {
    "flow": "intent",
    "expiry_time": 5
  }
}'
```

```json Response theme={null}
{
  "razorpay_payment_id": "pay_ERNEungCtXpZqM",
  "link": "upi://pay?pa=success@razorpay&pn=acme&tr=QTeEWVyigzIBlUD&tn=razorpay&am=500&cu=INR&mc=5411"
}
```

Refer to [Initiate a Payment](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/payment-methods/upi/intent.md#step-2-initiate-a-payment) for all the request parameters. The parameter below controls how long the QR code stays valid.

**upi.expiry\_time** `integer`

The time, in minutes, for which the intent link and the QR code are valid. The minimum value is `5` and the maximum is `5760` (96 hours). The default value is `10`.

### Step 3: Convert the Link into a QR Code

Pass the `link` to a QR code generator and show the image on your checkout. You can use any QR code library. The sample below uses the `qrcode` npm package.

```javascript Generate QR code theme={null}
const QRCode = require('qrcode');

// link from the response of the payment request
const link = "upi://pay?pa=success@razorpay&pn=acme&tr=QTeEWVyigzIBlUD&tn=razorpay&am=500&cu=INR&mc=5411";

// create a data URL and show it in an <img> tag on your checkout
const qrDataUrl = await QRCode.toDataURL(link);
```

The QR code carries the same intent link, so it is valid for the `expiry_time` you set. The customer opens any UPI app, scans the QR code, checks the amount and approves the payment with their UPI PIN.

> [!WARNING]
>
> **Watch Out!**
>
> * Encode the `link` exactly as you receive it. Do not trim it, HTML-escape it or change any parameter in it.
> * Generate a new QR code for every payment. Do not reuse a QR code across payments, as the reference and the amount in it will be wrong.
> * Show the QR code large enough to scan. Intent links are long, so a small or low-resolution QR code may not scan.
> * Use byte or UTF-8 encoding mode in your QR code library, as the link has characters such as `&`, `=` and `@`.

### Step 4: Verify the Payment Status

The customer is not redirected to your page after the payment. Verify the status of the payment using the following methods:

* [Subscribe to the Webhook events](https://razorpay.com/docs/webhooks/setup-edit-payments.md). Wait for `payment.captured` on success or `payment.failed` on failure.
* As a fallback, poll Razorpay servers for the payments made for the order using our [Fetch Payment APIs](https://razorpay.com/docs/api/orders/fetch-payments.md).

If the customer does not scan the QR code before it expires, the payment fails and you receive the `payment.failed` webhook event. Initiate a new payment and show a new QR code.

#### Test the Integration

Once you have completed the integration, test it using our [test cases for UPI QR](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/test-s2s/one-time/upi-qr.md).

### Related Information

* [UPI Intent](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/payment-methods/upi/intent.md)
* [Identify the UPI Fund Source](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/payment-methods/upi/fund-sources.md)
* [UPI Transaction Limits](https://razorpay.com/docs/payments/payment-methods/transaction-limits/upi.md)
* [Error Codes](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/payment-methods/upi/error-codes.md)
