Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Wallet/ChargeCommand.php
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | public function handle() | ||||
// Sanity check after refresh (owner deleted in meantime) | // Sanity check after refresh (owner deleted in meantime) | ||||
if (!$wallet->owner) { | if (!$wallet->owner) { | ||||
continue; | continue; | ||||
} | } | ||||
$charge = $wallet->chargeEntitlements(); | $charge = $wallet->chargeEntitlements(); | ||||
if ($charge > 0) { | if ($charge > 0) { | ||||
$this->info( | $this->info("Charged wallet {$wallet->id} for user {$wallet->owner->email} with {$charge}"); | ||||
"Charged wallet {$wallet->id} for user {$wallet->owner->email} with {$charge}" | |||||
); | |||||
// Top-up the wallet if auto-payment enabled for the wallet | // Top-up the wallet if auto-payment enabled for the wallet | ||||
\App\Jobs\WalletCharge::dispatch($wallet); | \App\Jobs\WalletCharge::dispatch($wallet); | ||||
} | } | ||||
if ($wallet->balance < 0) { | if ($wallet->balance < 0) { | ||||
// Check the account balance, send notifications, (suspend, delete,) degrade | // Check the account balance, send notifications, (suspend, delete,) degrade | ||||
// Also sends reminders to the degraded account owners | // Also sends reminders to the degraded account owners | ||||
\App\Jobs\WalletCheck::dispatch($wallet); | \App\Jobs\WalletCheck::dispatch($wallet); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |