#Malf-Balance

1 messages ยท Page 1 of 1 (latest)

static peak
#

Hi there, just want to clarify. Is this question related to balance or balance transaction?

wintry nova
#

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

static peak
wintry nova
#

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.

static peak
wintry nova
#

req_xmL3lwewZBHvdU

static peak
#

Thanks for the ID.

#

The response of this request is 200, and I don't see any errors.

wintry nova
static peak
#

Can you share with me the request ID that gave your an error?

wintry nova
#

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]);

static peak
#

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.

wintry nova
#

I see, thank you for the explanation ๐Ÿ™‚

#

Just to be certain, how would you write that line of code?

static peak
#

In the foreach loop, you can add something like

/// retrieve the charge object
...
wintry nova
#

thank you for the direction

wintry nova
#

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->....

static peak
#

It should be \Stripe\BalanceTransactions->

wintry nova
#

Much obliged