Step 1: Create an order with Cashfree Payments

To integrate with One Click Checkout, the initial step is to create an order with cart_details.

Prerequisites


Create an order

You can create the order using the Create Order API.

Once the order is successfully created, you will receive a payment_session_id. This payment_session_id is essential for proceeding to the checkout page.

ℹ️

It is important to include cart_details in the Create Order API request, as these details are necessary for the One Click Checkout process. They allow customers to review their cart at the time of checkout.

Example

curl --location 'https://sandbox.cashfree.com/pg/orders' \
--header 'x-client-id: TEST430329ae80e0f32e41a393d78b923034' \
--header 'x-client-secret: TESTaf195616268bd6202eeb3bf8dc458956e7192a85' \
--header 'x-api-version: 2022-09-01' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
    "order_amount": 1298,
    "order_currency": "INR",
    "customer_details": {
        "customer_id": "devstudio_user",
        "customer_name": "Harshith",
        "customer_email": "[email protected]",
        "customer_phone": "9876543210"
    },
    "order_meta": {
        "return_url": "https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}"
    },
    "order_note": "Fast_Checkout",
    "cart_details": {
        "cart_items": [
            {
                "item_id": "devstudio_cart_id_1",
                "item_name": "T Shirt",
                "item_description": "Test Description",
                "item_details_url": "https://chriscross.in/cdn/shop/files/95_800x.jpg",
                "item_image_url": "https://chriscross.in/cdn/shop/files/95_800x.jpg",
                "item_original_unit_price": 499,
                "item_discounted_unit_price": 499,
                "item_quantity": 1,
                "item_currency": "INR"
            },
            {
                "item_id": "devstudio_cart_id_2",
                "item_name": "Straight Jeans with forward seams",
                "item_description": "Test Description",
                "item_details_url": "https://shop.mango.com/assets/rcs/pics/static/T6/fotos/S/67001012_TM_B.jpg",
                "item_image_url": "https://shop.mango.com/assets/rcs/pics/static/T6/fotos/S/67001012_TM_B.jpg",
                "item_original_unit_price": 799,
                "item_discounted_unit_price": 799,
                "item_quantity": 1,
                "item_currency": "INR"
            }
        ]
    }
}'

Experience the all-new Cashfree Payments Docs! Faster, smarter, and easier to navigate. Check it out here!🎉