💳إنشاء واجهة برمجة تطبيقات الفاتورة
The Create Invoice API allows you to generate an invoice for a specific merchant. This API handles parameters like the merchant's information, reference ID, currency, and amount to create an invoice for a given transaction.
ملحوظة:
تأكد من اجتياز صالحةmerchant_id, reference_id، وكميةعند تقديم الطلب. إذا لم يتم العثور على التاجر أو المرجع، أو كان المبلغ غير صالح، سيتم إرجاع خطأ.
📝 معلمات الإدخال
| المعلمة | يكتب | مطلوب | وصف |
|---|---|---|---|
| merchant_id | string | ✔️ | المعرف الفريد للتاجر. هذا مطلوب لإنشاء فاتورة. |
| reference_id | string | ✔️ | The `reference_id` is a unique string used to track the user's order in the issuer's database. It can be the order ID from the issuer's database table. |
| currency_id | string | ✔️ | UUID of the enabled currency configured in the gateway. |
| كمية | string | ✔️ | The transaction amount. Must be a valid string representation of the amount (e.g., "10.50"). |
| وصف | string | ❌ | وصف اختياري للفاتورة (على سبيل المثال، لغرض المعاملة). |
- 🔹 تتطلب واجهة برمجة التطبيقاتمفتاح واجهة برمجة التطبيقاتللمصادقة.
- 🔹 الmerchant_idيجب أن يتم تمريرها في نص الطلب.
- 🔹 الكميةيجب أن يكون تمثيل سلسلة صالحًا لرقم وأكبر من 1.
💡 طلب مثال
POST https://core.dinakel.com/api/gateway/v1/invoices
Headers:
Authorization: Bearer <your_api_key>
Body:
{
"merchant_id": "<merchant_id>",
"reference_id": "<reference_id>",
"currency_id": "<currency_id>",
"amount": "<amount>",
"description": "<description>"
}
🔍 الرد المثالى
{
"status": true,
"statusCode": 201,
"invoice_id": "<invoice_id>",
"data": {
"invoice_id": "<invoice_id>"
}
}
⚠️ معالجة الأخطاء
توفر واجهة برمجة التطبيقات استجابات الخطأ التالية:
{
"status": false,
"statusCode": 400,
"message": "Amount must be a valid decimal number."
}
400 Bad Request:معلمة المبلغ غير صالحة. تأكد من أن المبلغ رقم عشري صالح وأكبر من 1.
{
"status": false,
"statusCode": 404,
"message": "Merchant or reference not found"
}
404 Not Found:معرف التاجر أو المرجع المقدم غير موجود في النظام. تحقق مرة أخرى من معرف التاجر والمرجع.
{
"status": false,
"statusCode": 500,
"message": "Internal server error"
}
500 Internal Server Error:حدث خطأ غير متوقع على الخادم. حاول مرة أخرى لاحقًا أو اتصل بالدعم.