#Durrell
1 messages · Page 1 of 1 (latest)
The likelihood of a race condition occurring is even greater since we would be performing these calls in a background job.
Is there a recommended way to retrieve the balance of the account at the time the Balance Transaction was created?
Unfortunately not, as there are a myriad of things (payments, refunds, disputes, fees, application fees, etc.) that could be contributing to that balance, so I don't know of a way to do that reliably.
ok that makes sense.
One option is to look up an account's balance whenever a balance effecting event occurs. So for example we could listen to the payout.paid event which sends a Payout object in its payload.
That could work! Though the race condition you mentioned will definitely be a possibility. That being said, you could do some validation to make sure the difference makes sense by also getting the balance before a payout is actually made. Obviously that only works if they're on manual payouts (e.g. the payouts are not schedule by Stripe), but that's the only thing I can think of as a novel solution
ok thank you. I can see that getting complicated.
Yeah, it feels a bit flimsy, but I'm struggling to think of an alternative