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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With