stripe / stripe-php

PHP library for the Stripe API.
https://stripe.com
MIT License
3.76k stars 848 forks source link

Provide a helper method to download the PDF of an invoice #1229

Open dunglas opened 2 years ago

dunglas commented 2 years ago

A helper method is provided to download the PDF of a quote ($quote->pdf()), but not for an invoice. Unfortunately, doing file_get_contents($invoice->invoice_pdf) to download the PDF doesn't work anymore because PHP doesn't handle the redirection to S3 properly.

Using curl is a working workaround (see https://github.com/dunglas/stripe-invoice-exporter/pull/1), but a dedicated helper method could be convenient.

Best regards,

richardm-stripe commented 1 year ago

Sorry for the late response. Thank you for the suggestion. I'm convinced this would be useful to add. Quote PDF is a special case because the API contains /v1/quotes/:quote/pdf which contains the PDF, but /v1/invoices/:invoice/pdf does not exist (yet?) so the implementation would have to be different. I'm imagining something like \Stripe\Util::download_file($invoice_pdf) which would be provided for convenience but would just use curl.