#Sven

1 messages ยท Page 1 of 1 (latest)

charred spireBOT
lavish charm
#

amount 120 (1.20 EUR), amount_captured 120. But where can I see the 029 (0.29 EUR) fee that Stripe took from the Merchant

vernal nexus
#

Hi ๐Ÿ‘‹ I believe the information you're looking for is stored on the Balance Transaction objects.

The path to get there from the Payment Intent is:
Payment Intent -> Charge
https://stripe.com/docs/api/payment_intents/object#payment_intent_object-latest_charge
Charge -> Balance Transaction
https://stripe.com/docs/api/charges/object#charge_object-balance_transaction
Check the fee and fee_details
https://stripe.com/docs/api/balance_transactions/object#balance_transaction_object-fee

You can leverage expand to retrieve that chain of objects in a single request:
https://stripe.com/docs/api/expanding_objects

charred spireBOT
lavish charm
#

Yes, you're right. Hence when we store the transaction in our database we will have to make yet another API request to get the transaction fee

#

(to have it saved for us in our database for easy access)

vernal nexus
#

Hm, I've not tried it before firsthand, but you may be able to use expand so the Charge and Balance Transaction are returned inline from the request that creates and confirms the Payment Intent.

lavish charm
#

There doesn't seem to be a direct relation transmitted in the webhook for payment_intent.succeeded that references to a balance transaction either. So probably would need to list balance transactions and then search for the source ch_ id

vernal nexus
#

Just confirmed that you can use expand to receive those properties in the response to the request that confirms the Payment Intent.

#

Correct, payment_intent.succeeded Events will not contain a reference to a Balance Transaction, but they will contain a reference to the associated Charge object, which has a reference to the related Balance Transaction.

lavish charm
#

I'll look into expand. Will this then also be included in the webhook for this event/charge, or that'll be additional API requests? ๐Ÿ™‚

#

We usually try to be as resourceful as possible with API requests, hence my questions

#

expand[]=latest_charge.balance_transaction would be the right one I believe

vernal nexus
#

I don't believe expand impacts webhook event payloads, and yes, if you're on the latest API version then expand: ['latest_charge.balance_transaction'] is what you're looking for (syntax may need to be changed based on the library you're using)

lavish charm
#

Thank you very much, I'll have a look into this! ๐Ÿ™‚

vernal nexus
#

Any time!

lavish charm
#

Have a lovely evening/day ahead!