💳Create Invoice API
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.
Ensure that you pass a validmerchant_id, reference_id, andamountwhen making a request. If the merchant or reference is not found, or the amount is invalid, an error will be returned.
📝 Input Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| merchant_id | string | ✔️ | Unique identifier for the merchant. This is required for creating an invoice. |
| 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. |
| amount | string | ✔️ | The transaction amount. Must be a valid string representation of the amount (e.g., "10.50"). |
| description | string | ❌ | Optional description for the invoice (e.g., for the purpose of the transaction). |
- 🔹 The API requires anAPI Keyfor authentication.
- 🔹 Themerchant_idshould be passed in the request body.
- 🔹 Theamountmust be a valid string representation of a number and greater than 1.
💡 Example Request
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>"
}
🔍 Example Response
{
"status": true,
"statusCode": 201,
"invoice_id": "<invoice_id>",
"data": {
"invoice_id": "<invoice_id>"
}
}
⚠️ Error Handling
The API provides the following error responses:
{
"status": false,
"statusCode": 400,
"message": "Amount must be a valid decimal number."
}
400 Bad Request:The amount parameter is invalid. Ensure the amount is a valid decimal number and greater than 1.
{
"status": false,
"statusCode": 404,
"message": "Merchant or reference not found"
}
404 Not Found:The merchant or reference ID provided does not exist in the system. Double-check the merchant ID and reference.
{
"status": false,
"statusCode": 500,
"message": "Internal server error"
}
500 Internal Server Error:An unexpected error occurred on the server. Try again later or contact support.