Sifr Wahid Developers

Architecture (HLD)

Order sync

The flow from the store to your system: a signed webhook tells you at once, you read the full order, send status back, and an hourly poll closes any gap.

Sifr Wahid Your receiver Worker and ERP 1. The event POST order.created X-Zo-Event, X-Zo-Delivery, X-Zo-Timestamp, X-Zo-Signature verify the v2 signature on the raw body; drop a duplicate X-Zo-Delivery; queue the work 2xx at once, within 15 seconds the order id (data.id), in the background 2. Read and write GET /orders/{id} 200: lines, amounts in halalas, status, payment method write the order into the ERP 3. Status back to the store POST /orders/{id}/status {"status":"ready"} POST /orders/{id}/shipments Idempotency-Key a move not allowed: 422 invalid_transition 4. Every hour: the polling fallback GET /orders?updated_since={largest updated_at} &per_page=100 200: data + meta.next_cursor same query + cursor={next_cursor}, until null store by id (upsert): the last second repeats
The receiver only verifies, de-duplicates and answers; a worker reads the full order and writes it into the ERP. The hourly poll reads every order changed since the largest updated_at you kept, page by page.

The steps

  1. Events

    Subscribe to order.created and order.status.updated. On each delivery: verify the signature, drop duplicates by X-Zo-Delivery, answer 2xx at once, then do the work in the background.

  2. Details

    GET /orders/{id} with the id in the event (data.id): lines, amounts in halalas, status and payment method. The customer's contact data and address appear only with customers.read.

  3. Status back

    GET /order-statuses gives, for each status, the statuses an order may move to (next). POST /orders/{id}/status with {"status":"ready","note":"…"}; a move that is not allowed is 422 invalid_transition. Shipping with your own carrier's tracking number: POST /orders/{id}/shipments with {"tracking_number":"…","carrier_name":"…"} and an Idempotency-Key.

  4. Polling fallback

    Every hour, GET /orders?updated_since={the largest updated_at you kept}&per_page=100 and follow next_cursor. The filter is inclusive, so the last second is read again: store by id (upsert). This catches any event you missed.

Amounts inside webhook payloads are in riyals (two decimals), as in the dashboard's webhooks, unlike the API's answers, which are in halalas. Read the order with GET /orders/{id} for the amounts you book.

The step-by-step guide: Sync orders into an ERP. The operations: Orders and Shipments.