💳Fatura API'si Oluştur
This endpoint creates an invoice scoped to the API key's merchant and returns a customer-ready payment URL.
Geçerli bir geçiş yaptığınızdan emin olunmerchant_id, reference_id, Vemiktarbir talepte bulunurken. Üye işyeri veya referans bulunamazsa veya tutar geçersizse hata döndürülür.
📝 Giriş Parametreleri
| Parametre | Tip | Gerekli | Tanım |
|---|---|---|---|
| merchant_id | string | ✔️ | Üye işyerinın benzersiz tanımlayıcısı. Bu, fatura oluşturmak için gereklidir. |
| reference_id | string | ✔️ | Your unique order ID (1–36 characters). Reuse the same value only when retrying the identical request. |
| currency_id | string | ✔️ | UUID of an operational currency on a network with an active wallet. |
| miktar | string | ✔️ | Decimal string, at least 1, up to 28 total digits and 12 decimal places; for example "10.50". |
| Tanım | string | ❌ | Optional, up to 500 characters; must remain unchanged on retries. |
- 🔹 API bir gerektirirAPI Anahtarıkimlik doğrulama için.
- 🔹 merchant_idistek gövdesine iletilmelidir.
- 🔹 miktarbir sayının geçerli bir dize temsili olmalı ve 1'den büyük olmalıdır.
Request body format
Send this request body as JSON. In Postman, select Body → raw → JSON. multipart/form-data is not supported by this endpoint.
The Idempotency-Key header is required and must exactly match the reference_id in the request body.
Backend integration examples
Choose your backend language. Every example reads secret credentials only from environment variables.
const response = await fetch("https://api.dinakel.com/api/gateway/v1/invoices", {
method: "POST"
headers: {
Authorization: `Bearer ${process.env.DINAKEL_API_KEY}`,
Accept: "application/json",
"Content-Type": "application/json",
"Idempotency-Key": process.env.DINAKEL_REFERENCE_ID
}
body: JSON.stringify({
merchant_id: process.env.DINAKEL_MERCHANT_ID,
reference_id: process.env.DINAKEL_REFERENCE_ID,
currency_id: process.env.DINAKEL_CURRENCY_ID,
amount: "10.50",
description: "Order payment"
})
});
const result = await response.json();
if (!response.ok) throw new Error(result.message || "Dinakel request failed");
console.log(result);💡 Örnek İstek
POST https://api.dinakel.com/api/gateway/v1/invoices
Headers:
Authorization: Bearer <your_api_key>
Idempotency-Key: <reference_id>
Content-Type: application/json
Accept: application/json
Body (raw JSON; not form-data):
{
"merchant_id": "<merchant_id>",
"reference_id": "<reference_id>",
"currency_id": "<currency_id>",
"amount": "<amount>",
"description": "<description>"
}
🔍 Örnek Yanıt
{
"status": true,
"statusCode": 201,
"invoice_id": "<invoice_id>",
"data": {
"invoice_id": "<invoice_id>",
"invoice_status": "draft",
"payment_url": "https://dinakel.com/gateway-payment?invoice_id=<invoice_id>",
"idempotency_replayed": false
}
}
For retries, resend the same reference_id and unchanged invoice data. A replay returns HTTP 200 with the original invoice ID; a new invoice returns HTTP 201.
⚠️ Hata İşleme
API aşağıdaki hata yanıtlarını sağlar:
{
"status": false,
"statusCode": 400,
"message": "Amount must be a valid decimal number."
}
400 Bad Request:Tutar parametresi geçersiz. Tutarın geçerli bir ondalık sayı olduğundan ve 1'den büyük olduğundan emin olun.
{
"status": false,
"statusCode": 409,
"message": "reference_id is already used with different invoice data",
"message_key": "api.invoice.idempotency_conflict"
}
409 Conflict: The reference was already used with different invoice data.
{
"status": false,
"statusCode": 403,
"message": "API key is not authorized for this merchant"
}
403 Forbidden: The key belongs to another merchant.
{
"status": false,
"statusCode": 409,
"message": "Financial commands are unavailable for this currency",
"operational_status": "maintenance"
}
409 Conflict: The network or currency is temporarily unavailable.
429 Too Many Requests: Up to 20 create requests per minute per key; use Retry-After.
{
"status": false,
"statusCode": 500,
"message": "Internal server error"
}
500 Internal Server Error:Sunucuda beklenmeyen bir hata oluştu. Daha sonra tekrar deneyin veya destek ekibiyle iletişime geçin.