Invoice External Payment (Mark as Paid)
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 solutions article: What is PayTabs Invoice?
Invoices Payment Page integration type is suitable for merchants with PCI SAQ A or merchants does not have any PCI levels as it follows Hosted Payment page mechanism. To customize the UI of the Invoices payment page, check this article, and to know more about the Invoices Payment Page PCI DSS merchant requirements, please check this article.The Mark as Paid feature allows merchants to manually update an invoice's status when payment is received outside the system, such as bank transfer, POS, cash, or cheque. To ensure accurate tracking, users must specify the payment method and include a brief description (e.g., cheque number or transaction reference). This helps maintain transparency and supports reconciliation of offline transactions within the invoice management workflow.
This feature is currently supported exclusively on the KSA and UAE instances.
Please note that this feature is not enabled by default. To request activation, kindly send an email to [email protected], including your Profile ID and region/instance, and our team will assist you accordingly.
The Endpoint and Related Postman Collectionβ
In this tutorial, we will rely on the PayTabs retrieve invoice details Transaction API Endpoint, mentioned on the PayTabs API endpoints postman collection, which you can access fromhere. he endpoint will need to be accessed with the mentioned HTTP request via the below URL endpoint:
POST | {{domain}}/payment/invoice/paid |
---|
Please note that not using the proper endpoint URL {domain} will lead to authentication issues within your responses. To find the your proper domain you can read ourWhat is my (Region)/(endpoint URL)?tutorial article.
- KSA
- UAE
https://secure.paytabs.sa/payment/invoice/paid
https://secure.paytabs.com/payment/invoice/paid
Required Parametersβ
To make Invoice External Payment (Mark as Paid) request for an invoice, there are required parameters that need to be passed with valid information. The specification of these required parameters is clarified below according to the request type:
Parameter | Data Type | Min | Max | Required |
---|---|---|---|---|
| INT | Accept only valid profile number. | β | |
The merchant Profile ID you can get from your PayTabs dashboard. For more information please check our How to get your account information from PT Dashboard? solution article. To know more about this parameter please click here. | ||||
| ||||
| STRING | β | ||
Indicates the existing invoice currency, which the customer was charged via offline payment. | ||||
| ||||
| DECIMAL | β | ||
Indicates the existing invoice total amount, which the customer was charged via offline payment. | ||||
| ||||
| ENUM | β | ||
Indicates the offline payment method used for collecting the invoice amount:
| ||||
| ||||
| STRING | 1 | 64 | β |
Include relevant details (e.g., cheque number or reference) | ||||
|
Sample Request Payloadsβ
The below sample request payload will show you how you can pass the above-mentioned parameters, which are needed to be passed with valid values to perform a request and mark the invoice as paid:
{
"profile_id": "11###",
"invoice_id": 1415964,
"invoice_currency": "SAR",
"invoice_total": 1000,
"pay_method": "cheque",
"pay_description": "Cheque number 123456789"
}
Sample Response Payloadsβ
The response will include the request details, along with the new transaction reference.
{
"profile_id": 11###,
"invoice_id": 1415964,
"invoice_currency": "SAR",
"invoice_total": "1000.00",
"pay_method": "Cheque",
"pay_description": "Cheque number 123456789",
"tran_ref": "PTS######"
}
When interacting with our API, you may occasionally encounter HTTP error responses. These errors are returned when a request cannot be successfully processed due to client-side constraints. Understanding these responses is essential for effective error handling and debugging.
- 404 Not Found
- 429 Too Many Requests
- 400 Bad Request
- 401 Unauthorized
If an invalid or not existing invoice ID has been provided, the API will respond with a 404 Not Found, indicating that this invoice ID not exist.
{
"code": 2,
"message": "Invoice not found",
"trace": "PMNT0401.685BF3BB.0000B10E"
}
If you sent 60 request per minute trying to retrieve an invoice details, the error 429 Too Many Requests will occurs.
{
"code": 5,
"message": "Too many requests, try again later.",
"trace": "PMNT0401.685BEC48.0000A2E6"
}
if you provide an invalid parameter/s value, the API will respond with a 401 Unauthorized, indicating a validation error perceived as a merchant side error.
If the required
profile_id
not provided:{
"code": 2,
"message": "Invoice ID must be set",
"trace": "PMNT0202.68A31B40.0005D651"
}If the provided invoice ID is already paid:
{
"code": 2,
"message": "Invoice already paid",
"trace": "PMNT0202.68A32365.0005DF8E"
}If provided a wrong invoice ID or not existing one:
{
"code": 2,
"message": "Invoice not found",
"trace": "PMNT0202.68A31AC7.0005D5C9"
}If the required
invoice_total
not provided:{
"code": 2,
"message": "Invoice total must be set",
"trace": "PMNT0202.68A31AEB.0005D5EB"
}If the required
invoice_currency
not provided:{
"code": 2,
"message": "Invoice currency must be set",
"trace": "PMNT0202.68A31B25.0005D62C"
}If the required
pay_method
not provided, or provided an invalid value:{
"code": 2,
"message": "Invalid payment method",
"trace": "PMNT0201.68A31AD7.0005D739"
}If the required
pay_description
not provided, or provided an empty value:{
"code": 2,
"message": "Payment description must be set",
"trace": "PMNT0202.68A31B13.0005D616"
}The
invoice_total
field must match the exact total specified on the associated invoice, Any deviation, whether greater, or lesser will result in rejection, also the theinvoice_currency
must be valid and must match the currency defined in the invoice..{
"code": 2,
"message": "Invoice amount mismatch",
"trace": "PMNT0202.68A31914.0005D3F6"
}
If an invalid profile_id or incorrect authorization server key is provided in the request header, the API will respond with a 401 Unauthorized, indicating authentication failure.
{
"code": 1,
"message": "Authentication failed. Check authentication header.",
"trace": "PMNT0402.685BF22C.0000AD86"
}
Expected Flow Behaviorβ
To mark an existing invoice as paid, follow the steps below. This flow assumes that you have already initiated an invoice and received a valid invoice_id
.:
Begin by calling the API endpoint responsible for invoice creation. Upon successful creation, the response will include a unique invoice_id. This ID is essential for all subsequent operations related to the invoice.
{
.
"invoice_id": "3251338",
.
}ImportantStore the
invoice_id
securely in your system. It serves as the primary reference for managing the invoice via API like retrieving or updating the invoice.Once you have the
invoice_id
, businesses may settle the invoice amount through offline channels. Such as cash, cheque, bank transfer, or POS. And utilize this method to formally record the payment against the invoice.Upon submitting the request, the system will return the corresponding payment transaction reference, confirming the linkage between the invoice and the recorded offline settlement.
{
"profile_id": 11###,
"invoice_id": 1415964,
"invoice_currency": "SAR",
"invoice_total": "1000.00",
"pay_method": "Cheque",
"pay_description": "Cheque number 123456789",
"tran_ref": "PTS24163######"
}In the meantime, the transaction would be already created on your dashboard, which you can access from your merchant dashboard.