#juanito-invoice

1 messages ยท Page 1 of 1 (latest)

dawn tartan
#

@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.

half thistle
#

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

dawn tartan
#

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?

half thistle
#

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 ๐Ÿ˜‰

dawn tartan
#

it's just the same way you'd download any file in PHP it's not Stripe-specific

#

what code did you try exactly?

half thistle
half thistle
#

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)

dawn tartan
#

worked fine for me when I tried it

#

that's what I used if it helps

half thistle
#

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

dawn tartan
#

it would be the same for any invoice

#

what URL do you use

half thistle
#

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

dawn tartan
#

do you have the in_xxx ID of that invoice? (from the API/dashboard)

half thistle
#

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

smoky fjord
#

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)

half thistle
#

Hi, thanks for your help, here is the id of an invoice: in_1K5SGkHr4Qvn9djgYG89Cd6

smoky fjord
#

Hmm, that seems invalid

half thistle
#

I take this information from stripe api

smoky fjord
#

There's a character missing from what you sent

#

in_1K5SGkHr4Qvn9djJgYG89Cd6

half thistle
#

Oh dear, I'm sorry

smoky fjord
#

It's working for me using the URL from that Invoice object

half thistle
#

So you can download the invoice in php using the invoice id? Do you use the "invoice_pdf" parameter?

smoky fjord
#

I used the URL from invoice_pdf field, yes

#

The $url variable in the code @dawn tartan shared

half thistle
#

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)

smoky fjord
#

https://pay.stripe.com/invoice/acct_1G81rWHr4Qvn9djJ/live_YWNjdF8xRzgxcldIcjRRdm45ZGpKLF9La3lETWhKbGZOdXZwelZTR2x5QUwxZXhCM1lsVXk001007nXrC0U8/pdf

half thistle
#

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

lean spear
#

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.

half thistle
#

But did you use the same code as the one used before or another one (in another language?)

lean spear
#

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

half thistle
#

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 ๐Ÿ‘