The Orders API handles the full order lifecycle from placement through payment verification and status updates. Orders are created when a customer checks out, linked to a Stripe Checkout session, and tracked through three sequential statuses: Food Processing → Out for delivery → Delivered. The order document also carries aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/bhavnesh7781/Food-Delivery-App/llms.txt
Use this file to discover all available pages before exploring further.
payment boolean that is set to true only after a successful Stripe payment callback.
POST /api/order/place
Places a new order for the authenticated user. The controller saves the order to MongoDB, clears the user’s cart, builds a Stripe Checkout session from the supplied items plus a fixed ₹2 delivery charge, and returns the hosted Stripe session URL. The client should redirect the user to that URL to complete payment.The
amount field is stored in MongoDB exactly as supplied. The controller independently adds a ₹2 delivery charge as a separate Stripe line item — you do not need to include it in amount. Typically the frontend sends the sum of (item.price × item.quantity) for all items.Request Headers
A valid JWT token issued at login.
userId is injected by the auth middleware.Request Body
Array of cart items to order. Each element must include:
Total order amount in INR. This value is stored as-is in MongoDB. The ₹2 delivery charge is added to the Stripe session separately and does not need to be included here.
Delivery address for the order.
Response
true when the order was created and the Stripe session was generated.The full Stripe-hosted Checkout URL. Redirect the user here to complete payment (e.g.,
"https://checkout.stripe.com/c/pay/cs_test_...").Example
POST /api/order/verify
Called by the frontend after Stripe redirects back to the application. Stripe appendssuccess=true or success=false plus the orderId to the redirect URL; the frontend extracts these and posts them here.
- If
successis"true"— the order’spaymentfield is set totrue. - If
successis"false"— the order document is permanently deleted from MongoDB.
Request Body
The MongoDB
_id of the order to verify, returned by /api/order/place.String
"true" (payment succeeded) or "false" (payment cancelled or failed). Note this is a string, not a boolean, as it comes directly from the Stripe redirect query parameter.Response
true when payment was confirmed; false when the order was not paid."Paid" on successful payment, "Not Paid" when payment failed or was cancelled.Example
POST /api/order/userorders
Fetches all orders belonging to the authenticated user. Used by the “My Orders” page on the frontend to display order history and current status.Request Headers
A valid JWT token.
userId is injected by the auth middleware.Request Body
Send an empty JSON object.Response
true when orders were fetched successfully.Array of order documents for the authenticated user.
Example
GET /api/order/list
Returns every order in the system, regardless of user. Intended for the admin panel to display and manage all incoming orders.Response
true when the order list was fetched successfully.Array of all order documents across all users. Each object has the same fields as described in POST /api/order/userorders.
Example
POST /api/order/status
Updates the status field of a specific order. Used by the admin panel to progress an order through the delivery pipeline.Request Body
The MongoDB
_id of the order to update.The new status value. Should be one of:
"Food Processing"— order received, kitchen is preparing"Out for delivery"— order dispatched to the customer"Delivered"— order successfully delivered
Response
true when the status was updated successfully."Status Updated" on success, "Error" on failure.Example
Order Status Lifecycle
Every order begins in the Food Processing state the moment it is created. An admin uses the/api/order/status endpoint to advance it through the pipeline. The three states flow in sequence:
| Stage | Meaning |
|---|---|
| Food Processing | Default state. The kitchen has received the order and is preparing it. |
| Out for delivery | The order has been packed and dispatched to the delivery agent. |
| Delivered | The order has been successfully handed to the customer. |