Prerequisites
Ensure the following are in place before you start the sandbox flow:- Use the sandbox base URL:
https://sandbox.cashfree.com/pg. - Send a supported API version in
x-api-version(for example,2025-01-01), consistent with your integration. - Use
x-client-idandx-client-secretto authenticate calls to the Create Order API and the Preauthorisation API. The Order Pay API does not require these headers. You can call it directly from the client.
Preauthorisation flow
Complete a preauthorisation transaction in the sandbox by following the three stages below.Create an order
For sandbox preauthorisation testing, setorder_note to preauth_transaction in your Create Order API request. If this value is missing or incorrect, Cashfree may not recognise the order as a sandbox preauthorisation transaction.
CURL
order_id and payment_session_id from the response. You will need both values for the Order Pay API.
order_tags, order_meta, and customer fields follow the usual Create Order API rules. Use a valid notify_url if you rely on Payment Webhooks for payment status.Initiate payment with Order Pay API
Send the Order Pay API request (POST /orders/sessions) with the payment_session_id from the Create Order API. Set channel to link so the response returns a redirect URL for the customer.
Card payments (link channel)
Use the following request to initiate a card preauthorisation payment. Replace the placeholder card details with values from the Data to Test Integration page.CURL
data.url (when action is link) to complete the payment in the browser.
UPI payments (link channel)
For UPI preauthorisation, setauthorize_only to true and pass an authorization object with the following fields:
| Field | Description |
|---|---|
approve_by | The deadline by which the customer must approve the request (ISO 8601 with offset, for example 2025-12-20T19:20:12+05:30). |
start_time | The time at which the hold or mandate window starts (ISO 8601, UTC Z allowed). |
end_time | The time until which the hold applies (ISO 8601). You can capture or void using the Preauthorisation API while the authorisation is valid, subject to Preauthorisation product rules. |
CURL
Capture or void the payment
Once you simulate the payment as successfully authorised in sandbox, call the Preauthorisation API (POST /orders/{order_id}/authorization) with the same order_id you received when you created the order. Use either action below depending on whether you want to collect or release the funds:
amount as a number or as a decimal string such as "100.00". The amount must not exceed the authorised order amount. Cashfree supports partial capture. A void request does not require an amount.
You can capture or void each authorisation only once. For business rules such as time limits, refer to Preauthorisation.
Go live
The sandbox flow above and the production flow use the same APIs. Two things change when you go live:- Base URL: Replace
https://sandbox.cashfree.com/pgwithhttps://api.cashfree.com/pg. order_note: The valuepreauth_transactionis a sandbox-only flag that tells Cashfree to treat the order as a preauth test. In production,order_notefollows your account configuration. Check with your integration or support. Contact if you already use this field for other purposes.
Best practices
Follow these practices when integrating preauthorisation in sandbox and production:-
Confirm authorisation before capturing or voiding: Do not call capture or void based on a client-side redirect alone. Set
order_meta.notify_urlin the Create Order API and wait for the authorisation-success event via Payment Webhooks on your server before you proceed. -
Use idempotency keys for capture and void requests: Each authorisation can be captured or voided only once. If a network error leaves the outcome uncertain, resend the same request with the
x-idempotency-keyheader so Cashfree returns the original result instead of rejecting a duplicate. Refer to API Best Practices for usage details. - Capture within the time limit: If you do not capture or void an authorisation within seven days, the hold expires and the funds are released to the customer automatically. Build a reminder or scheduled job so authorised orders do not go unresolved. Refer to Preauthorisation for the full set of timing rules.