2. Create an Order
To process any payment on Cashfree PG, the merchant needs to create an order in the cashfree system.
Order creation must happen from your backend (as this API uses your secret key). Please do not call this directly from your mobile application.
Production -> https://api.cashfree.com/pg/orders
Sandbox -> https://sandbox.cashfree.com/pg/orders
Note:
Please see the description of the request below.
Order creation API
curl -XPOST -H 'Content-Type: application/json'
-H 'x-client-id: "YOUR APP ID GOES HERE"'
-H 'x-client-secret: "YOUR SECRET KEY GOES HERE'
-H 'x-api-version: "2022-09-01"'
-H 'x-request-id: "developer_name"'
-d '{
"order_amount": 1.00,
"order_id": "order_id"
"order_currency": "INR",
"customer_details": {
"customer_id": "customer_id",
"customer_name": "customer_name",
"customer_email": "customer_email",
"customer_phone": "customer_phone"
},
"order_meta": {
"notify_url": "https://test.cashfree.com"
},
"order_note": "some order note here",
}' 'https://sandbox.cashfree.com/pg/orders'
{
"cf_order_id": 514853406,
"order_id": "order_id",
"entity": "order",
"order_currency": "INR",
"order_amount": 1.00,
"order_expiry_time": "2021-08-22T13:09:23+05:30",
"customer_details": {
"customer_id": "customer_id",
"customer_name": "customer_name",
"customer_email": "customer_email",
"customer_phone": "customer_phone"
},
"order_meta": {
"return_url": "https://test.cashfree.com"
"notify_url": "https://test.cashfree.com"
"payment_methods": null
},
"settlements": {
"url": "settlements_url"
},
"payments": {
"url": "payments_url"
},
"refunds": {
"url": "refunds_url"
},
"order_status": "ACTIVE",
"order_token": null
"order_note": "some order note here",
"payment_link": null,
"payment_session_id": "session_V7z6rNXpYJxPfRkozFQ7MpL12nzrpSjS4qWcAHA19OWJHzA3I9vZiawsnN1JCrKzpb_1s-pZkxExeDb15UA9TVcz60IJuVecBQbv_LqbRVBh", // This is the payment_session_id that has to be sent to the SDK
}
If the order creation is successful you will receive a 200 response and the order entity in response. This order entity contains relevant details for the order.
We recommend that you store the following parameters at your end order_id
, cf_order_id
, payment_session_id
, and the order_status
.
Note:
The payment_session_id
contains all the order details and has to be sent to the SDK while initiating the payment.
Please refer our Order Creation for more details regarding parameters and more.
Updated 12 months ago