I'm using the Stripe API and I'd like to present my customer's a list of their invoice history along with the relevant receipts.
I can't find anywhere in the Stripe API (https://stripe.com/docs/api?lang=php) that allows me fetch a list of a customer's receipts. Is there something I'm missing?
It really wouldn't be too hard. First you would get all invoices:
https://stripe.com/docs/api?lang=php#invoice_object https://stripe.com/docs/api?lang=php#list_customer_invoices
Each invoice has a "customer" property, so all you need to do is search through them for the invoice that has a customer id that matches yours.
Each invoice has a "receipt_number" property, so you should be good to go!
Each invoice includes a
charge
property which contains the id of its last charge. This will either be the current/final payment attempt (for invoices not successfully paid) or the successful payment (for paid invoices).This allows you to easily use the charge and invoice data to present a receipt to the user, but a "receipt" is itself more of an application-side notion; its needs and presentation vary with the application.
Once you've got the data, you can present a receipt however you like.
Ideally, I recommend caching these records locally. It's almost painless to do if you're receiving webhooks. You can then model (and search!) a local receipt record as best fits your needs, your customer then gets the benefit of very fast billing display, and we all get the benefit of less load on Stripe's API endpoints.