3. Confirm Payment

3. Confirm Payment

Learn how to return your customers to your website after payment and the ways to check your payment/order status.

Prerequisites

  1. Make sure you have created Cashfree Account and API keysare generated.
  2. You have created an order.
  3. 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.

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=sample_123"
  }

}

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. Also, remember to add context of order_id in your return url so that you can identify the order for which we have hit to your return url.

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: 2023-08-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.


What’s Next