Prevent deleted invoice from being paid
This commit is contained in:
parent
7b5cd9e4c1
commit
2a97fc5456
2 changed files with 10 additions and 1 deletions
|
|
@ -70,7 +70,7 @@ class OnlinePaymentController extends BaseController
|
|||
]);
|
||||
}
|
||||
|
||||
if ( ! floatval($invitation->invoice->balance)) {
|
||||
if ( ! $invitation->invoice->canBePaid()) {
|
||||
return redirect()->to('view/' . $invitation->invitation_key);
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +103,10 @@ class OnlinePaymentController extends BaseController
|
|||
$gatewayTypeId = Session::get($invitation->id . 'gateway_type');
|
||||
$paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId);
|
||||
|
||||
if ( ! $invitation->invoice->canBePaid()) {
|
||||
return redirect()->to('view/' . $invitation->invitation_key);
|
||||
}
|
||||
|
||||
try {
|
||||
$paymentDriver->completeOnsitePurchase($request->all());
|
||||
|
||||
|
|
|
|||
|
|
@ -514,6 +514,11 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||
return storage_path() . '/pdfcache/cache-' . $this->id . '.pdf';
|
||||
}
|
||||
|
||||
public function canBePaid()
|
||||
{
|
||||
return floatval($this->balance) > 0 && ! $this->is_deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice
|
||||
* @return string
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue