YUMBI Gateway Docs 0.2 Help

Order Notification Webhook

POST method/webhooks/orders/notification

This webhook is sent to notify that an order has been placed.

Request parameters

{ "event_type": "orders.notification", "event_id": "example", "event_timestamp": 77, "data": { "store_id": "example", "order_id": "example", "status": "created" }, "resource_href": "example" }

Responses

{ "received": true }
{ "code": 81, "message": "example" }

Webhook Delivery Failure

If a webhook fails to deliver, YUMBI Gateway will attempt to resend it following this incremental backoff strategy:

  1. Retry after 5 seconds from the initial failure.

  2. Retry after 10 seconds from the previous attempt.

  3. Retry after 15 seconds from the previous attempt.

  4. Retry after 30 seconds from the previous attempt.

  5. Retry after 60 seconds from the previous attempt.

  6. Final retry 60 seconds from the previous attempt.

If all retries fail, YUMBI Gateway will cease further attempts and mark the order as failed.

Unavailable Webhook Endpoint

If the webhook endpoint is unavailable, integrators can query the /orders endpoint to retrieve recently created orders. By filtering for orders in the 'created' status, the list will include all orders that have not yet been accepted or rejected and have not timed out.

Timeout

Orders in the created state will time out if they are not accepted or rejected within 3 minutes of creation. After 3 minutes, the order will be moved to the cancelled state. Attempting to accept or reject a cancelled order will result in a 400 error.

Validating the payload

The body of the webhook request will be signed with an HMAC-SHA256 signature. The signature is calculated using the API key as the secret key and the body of the request as the message. The signature is then included in the X-HMAC header of the request.

The following C# code snippet demonstrates how to calculate the HMAC signature:

string CalculateHmac(string apiKey, string body) { var apiKeyBytes = Encoding.UTF8.GetBytes(apiKey); var bodyBytes = Encoding.UTF8.GetBytes(body); var hmac = new HMACSHA256(apiKeyBytes); var hash = hmac.ComputeHash(bodyBytes); return BitConverter.ToString(hash).Replace("-", "").ToLower(); }
Last modified: 05 August 2024