Stripe API - Receipts Listing

2020-06-07 08:22发布

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?

2条回答
smile是对你的礼貌
2楼-- · 2020-06-07 08:26

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!

查看更多
该账号已被封号
3楼-- · 2020-06-07 08:49

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.

查看更多
登录 后发表回答