Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get total amount spent for a Stripe customer

What would be the easiest way to calculate the total amount a specific Stripe customer has spent?

fn(stripeCustomerId) -> totalAmountSpent

I don't believe there are any API endpoints that allow aggregate queries, so I'm guessing I'd have to enumerate all payment intents or invoices and manually calculate the total?

like image 656
pqvst Avatar asked Oct 22 '25 06:10

pqvst


1 Answers

You're right, there aren't Stripe API endpoints for aggregate queries! I'd list Charges or Payment Intents specifying the Customer parameter and then sum on your side.

As an alternative, you could use something like Stripe's Sigma to create SQL queries from your data, but this feature comes at an additional cost.

like image 107
duck Avatar answered Oct 24 '25 10:10

duck