AgroPulse uses a multi-stage payment pipeline to protect both buyers and farmers. When a buyer pays for an order, funds are not released to the farmer immediately — they are held in escrow until the buyer’s delivery is confirmed. After confirmation, the platform calculates aDocumentation 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.
PaymentSplit and initiates separate payouts to the farmer and the transporter. Every step of this flow involves the Squad payment gateway, which handles checkout, webhook callbacks, and bank transfers.
Initialize payment
When a buyer is ready to pay for aPENDING order, they call:
Payment record linked to the order and calls the Squad API to generate a hosted checkout session. The response includes a checkout_url that the buyer’s client should redirect to or open in a browser.
CARD, TRANSFER, USSD, or VIRTUAL-ACCOUNT).
Webhook callback
After a successful payment, Squad sends a signedPOST request to:
- Sets
payment_statustoSUCCESSon thePaymentrecord - Records the
squad_transaction_idreturned by Squad - Sets
webhook_receivedandwebhook_verifiedtotrue - Advances the linked
Order.order_statusfromPENDINGtoPAID - Creates an
EscrowAccountholding the full payment amount atrelease_status: "HELD"
Verify payment
If a buyer needs to manually confirm whether their payment was captured (for example, after a network timeout during checkout), they can call:squad_transaction_id and reconciles it against the local Payment record. The response reflects the current payment_status.
Escrow
Escrow is enabled by default on all payments (escrow_enabled: true). The EscrowAccount model holds funds on behalf of the farmer until delivery is confirmed.
| Field | Type | Description |
|---|---|---|
amount_held | decimal | Total amount held in escrow |
release_status | enum | Current state: HELD, RELEASED, or DISPUTED |
released_at | datetime | Timestamp of release, set when delivery is confirmed |
HELD through the PROCESSING and IN_TRANSIT order stages. Release is triggered automatically when the transporter calls POST /api/deliveries/{id}/delivery_confirmation/, which sets release_status to RELEASED and records released_at.
To release funds manually (e.g., in a dispute resolution flow):
release_status is set to DISPUTED and funds are held pending resolution.
Payment splits
Immediately after escrow release, AgroPulse creates aPaymentSplit record that divides the total payment into three components:
| Field | Type | Description |
|---|---|---|
farmer_amount | decimal | Amount owed to the farmer for the produce |
rider_amount | decimal | Amount owed to the transporter for delivery |
platform_fee | decimal | AgroPulse’s platform fee retained from the transaction |
farmer_processed and rider_processed are boolean flags that track whether each payout has been initiated. For PICKUP orders, rider_amount is 0.00 and rider_processed is set to true immediately.
Payouts
APayout record is created for each recipient — one for the farmer (payout_type: "FARMER") and, for delivery orders, one for the transporter (payout_type: "RIDER"). Each payout tracks disbursement to the recipient’s virtual account.
Payout statuses
payout_status | Meaning |
|---|---|
PENDING | Payout created, not yet initiated |
PROCESSING | Transfer request sent to Squad |
COMPLETED | Funds successfully disbursed to recipient’s account |
FAILED | Transfer failed; bank_reference may contain error details |
completed_at timestamp is recorded when a payout reaches COMPLETED.
Payment statuses
ThePayment.payment_status field tracks the overall state of the buyer’s payment:
| Status | Meaning |
|---|---|
PENDING | Payment initialized; buyer has not yet completed checkout |
SUCCESS | Squad confirmed payment; escrow is active |
FAILED | Payment attempt was unsuccessful at the gateway |
REFUNDED | Payment was reversed after a cancellation or dispute |
Full payment flow
Buyer initializes payment
POST /api/payments/initialize_payment/ creates a Payment record and returns a checkout_url. payment_status is PENDING.Buyer completes checkout
The buyer pays via the Squad-hosted checkout page using card, USSD, transfer, or virtual account.
Squad sends webhook
Squad calls
POST /api/payments/webhook_callback/. AgroPulse verifies the signature, sets payment_status to SUCCESS, records squad_transaction_id, and creates the EscrowAccount with release_status: "HELD". The order advances to PAID.Farmer processes and transporter delivers
The order moves through
PROCESSING and IN_TRANSIT. Escrow remains HELD throughout this period.Delivery confirmed — escrow released
POST /api/deliveries/{id}/delivery_confirmation/ triggers escrow release (release_status → RELEASED). A PaymentSplit is created, dividing the amount into farmer_amount, rider_amount, and platform_fee.