Skip to main content

Edit Invoices

In this manual, we'll guide you through Editing a previous created invoice. You'll learn about the necessary parameters required for the request and all the optional parameters available. We strongly recommend reviewing theInvoice Payment Page | Payment Workflowmanual first to understand the business logic behind this integration and how you can first craete your invoices.
Finally, and once you have already created your invoice, you can follow the guide mentioned here to be able edit this invoice using our APIs


Limitations


  • Only Pending Invoices: the only limitations for this option is that you can only edit an invoice with the "pending" status. Any invoice that was already paid or canceled can not be edited.

The Endpoint and Related Postman Collection

In this section, we will rely on the PayTabs Invoice Payment Page edit API Endpoint, mentioned on PayTabs API endpoints postman collection, which you can access from po_link. The endpoint will need to be accessed with a POST request on the below-mentioned URL

POST{{domain}}/payment/invoice/<invoiceID>/edit
Be Aware Of

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.

https://secure.paytabs.sa/payment/invoice/<invoiceID>/edit



The Minimum Required Parameters

To edit/update a pending invoice at least you need to provide the following parameter within your request payload along with the parameter/s you want to update if note included:

{
"profile_id": 180###,
"tran_type": "sale",
"tran_class": "ecom",
"cart_currency": "SAR",
"cart_amount": "666",
"cart_id": "CART#1001",
"cart_description": "Description of the invoice items/services",
"invoice": {
"line_items": [
{
"quantity": 1,
"unit_cost": 666
}
]
}
}



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 update the invoice reference code:

Make sure you are using the valid invoice ID within the endpoint as shown below, along with the authorization details:

transaction view
{
"profile_id": 1801##,
"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": {
"ref": "The Invoice Reference code",
"line_items": [
{
"unit_cost": 100,
"quantity":2
}
]
}
}



Sample Response Payloads

{
"invoiceID": 3126###,
"status": "invoice updated successfully",
"trace": "PMNT0401.674DB9E5.000BBE4C"
}



Expected Flow Behavior

Reaching this point, you already should have an pending invoice that you want to update:

  1. As we mentioned above you will use the required parameters along with desired parameters that needs to be updated if not included [Sample].
  2. If the invoice is pending, then the invoice reference will updated and you will get a success response.
  3. In case, the invoice is not editable like its status is Cancelled, Overdue, or Paid, you will get 400 Bad Request invalid request:
  4. {
    "code": 1,
    "message": "Invoice is not editable",
    "trace": "PMNT0401.674E9C9B.000D1AC0"
    }

We are glad to be always in help. We aim to serve you better each time. As such, please spare a minute to share feedback about your recent experience with PayTabs Developers , on Trustpilot, or Google Reviews.