Skip to main content

Downloading an Invoice

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.

This endpoint is handy once your invoice is initiated to download it via a simple GET request and empower your customers on how they can display and download a static PDF of this invoice.


In this tutorial, we will rely on the PayTabs Download Invoice API Endpoint, mentioned on PayTabs API endpoints postman collection, which you can access fromPayTabs Postman APIs Collection. The endpoint will need to be accessed with a POST request on the below-mentioned URL

GET{{domain}}/payment/invoice/{{InvoiceId}}/download/pdf
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}}/download/pdf


Request Parameters​

To initiate a a download invoice request, there are minimum required URI params that need to be passed with valid information. The specification of these required parameters is clarified below:

In the GET invoice status, we simply use a GET request passing only the [invoice_id] as a param in the endpoint URL to get the status, find below the specifications to this param:

ParameterData TypeRequired
invoice_id
INTβœ”
Indicates the invoice reference you want to query.
To know more about this parameter pleaseclick here.
{
"invoice_id": 123456
}

Request & Response Payload Samples​

This section is dedicated give you a sample API request payload using the above mentioned required parameters, along with showing you the response payload received upon using the request payload.

The below sample request payload will show you how you can pass the above-mentioned required parameter/s, which are needed to be passed with valid values to perform a request. Along with the response payload received after using this request payload.

curl --location --request GET 'https://secure.paytabs.com/payment/invoice/123456/download/pdf' \
--header 'Authorization: SGJNBXXXXX-J6RNNXXXXX-2ZGWLXXXXX'

The Payment Page Experience​

Reaching this point, you already should have initiated your invoice indeed and just wanted to share it with your customers. Here’s how it works:

  1. Initiating the Request: Once you initiate an invoice request, you will receive a response that includes either a redirect URL, or an invoice link (depending on how you initiated it. To know moreclick here). This URL is crucial for guiding your customer through the payment process.
"redirect_url": "https://secure.paytabs.com/payment/page/59946B********************B4817FD4488",
"invoice_link": "https://secure.paytabs.com/payment/request/invoice/2072841/A8CB**************868206DB76382A"
  1. Redirecting the Customer: You should redirect your customer to one of these URLs as you normally would in a payment transaction. This step allows the customer to complete their payment securely and efficiently. Below are the resulted payment page that your customer will be redirected to:

Sample Invoice Page Sample Invoice Payment Page

  1. Download the invoice: Using the same steps clarified in this section.

Sample Invoice PDF Response

  1. Share the invoice: After that, you can use the object sent you earlier in the above response with the associated libraries according to your development language to read/convert it as a displayable PDF document that even can be downloaded s the following:

Sample Invoice PDF Page

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.