From a6c9e0e8b3383b460a79632606cae08ec4fb61af Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 27 Oct 2021 15:40:14 +1100 Subject: [PATCH] Fix for double Update Entity Webhook call --- app/Listeners/Credit/CreditEmailedNotification.php | 2 +- app/Listeners/Invoice/InvoiceEmailedNotification.php | 2 +- app/Listeners/Quote/QuoteEmailedNotification.php | 2 +- app/PaymentDrivers/BaseDriver.php | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Listeners/Credit/CreditEmailedNotification.php b/app/Listeners/Credit/CreditEmailedNotification.php index c3a1ef17bf93..ad259f781ebe 100644 --- a/app/Listeners/Credit/CreditEmailedNotification.php +++ b/app/Listeners/Credit/CreditEmailedNotification.php @@ -42,7 +42,7 @@ class CreditEmailedNotification implements ShouldQueue $credit = $event->invitation->credit; $credit->last_sent_date = now(); - $credit->save(); + $credit->saveQuietly(); $nmo = new NinjaMailerObject; $nmo->mailable = new NinjaMailer( (new EntitySentObject($event->invitation, 'credit', $event->template))->build() ); diff --git a/app/Listeners/Invoice/InvoiceEmailedNotification.php b/app/Listeners/Invoice/InvoiceEmailedNotification.php index 59ac94e2c3ef..3918c630f1da 100644 --- a/app/Listeners/Invoice/InvoiceEmailedNotification.php +++ b/app/Listeners/Invoice/InvoiceEmailedNotification.php @@ -42,7 +42,7 @@ class InvoiceEmailedNotification implements ShouldQueue $invoice = $event->invitation->invoice; $invoice->last_sent_date = now(); - $invoice->save(); + $invoice->saveQuietly(); $nmo = new NinjaMailerObject; $nmo->mailable = new NinjaMailer( (new EntitySentObject($event->invitation, 'invoice', $event->template))->build() ); diff --git a/app/Listeners/Quote/QuoteEmailedNotification.php b/app/Listeners/Quote/QuoteEmailedNotification.php index c601dbfa18ef..68d1264c11b6 100644 --- a/app/Listeners/Quote/QuoteEmailedNotification.php +++ b/app/Listeners/Quote/QuoteEmailedNotification.php @@ -42,7 +42,7 @@ class QuoteEmailedNotification implements ShouldQueue $quote = $event->invitation->quote; $quote->last_sent_date = now(); - $quote->save(); + $quote->saveQuietly(); $nmo = new NinjaMailerObject; $nmo->mailable = new NinjaMailer( (new EntitySentObject($event->invitation, 'quote', $event->template))->build() ); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 397583bd6e43..9c6238c506c3 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -405,6 +405,10 @@ class BaseDriver extends AbstractPaymentDriver public function sendFailureMail(string $error) { + if (!is_null($this->payment_hash)) { + $this->unWindGatewayFees($this->payment_hash); + } + PaymentFailedMailer::dispatch( $this->payment_hash, $this->client->company, @@ -419,7 +423,6 @@ class BaseDriver extends AbstractPaymentDriver if ($this->payment_hash && is_array($this->payment_hash->invoices())) { - $nmo = new NinjaMailerObject; $nmo->mailable = new NinjaMailer((new ClientPaymentFailureObject($this->client, $error, $this->client->company, $this->payment_hash))->build()); $nmo->company = $this->client->company;