Paytabs provides you with a collection of API endpoints which used to process all payments, regardless of if they are through either your own payment pages, the managed payment pages, or if you are using the hosted payment pages.
An invoice is a document you send to your client after purchasing goods or services from you, both as a means of recording the sale and requesting payment from them. You can catch everything you need about PayTabs invoices in our what Paytabs Invoices is? solutions article.
This article is dedicated to the clarification of the invoice (invoice) parameter. "invoice" is the mandatory parameter and the unique parameter for the invoice request. The "invoice" parameter is an object parameter that contains all the specifications parameters for the invoice request. Find below the specifications for both the required invoice-included parameters and the optional too.
In this article, you will be going to know:
Specifications
Along with the required parameters mentioned in our Step 3 - PT2 API Endpoints | Initiating the Parameter:payment solution article, you will need to set the "invoice" object in your request payload. Find below the specifications for the "invoice" object type parameter and the "invoice" sub-parameters specifications. Note that part of these parameters is required and the other part is optional.
- invoice
- invoice.lang
- invoice.disable_edit
- invoice.line_items
- line_items.unit_cost
- line_items.quantity
- invoice.shipping_charges
- invoice.extra_charges
- invoice.extra_discount
- invoice.total
- invoice.activation_date
- invoice.expiry_date
- invoice.due_date
- line_items.sku
- line_items.description
- line_items.url
- line_items.net_total
- line_items.discount_rate
- line_items.discount_amount
- line_items.tax_rate
- line_items.tax_total
- line_items.total
- notifications
- notifications.emails
- notifications.phone_numbers
Parameter: invoice
The Parameter Tag/Name invoice JSON Example {
"invoice": { }
}Data Type Object Required ✔Purpose This is the main object that holds other parameters related to invoice creation. Including this in your request is considered the main flag to be treated as an Invoice creation request, not a normal hosted payment page request. Validation rules At least "line_items" must be included. Parameter: invoice.lang
The Parameter Tag/Name lang JSON Example { "invoice": { "lang":"ar" } }
Data Type string Required XPurpose This is the parameter will define the invoice page langues Validation rules Only “en” or “ar” is supported Parameter: invoice.disable_edit
The Parameter Tag/Name disable_edit JSON Example { "Invoice":{ "disable_edit": true, } }
Data Type boolean Required XPurpose This parameter will disable editing the invoice through the merchant dashboard. Validation rules true or false Parameter: invoice.line_items
The Parameter Tag/Name line_items JSON Example { "invoice": { "line_items": [ { } ] } }
Data Type Array of Objects Required ✔Purpose This is an array of the invoice objects/items that your customer purchased. Each item will be an object that holds its specific details.
Min 1 Max Validation rules At least one item must be included
Parameter: line_items.unit_cost
The Parameter Tag/Name line_items.unit_cost JSON Example { "invoice": { "line_items": [ { "unit_cost": 9.5, } ] } }
Data Type Decimal Required ✔Purpose Indicates this invoice item cost. It must be in the same currency passed already in the Initial Request Parameters.
Min 0.1 Max 9999999999.99 Validation rules Decimal numbers only Parameter: line_items.quantity
The Parameter Tag/Name quantity JSON Example {
"invoice": {
"line_items": [
{
"quantity": 1
}
]
}
}Data Type INT Required ✔Purpose Indicates the purchased quantity of this invoice item.
Min 1 Max 9999999999
Validation rules Decimal numbers only
Parameter: invoice.shipping_charges
The Parameter Tag/Name | shipping_charges |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | Indicates the shipping charges that the merchant would add to the total invoice amount if he or she has shippable items. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules |
Parameter: invoice.extra_charges
The Parameter Tag/Name | extra_charges |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | Indicates any extra charges that the merchant would add to the total invoice amount. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules |
Parameter: invoice.extra_discount
The Parameter Tag/Name | extra_discount |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | Indicates an extra discount that the merchant would exclude from the total invoice amount. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules |
Parameter: invoice.total
The Parameter Tag/Name | total |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | Indicates the total amount of the invoice which equals the total price of "line_items" plus "shipping_charges" + "extra_charges" minus "extra_discount". Notes that if left as 0 or null it will be auto-calculated. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules |
Parameter: invoice.activation_date
The Parameter Tag/Name | activation_date |
JSON Example | |
Data Type | DATE |
Required | ❌ |
Purpose | Indicates the invoice activation date, which will make the invoice unavailable before this date. |
Min | |
Max | |
Validation Rules | The data must be after the current day date |
Parameter: invoice.expiry_date
The Parameter Tag/Name | expiry_date |
JSON Example | |
Data Type | DATE |
Required | ❌ |
Purpose | Indicates the invoice expiry date which will make the invoice unavailable after this date. |
Min | |
Validation Rules | To be dated after the "activation_date" parameter. |
Parameter: invoice.due_date
The Parameter Tag/Name | due_date |
JSON Example | |
Data Type | DATE |
Required | ❌ |
Purpose | Indicates the invoice due date which will make the invoice unavailable before this date. |
Min | |
Validation Rules | To be after "activation_date" |
Parameter: line_items.sku
The Parameter Tag/Name | sku |
JSON Example | |
Data Type | STRING |
Required | ❌ |
Purpose | Indicates the SKU of a cerin item to be included with item details. |
Min | 0 |
Max | |
Validation Rules |
Parameter: line_items.description
The Parameter Tag/Name | description |
JSON Example | |
Data Type | STRING |
Required | ❌ |
Purpose | Indicates the item description to be included with the item details. |
Min | 0 |
Validation Rules |
Parameter: line_items.url
The Parameter Tag/Name | url |
JSON Example | |
Data Type | STRING |
Required | ❌ |
Purpose | Indicates the item URL to be included with the item details. |
Min | |
Max | 255 (Valid URL) |
Validation Rules |
Parameter: line_items.net_total
The Parameter Tag/Name | net_total |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | This parameter indicates the net price of the current item without applying tax or discount. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules | Decimal values only |
Parameter: line_items.discount_rate
The Parameter Tag/Name | discount_rate |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | This parameter indicates the discount rate for the current item. The rate is a percentage value that will be multiplied by the net price of the item and will be included in the total price of the item. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules | Decimal values only |
Parameter: line_items.discount_amount
The Parameter Tag/Name | discount_amount |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | This parameter indicates the discount amount for the current item. This amount will be excluded. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules | Decimal values only |
Parameter: line_items.tax_rate
The Parameter Tag/Name | tax_rate |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | This parameter indicates the tax rate for the current item to be included in the total price of the item. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules | Decimal values only |
Parameter: line_items.tax_total
The Parameter Tag/Name | tax_total |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | This parameter indicates the tax total for the current item to be included in the total price of the item. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules | Decimal values only |
Parameter: line_items.total
The Parameter Tag/Name | total |
JSON Example | |
Data Type | DECIMAL |
Required | ❌ |
Purpose | This parameter indicates the total price of the current item to be included with the item details. |
Min | 0.01 |
Max | 9999999999.99 |
Validation Rules | Decimal values only |
Parameter: notifications
The Parameter Tag/Name | notifications |
JSON Example | |
Data Type | OBJECT |
Required | ❌ |
Purpose | This parameter indicates the notification options through our APIs. Using this, you will be able to send the created invoice to an array of emails or phone numbers via SMS |
Validation Rules | Accept two arrays only: emails[] and phone_numbers[] |
Parameter: notifications.emails
The Parameter Tag/Name | emails |
JSON Example | |
Data Type | Array |
Required | ❌ |
Purpose | This parameter indicates an array of emails that the created invoice will be sent to it. |
Min | 0 emails |
Max | 5 emails |
Validation Rules | Valid email format |
Parameter: notifications.phone_numbers
The Parameter Tag/Name | phone_numbers |
JSON Example | |
Data Type | Array |
Required | ❌ |
Purpose | This parameter indicates an array of phone numbers that the created invoice will be sent to it via SMS. |
Min | 0 phone numbers |
Max | 5 phone numbers |
Validation Rules | Valid phone number format |
Usage Workflow
Along with the required parameters mentioned in our 3.2.4 PT2 API Endpoints | Invoices | Initiating the payment solution article, you will need to set the "invoice" as shown below:
Sample Request Payload
{ "profile_id": , "tran_type": "sale", "tran_class": "ecom", "cart_currency": "AED", "cart_amount": "9.5", "cart_id": "cart_12345", "cart_description": "Test Description", "hide_shipping": true, "customer_ref":"CUST0101", "customer_details": { "name": "First Last", "email": "wj@email.com", "street1": "404, 11th st, void", "city": "Dubai", "country": "AE" }, "invoice": { "lang": "ar", "shipping_charges": 0, "extra_charges": 0, "extra_discount": 0, "total": 0, "activation_date": "", "expiry_date": "2022-09-27T13:33:00+04:00", "due_date": "2022-09-26T12:36:00+04:00", "line_items": [ { "sku": "sku", "description": "desc", "url": "https://www.costacoffee.ae/whats-new/flat-white", "unit_cost": 9.5, "quantity": 1, "net_total": 9.5, "discount_rate": 0, "discount_amount": 0, "tax_rate": 0, "tax_total": 0, "total": 9.5 } ] }, "callback": "", "return": "" }
Sample Response Payload
{ "invoice_id": 10000010001, "invoice_link": "https://secure.paytabs.com/payment/request/invoice/1320598/C959A415A47D4E3E8F5000000AAAAABBBBCCCCADE9A01" }