0
إجمالي الفواتير
0 ر.س
إجمالي المبيعات
0 ر.س
إجمالي الضريبة
📝 بيانات الفاتورة
أدخل بيانات الفاتورة لإنشاء فاتورة إلكترونية متوافقة مع ZATCA
📋 الفواتير الصادرة
قائمة بجميع الفواتير الإلكترونية المنشأة
لا توجد فواتير حالياً
قم بإنشاء فاتورة جديدة🔗 تكامل مع موقع hasan.sa
أضف هذا الكود في موقعك لإصدار فواتير تلقائية عند كل عملية شراء
📌 الكود المطلوب إضافته في موقعك
انسخ هذا الكود وضعه في صفحة "شكراً على الشراء" في موقعك:
<script>
// إرسال بيانات الطلب لإنشاء فاتورة تلقائية
fetch('https://hasan.sa/api.php/webhook', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
orderId: 'ORDER-12345',
customer: {
name: 'أحمد محمد',
email: 'ahmed@example.com',
address: 'الرياض',
city: 'الرياض'
},
items: [
{ name: 'منتج 1', quantity: 2, unitPrice: 50 },
{ name: 'منتج 2', quantity: 1, unitPrice: 100 }
],
total: 230,
paymentMethod: 'CASH'
})
})
.then(res => res.json())
.then(data => {
if(data.success) {
console.log('✅ Invoice:', data.invoice.invoiceNumber);
// يمكنك عرض رقم الفاتورة للعميل هنا
}
});
</script>
📌 مثال بـ PHP (للخادم)
<?php
// بعد نجاح الدفع في موقعك
$orderData = [
'orderId' => 'ORDER-' . $orderId,
'customer' => [
'name' => $customerName,
'email' => $customerEmail,
'address' => $customerAddress,
'city' => $customerCity
],
'items' => array_map(function($item) {
return [
'name' => $item['name'],
'quantity' => $item['qty'],
'unitPrice' => $item['price']
];
}, $cartItems),
'total' => $orderTotal,
'paymentMethod' => $paymentMethod
];
$ch = curl_init('https://hasan.sa/api.php/webhook');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($orderData));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$result = json_decode($response, true);
if($result['success']) {
// حفظ رقم الفاتورة في قاعدة البيانات
$invoiceNumber = $result['invoice']['invoiceNumber'];
}
?>
📌 اختبار التكامل
يمكنك اختبار API مباشرة:
curl -X POST https://hasan.sa/api.php/webhook \
-H "Content-Type: application/json" \
-d '{
"orderId": "TEST-123",
"customer": {"name": "أحمد", "email": "test@test.com"},
"items": [{"name": "منتج", "quantity": 1, "unitPrice": 100}],
"total": 115
}'