Request/Response: Invoice ID (invoice_id)
This parameter ONLY working with those integration types (Invoices, and Invoices(Payment Endpoint)).
In the dynamic world of digital payments, accurate tracking and reference are crucial. PayTabs introduces the invoice_id parameter, a key element designed to simplify invoice management and enhance transaction visibility. This parameter provides merchants with a unique identifier for every invoice created, ensuring precise control and easy retrieval of payment details.
Instead of relying on generic references, the invoice_id parameter empowers merchants to store, search, and manage invoices efficiently. It can be used to fetch invoice details after payment, maintain accurate records in the merchant’s database, and quickly locate transactions in the dashboard.
This functionality not only improves operational efficiency but also strengthens the overall payment experience for both merchants and customers.
How this parameter could benefit you?
The invoice_id parameter offers significant advantages for merchants managing multiple profiles. Here’s how it can benefit you:
- Unique Identifier: The
invoice_idfield is generated and returned only when an invoice is created. It remains unique for each merchant profile. - Post-Payment Reference: This ID allows merchants to retrieve complete invoice details after a payment has been processed.
- Database Storage: Merchants can securely store the
invoice_idin their database for accurate record-keeping and future use. - Dashboard Search: The
invoice_idenables quick and precise searches for invoices directly within the merchant dashboard. - Invoice Status Tracking: The
invoice_idis required to check and monitor the current status of any invoice. - Invoice Cancellation: Merchants can cancel an invoice using its
invoice_idthrough the appropriate endpoint. - Invoice Editing: The
invoice_idis essential when making updates or modifications to an existing invoice. - Mark as Paid: Merchants can mark an invoice as paid by referencing its
invoice_idin the relevant endpoint. - Transaction Reference: When accessing a transaction completed through an invoice, the
invoice_idwill appear as a reference, ensuring clear linkage between the transaction and its corresponding invoice.
Name but a few different Businesses/Industries that can benefit from this API parameter:
- Retail & E-commerce: Use
invoice_idto track orders and manage refunds. - Food & Beverage: Link
invoice_idto receipts for easy reconciliation. - Hospitality & Travel: Track bookings and payments using
invoice_id. - Education: Manage tuition and course payments with
invoice_idfor reporting. - Healthcare: Associate
invoice_idwith patient billing and medical service payments. - Professional Services: Use
invoice_idto manage client invoices for consulting, legal, or accounting work. - Logistics & Transportation: Track shipment invoices and reconcile freight or delivery charges with
invoice_id.
How to Use?
In order for you to properly handle the invoice_id parameter, you kindly need to follow the below simple steps:
- Within the initiation step of the invoice creation (Step 3), the
invoice_idis a response-only field. You should normally follow the steps atInvoice | Step 3 - Initiating the payment. - At this point, in the success case, you will receive the
invoice_idin the response payload along with other details.{
"invoice_id": 335XXX3,
"invoice_link": "https://secure.paytabs.sa/payment/request/invoice/335XXXX3/2250EA0B26A34AXXXXXXX684E7FBE435",
"trace_code": "PMNTXXX1.69XXXE04.000XXXX46"
} - Once you have obtained the
invoice_id, this parameter becomes crucial for subsequent operations. It can be used as a request field in the following endpoints: - Finally, ensure that you store and reference the
invoice_idcorrectly, as it is the unique identifier required for managing the lifecycle of the invoice across all related API endpoints.
Parameter Specifications
-
invoice_idParameter invoice_idDescription invoice_idis one of the parameters that received from our side in the payload. returned in the success only, it's used as a Request parameter in some management endoints ( cancel, edit , mark as paid , etc .. )Data Type INT Required ✘ Min 1 Max 9999999999 Sample {
"invoice_id": "10000010001"
}
Request & Response Payloads Samples
- Create Invoices
- Manage Invoices
invoice_id serves as response parameter, don't expect to see it in the request.- Request Sample Payload
- Response Sample Payload
{
"profile_id": "123XXX",
"tran_type": "sale",
"tran_class": "ecom",
"cart_description": "Description of the items/services",
"cart_id": "Unique order reference00",
"cart_amount": 100,
"cart_currency": "SAR",
"invoice": {
"line_items": [
{
"unit_cost": 100,
"quantity":2
}
]
}
}
{
"invoice_id": 2072841,
"invoice_link": "https://secure.paytabs.com/payment/request/invoice/2072841/A8C678206DB76382A"
}
invoice_id serves as a Request Parameter required to retrieve, cancel, edit, download, check the status, or mark invoices as paid. Please refer to the solution article for detailed information about each endpoint and review the corresponding request/response examples.Expected Payment Flow Behavior
- Create & Pay Invoice
- Manage Invoice (using invoice_id)
- As mentioned above in the How to Use? and Parameter Specifications sections, as a merchant you will create an invoice by calling the Create Invoice endpoint , following the sample payloads in the Request & Response Payloads section.
- On a successful creation, you receive a response that includes a unique
invoice_idalong with a customer-facinginvoice_link.{
"invoice_id": 2072841,
"invoice_link": "https://secure.paytabs.com/payment/request/invoice/2072841/A8C678206DB76382A"
} - You can copy or share the
invoice_linkwith your customer (via email, SMS, chat, etc.) or redirect them to it directly from your application. - The customer opens the invoice link and proceeds to payment by entering their card/payment details. If you configured amounts/line items, they will be shown on the invoice page.
- The customer is then redirected to their issuer bank’s 3DS/OTP page (if applicable) to authenticate the card/payment method.
- After authentication, the customer is redirected to a success/error page accordingly. At this stage:
- You can see the resulting transaction on your merchant dashboard (accepted/authorized/declined), and it will be linked to the corresponding
invoice_idfor traceability. - The
invoice_idcan be used later to retrieve the invoice details and status, reconcile records, or manage the invoice lifecycle.
- You can see the resulting transaction on your merchant dashboard (accepted/authorized/declined), and it will be linked to the corresponding
- After capturing and storing the
invoice_idfrom the creation response, you can use it to manage the invoice via the dedicated endpoints listed in How to Use? and Request & Response Payloads. - Typical operations that require
invoice_idas a request parameter include:- Invoice Status – check current invoice state (e.g., created, pending, paid, cancelled, expired).
- Retrieve Invoice Details – fetch all invoice metadata/line items.
- Invoice Edit – update editable fields when the invoice is not yet paid/locked.
- Invoice Cancel – invalidate the invoice if it is still open.
- Mark as Paid – mark an invoice as paid (permitted scenarios only; typically for offline settlements).
- Download an Invoice – retrieve a file version of the invoice for records/sharing.
- Example request (Cancel Invoice):Example response (success):
{
"invoice_id": 2072841
}{
"message": "Invoice has been cancelled"
} - Expected outcomes by operation:
- Status: Returns the latest invoice state so you can drive UI flows (e.g., disable the pay button if paid/cancelled).
⚠️ The JSON response does not includeinvoice_id. - Retrieve Details: Returns the full invoice object (merchant reference, line items, amounts, customer data, etc.).
✔️ Theinvoice_idis also included in the response payload. - Edit: Updates allowed fields if the invoice is still editable (not paid/locked). Invalid edit attempts will be rejected.
✔️ The updated response also contains the sameinvoice_id. - Cancel: Prevents further payment attempts; the
invoice_linkbecomes unusable.
⚠️ The JSON response does not includeinvoice_id. - Mark as Paid: Sets the invoice to paid (for permitted offline settlement cases).
✔️ The response also includes theinvoice_idfor tracking. - Download: Generates a downloadable PDF version of the invoice.
⚠️ The JSON response does not includeinvoice_id.
✔️ Theinvoice_idis present inside the PDF document itself.
- Status: Returns the latest invoice state so you can drive UI flows (e.g., disable the pay button if paid/cancelled).