#mrr3dl1ne_webhooks
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1420460565532381205
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello, payment intents create Charges and Charges have a BalanceTransactions which has fee info that you can use to calculate this https://docs.stripe.com/expand/use-cases#stripe-fee-for-payment
@shy badger the same issue happens with the charge.succeeded webhook
there is no fee or net amount there either
Yep, charges themselves don't have fee info, that is just on the balance transaction which by default gets created slightly after the charge object. If you listen to charge.updated events you will see an event when the balance transaction gets added and can look up the fee from there.
https://docs.stripe.com/payments/payment-intents/asynchronous-capture#listen-webhooks
You can change that by passing capture_method: 'automatic' when creating payment intents but that will make your payment intent confirmations slower. Basically by default a confirm will return after funds have been authorized but before they are captured (which is when the fees and such are calculated). If you pass that param, we wait for both the auth and capture to complete before the confirm returns which also means the initial charge that is created will have the balance transaction.
ah ok - so if I just listen to charge.updated that will allow me to capture that info?
Yep yep, you'll have to retrieve the balance transaction in your webhook handler but that will get you the fee info
perfect! thank you for the quick help on this
Of course! Also I just remembered that balance transactions actually already have a net amount field, so you don't even have to do the subtraction! https://docs.stripe.com/api/balance_transactions/object#balance_transaction_object-net
perfect - one last question for you ..
i can capture this via the api also right? so, I could run an hourly bg script to look through all transactions on our side that haven't been updated with a 'net amount' yet and just pull them from the api as needed?
just trying to think through the most resilient solution
Yep you can list them via the API and each call can return up to 100 balance transactions. Looking at the call, I think what you would want to do is pass the latest balance transaction that you have received that way to the ending_before parameter that way you will only get transactions more recent than that one https://docs.stripe.com/api/balance_transactions/list
Also helpful, our API libraries usually have auto-pagination functionality to make paging through the list easier https://docs.stripe.com/api/pagination/auto
this is great. thank you so much!
Of course, glad I could help!