Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/StripeInfo.php
Show All 39 Lines | public function handle() | ||||
$this->info("Found user: {$user->id}"); | $this->info("Found user: {$user->id}"); | ||||
$wallet = $user->wallets->first(); | $wallet = $user->wallets->first(); | ||||
$provider = PaymentProvider::factory('stripe'); | $provider = PaymentProvider::factory('stripe'); | ||||
if ($mandate = $provider->getMandate($wallet)) { | if ($mandate = $provider->getMandate($wallet)) { | ||||
$amount = $wallet->getSetting('mandate_amount'); | $amount = $wallet->getSetting('mandate_amount'); | ||||
$balance = $wallet->getSetting('mandate_balance') ?: 0; | $balance = $wallet->getSetting('mandate_balance') ?: 0; | ||||
$status = 'invalid'; | |||||
if ($mandate['isPending']) { | |||||
$status = 'pending'; | |||||
} elseif ($mandate['isValid']) { | |||||
$status = 'valid'; | |||||
} | |||||
if ($wallet->getSetting('mandate_disabled')) { | |||||
$status .= ' (disabled)'; | |||||
} | |||||
$this->info("Auto-payment: {$mandate['method']}"); | $this->info("Auto-payment: {$mandate['method']}"); | ||||
$this->info(" id: {$mandate['id']}"); | $this->info(" id: {$mandate['id']}"); | ||||
$this->info(" status: " . ($mandate['isPending'] ? 'pending' : 'valid')); | $this->info(" status: {$status}"); | ||||
$this->info(" amount: {$amount} {$wallet->currency}"); | $this->info(" amount: {$amount} {$wallet->currency}"); | ||||
$this->info(" min-balance: {$balance} {$wallet->currency}"); | $this->info(" min-balance: {$balance} {$wallet->currency}"); | ||||
} else { | } else { | ||||
$this->info("Auto-payment: none"); | $this->info("Auto-payment: none"); | ||||
} | } | ||||
// TODO: List user payments history | // TODO: List user payments history | ||||
} else { | } else { | ||||
// TODO: Fetch some info/stats from Stripe | // TODO: Fetch some info/stats from Stripe | ||||
} | } | ||||
} | } | ||||
} | } |