3. Confirm Payment
Learn how to return your customers to your website after payment and the ways to check your payment/order status.
Prerequisites
- Make sure you have created Cashfree Account and API keysare generated.
- You have created an order.
- You have included and initialised JS SDK in your client code.
1. Redirect customers back to your page
What is Return url?
Once a payment is completed (either success or failure), Cashfree will redirect the customer to the return_url
mentioned when creating an order. Cashfree accepts return url in this format - https://mywebsite.com?order_id={order_id}
While redirecting back, we replace the the placeholder {order_id}
with the actual order ID.
A create order request json would look like this
{
"order_amount": "10",
"order_id":"sample_123"
"order_currency": "INR",
"customer_details": {
"customer_id": "USER123"
"customer_phone": "+919876543210"
},
"order_meta": {
"return_url": "https://mywebsite.com?order_id={order_id}"
}
}
For the above order, once the payment reaches terminal state, we will redirect the customer to https://mywebsite.com?order_id=sample_123
We recommend you to provide a return URL while creating an order. This will improve the overall user experience by ensuring your customers don’t land on broken or duplicated pages.
If you do not provide any return URL, your customers will be redirected to Cashfree Payments default page.
2. Check order status
You can check the payment/order status through three ways:
In an integration workflow, when the customer gets redirected back to the return_url, you can use the order_id from query params to check the status of the Order either via Webhook or Get Order status API.
GET Order Status API
Sample Request
curl --request GET \
--url https://sandbox.cashfree.com/pg/orders/order_id \
--header 'accept: application/json' \
--header 'x-api-version: 2022-09-01'
You must fetch the order status from your backend as it uses your API secret key.
Sample Response
{
"cf_order_id": 594193729,
"entity": "order",
"order_amount": 1.00
...
"order_status": "PAID",
...
}
In webhooks or API response, order_status
denotes the status of the payment.
Updated 12 months ago