From b2baadc429ab5a8f0ebf3198ff3a658724b0a0cc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 21 Sep 2021 07:52:21 +1000 Subject: [PATCH] Resolve client correctly in webhooks --- app/Jobs/Util/WebhookHandler.php | 13 +++++++++++-- app/Mail/Engine/PaymentEmailEngine.php | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Jobs/Util/WebhookHandler.php b/app/Jobs/Util/WebhookHandler.php index da2419ea3306..aad1fb2d537a 100644 --- a/app/Jobs/Util/WebhookHandler.php +++ b/app/Jobs/Util/WebhookHandler.php @@ -120,7 +120,7 @@ class WebhookHandler implements ShouldQueue SystemLog::CATEGORY_WEBHOOK, SystemLog::EVENT_WEBHOOK_SUCCESS, SystemLog::TYPE_WEBHOOK_RESPONSE, - $this->company->clients->first(), + $this->resolveClient(), $this->company ); @@ -137,7 +137,7 @@ class WebhookHandler implements ShouldQueue SystemLog::CATEGORY_WEBHOOK, SystemLog::EVENT_WEBHOOK_RESPONSE, SystemLog::TYPE_WEBHOOK_RESPONSE, - $this->company->clients->first(), + $this->resolveClient(), $this->company, ); @@ -145,6 +145,15 @@ class WebhookHandler implements ShouldQueue } + private function resolveClient() + { + if($this->entity->client()->exists()){ + return $this->entity->client; + } + + return $this->company->clients->first(); + } + public function failed($exception) { nlog(print_r($exception->getMessage(), 1)); diff --git a/app/Mail/Engine/PaymentEmailEngine.php b/app/Mail/Engine/PaymentEmailEngine.php index a582822e6bf6..ed36c8ae321f 100644 --- a/app/Mail/Engine/PaymentEmailEngine.php +++ b/app/Mail/Engine/PaymentEmailEngine.php @@ -135,6 +135,7 @@ class PaymentEmailEngine extends BaseEmailEngine { $data = []; + $data['$from'] = ['value' => '', 'label' => ctrans('texts.from')]; $data['$to'] = ['value' => '', 'label' => ctrans('texts.to')]; $data['$number'] = ['value' => $this->payment->number ?: ' ', 'label' => ctrans('texts.payment_number')];