أحداث Webhook

قائمة كاملة بالأحداث المتاحة وبياناتها.

الأحداث المتاحة

الحدث الوصف
booking.created حجز جديد تم إنشاؤه
booking.updated حجز تم تعديله
booking.cancelled حجز ملغي
booking.completed حجز مكتمل (تمت الخدمة)
booking.no_show لم يحضر العميل
payment.completed دفع مكتمل
payment.failed دفع فاشل
payment.refunded دفع تم استرداده
customer.created عميل جديد مسجل
customer.updated عميل محدّث
order.created طلب جديد تم إنشاؤه
order.shipped طلب تم إرساله
order.delivered طلب تم تسليمه

booking.created

يتم تشغيله عند إنشاء حجز جديد.

JSON Payload
{
    "id": "evt_abc123",
    "type": "booking.created",
    "created": "2024-01-20T10:30:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "booking": {
            "id": 12345,
            "codigo": "ABC123XY",
            "fecha": "2024-01-25",
            "hora_inicio": "10:30",
            "hora_fin": "11:00",
            "servicios": [
                {
                    "id": 15,
                    "nombre": "Corte Clásico",
                    "precio": 25.00,
                    "duracion_minutos": 30
                }
            ],
            "profesional": {
                "id": 5,
                "nombre": "Carlos García"
            },
            "cliente": {
                "id": 456,
                "nombre": "Juan Pérez",
                "email": "juan@email.com",
                "telefono": "+34612345678"
            },
            "total": 25.00,
            "estado": "confirmada",
            "notas": "Primera visita",
            "created_at": "2024-01-20T10:30:00Z"
        }
    }
}

booking.updated

يتم تشغيله عند تعديل حجز (تغيير التاريخ، الوقت، المحترف، إلخ).

JSON Payload
{
    "id": "evt_def456",
    "type": "booking.updated",
    "created": "2024-01-20T11:00:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "booking": {
            "id": 12345,
            "codigo": "ABC123XY",
            "fecha": "2024-01-26",
            "hora_inicio": "11:00",
            "hora_fin": "11:30"
            // ... البيانات الكاملة للحجز
        },
        "changes": {
            "fecha": {
                "old": "2024-01-25",
                "new": "2024-01-26"
            },
            "hora_inicio": {
                "old": "10:30",
                "new": "11:00"
            }
        }
    }
}

booking.cancelled

يتم تشغيله عند إلغاء حجز.

JSON Payload
{
    "id": "evt_ghi789",
    "type": "booking.cancelled",
    "created": "2024-01-20T12:00:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "booking": {
            "id": 12345,
            "codigo": "ABC123XY",
            "estado": "cancelada"
            // ... البيانات الكاملة
        },
        "cancellation": {
            "cancelled_by": "cliente",
            "reason": "Cambio de planes",
            "cancelled_at": "2024-01-20T12:00:00Z"
        },
        "refund": {
            "applicable": true,
            "amount": 25.00,
            "status": "pending"
        }
    }
}

booking.completed

يتم تشغيله عند إتمام الخدمة وتعليم الحجز كمكتمل.

JSON Payload
{
    "id": "evt_jkl012",
    "type": "booking.completed",
    "created": "2024-01-25T11:05:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "booking": {
            "id": 12345,
            "estado": "completada",
            "completed_at": "2024-01-25T11:05:00Z"
            // ... البيانات الكاملة
        },
        "points_earned": 25
    }
}

booking.no_show

يتم تشغيله عندما لا يحضر العميل للموعد.

JSON Payload
{
    "id": "evt_mno345",
    "type": "booking.no_show",
    "created": "2024-01-25T11:30:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "booking": {
            "id": 12345,
            "estado": "no_show",
            "marked_at": "2024-01-25T11:30:00Z"
        }
    }
}

payment.completed

يتم تشغيله عند اكتمال الدفع بنجاح.

