Webhooks
إشعارات تلقائية يرسلها النظام عند حدوث أحداث معينة.
نظرة عامة
Webhooks تتيح للشركات استقبال إشعارات فورية عن الأحداث المتعلقة بحجوزاتهم.
الأحداث المدعومة
| الحدث | الوصف |
|---|---|
booking.created | حجز جديد |
booking.confirmed | تأكيد حجز |
booking.cancelled | إلغاء حجز |
trip.started | بدء رحلة |
trip.completed | انتهاء رحلة |
إعداد Webhook
POST /api/webhooks
Authorization: Bearer {token}
Content-Type: application/json
{
"url": "https://your-domain.com/webhook",
"events": ["booking.created", "booking.cancelled"],
"secret": "your-secret-key"
}
شكل الإشعار
{
"event": "booking.created",
"timestamp": "2024-01-15T10:30:00Z",
"data": {
"booking_id": "uuid",
"booking_code": "SB-ABC123",
"trip_id": "uuid",
"passenger_count": 2,
"total_amount": 25000
},
"signature": "sha256=..."
}
التحقق من التوقيع
const crypto = require("crypto");
function verifySignature(payload, signature, secret) {
const expected = crypto
.createHmac("sha256", secret)
.update(JSON.stringify(payload))
.digest("hex");
return `sha256=${expected}` === signature;
}
حالة التطوير
🚧 قيد التطوير - Webhooks ستكون متاحة في الإصدار القادم.