#NewtReyes
1 messages · Page 1 of 1 (latest)
Hey there
The best way to do this would be to look at the date of your most recent payout and the available_on of the Balance Transaction (https://stripe.com/docs/api/balance_transactions/object#balance_transaction_object-available_on)
But there is no way to do this directly... you have to deduce it based on the above
Or, you list balance transactions by payout using: https://stripe.com/docs/api/balance_transactions/list#balance_transaction_list-payout
And then the remaining have not been paid out yet
But that's pretty inefficient
Mmmmm
Alternative question: is there a way to know which transactions were included in the available and pending balances that can be retrieved using https://stripe.com/docs/api/balance/balance_retrieve?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Not without doing a similar thing to what I discussed above
It sounds like really what you want is to cache this data yourself
So each time a payout is made you list the balance transactions for that payout
And store it
Then you can always compare to that
Nice idea
Interesting
Is there a way to receive a webhook whenever a balance transaction is created?
No, we fire balance.available each day when the new balance is available to be paid out: https://stripe.com/docs/api/events/types#event_types-balance.available
But not hook for every BT
So, here's what we are trying to achieve: we would like to make sure an external system is in sync with the information on the Stripe side.
For that, we are already listening to the payouts so we make sure all balance transactions included in the payouts are present and correct in the system.
But sometimes, the available balance in the external system is different from the one Stripe shows. So, we want to review all balance transactions that add up to the available balance that Stripe shows us so that we can auto correct any issues this system may have.
Based on your idea, if we could cache all balance transactions that are created for a specific connected account, then when a payout is generated we could remove the payout balance transactions from the list that we have cached. That should give us all balance transactions that have not been included yet.
Yep that's what I'd do
But we still need to figure out how to cache all the balance transactions that are created since there is no webhook that notifies us of that.
We will have to listen to lots of webhooks to cache them all.
Am I missing something?
In this case I think you just want to poll your server here
Instead of using webhooks
You list balance transactions using https://stripe.com/docs/api/balance_transactions/list
So basically you retrieve balance via the API when you display this balance in your external system.
If that balance doesn't match, you list balance transactions
And then update your cached list
If you want to keep that cached list more up-to-date then you could update the cached list each time there is a payout.paid
How far back in time should I go when calling https://stripe.com/docs/api/balance_transactions/list to make sure I am getting all transactions that have not been included in a payout?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Sorry if I am missing your point
I am really trying to understand
Let's back up one sec to the root cause here
How are you calculating the available balance in your external system to begin with?
Like why is it not in-sync?
Here's what we were doing: every time a new payout was generated, we retrieved all the related balance transactions and made sure that the system had all the required information to back those balance transactions with payments, refunds, disputes, transfer reversals, etc. At that point, if anything was out of sync, it got automatically synchronized.
That allows us to make sure the system is in sync up to the last balance transaction that was included in the last payout.
Now, we still need to do the same for any transaction that has not yet been included in a payout.
So, we need a way to retrieve those balance transactions so that we can perform the same process on those.
Does that make sense?
Yes it does
Now, if I go back to your idea: if we could cache all balance transactions on our side and then remove the ones that are included in a payout (by mean of the payout.paid webhook), then we would be able to do that
Correct
Yes
That mostly depends on the different payment methods that you are using
right
For how long from when the BT is created until it would be available
And what about this: Could we use the balance.available webhook to know when a new balance transaction is available?
No, it fires when your funds become available each day
Not each time a new BT is created
Got it
what about retrieving 2 days of transactions every day and remove the ones that are already included in a new payout when a new one is available?
Sooo also, why are you focused on the BTs?
Why not just retrieve the balance itself?
Because you want to show the BTs?
Sure doing things methodically is great if you don't care about your external Dashboard being up-to-date
BTs allow us to see if we are missing any piece of information in that external system. Ex. We receive a balance transaction for a charge and that charge is not in the system or it is out of sync. Then we trigger a synchronization for that charge (called payment in the external system)
Okay so this isn't about a UI here, then?
Correct. It's about keeping an external system in sync with Stripe
We are using the Stripe balance to detect when the 2 are out of sync.
We are also using the payouts, but that only allows us to sync up to the last transaction included in the last payout.
Also, we are already using webhooks extensively. But even those fail from time to time and we need to make sure we have a back up plan that could resync this external system automatically.
Okay okay okay
I thought this was about an external system UI that you wanted to show available balance
This is way easier then and you just poll like you were saying
Run it each day
And then run it if you need to sync
By "run it" I just mean List balance transactions via the API
And update your internal data
If you need to sync it outside this regular runtime, you just list BTs since the last time you listed them