Every order in AgroPulse follows a defined state machine. When a buyer places an order, it starts asDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/OluwagbeminiyiA/agro_pulse-API/llms.txt
Use this file to discover all available pages before exploring further.
PENDING and progresses through payment, fulfillment, and delivery before reaching COMPLETED. Each transition is driven by a specific API action — no state can be skipped, and any order can be moved to CANCELLED if the transaction cannot continue. Understanding this lifecycle is essential for integrating correctly with the orders, payments, and deliveries APIs.
Order statuses
Theorder_status field on the Order model can hold one of the following values:
| Status | Meaning |
|---|---|
PENDING | Order has been placed but payment has not been received |
PAID | Payment confirmed by Squad; escrow is active |
PROCESSING | Farmer has accepted the order and is preparing it |
IN_TRANSIT | A transporter has picked up the order and is en route |
COMPLETED | Delivery confirmed; escrow funds released |
CANCELLED | Order was cancelled at any point before completion |
Delivery types
Thedelivery_type field determines whether a transporter is involved:
| Value | Meaning |
|---|---|
PICKUP | Buyer collects the order directly from the farm — no transporter is assigned |
DELIVERY | A transporter is assigned to collect from the farm and deliver to the buyer |
PICKUP orders skip rider assignment, the IN_TRANSIT transition, and all transporter payout steps. After the farmer marks the order as PROCESSING, the buyer collecting in person triggers COMPLETED directly.Full order flow
Buyer places an order (PENDING)
The buyer sends a
POST /api/orders/ request specifying the farmer, produce items, quantities, and delivery_type. The order is created with order_status: "PENDING" and a total calculated from the OrderItem subtotals.Buyer initializes and completes payment (PENDING → PAID)
The buyer calls
POST /api/payments/initialize_payment/ with the order ID. The API creates a Payment record and contacts Squad to generate a checkout_url. The buyer is redirected to Squad’s hosted checkout to complete payment.Once payment is captured, Squad sends a webhook to POST /api/payments/webhook_callback/. The API verifies the payload, sets payment_status to SUCCESS, and advances order_status to PAID. An EscrowAccount is created simultaneously, holding the funds at release_status: "HELD".Payment status can also be checked manually:Farmer processes the order (PAID → PROCESSING)
The farmer reviews their incoming orders and accepts the one that has reached
PAID. They update the order status via:order_status advances to PROCESSING, signalling to the platform that fulfillment has begun.Transporter picks up and starts delivery (PROCESSING → IN_TRANSIT)
(DELIVERY orders only)A transporter is assigned to the order. Once they pick up the goods from the farm, they call:This sets the
Delivery record’s delivery_status to IN_TRANSIT and advances order_status to IN_TRANSIT. The picked_up_at timestamp is recorded on the Delivery.Delivery confirmed and order completed (IN_TRANSIT → COMPLETED)
When the goods are delivered, the transporter (or system) confirms delivery:This sets
delivery_status to DELIVERED, records delivered_at, and advances order_status to COMPLETED. The escrow is released (release_status → RELEASED), a PaymentSplit record is created, and Payout records are queued for the farmer and rider.Cancellation
An order can be cancelled from any status beforeCOMPLETED using:
PAID and escrow is active, the escrow release_status moves to DISPUTED pending resolution. Refund handling should be managed separately.
Key endpoints by stage
| Stage | Endpoint | Actor |
|---|---|---|
| Place order | POST /api/orders/ | Buyer |
| Initialize payment | POST /api/payments/initialize_payment/ | Buyer |
| Webhook callback | POST /api/payments/webhook_callback/ | Squad (system) |
| Verify payment | POST /api/payments/{id}/verify_payment/ | Buyer |
| Process order | PATCH /api/orders/{id}/update_status/ | Farmer |
| Start transit | POST /api/deliveries/{id}/start_transit/ | Transporter |
| Confirm delivery | POST /api/deliveries/{id}/delivery_confirmation/ | Transporter |
| Cancel order | PATCH /api/orders/{id}/update_status/ | Buyer or Farmer |