Sifr Wahid Developers

Guides

Common mistakes

Each mistake as the problem you see, its cause and the fix.

Sending a quantity on a product

Problem
The product write is answered 422.
Cause
Any quantity key on a product is refused.
Fix
Stock goes through POST /inventory/adjustments only.

set for every movement

Problem
Sales the store made disappear from the stock count.
Cause
set erases the store's sales between your read and your write.
Fix
Use increment and decrement, and set for stock counts.

A random Idempotency-Key on each retry

Problem
An order or a stock movement happens twice.
Cause
A new key on a retry repeats the call.
Fix
Derive the key from the document number and keep it for every try.

Verifying the signature on re-encoded JSON

Problem
Real deliveries fail your signature check.
Cause
The signature covers the body as it arrived.
Fix
Read the raw body before any parsing.

Long work before answering a delivery

Problem
Deliveries are retried, and the webhook may switch off.
Cause
Past 15 seconds the delivery is retried, and after 50 failures in a row, or 10 timeouts in a row, the webhook switches itself off.
Fix
Answer first, then work.

Riyals instead of halalas

Problem
Prices are a hundred times too small.
Cause
price: 50 means 50 halalas.
Fix
50 SAR is 5000.

One key for every system

Problem
Revoking it stops them all, and you cannot tell who did what.
Cause
Several systems share one key.
Fix
One key per system.

The key in the URL

Problem
The call is refused.
Cause
A key in the query string is refused, and it stays in logs.
Fix
The header only: Authorization: Bearer zo_live_….

Expecting customer.mobile without customers.read

Problem
The order's customer has no mobile.
Cause
It never appears without customers.read.
Fix
Add the scope or work with the customer id.

Retrying a 429 at once

Problem
The call is refused again.
Cause
The key is past its per-minute limit.
Fix
Wait Retry-After.