#juanito-invoice
1 messages ยท Page 1 of 1 (latest)
@half thistle if you get a 429, try passing a User-Agent HTTP header on the request you're making to download the invoice
it's just that we block 'anonymous' requests, if you pass a UA it should just work. you should never get a 500.
thank you for your answer, currently I make <a href> which redirects towards the link of the parameter "invoice_pdf" the limit being 100 operations per second I limit the opening of tab to 45 but the downloading blocks from some downloading by returning me a code 500 I do not understand knowing that it is the browser which carries out the requete
that seems like a really strange way to do things.
why aren't you writing a script to just download the PDF and save it to whatever database/system you need?
I agree with you, that's what I tried to do but the stripe api only allows access to the invoice through "invoice_pdf" which is a direct download link, I didn't succeed in php to download this file otherwise
If you have a way to access the pdf invoice without getting the direct download link or if you know how to download the document from the "invoice_pdf" parameter in php I'm interested ๐
it's just the same way you'd download any file in PHP it's not Stripe-specific
what code did you try exactly?
I've used this answer before(https://stackoverflow.com/a/18725585/9769731) and it works fine
Yes but the problem is that "invoice_pdf" is not the link of the document, but the link of direct download of the document what does not allow to download it "normally" via php
I will take a look at your link, thanks for your help ๐
I have just tried for an invoice and in the same way as I had tried before to download the invoices, it creates me an empty pdf file (however, the link to the invoice refers to an existing invoice)
I don't understand I still have my empty invoice.pdf file with your code after replacing $url with the url of a real invoice ๐ค
Did you try with a test invoice or with a real invoice? I don't know if this can explain the difference
I agree with you that's why I don't understand, I can share a real url of a client if you want to test
the url is in the form : https://pay.stripe.com/invoice/acct_xxx/live_xxx/pdf
do you have the in_xxx ID of that invoice? (from the API/dashboard)
here is an example of a link "invoice_pdf" of a real invoice:
(Please do not share it )
If I use this link in the code you shared with me, I get an empty file
Hey, taking over from @dawn tartan
You should instead just share the Invoice object ID
We can get the URL from there
(this is a public channel)
Hi, thanks for your help, here is the id of an invoice: in_1K5SGkHr4Qvn9djgYG89Cd6
Hmm, that seems invalid
I take this information from stripe api
Oh dear, I'm sorry
It's working for me using the URL from that Invoice object
So you can download the invoice in php using the invoice id? Do you use the "invoice_pdf" parameter?
I used the URL from invoice_pdf field, yes
The $url variable in the code @dawn tartan shared
can you send me the invoice_pdf link of the invoice ? i can send you too its juste to compare because on my side I just get a empty pdf (thank you for your help)
https://pay.stripe.com/invoice/acct_1G81rWHr4Qvn9djJ/live_YWNjdF8xRzgxcldIcjRRdm45ZGpKLF9La3lETWhKbGZOdXZwelZTR2x5QUwxZXhCM1lsVXk001007nXrC0U8/pdf
Yes, we have the same link, I tried on server and I also get an empty pdf when I execute the previous code replacing the $url
Hi ๐ I'm getting caught up on this thread.
I'm not as familiar with doing this from PHP, but when I was downloading invoice PDFs via curl I know it was important that I let it follow redirects.
But did you use the same code as the one used before or another one (in another language?)
I was downloading it directly from my terminal with this command (just checked and it worked with the URL provided here)
curl -L https://pay.stripe.com/invoice/acct_1G81rWHr4Qvn9djJ/live_YWNjdF8xRzgxcldIcjRRdm45ZGpKLF9La3lETWhKbGZOdXZwelZTR2x5QUwxZXhCM1lsVXk001007nXrC0U8/pdf --output new_invoice.pdf
Yes I agree with you, you can do it with the terminal but via php I only get an empty file, I will try to execute your command under php
I managed to execute your command via php, I think I can get around my initial problem with your command, thank you for your help good evening ๐