Make sure invoice is emailed if auto-billing fails

This commit is contained in:
Hillel Coren 2016-12-22 19:42:21 +02:00
parent 4658abfbd4
commit 67b7d6ff21
2 changed files with 10 additions and 7 deletions

View File

@ -6,7 +6,6 @@ use App\Ninja\Repositories\AccountRepository;
use App\Services\PaymentService; use App\Services\PaymentService;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Account; use App\Models\Account;
use Exception;
/** /**
* Class ChargeRenewalInvoices * Class ChargeRenewalInvoices
@ -81,11 +80,10 @@ class ChargeRenewalInvoices extends Command
continue; continue;
} }
try { $this->info("Charging invoice {$invoice->invoice_number}");
$this->info("Charging invoice {$invoice->invoice_number}"); if ( ! $this->paymentService->autoBillInvoice($invoice)) {
$this->paymentService->autoBillInvoice($invoice); $this->info('Failed to auto-bill, emailing invoice');
} catch (Exception $exception) { $this->mailer->sendInvoice($invoice);
$this->info('Error: ' . $exception->getMessage());
} }
} }

View File

@ -3,6 +3,7 @@
use App\Models\Invoice; use App\Models\Invoice;
use Utils; use Utils;
use Auth; use Auth;
use Exception;
use App\Models\Account; use App\Models\Account;
use App\Models\Client; use App\Models\Client;
use App\Models\Activity; use App\Models\Activity;
@ -120,7 +121,11 @@ class PaymentService extends BaseService
} }
} }
return $paymentDriver->completeOnsitePurchase(false, $paymentMethod); try {
return $paymentDriver->completeOnsitePurchase(false, $paymentMethod);
} catch (Exception $exception) {
return false;
}
} }
public function getDatatable($clientPublicId, $search) public function getDatatable($clientPublicId, $search)