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

# Accept Payments with UPI QR Codes

> Compare static, dynamic, and pay-on-delivery (POD) UPI QR codes on Cashfree, and generate dynamic and POD QR codes with the Order Pay API.

A UPI QR code lets your customer pay by scanning a code with any UPI app. Cashfree QR codes follow the UPI QR standards, so any UPI app can read them.

## Choose a QR code type

Cashfree offers three types of UPI QR code. The following table compares them:

| Attribute | Static QR code | Dynamic QR code | Pay-on-delivery (POD) QR code |
| :- | :- | :- | :- |
| **Amount** | The customer types it. | Fixed in the code. | Fixed in the code. |
| **Use** | Many payments | One payment | One order, with repeated attempts allowed |
| **Validity** | Permanent | The transaction time limit set in your Merchant Dashboard, from 10 minutes to 24 hours (see [Configure order expiry time and TTL](https://www.cashfree.com/docs/payments/online/resources/payment-lifecycle.md#configure-order-expiry-time-and-ttl)), or the `transaction_expiry_time` you set, from 5 minutes to 5 days | 30 days by default, or a time to live (TTL) that Cashfree sets for your account on request |
| **Order matching** | Manual | Automatic, by order ID | Automatic, by order ID |
| **Use for** | A fixed counter or store with no website or app | Desktop checkout, kiosks, and point-of-sale systems | Deliveries, printed bills, and invoices sent ahead of payment |

## Static QR codes

<video autoPlay muted loop playsInline src="https://mintcdn.com/cashfreepayments-d00050e9/9Qy97XLzTQmWw4tu/static/payments/upi/upi-qr-code-flow.mp4?fit=max&auto=format&n=9Qy97XLzTQmWw4tu&q=85&s=352695de1db3b1ac4d87e84bafdd62c3" type="video/mp4" />

A static QR code is a fixed image that encodes only your UPI ID and business details. Your customer scans it, types the amount, and enters their UPI PIN.

Because a static QR code carries no order ID, you can't match a payment to an order automatically. You confirm payments through transaction reports or notifications instead. Use a static QR code only when you can't generate a code for each order, such as at a counter with no website or app. If you sell online, deliver, or invoice remotely, use a [dynamic QR code](#dynamic-qr-codes) or a [POD QR code](#pay-on-delivery-pod-qr-codes).

To get static QR codes for your stores or agents, use [Offline Payments](https://www.cashfree.com/docs/payments/softpos/introduction.md). Field agents can also show static QR codes from the [Cashfree softPOS app](https://www.cashfree.com/docs/payments/softpos/agent-collection-mode.md).

## Dynamic QR codes

A dynamic QR code is generated for one payment. It encodes your UPI ID, the exact amount, and a unique reference for the order. Your customer scans the code and enters their UPI PIN. They can't change the amount. The payment webhook identifies the order that the payment belongs to.

> [!NOTE]
>
> Generating QR codes through the Order Pay API requires server-to-server (S2S) payments to be enabled for your account. To enable it, fill out the [Support Form](https://merchant.cashfree.com/merchants/landing?env=prod\&raise_issue=1).

To generate a dynamic QR code, complete the following steps:

1. Create an order with the [Create Order API](https://www.cashfree.com/docs/api-reference/payments/latest/orders/create-order.md) to get a `payment_session_id`.
2. Call the [Order Pay API](https://www.cashfree.com/docs/api-reference/payments/latest/payments/order-pay.md) with the `payment_session_id` and set `payment_method.upi.channel` to `qrcode`.
3. Display the base64-encoded image from `data.payload.qrcode` to your customer.
4. Wait for the payment webhook, and then confirm the final status before you fulfil the order.

### Request

Send the request to `POST /pg/orders/sessions`. Use `https://sandbox.cashfree.com/pg` for testing and `https://api.cashfree.com/pg` for production. This API authenticates with the `payment_session_id`, so it doesn't need your client ID and secret. Pass the `x-api-version` header with the API version you use.

The following table describes the request parameters for a QR code:

| Parameter | Type | Required | Description |
| :- | :- | :- | :- |
| `payment_session_id` | string | Yes | The session ID returned by the Create Order API. |
| `payment_method.upi.channel` | string | Yes | Set to `qrcode` for a dynamic QR code, or `podQrCode` for a [POD QR code](#pay-on-delivery-pod-qr-codes). |
| `transaction_expiry_time` | string (ISO 8601) | No | The latest time by which the payment attempt must reach a final state. After this time, the payment can't be completed. Cashfree checks the payment status with the bank, and if the bank returns no result, Cashfree marks the payment `USER_DROPPED`. Timestamps are stored in IST, for example `2021-07-02T10:20:12+05:30`. A UTC value appears as `2021-07-02T10:20:12Z`. This value overrides the default validity of the QR code: the transaction time limit set in your Merchant Dashboard for a dynamic QR code, or the TTL for a POD QR code. For a dynamic QR code, set it from 5 minutes to 5 days from now. For a POD QR code, you can't set it later than the TTL. It applies to one transaction, which is one Order Pay call and the QR code that it returns. |

### Response

The following table describes the response fields that you use for QR codes:

| Field | Type | Description |
| :- | :- | :- |
| `cf_payment_id` | string | Cashfree's identifier for the payment attempt. |
| `action` | string | Returns `custom`, which means your checkout must display the QR code itself. |
| `channel` | string | Returns the channel you requested. |
| `data.payload.qrcode` | string | The QR code as a base64-encoded PNG image. |

If the request fails, the API returns an error object with `message`, `code`, and `type`. For all error codes, see the [Order Pay API](https://www.cashfree.com/docs/api-reference/payments/latest/payments/order-pay.md) reference.

The following example requests a dynamic QR code:

```bash Request theme={"dark"}
curl --request POST \
  --url https://sandbox.cashfree.com/pg/orders/sessions \
  --header 'Content-Type: application/json' \
  --header 'x-api-version: 2026-01-01' \
  --data '{
    "payment_session_id": "<PAYMENT_SESSION_ID>",
    "payment_method": {
      "upi": {
        "channel": "qrcode"
      }
    }
  }'
```

```json Success response theme={"dark"}
{
  "action": "custom",
  "cf_payment_id": "<CF_PAYMENT_ID>",
  "channel": "qrcode",
  "payment_method": "upi",
  "payment_amount": 100,
  "data": {
    "url": null,
    "payload": {
      "qrcode": "data:image/png;base64,<BASE64_QR_IMAGE>"
    },
    "content_type": null,
    "method": null
  }
}
```

```json Error response theme={"dark"}
{
  "message": "<ERROR_MESSAGE>",
  "code": "request_failed",
  "type": "invalid_request_error"
}
```

> [!WARNING]
>
> This example is untested, illustrative, and abbreviated. Check the [Order Pay API](https://www.cashfree.com/docs/api-reference/payments/latest/payments/order-pay.md) reference for the current response schema.

## Pay-on-delivery (POD) QR codes

A pay-on-delivery (POD) QR code is a UPI QR code for payments that happen later than the moment you create the code. Examples include a delivery invoice, a printed restaurant bill, or an invoice sent over WhatsApp before collection.

A standard dynamic QR code doesn't suit these cases. It expires after the transaction time limit set in your Merchant Dashboard, or at most 5 days with `transaction_expiry_time`, and a failed attempt ends the transaction, so you must issue a new code. A POD QR code handles both cases:

* **Repeated attempts**: The same code keeps working until it expires, so you don't need to generate a new one after a failed attempt.
* **Longer validity**: The TTL is 30 days by default. Cashfree sets a different TTL for your account on request, from a few hours to more than 30 days. To request it, fill out the [Support Form](https://merchant.cashfree.com/merchants/landing?env=prod\&raise_issue=1).
* **Status confirmed at the right time**: Failed attempts within the TTL don't fail the order, so a customer who pays late isn't recorded as a failure.

### Generate a POD QR code

To generate a POD QR code, call the [Order Pay API](https://www.cashfree.com/docs/api-reference/payments/latest/payments/order-pay.md) as you would for a dynamic QR code, and set `payment_method.upi.channel` to `podQrCode`. The response follows the same shape as a dynamic QR code response, with the base64-encoded image in `data.payload.qrcode`. Print the image on a bill or invoice, or share it digitally. For the success and error response formats, see the [dynamic QR code example](#dynamic-qr-codes).

```json Request body theme={"dark"}
{
  "payment_session_id": "<PAYMENT_SESSION_ID>",
  "payment_method": {
    "upi": {
      "channel": "podQrCode"
    }
  }
}
```

### How Cashfree decides the final status

A POD QR code order moves to its final status in the following ways:

* **During the TTL**: Cashfree ignores failed attempts. As soon as a valid payment arrives, Cashfree marks the payment `SUCCESS` and the order `PAID`.
* **When the TTL expires without a payment**: Cashfree marks the payment `USER_DROPPED`.

## Test QR code payments

To test a QR code payment in the sandbox environment, complete the following steps:

1. Create an order with your sandbox keys, and call the Order Pay API with `payment_method.upi.channel` set to `qrcode` or `podQrCode`.
2. Copy the `cf_payment_id` from the response.
3. Call the [Simulate Payment API](https://www.cashfree.com/docs/api-reference/payments/latest/simulation/simulate-payment.md) with `entity` set to `PAYMENTS`, `entity_id` set to the `cf_payment_id`, and `entity_simulation.payment_status` set to the outcome you want to test: `SUCCESS`, `FAILED`, `PENDING`, or `USER_DROPPED`.
4. Check that your integration handles the simulated status correctly.

For other sandbox test data, see [Sandbox environment](https://www.cashfree.com/docs/payments/online/resources/sandbox-environment.md).

Related topics

<ul>
  <li>[Order Pay API](https://www.cashfree.com/docs/api-reference/payments/latest/payments/order-pay.md)</li>
  <li>[Create Order API](https://www.cashfree.com/docs/api-reference/payments/latest/orders/create-order.md)</li>
  <li>[Offline Payments](https://www.cashfree.com/docs/payments/softpos/introduction.md)</li>
</ul>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.