Invoice PDF download via REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm making POC for my client. I need to download batch of invoices in PDF format(for example, all invoices from last month). Is it possible to download pdf files via REST API? When I crawled on site I noticed request(aftek click PDF button in invoice actions) like this:
https://www.sandbox.paypal.com/invoice/actions/render-pdf/INV2-3DM5-KT37-4G3G-NU9T?time=161084669850...
Can I make that request from server side?
- Labels:
-
Invoicing REST APIs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@m8code --
Your link requires the viewer to be logged-in to their account, and will only display the invoice if the logged-in user is a party to the invoice. There is a not-so-well-know URI that took me several months to figure out. In demonstration, here's a PHP function that cURL's the PDF's bytes of a specific invoice so they can be later saved as appropriate:
function get_invoice_bytes($paypal_id) {
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://www.sandbox.paypal.com/invoice/payerView/detailsInternal/' . $paypal_id .'?printPdfMode=true ',
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_HEADER => FALSE,
CURLOPT_RETURNTRANSFER => TRUE,
));
$bytes = curl_exec($ch);
curl_close($ch);
return $bytes;
}
$pdf_bytes = get_invoice_bytes('INV2-3DM5-KT37-4G3G-NU9T');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have write a little php script which downloads invoice details and renders the links to download as html page. then u can open it into browser and open all links in tabs at once for multi download.

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Charge a customer for the remaining balance after a purchase has been made? in REST APIs
- Generating Wrong Data for Invoices using REST sandbox account in Sandbox Environment
- Usa in REST APIs
- UNPROCESSABLE_ENTITY MISSING_RECIPIENT_EMAIL in REST APIs
- Unable to download dispute related attachment via Rest Api in REST APIs