Overview
Creates a new order using a valid checkout token after the customer completes payment. This endpoint validates the checkout session, verifies order details haven’t changed, and creates the order in placed status with pending payment.
Authentication
Requires authentication with JWT token. Available to student and faculty roles.
Endpoint
Request body
The JWT token returned from the checkout session endpoint. Valid for 15 minutes.
The UPI transaction ID from the payment app (8-40 alphanumeric characters). Automatically converted to uppercase.
Response
Indicates if the order was created successfully
Human-readable status message
The created order object Human-readable order number for reference
Unique payment reference starting with CBPAY
Total order amount in rupees
Payment status: pending, success, or failed
Order lifecycle status: placed, accepted, processing, ready, picked_up, or cancelled
Payment method used (e.g., direct_store_upi)
UPI transaction ID if provided
Array of ordered items with name, price, quantity, and total
Customer’s special instructions if provided
Whether customer confirmed they’re on the way (required for users with no-show history)
ISO timestamp when commitment confirmation expires (4 minutes from order creation)
Store details including id, name, location
ISO timestamp when order was created
ISO timestamp when order was last updated
Order lifecycle
After creating an order, the typical flow is:
placed (initial state) - Order created, payment pending
Store verifies payment → accepted
Store starts preparation → processing
Store completes preparation → ready (OTP generated)
Customer provides OTP → picked_up
Orders are automatically cancelled if:
Payment not confirmed within 8 minutes
Customer doesn’t show up within 20 minutes after order is ready
If you submit the same checkout token multiple times, the API returns the existing order instead of creating a duplicate.
Example request
curl -X POST https://api.campusbite.com/api/orders \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"checkoutToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"transactionId": "UPI12345678"
}'
Example response
{
"success" : true ,
"message" : "Order placed. Complete payment and let the store verify before preparation." ,
"data" : {
"id" : "65f7a8b9c1234567890abcde" ,
"orderNumber" : "ORD-20240318-001" ,
"paymentReference" : "CBPAY1A2B3C4D5E" ,
"totalAmount" : 249.50 ,
"paymentStatus" : "pending" ,
"orderStatus" : "placed" ,
"paymentMethod" : "direct_store_upi" ,
"transactionId" : "UPI12345678" ,
"items" : [
{
"menuItemId" : "65f7a8b9c1234567890abcdf" ,
"name" : "Paneer Burger" ,
"price" : 120 ,
"quantity" : 1 ,
"total" : 120
},
{
"menuItemId" : "65f7a8b9c1234567890abce0" ,
"name" : "French Fries" ,
"price" : 80 ,
"quantity" : 1 ,
"total" : 80
},
{
"menuItemId" : "65f7a8b9c1234567890abce1" ,
"name" : "Cold Coffee" ,
"price" : 49.50 ,
"quantity" : 1 ,
"total" : 49.50
}
],
"specialInstructions" : "Extra cheese on the burger please" ,
"isCommitmentConfirmed" : false ,
"commitmentDeadlineAt" : "2024-03-18T14:34:00.000Z" ,
"store" : {
"id" : "65f7a8b9c1234567890abce2" ,
"name" : "Campus Cafe" ,
"location" : "Building A, Ground Floor"
},
"createdAt" : "2024-03-18T14:30:00.000Z" ,
"updatedAt" : "2024-03-18T14:30:00.000Z"
}
}
Error responses
Show 400 - Checkout token required
{
"success" : false ,
"message" : "Checkout token is required."
}
Show 400 - Invalid checkout token
{
"success" : false ,
"message" : "Checkout session expired or invalid. Please retry payment."
}
Show 400 - Invalid transaction ID
{
"success" : false ,
"message" : "UPI transaction ID must be 8-40 alphanumeric characters when provided."
}
Show 403 - User restricted
{
"success" : false ,
"message" : "Ordering is temporarily restricted due to repeated no-shows until Mon Mar 25 2024 14:30:00 GMT+0530."
}
Show 409 - Duplicate transaction ID
{
"success" : false ,
"message" : "This transaction ID is already linked to another order. Please check the ID and try again."
}
{
"success" : false ,
"message" : "Cart details changed during payment. Please retry checkout with updated cart."
}
Trust tier system
CampusBite uses a trust tier system to prevent no-shows:
good : No recent no-shows, can order freely
watch : 2+ no-shows, may require commitment confirmation
restricted : 3+ no-shows, ordering blocked for 14 days
Users with watch or restricted status must call the confirm commitment endpoint after creating an order before the store can accept it.