loadBalance(); } public function loadBalance(): void { try { $this->balance = Cache::remember('stripe_balance', now()->addMinutes(15), function () { Stripe::setApiKey(config('services.stripe.secret')); $balance = Balance::retrieve(); return [ 'available' => collect($balance->available)->map(fn($b) => [ 'amount' => $b->amount / 100, 'currency' => strtoupper($b->currency), ])->toArray(), 'pending' => collect($balance->pending)->map(fn($b) => [ 'amount' => $b->amount / 100, 'currency' => strtoupper($b->currency), ])->toArray(), ]; }); $this->error = null; } catch (\Exception $e) { $this->error = 'Unable to fetch Stripe balance'; $this->balance = null; } } public function refresh(): void { Cache::forget('stripe_balance'); $this->loadBalance(); } }; ?>

Stripe Balance

@if($error)

{{ $error }}

@elseif($balance)
@foreach($balance['available'] as $available)

Available

${{ number_format($available['amount'], 2) }} {{ $available['currency'] }}

@endforeach @foreach($balance['pending'] as $pending) @if($pending['amount'] > 0)

Pending

${{ number_format($pending['amount'], 2) }} {{ $pending['currency'] }}

@endif @endforeach
@else
@endif

Cached for 15 min