Skip to main content

Create Order

curl -X POST https://your-domain.com/api/cliente/pedidos \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "empresa_id": 3,
    "hora_recogida": "14:30"
  }'
Creates a new order from the cart items for a specific business. The order is created in pending payment status.

Headers

Authorization
string
required
Bearer token for authentication

Body Parameters

empresa_id
integer
required
ID of the business to create the order for
hora_recogida
string
required
Pickup time in HH:mm format (e.g., “14:30”)

Response

message
string
Success message: “Pedido generado pendiente de pago.”
pedido
object
Created order object

Error Responses

message
string
Error message when:
  • Cart is empty (400)
  • No products from specified business in cart (422)
  • Insufficient stock for a product (422)
  • Already has a pending unpaid order (200 with existing order)

Get My Orders

curl -X GET https://your-domain.com/api/cliente/mis-pedidos \
  -H "Authorization: Bearer {token}" \
  -H "Accept: application/json"
Retrieves all orders for the authenticated customer, ordered by most recent first.

Headers

Authorization
string
required
Bearer token for authentication

Response

pedidos
array
Array of order objects

Cancel Order

curl -X POST https://your-domain.com/api/cliente/pedidos/12/cancelar \
  -H "Authorization: Bearer {token}" \
  -H "Accept: application/json"
Cancels a pending order. If the order was already paid, stock is returned to inventory.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

id
integer
required
ID of the order to cancel

Response

message
string
Success message: “Pedido cancelado y stock devuelto”

Error Responses

message
string
Error message when:
  • Order not found or doesn’t belong to user (404)
  • Order is not in “Pendiente” status (400)

Pay for Order

curl -X POST https://your-domain.com/api/cliente/pedidos/12/pagar \
  -H "Authorization: Bearer {token}" \
  -H "Accept: application/json"
Initiates payment process for an order through Mercado Pago.

Headers

Authorization
string
required
Bearer token for authentication

Path Parameters

id
integer
required
ID of the order to pay for

Response

init_point
string
Mercado Pago checkout URL to redirect the user

Error Responses

message
string
Error message when:
  • Not authorized to pay this order (403)
  • Order already paid (400)
After payment is processed, Mercado Pago will send a webhook notification to /api/webhook/mercadopago to update the order status.

Build docs developers (and LLMs) love