From edf5947316b7834efcfa4ce1e0114295c8db998f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 19 Apr 2024 10:32:16 +1000 Subject: [PATCH] bump sleep for failed sends --- app/Console/Commands/DemoMode.php | 4 +++- app/Jobs/Mail/NinjaMailerJob.php | 2 +- app/Services/Invoice/AutoBillInvoice.php | 18 +++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/Console/Commands/DemoMode.php b/app/Console/Commands/DemoMode.php index ffac5f08634b..7ea0edb4e604 100644 --- a/app/Console/Commands/DemoMode.php +++ b/app/Console/Commands/DemoMode.php @@ -110,7 +110,9 @@ class DemoMode extends Command $this->info('Creating Small Account and Company'); - $account = Account::factory()->create(); + $account = Account::factory()->create([ + "set_react_as_default_ap" => 0, + ]); $company = Company::factory()->create([ 'account_id' => $account->id, 'slack_webhook_url' => config('ninja.notification.slack'), diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index d53872557057..6c104922067c 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -223,7 +223,7 @@ class NinjaMailerJob implements ShouldQueue } /* Releasing immediately does not add in the backoff */ - sleep(rand(0, 3)); + sleep(rand(5, 10)); $this->release($this->backoff()[$this->attempts() - 1]); } diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 96c310d4391d..341d6990ef3f 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -150,19 +150,19 @@ class AutoBillInvoice extends AbstractService ->setPaymentHash($payment_hash) ->tokenBilling($gateway_token, $payment_hash); } catch (\Exception $e) { - $this->invoice->auto_bill_tries += 1; - - if ($this->invoice->auto_bill_tries == 3) { - $this->invoice->auto_bill_enabled = false; - $this->invoice->auto_bill_tries = 0; //reset the counter here in case auto billing is turned on again in the future. - $this->invoice->save(); - } - - $this->invoice->save(); nlog('payment NOT captured for '.$this->invoice->number.' with error '.$e->getMessage()); } + $this->invoice->auto_bill_tries += 1; + + if ($this->invoice->auto_bill_tries == 3) { + $this->invoice->auto_bill_enabled = false; + $this->invoice->auto_bill_tries = 0; //reset the counter here in case auto billing is turned on again in the future. + } + + $this->invoice->save(); + if ($payment) { info('Auto Bill payment captured for '.$this->invoice->number); }