#mounirmtl
1 messages · Page 1 of 1 (latest)
Hi, yes you could list all charges for a given customer id, https://stripe.com/docs/api/charges/list.
That's what I thought indeed. But It's not clear how to use the charge data to have an accurate representation of the amount spent between refunds and everything
Should I just sum up the amount and substract refunds?
What about charges not captured yet?
Also how do I keep this number up to date?
I guess by subscribing to charge updates webhook. But how do I know if the charge can be added to the amount spent or if I should wait for a next update?
Yes, you could do that. That is up to you. Reporting is not our expertise here. We're happy to help with any integration related questions. You might want to reach out to stripe support at https://support.stripe.com/contact on reporting questions. Otherwise, you can list all charges, and refunds to get the data needed. You, can also use Metadata on your end to track this as well.
Maybe you have an idea on what fields should I look at on the charge object?
The charge object has a lot of fields and I'm not sure which ones to rely on.
For example there are the following fields amount, amount_captured, refunded, captured, paid.
refunded is false if the charge is partially refunded but how do I get the partial refund amount for this charge?
What's the difference between captured and paid?
If amount_captured < amount, does that mean that more amount will be captured later?
Ah, I see. let me add some context (typing)
amount_captured - shows the amount that was captured for that charge. In cases where the amount and the amount_captured are not the same, the remaining amount is reversed back to the customer. Captured and paid are essentially the same to me.
in what scenario amount_captured and amount can be different? Is amount_captured = amount - refunds
No, when you capture the payment manually, the amount can differ. You can read more about it here: https://stripe.com/docs/payments/place-a-hold-on-a-payment-method
Yeap!
Thanks