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

View File

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