Search code examples
stripe-payments

Stripe retrieve all the paid amount on a subscription


I have a subscription with proration. So for the first months, the client is charged 10 euros and for the last month the client is charged 9.99. Sometimes, some coupons are applied and the client is charged 5 euros. How can I get the total of all the amounts paid by this customer for this subscription? I need to get the sum of 10 x (number of months) + 9.99 + 5 x (number of months where coupons was applied).. In other words, I need to get all the amount of all the money he previously paid until now.


Solution

  • You can retrieve all the invoices for a given Customer https://stripe.com/docs/api/invoices/list. If you want the invoices for a particular Subscription, pass in the subscription parameter.

    You can then iterate through all the invoices and sum the amounts paid. Note that you can only retrieve up to 100 invoices.