From 7d61ec831759e0db95767c76df33b66ce9848d8b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 29 Dec 2021 09:14:41 +1100 Subject: [PATCH 1/3] Fixes for gatewayTypeId --- app/Http/Controllers/ClientPortalController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ClientPortalController.php b/app/Http/Controllers/ClientPortalController.php index 0a768426d770..ae82faca997e 100644 --- a/app/Http/Controllers/ClientPortalController.php +++ b/app/Http/Controllers/ClientPortalController.php @@ -140,7 +140,7 @@ class ClientPortalController extends BaseController $paymentURL = ''; if (count($paymentTypes) == 1) { $paymentURL = $paymentTypes[0]['url']; - if (in_array($paymentTypes[0]['gatewayTypeId'], [GATEWAY_TYPE_CUSTOM1, GATEWAY_TYPE_CUSTOM2, GATEWAY_TYPE_CUSTOM3])) { + if (array_key_exists('gatewayTypeId', $paymentTypes[0]) && in_array($paymentTypes[0]['gatewayTypeId'], [GATEWAY_TYPE_CUSTOM1, GATEWAY_TYPE_CUSTOM2, GATEWAY_TYPE_CUSTOM3])) { // do nothing } elseif (! $account->isGatewayConfigured(GATEWAY_PAYPAL_EXPRESS)) { $paymentURL = URL::to($paymentURL); @@ -162,6 +162,11 @@ class ClientPortalController extends BaseController $showApprove = false; } + $gatewayTypeIdCast = false; + + if(array_key_exists('gatewayTypeId', $paymentTypes[0])) + $gatewayTypeIdCast = $paymentTypes[0]['gatewayTypeId']; + $data += [ 'account' => $account, 'showApprove' => $showApprove, @@ -173,7 +178,7 @@ class ClientPortalController extends BaseController 'paymentTypes' => $paymentTypes, 'paymentURL' => $paymentURL, 'phantomjs' => Request::has('phantomjs'), - 'gatewayTypeId' => count($paymentTypes) == 1 ? $paymentTypes[0]['gatewayTypeId'] : false, + 'gatewayTypeId' => count($paymentTypes) == 1 ? $gatewayTypeIdCast : false, ]; if ($invoice->canBePaid()) { From 60897083d11109694e24235956ee0aa8664742b2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 29 Dec 2021 17:05:04 +1100 Subject: [PATCH 2/3] Minor fixes --- app/Http/Controllers/ClientPortalController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientPortalController.php b/app/Http/Controllers/ClientPortalController.php index ae82faca997e..fe5f666c3e58 100644 --- a/app/Http/Controllers/ClientPortalController.php +++ b/app/Http/Controllers/ClientPortalController.php @@ -164,7 +164,7 @@ class ClientPortalController extends BaseController $gatewayTypeIdCast = false; - if(array_key_exists('gatewayTypeId', $paymentTypes[0])) + if(count($paymentTypes) >= 1 && array_key_exists('gatewayTypeId', $paymentTypes[0])) $gatewayTypeIdCast = $paymentTypes[0]['gatewayTypeId']; $data += [ From 95c36f111bf8e665a9c9a808398007568001f6b8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 2 Jan 2022 23:01:07 +1100 Subject: [PATCH 3/3] Fixes for mail notifications --- app/Http/Controllers/InvoiceController.php | 4 ++-- app/Jobs/SendInvoiceEmail.php | 2 +- app/Jobs/SendNotificationEmail.php | 24 ++++++++++++---------- app/Listeners/NotificationListener.php | 21 +++++++++++-------- app/Ninja/Mailers/UserMailer.php | 2 +- 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 242f6009ac41..d21ae1c13fed 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -25,9 +25,9 @@ use App\Services\RecurringInvoiceService; use Auth; use Cache; use DB; +use Illuminate\Support\Facades\Session; use Redirect; use Request; -use Session; use URL; use Utils; use View; @@ -427,7 +427,7 @@ class InvoiceController extends BaseController $response = $this->emailRecurringInvoice($invoice); } else { $userId = Auth::user()->id; - $this->dispatch(new SendInvoiceEmail($invoice, $userId, $reminder, $template)); + dispatch(new SendInvoiceEmail($invoice, $userId, $reminder, $template)); $response = true; } diff --git a/app/Jobs/SendInvoiceEmail.php b/app/Jobs/SendInvoiceEmail.php index effa021b9be7..efa5336773be 100644 --- a/app/Jobs/SendInvoiceEmail.php +++ b/app/Jobs/SendInvoiceEmail.php @@ -21,7 +21,7 @@ class SendInvoiceEmail extends Job implements ShouldQueue /** * @var Invoice */ - protected $invoice; + public $invoice; /** * @var bool diff --git a/app/Jobs/SendNotificationEmail.php b/app/Jobs/SendNotificationEmail.php index cf475f77db4c..b6eec96adde1 100644 --- a/app/Jobs/SendNotificationEmail.php +++ b/app/Jobs/SendNotificationEmail.php @@ -2,51 +2,53 @@ namespace App\Jobs; +use App\Models\Invoice; use App\Models\Payment; +use App\Models\Traits\SerialisesDeletedModels; +use App\Models\User; use App\Ninja\Mailers\UserMailer; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; -use App\Models\Traits\SerialisesDeletedModels; /** * Class SendInvoiceEmail. */ class SendNotificationEmail extends Job implements ShouldQueue { - use InteractsWithQueue, SerializesModels, SerialisesDeletedModels { - SerialisesDeletedModels::getRestoredPropertyValue insteadof SerializesModels; - } + use InteractsWithQueue; + + public $deleteWhenMissingModels = true; /** * @var User */ - protected $user; + public User $user; /** * @var Invoice */ - protected $invoice; + public Invoice $invoice; /** * @var string */ - protected $type; + public $type; /** * @var Payment */ - protected $payment; + public ?Payment $payment; /** * @var string */ - protected $notes; + public $notes; /** * @var string */ - protected $server; + public $server; /** * Create a new job instance. @@ -59,7 +61,7 @@ class SendNotificationEmail extends Job implements ShouldQueue * @param mixed $type * @param mixed $payment */ - public function __construct($user, $invoice, $type, $payment, $notes) + public function __construct(User $user, Invoice $invoice, $type, ?Payment $payment, $notes) { $this->user = $user; $this->invoice = $invoice; diff --git a/app/Listeners/NotificationListener.php b/app/Listeners/NotificationListener.php index a906436519ec..b5d2af556410 100644 --- a/app/Listeners/NotificationListener.php +++ b/app/Listeners/NotificationListener.php @@ -1,17 +1,20 @@ -account->users as $user) { diff --git a/app/Ninja/Mailers/UserMailer.php b/app/Ninja/Mailers/UserMailer.php index 881ab1b1a90b..e47560246675 100644 --- a/app/Ninja/Mailers/UserMailer.php +++ b/app/Ninja/Mailers/UserMailer.php @@ -73,7 +73,7 @@ class UserMailer extends Mailer User $user, Invoice $invoice, $notificationType, - Payment $payment = null, + ?Payment $payment, $notes = false ) { if (! $user->shouldNotify($invoice)) {