#cuberick.

1 messages · Page 1 of 1 (latest)

royal furnaceBOT
exotic kindle
#

HI 👋

You can use the Balance Transaction API to list all Balance Transactions associated with a Payout: https://stripe.com/docs/api/balance_transactions/list

This will let you know what Invoices (through their related Payment Intents) are included in each payout

cinder crow
#

thanks @exotic kindle looking at that endpoint i can't fetch a balance transaction based on a particular payment object so I'm not sure the best way to do it still. I don't see webhooks for when new balance transactions are created.

exotic kindle
#

No

#

that isn't how you use the API in this case.

#

Unfortunately the only way you can get that information is to go from the Payout object and see if an Invoice was included in it

#

You can't go from the Payment -> Payout

cinder crow
#

but i don't know which payout would contain it... but yea i guess since we're just doing payouts daily i could have a nightly batch that gets everything for the daily payout, then sweeps through marking the payments that were in there as 'really succeeded'

exotic kindle
#

But if you have a particular payment you can find it's Balance Transaction to see the timestamp for when it landed in your account

cinder crow
#

oh? ok. let me go look at that closer.

exotic kindle
#

It's kind of a long trail but you can simplify it by using the expand parameter: https://stripe.com/docs/expand

So if you had an Invoice ID you could get the whole chain by passing payment_intent.latest_charge.balance_transaction in the expand parameter when retrieving the Invoice.

cinder crow
#

ok. seems promising. looking at the dashboard now for some existing payments.

#

oh maybe dashboard does not expose the charge object. I'll have to poke at the API maybe to try your suggestion.

exotic kindle
#

Yeah, we're a coder focused server so most of our advice will recommend API endpoints to solve problems

cinder crow
#

From our business case perspective are we doing something wrong here?

#

I just wonder if making sure the money is in the bank is an unnecessary precaution

exotic kindle
#

I don't see anything particularly wrong here, just that funds settlement timing can be a little variable (especially depending on the payment method type) so there will be times where an invoice is succesful but the funds haven't settled by the payout cutoff. In that case the funds will be in the next payout.

cinder crow
#

OK. Just wondering since the webhooks for an invoice stop after the payment is successful and invoice gets marked paid.

#

Given this requirement having the payment have another webhook when funds were paid out would make this easy.

exotic kindle
#

That is the last state change for the Invoice object so that is where the data trail ends for Stripe.

cinder crow
#

Ok. So the approach I think we're going with here will require me to have a nightly batch that runs AFTER stripe does the daily payout and checks all our paid invoices where funds have yet to be delivered. If a particular invoice has a balance_transaction then I will be able to deliver funds for that invoice.

The way i'll know it's time to run this batch is by listening for a payout.paid event.

exotic kindle
#

yes that is a valid approach to verify the funds delivery at time of payout

cinder crow
#

Thanks for all your help here. I am amazed at how quickly I got to talk to somebody so knowledgeable.

#

Also I like your handle! Moomintroll FTW!