انتقل إلى المحتوى الرئيسي

Create Order

This API endpoint allows customers to place an order with the e-commerce website. Customers can choose items from the website's catalog, select their preferred delivery method, and complete their purchase.

  • Endpoint: api/customer/orders

  • Http Method: POST

نصيحة

if a user selects pickup from a branch, please ensure that they do not provide an address ID in the request body. To enable pickup from a branch, check the ENABLE_CHECKOUT_PICKUP_FROM_STORE configuration.

  • Request Body:
KeyTypeDescription
address_idintegerThe ID of the address where the order will be delivered.
branch_idintegerThe ID of the branch where the order will be delivered.
payment_methodintegerThe payment method ID that the user wishes to use.
time_slot_idintegerThe time slot ID in which the user wishes to receive the delivery.
verification_codestringA verification code that the customer needs to provide if they don't have a verified phone number on their profile.
نصيحة

If a customer doesn't have a verified phone number on their profile, the API will return a status code of 409, and the customer will need to provide a verification code to proceed with placing the order.

  • Response Status Codes:

    • 200 OK: The order was successfully placed.
    • 202 OK: The order was successfully validated and returned payment url.
    • 401: The user does not have permission to perform the requested action.
    • 409: The customer does not have a verified phone number on their profile.
    • 423: The order validation failed. The response will contain a message parameter describing the reason for the failure.
  • Success Response:

Response example with online payment method
{
"code": 202,
"data": {
"pay_url": "https://docapi.supercommerce.io"
}
}
Order Details Resource

Check the following section to learn more about the Order Details Resource.

Response example with COD method
{
"code": 200,
"data": {
"id": 66777,
"uuid": "2161d544-ed3e-4771-b853-7e3bae3a2bb5",
"user": {
"id": 1017390,
"full_name": "Test Documentation",
"name": "Test Documentation",
"phone": "01111111115",
"is_guest": 0
},
"date": "2023-04-09 11:09:33",
"user_agent": "web",
"phone": "01111111115",
"state": {
"id": 1,
"name": "Placed",
"name_ar": "تم الطلب"
},
"items": [
{
"id": 136160,
"amount": 1,
"sku": "110248",
"name": "Manzanilla Oro Lightening Hair Lotion 180 ml",
"name_ar": "مانزانيلا أورو لوشن لتفتيح الشعر 180 مل",
"image": "https://api.alabdellatif-tarshouby.com/storage/uploads/110248.jpg",
"price": 350,
"discount_price": null,
}
],
"missing_items": [],
"returned_items": [],
"states": [
{
"id": 1,
"name_ar": "تم الطلب",
"name": "Placed"
},
//...
],
"address": {
"id": 49124,
"user_id": 1017390,
"formatted_address_ar": "مبني 10, دور 1, شارع test address, شقة 1, المعادي, القاهرة",
"formatted_address_en": "building 10, floor 1, address test address, apartment 1, Maadi, Cairo",
"district": null,
"area": {
"id": 125,
"name": "Maadi",
//...
},
"city": {
"id": 10,
"name": "Cairo",
"name_ar": "القاهرة",
//...
}
},
"notes": null,
"invoice": {
"id": 63946,
"cod_amount": "0.00",
"cost_amount": null,
"delivery_fees": 0,
"discount": null,
"free_delivery": 0,
"grand_total": 350,
"invoice_number": null,
"invoice_url": null,
"loyalty_discount": 0,
"loyalty_points": null,
"online_paid_amount": 0,
"original_delivery_fees": 0,
"paid_amount": 0,
"promo_id": null,
"qr_code": null,
"tax_amount": 0,
"total_amount": 350,
"wallet_paid_amount": 0,
"total_cash_amount": 350,
"refund_amount": 0,
"total_invoice": 350,
"refunded_online_paid_amount": 0,
"refunded_wallet_amount": 0,
"refunded_loyalty_amount": 0
},
"total": 350,
"item_total": 350,
"item_total_discount": null,
"delivery_fees": 0,
"discount": 0,
"active": true,
"scheduled_at": "2023-04-10 00:00:00",
"schedule": null,
"total_delivery_fees": 0,
"payment_method_object": {
"id": 1,
"name": "Cash On Delivery",
"name_ar": "الدفع عند الاستلام",
"is_online": 0,
"type": 0,
"icon": "https://docapi.supercommerce.io/images/payment_methods/cash_payment.png",
"plans": []
},
"branch": null,
"time_slot_en": "Tomorrow, 10:00 AM - 05:00 PM",
"time_slot_ar": "غدا, 10:00 ص - 05:00 م",
"wallet_paid_amount": 0,
"online_paid_amount": 0,
"loyalty_discount": 0,
"item_total_exc_vat": 350,
"item_total_discount_exc_vat": null,
"returned_invoice": []
}
}
  • Failure Response:
The order validation failed
{
"code": 423,
"message": "The payment method field is required.",
"message_ar": "The payment method field is required.",
"errors": {
"0": "The given data was invalid.",
"message_ar": "The given data was invalid.",
"errorMessage": "Invalid Data",
"errorDetails": {
"payment_method": [
"The payment method field is required."
]
}
},
}
A phone number doesn't verified
{
"code": 409,
"message": "please verify your phone",
"errors": {
"errorMessage": "Invalid data",
"errorDetails": [
{},
{}
]
}
}

Delivery OR Pickup options

When interacting with APIs that involve delivery or pickup options, developers should consider including specific parameters in the API request based on the customer's selection.

  • Get Delivery to Address: If the customer selects the address, it is recommended to include the address_id parameter in the API request. This parameter represents the unique identifier to the customer's selected delivery address.

  • Pickup from Store: If the customer chooses the option to pick up the order from a store or branch, developers should include the branch_id parameter in the API request. This parameter specifies the unique identifier or reference to the selected store or branch from which the customer intends to pick up their order.

معلومات

Check the following section to learn more about the Create Order API Reference