Integrating a Courier API into an E-Commerce Platform

Booking, tracking and failure handling: connecting a courier API so order status stays accurate end to end.
On Habbits Food, orders are dispatched through the Leopard Courier API. A courier integration looks like one API call, but reliable delivery tracking needs a little more structure.
Book shipments from a job, not the request
When an order is confirmed, enqueue a booking job. If the courier API is slow or down, the customer's checkout still succeeds and the job retries with backoff.
Store the courier's reference
Save the tracking number and the courier's shipment id on the order. Every later status update is matched using these ids.
Tracking updates
- Use status webhooks when the courier offers them.
- Otherwise poll active shipments on a schedule, never on every page view.
- Map courier-specific statuses to your own small set: booked, in_transit, delivered, returned, failed.
Plan for failure
Addresses are wrong, phones are off and parcels come back. Give admins a clear view of failed and returned shipments with the reason, so a human can act quickly.
Keep customers informed
Send a message on booking with the tracking link, and on delivery. Most "where is my order" support tickets disappear once tracking is visible.









