Skip to main content

Overview

Retrieves complete details for a single order. Access is role-based:
  • Customers: Can only view their own orders
  • Store employees: Can only view orders for their store

Authentication

Requires authentication with JWT token. Available to all authenticated users.

Endpoint

GET /api/orders/:id

Path parameters

id
string
required
The unique order ID (MongoDB ObjectId)

Response

success
boolean
Indicates if the request was successful
data
object
Complete order details

Example request

curl -X GET https://api.campusbite.com/api/orders/65f7a8b9c1234567890abcde \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Example response (Customer)

{
  "success": true,
  "data": {
    "id": "65f7a8b9c1234567890abcde",
    "orderNumber": "ORD-20240318-001",
    "paymentReference": "CBPAY1A2B3C4D5E",
    "orderStatus": "ready",
    "paymentStatus": "success",
    "paymentMethod": "direct_store_upi",
    "transactionId": "UPI12345678",
    "totalAmount": 249.50,
    "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": true,
    "commitmentConfirmedAt": "2024-03-18T14:32:00.000Z",
    "commitmentDeadlineAt": null,
    "readyAt": "2024-03-18T14:45:00.000Z",
    "readyExpiresAt": "2024-03-18T15:05:00.000Z",
    "isOtpVerified": false,
    "store": {
      "id": "65f7a8b9c1234567890abce2",
      "name": "Campus Cafe",
      "location": "Building A, Ground Floor",
      "description": "Your favorite campus hangout spot",
      "phoneNumber": "+919123456789",
      "upiId": "campuscafe@paytm",
      "isActive": true
    },
    "createdAt": "2024-03-18T14:30:00.000Z",
    "updatedAt": "2024-03-18T14:45:00.000Z"
  }
}

Example response (Store Employee)

{
  "success": true,
  "data": {
    "id": "65f7a8b9c1234567890abcde",
    "orderNumber": "ORD-20240318-001",
    "paymentReference": "CBPAY1A2B3C4D5E",
    "orderStatus": "placed",
    "paymentStatus": "pending",
    "paymentMethod": "direct_store_upi",
    "transactionId": "UPI12345678",
    "totalAmount": 249.50,
    "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",
    "customer": {
      "id": "65f7a8b9c1234567890abce6",
      "name": "Rahul Sharma",
      "email": "[email protected]",
      "phoneNumber": "+919876543210",
      "role": "student",
      "registerNumber": "21CS001"
    },
    "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

Order status meanings

  • placed: Order created, awaiting payment verification
  • accepted: Payment confirmed, awaiting preparation
  • processing: Order is being prepared by the store
  • ready: Order is ready for pickup, OTP generated
  • picked_up: Order collected by customer
  • cancelled: Order cancelled due to payment failure, timeout, or no-show
When an order reaches ready status, a 6-digit OTP is generated and sent to the customer. The store must verify this OTP when the customer arrives to collect the order.

Build docs developers (and LLMs) love