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-01-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": "W8zVBhADaw2EDP7crdyM", // This is the order_token that has to be sent to the SDK
    "order_note": "some order note here",
    "payment_link": "https://cashfree.com/pgbillpaywebapp/#W8zVBhADaw2EDP7crdyM" // This link opens the payment page provided by Cashfree
}

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 , order_token, and the order_status.

Note: The order_token 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.


Did this page help you?