Skip to main content

List Business Orders

Retrieves all paid orders received by the authenticated business.

Headers

Authorization
string
required
Bearer token from authentication

Response

[].id
integer
Order ID
[].user_id
integer
Customer user ID
[].empresa_id
integer
Business ID
[].estado
string
Order status: “Pendiente”, “Preparando”, “Listo”, “Entregado”, “Cancelado”
[].estado_pago
string
Payment status: “pendiente”, “aprobado”, “rechazado”
[].hora_recogida
string
Pickup time in HH:MM format
[].total
float
Order total amount
[].created_at
string
Order creation date and time
[].updated_at
string
Last update timestamp
[].cliente
object
Customer information
[].productos
array
Array of products in the order

Filtering

This endpoint only returns orders where estado_pago = "aprobado". Unpaid orders are not shown to businesses.

Error Responses

404 Not Found - User has no associated business
{
  "message": "No tienes empresa asociada."
}

Example Request

curl -X GET https://api.beanquick.com/api/empresa/pedidos \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Example Response

[
  {
    "id": 42,
    "user_id": 15,
    "empresa_id": 5,
    "estado": "Preparando",
    "estado_pago": "aprobado",
    "hora_recogida": "14:30",
    "total": 85.50,
    "created_at": "05/03/2024 10:15",
    "updated_at": "2024-03-05T10:20:00.000000Z",
    "cliente": {
      "id": 15,
      "name": "María González"
    },
    "productos": [
      {
        "id": 8,
        "nombre": "Café Americano",
        "precio": 15.50,
        "imagen_url": "https://api.beanquick.com/storage/productos/americano.jpg",
        "pivot": {
          "pedido_id": 42,
          "producto_id": 8,
          "cantidad": 2,
          "precio_unitario": 15.50
        }
      },
      {
        "id": 12,
        "nombre": "Croissant",
        "precio": 12.00,
        "imagen_url": "https://api.beanquick.com/storage/productos/croissant.jpg",
        "pivot": {
          "pedido_id": 42,
          "producto_id": 12,
          "cantidad": 3,
          "precio_unitario": 12.00
        }
      }
    ]
  }
]

Update Order Status

Updates the status of an order. Only works for paid orders (estado_pago = "aprobado").

Headers

Authorization
string
required
Bearer token from authentication
Content-Type
string
required
application/json

Path Parameters

id
integer
required
Order ID to update

Body Parameters

estado
string
required
New order status. Must be one of:
  • Preparando - Order is being prepared
  • Listo - Order is ready for pickup
  • Entregado - Order has been delivered/picked up
  • Cancelado - Order was cancelled

Response

message
string
“Estado actualizado con éxito”
pedido
object
Updated order object with same structure as GET response

Error Responses

400 Bad Request - Cannot modify unpaid order
{
  "message": "No puedes modificar un pedido que no ha sido pagado."
}
404 Not Found - Order not found 422 Unprocessable Entity - Validation error for invalid status value 500 Internal Server Error - Server error

Example Request

curl -X PATCH https://api.beanquick.com/api/empresa/pedidos/42/estado \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "estado": "Listo"
  }'

Example Response

{
  "message": "Estado actualizado con éxito",
  "pedido": {
    "id": 42,
    "user_id": 15,
    "empresa_id": 5,
    "estado": "Listo",
    "estado_pago": "aprobado",
    "hora_recogida": "14:30",
    "total": 85.50,
    "created_at": "05/03/2024 10:15",
    "updated_at": "2024-03-05T10:45:00.000000Z"
  }
}

Order Status Workflow

Orders typically follow this status progression:
  1. Pendiente - Initial state when order is created (before payment)
  2. Preparando - Business is preparing the order (after payment approved)
  3. Listo - Order is ready for customer pickup
  4. Entregado - Customer has picked up the order
  5. Cancelado - Order was cancelled (by customer or business)

Payment States

  • pendiente - Payment not yet processed
  • aprobado - Payment confirmed (order appears in business panel)
  • rechazado - Payment failed or cancelled

Important Notes

  • Only orders with estado_pago = "aprobado" can have their status modified
  • Stock is deducted when payment is approved, not when order is created
  • Cancelled orders restore stock only if they were previously paid
  • Status values are case-insensitive but stored with first letter capitalized

Build docs developers (and LLMs) love