To get the balance object from stripe I know to use the following call:
$balance = $this->stripe->balance->retrieve(null, [
'stripe_account' => $facility->stripe_account_id
]);
However this provides an array of arrays, the 2 main keys pending
and available
both have arrays beneath but from what I can tell there is only 1 item in that nested array.
I also believe that to get a total balance you need to add the contents of pending
and available
. However, would there ever be a reason for a second item within either of those top level items?
Would this implementation work, or do I need to loop both available and pending to get an accurate total balance:
$totalBalance = $balance->available[0]->amount + $balance->pending[0]->amount;
Actual php response
#_originalValues: array:4 [
"object" => "balance"
"available" => array:1 [
0 => array:3 [
"amount" => 0
"currency" => "gbp"
"source_types" => array:1 [
"card" => 0
]
]
]
"livemode" => false
"pending" => array:1 [
0 => array:3 [
"amount" => 0
"currency" => "gbp"
"source_types" => array:1 [
"card" => 0
]
]
]
]