INA-2 | Added counter logic into the auto bill service

This commit is contained in:
Nikola Cirkovic 2022-05-17 01:33:52 +02:00
parent b15018a73a
commit 6d2b3a1c05

View File

@ -117,13 +117,22 @@ class AutoBillInvoice extends AbstractService
$payment = false;
$number_of_retries = $this->invoice->auto_bill_tries;
try {
$payment = $gateway_token->gateway
->driver($this->client)
->setPaymentHash($payment_hash)
->tokenBilling($gateway_token, $payment_hash);
} catch (\Exception $e) {
//increase the counter
$this->invoice->auto_bill_tries = $number_of_retries + 1;
$this->invoice->save();
//disable auto bill if limit of 3 is reached
if ($this->invoice->auto_bill_tries == 3) {
$this->invoice->auto_bill_enabled = false;
$this->invoice->save();
}
catch(\Exception $e){
nlog("payment NOT captured for " . $this->invoice->number . " with error " . $e->getMessage());
// $this->invoice->service()->removeUnpaidGatewayFees();
}