JSON Payload
{
    "id": "evt_pqr678",
    "type": "payment.completed",
    "created": "2024-01-20T10:35:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "payment": {
            "id": 789,
            "amount": 25.00,
            "currency": "EUR",
            "method": "card",
            "stripe_payment_intent_id": "pi_abc123",
            "status": "succeeded"
        },
        "booking": {
            "id": 12345,
            "codigo": "ABC123XY"
        },
        "cliente": {
            "id": 456,
            "nombre": "Juan Pérez",
            "email": "juan@email.com"
        }
    }
}

payment.failed

يتم تشغيله عند فشل محاولة الدفع.

JSON Payload
{
    "id": "evt_stu901",
    "type": "payment.failed",
    "created": "2024-01-20T10:35:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "payment": {
            "id": 790,
            "amount": 25.00,
            "currency": "EUR",
            "status": "failed",
            "error_code": "card_declined",
            "error_message": "Tu tarjeta fue rechazada"
        },
        "booking": {
            "id": 12346
        }
    }
}

payment.refunded

يتم تشغيله عند إجراء استرداد.

JSON Payload
{
    "id": "evt_vwx234",
    "type": "payment.refunded",
    "created": "2024-01-21T09:00:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "refund": {
            "id": 100,
            "amount": 25.00,
            "currency": "EUR",
            "reason": "Cancelación por cliente",
            "stripe_refund_id": "re_abc123"
        },
        "original_payment": {
            "id": 789,
            "amount": 25.00
        },
        "booking": {
            "id": 12345
        }
    }
}

customer.created

يتم تشغيله عند تسجيل عميل جديد.

JSON Payload
{
    "id": "evt_yza567",
    "type": "customer.created",
    "created": "2024-01-20T10:25:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "customer": {
            "id": 456,
            "nombre": "Juan Pérez",
            "email": "juan@email.com",
            "telefono": "+34612345678",
            "source": "widget",
            "created_at": "2024-01-20T10:25:00Z"
        }
    }
}

customer.updated

يتم تشغيله عند تحديث العميل لملفه الشخصي.

JSON Payload
{
    "id": "evt_bcd890",
    "type": "customer.updated",
    "created": "2024-01-22T15:00:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "customer": {
            "id": 456,
            "nombre": "Juan Pérez García",
            "email": "juan@email.com",
            "telefono": "+34612345678"
        },
        "changes": {
            "nombre": {
                "old": "Juan Pérez",
                "new": "Juan Pérez García"
            }
        }
    }
}

order.created

يتم تشغيله عند إنشاء طلب منتجات جديد.

JSON Payload
{
    "id": "evt_ord123",
    "type": "order.created",
    "created": "2024-01-20T14:30:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "order": {
            "id": 789,
            "numero": "PED-2024-0789",
            "cliente": {
                "id": 456,
                "nombre": "Juan Pérez",
                "email": "juan@email.com"
            },
            "items": [
                {
                    "producto_id": 12,
                    "nombre": "Shampoo Profesional",
                    "cantidad": 2,
                    "precio_unitario": 15.00,
                    "subtotal": 30.00
                }
            ],
            "subtotal": 30.00,
            "envio": 5.00,
            "total": 35.00,
            "estado": "pending",
            "created_at": "2024-01-20T14:30:00Z"
        }
    }
}

order.shipped

يتم تشغيله عند إرسال طلب.

JSON Payload
{
    "id": "evt_ord456",
    "type": "order.shipped",
    "created": "2024-01-21T10:00:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "order": {
            "id": 789,
            "numero": "PED-2024-0789",
            "estado": "shipped",
            "tracking_number": "1Z999AA10123456784",
            "tracking_url": "https://tracking.example.com/1Z999AA10123456784",
            "shipped_at": "2024-01-21T10:00:00Z"
        }
    }
}

order.delivered

يتم تشغيله عند تسليم طلب.

JSON Payload
{
    "id": "evt_ord789",
    "type": "order.delivered",
    "created": "2024-01-23T16:45:00Z",
    "tenant_id": "uuid-tenant",
    "data": {
        "order": {
            "id": 789,
            "numero": "PED-2024-0789",
            "estado": "delivered",
            "delivered_at": "2024-01-23T16:45:00Z"
        }
    }
}