#MarcusStripe-payment-intents

1 messages ยท Page 1 of 1 (latest)

fallow furnace
#

Hi ๐Ÿ‘‹ yes, you can use the API to interact with Payment Intents that were created automatically by Invoices or Subscriptions.

tidal ocean
#

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?

fallow furnace
#

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

tidal ocean
#

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?

fallow furnace
#

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.

tidal ocean
#

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

fallow furnace
tidal ocean
#

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?

fallow furnace
#

Yeah, it looks like that would get what you're looking for, does it when you run it?

tidal ocean
#

I had no chance to try yey

#

yet

#

ok will do and get back if not

#

thanks

fallow furnace
#

Sounds good!

tidal ocean
#

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

fallow furnace
#

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.

tidal ocean
#

yay! That seems simple

#

thanks. bye ๐Ÿ™‚

fallow furnace
#

๐Ÿ‘‹