Choose a QR code type
Cashfree offers three types of UPI QR code. The following table compares them:Static QR codes
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 or a POD QR code. To get static QR codes for your stores or agents, use Offline Payments. Field agents can also show static QR codes from the Cashfree softPOS app.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.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.
- Create an order with the Create Order API to get a
payment_session_id. - Call the Order Pay API with the
payment_session_idand setpayment_method.upi.channeltoqrcode. - Display the base64-encoded image from
data.payload.qrcodeto your customer. - Wait for the payment webhook, and then confirm the final status before you fulfil the order.
Request
Send the request toPOST /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:
Response
The following table describes the response fields that you use for QR codes:
If the request fails, the API returns an error object with
message, code, and type. For all error codes, see the Order Pay API reference.
The following example requests a dynamic QR code:
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 withtransaction_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.
- 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 as you would for a dynamic QR code, and setpayment_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.
Request body
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
SUCCESSand the orderPAID. - 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:- Create an order with your sandbox keys, and call the Order Pay API with
payment_method.upi.channelset toqrcodeorpodQrCode. - Copy the
cf_payment_idfrom the response. - Call the Simulate Payment API with
entityset toPAYMENTS,entity_idset to thecf_payment_id, andentity_simulation.payment_statusset to the outcome you want to test:SUCCESS,FAILED,PENDING, orUSER_DROPPED. - Check that your integration handles the simulated status correctly.