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
string
required
A valid JWT token issued at login.
userId is injected by the auth middleware.Request Body
array
required
Array of cart items to order. Each element must include:
number
required
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.
object
required
Delivery address for the order.
Response
boolean
true when the order was created and the Stripe session was generated.string
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
string
required
The MongoDB
_id of the order to verify, returned by /api/order/place.string
required
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
boolean
true when payment was confirmed; false when the order was not paid.string
"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
string
required
A valid JWT token.
userId is injected by the auth middleware.Request Body
Send an empty JSON object.Response
boolean
true when orders were fetched successfully.array
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
boolean
true when the order list was fetched successfully.array
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
string
required
The MongoDB
_id of the order to update.string
required
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
boolean
true when the status was updated successfully.string
"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: