#Malf-Balance
1 messages ยท Page 1 of 1 (latest)
Hi there, just want to clarify. Is this question related to balance or balance transaction?
It is of my understanding those two goes hand in hand?
I had a working application in testmode, due to the delay with payments live I have to modify.
What I want to accomplish is when balance is available, compare it to payments done and do some stuff behind the scenes
When balance is available I want to transfer it to connected accounts
If the purpose is to retrieve the available balance of your account, you can just call this API https://stripe.com/docs/api/balance/balance_retrieve instead of getting the list of balance transactions.
Sorry for my bad english.
Trying again ๐
I need to list the transactions done which has balance available.
$stripe->balanceTransactions->all(['limit' => 3]) using this snippet only gives me an error and I cant understand why.
Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
req_xmL3lwewZBHvdU
Can you share with me the request ID that gave your an error?
event_id, does it work for you? evt_3LVNL6ALfhnGkkrl0CftoXga
this row gives me an error and I can't see the fault: $balance_transactions = $stripe->balanceTransactions->all(['limit' => 3]);
OK. I think I know why it fails.
The source property in a balance_transaction object can be many different thing, it can be a dispute, payout, charge and many other things.
Since you are only interested in charge, you shall check the type of the balance transaction, and only attempt to retrieve the charge object if type==charge.
Otherwise, if the type of the balance transaction equals to other value, calling the charge retrieve API will fail because the source is not a valid charge ID.
I see, thank you for the explanation ๐
Just to be certain, how would you write that line of code?
In the foreach loop, you can add something like
/// retrieve the charge object
...
thank you for the direction
to make the balanceTransactions call.
\Stripe\balanceTransactions->all(['limit' => 3]);
I have not learned the syntax 100% yet towards the API
it is an event right?
so it should be: \Stripe\event::balanceTransactions->....
It should be \Stripe\BalanceTransactions->
Btw this is the legacy way of using Stripe PHP library, please consider to use StripeClient instead. Here's the migration guide https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0
Much obliged