diff --git a/app/Jobs/Payment/EmailPayment.php b/app/Jobs/Payment/EmailPayment.php index edcdf83a4c..46d4c3bad4 100644 --- a/app/Jobs/Payment/EmailPayment.php +++ b/app/Jobs/Payment/EmailPayment.php @@ -83,11 +83,21 @@ class EmailPayment implements ShouldQueue $invitation = null; + $nmo = new NinjaMailerObject; + if ($this->payment->invoices && $this->payment->invoices->count() >= 1) { - $invitation = $this->payment->invoices->first()->invitations()->first(); + + if($this->contact){ + $invitation = $this->payment->invoices->first()->invitations()->where('contact_id', $this->contact->id)->first(); + } + else + $invitation = $this->payment->invoices->first()->invitations()->first(); + + if($invitation) + $nmo->invitation = $invitation; } - $nmo = new NinjaMailerObject; + $nmo->mailable = new TemplateEmail($email_builder, $this->contact, $invitation); $nmo->to_user = $this->contact; $nmo->settings = $this->settings; diff --git a/app/Jobs/Payment/EmailRefundPayment.php b/app/Jobs/Payment/EmailRefundPayment.php index a6e5de75b2..0da81a9253 100644 --- a/app/Jobs/Payment/EmailRefundPayment.php +++ b/app/Jobs/Payment/EmailRefundPayment.php @@ -88,11 +88,22 @@ class EmailRefundPayment implements ShouldQueue $invitation = null; + $nmo = new NinjaMailerObject; + if ($this->payment->invoices && $this->payment->invoices->count() >= 1) { - $invitation = $this->payment->invoices->first()->invitations()->first(); + + if($this->contact) { + $invitation = $this->payment->invoices->first()->invitations()->where('contact_id', $this->contact->id)->first(); + } else { + $invitation = $this->payment->invoices->first()->invitations()->first(); + } + + if($invitation) + $nmo->invitation = $invitation; } - $nmo = new NinjaMailerObject; + + $nmo->mailable = new TemplateEmail($email_builder, $this->contact, $invitation); $nmo->to_user = $this->contact; $nmo->settings = $this->settings;