The complete flow
Step 1 — Validate on startup
Before your checkout can work, confirm your API key is active and your merchant pickup address is configured. Call this once on server startup (or when onboarding a new merchant).Step 2 — Capture the customer’s location, then quote
Yonne calculates the delivery fee based on the real distance between your pickup point and the customer’s location. A typed address is not sufficient — you must send precise GPS coordinates (delivery_lat, delivery_lng).
Get the customer’s coordinates first, using the browser Geolocation API on your frontend:
POST /api/v1/external/quote from your server and display the returned delivery_fee and eta on the checkout page.
- Display
delivery_fee(in MWK) andetaon your checkout page. - Store
delivery_feein your checkout session — you’ll pass it unchanged to create-order. - Optionally show
suggested_vehicle_class(“A bike will deliver your order”).
Step 3 — Collect payment
This step happens entirely in your existing payment flow. Yonne is not involved. Ensure the total your payment gateway charges includes thedelivery_fee from the quote. When the payment succeeds, proceed to Step 4.
Never create a Yonne order before the payment is confirmed. Create it in your payment success webhook or confirmation callback, not in the checkout page render.
Step 4 — Create the order (dispatch the rider)
CallPOST /api/v1/external/create-order server-side, immediately after payment is confirmed. The Idempotency-Key header is required — generate it from your internal order ID so retries are safe.
- Save
order_id— use it for cancellations, status checks, and support lookups. - Save
tracking_id— use it in customer-facing tracking links. - Show
tracking_linkon the order confirmation page so the customer can track in real time.
Handling create-order failures
402 Insufficient Funds
- Flag the order internally as
dispatch_failed_insufficient_funds. - Alert your operations team immediately — they need to top up the wallet.
- After topping up, retry create-order with the same
Idempotency-Key. - Do not leave the customer without a response — send them an “order confirmed, we’ll dispatch soon” message.
422 ERR_NO_CAPACITY_AVAILABLE
dispatch_failed_no_capacity and retry later.
Step 5 — Show the customer their tracking link
Aftercreate-order succeeds, surface tracking_link on the order confirmation page:
Integration checklist
Before going live with this flow:-
GET /validateis called on startup andhasPickupis confirmed - Customer location is collected via the browser Geolocation API (or geocoding) before calling
/quote -
delivery_feefrom the quote is passed unchanged into create-order (not recalculated) -
Idempotency-Keyis generated from your internal order ID on every create-order call -
order_idandtracking_idare saved to your database -
402and422errors alert your ops team rather than failing silently - Webhook receiver is live to receive status updates without polling
