Page MenuHomePhorge

MollieInfo.php
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

MollieInfo.php

<?php
namespace App\Console\Commands;
use App\Console\Command;
use App\User;
class MollieInfo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'mollie:info {user?}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Mollie information';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if ($this->argument('user')) {
$user = $this->getUser($this->argument('user'));
if (!$user) {
return 1;
}
$this->info("Found user: {$user->id}");
$wallet = $user->wallets->first();
$provider = new \App\Providers\Payment\Mollie();
if ($mandate = $provider->getMandate($wallet)) {
$amount = $wallet->getSetting('mandate_amount');
$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(" id: {$mandate['id']}");
$this->info(" status: {$status}");
$this->info(" amount: {$amount} {$wallet->currency}");
$this->info(" min-balance: {$balance} {$wallet->currency}");
} else {
$this->info("Auto-payment: none");
}
// TODO: List user payments history
} else {
$this->info("Available payment methods:");
foreach (mollie()->methods()->all() as $method) {
$this->info("- {$method->description} ({$method->id}):");
$this->info(" status: {$method->status}");
$this->info(sprintf(
" min: %s %s",
$method->minimumAmount->value,
$method->minimumAmount->currency
));
if (!empty($method->maximumAmount)) {
$this->info(sprintf(
" max: %s %s",
$method->maximumAmount->value,
$method->maximumAmount->currency
));
}
}
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Nov 21, 3:41 PM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
387522
Default Alt Text
MollieInfo.php (2 KB)

Event Timeline