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.


In this article, we will walk you through the proper way to download the invoice as a PDF byte object using the mentioned endpoint, so that you can use it to either download or display it to your customer. We highly recommend that you and your team check our "Step 3.1.4 - Invoices | Payment Workflow" solution article first to understand the business/logic this integration type relay on.


In this article, you will be going to know about:




Why do you need to Download the invoice?


Once your invoice is initiated, you can use the above-mentioned endpoint along with your server key and your invoice ID to download this invoice via a simple GET request and let your customer display and download the static PDF of this invoice.


The Minimum Required Parameters


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


  • via a GET Request

    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:

    Parameter

    Data Type

    Required

    Purpose

    invoice_id

    INT

    Indicates the invoice reference you want to query.

    To know more about this parameter, please click here.



Sample Request Payload 


The below sample request payload will show you how you can use the download invoice API endpoint to  perform a request via CURL:


  • via a GET Request 

    curl --location --request GET 'https://secure.paytabs.sa/payment/invoice/{{InvoiceId}}/download/pdf' \
    --header 'Authorization: {{server_key}}'




Sample Response Payload


Once you follow the above steps, you will receive a PDF byte object as a response to your request, and it will contain data that looks something like the following:




 After that, you can use this object 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:









⌂ To get familiar with the whole process and the other steps, kindly navigate to our "The PT2 API Endpoints Integration Manual" solution article. 

 And to get familiar with the rest of the steps regarding the current step "Step 7 - Manage Transactions" kindly click here.

 And to navigate to the previous step in the integration process "Step 6 - Handle the post payment responses" kindly click here.