أحداث Webhooks

استقبل إشعارات لحظية عند حدوث أحداث مهمة

كيف يعمل

POST https://your-app.com/webhooks/fez
Content-Type: application/json
X-Fez-Signature: sha256=<HMAC-SHA256>
X-Fez-Event: order.created

{
  "event": "order.created",
  "timestamp": "2026-02-27T01:00:00Z",
  "storeId": "store_abc123",
  "data": {
    "id": "order_xyz",
    "total": 299.00,
    "items": [...]
  }
}

التحقق من التوقيع

const crypto = require("crypto");

function verifyWebhook(payload, signature, secret) {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(payload)
    .digest("hex");
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

قائمة الأحداث

EventRequired ScopeDescription
order.createdread_ordersNew order placed
order.updatedread_ordersOrder details changed
order.cancelledread_ordersOrder cancelled
order.fulfilledread_ordersOrder shipped/delivered
product.createdread_productsNew product added
product.updatedread_productsProduct details changed
product.deletedread_productsProduct removed
inventory.lowread_productsStock below threshold
inventory.outread_productsOut of stock
customer.createdread_customersNew customer registered
customer.updatedread_customersCustomer profile updated

نظام الحماية (Circuit Breaker)

إذا فشلت 5 محاولات متتالية، يتم تعطيل الـ endpoint تلقائياً لحماية النظام.

يمكنك إعادة تفعيله يدوياً من لوحة الشركاء.

سياسة إعادة المحاولة

يعيد النظام المحاولة 3 مرات مع تأخير أسّي:

1st: 30s2nd: 5min3rd: 30min