osb/app/Console/Commands/Intuit/PaymentSync.php

44 lines
825 B
PHP

<?php
namespace App\Console\Commands\Intuit;
use Illuminate\Console\Command;
use Intuit\Traits\ProviderTokenTrait;
use App\Jobs\AccountingPaymentSync as Job;
class PaymentSync extends Command
{
use ProviderTokenTrait;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'intuit:payment:sync'
.' {user? : User Email}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Synchronise payments with accounting system';
/**
* Execute the console command.
*
* @return int
* @throws \Intuit\Exceptions\NotTokenException
*/
public function handle()
{
$to = $this->providerToken($this->argument('user'));
foreach ($to->API()->getPayments() as $acc)
Job::dispatchSync($to,$acc);
return self::SUCCESS;
}
}