#MarcusStripe-payment-intents
1 messages ยท Page 1 of 1 (latest)
Hi ๐ yes, you can use the API to interact with Payment Intents that were created automatically by Invoices or Subscriptions.
and then I iterative over the list and sum up the amount_received ?
is this aleadt the total, or does this have negative amounts for refunds?
The amount field on the Payment Intent is the amount that the payment processed, and does not include refunds. From the Payment Intent you can find its related Charge object in the charges field:
https://stripe.com/docs/api/payment_intents/object#payment_intent_object-charges
Charge objects have a refunds parameter that points to any related Refund objects:
https://stripe.com/docs/api/charges/object#charge_object-refunds
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so, you are saing, from the payment intent, I need to go to the charge, and if there are refunds, I have to go to the refunds from there...
Is this already included / can I use one or more exends, or do I need to make several calls for it?
You can use expand for part of this, but expansion has a limit of only being able to go four layers deep. So you may hit limits with that since both Charges and Refunds are inside of arrays.
PaymentIntentCollection paymentIntents =
PaymentIntent.list(
PaymentIntentListParams.builder()
.setCustomer(stripeCustomerId)
.build());
for (PaymentIntent paymentIntent : paymentIntents.getData()) {
for (Charge charge : paymentIntent.getCharges().getData()) {
charge.getAmount();
//charge.getRefunded()
for (Refund refund : charge.getRefunds().getData()) {
refund.getAmount();
}
}
}
Do I actually need an extent here... since i do not call any "..object" items.. which usually indicate extension points
also I wonder - charge.getRefunded - is it true if there is ANY refund, or is it true if the entire amount is refunded.. Nothing in the api documentation found about it
Did you look at the API spec for the refunded field? It states:
Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.
https://stripe.com/docs/api/charges/object#charge_object-refunded
I did not find the field at all there
thanks
ok, so... based on my above code... do you agree it seems it could work without any extend points?
Yeah, it looks like that would get what you're looking for, does it when you run it?
Sounds good!
one more little thing-
the idea would be -
calling this at the first of the month. Now for any given customer.. of course that could be just before or after a monthly charge
can I limit the charges seen.. by date or so?
and just assuming the customer stays for lets say 10 years... it would be 120 charges at a minimum.. there is probably a limit of 100 as in other endpoints?
so giving it a start and end date would be great
If you're listing Charges (rather than retrieving them directly by their ID), then yes you can use the parameters within the created hash to set bounds on the objects returned.
https://stripe.com/docs/api/charges/list#list_charges-created
Yes, all of our list functions max out at returning 100 objects per page.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
๐