mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Support queues for payment emails
This commit is contained in:
parent
dc034d06dd
commit
71694d108d
78
app/Jobs/SendPaymentEmail.php
Normal file
78
app/Jobs/SendPaymentEmail.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Payment;
|
||||
use App\Ninja\Mailers\ContactMailer;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Services\PushService;
|
||||
use Monolog\Logger;
|
||||
use Carbon;
|
||||
|
||||
/**
|
||||
* Class SendInvoiceEmail
|
||||
*/
|
||||
class SendPaymentEmail extends Job implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Payment
|
||||
*/
|
||||
protected $payment;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
|
||||
* @param UserMailer $userMailer
|
||||
* @param ContactMailer $contactMailer
|
||||
* @param PushService $pushService
|
||||
*/
|
||||
public function __construct($payment)
|
||||
{
|
||||
$this->payment = $payment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param ContactMailer $mailer
|
||||
*/
|
||||
public function handle(UserMailer $userMailer, ContactMailer $contactMailer, PushService $pushService)
|
||||
{
|
||||
$payment = $this->payment;
|
||||
$invoice = $payment->invoice;
|
||||
|
||||
$contactMailer->sendPaymentConfirmation($payment);
|
||||
|
||||
$payment->account->load('users');
|
||||
foreach ($payment->account->users as $user)
|
||||
{
|
||||
if ($user->notify_paid)
|
||||
{
|
||||
$userMailer->sendNotification($user, $invoice, 'paid', $payment);
|
||||
}
|
||||
}
|
||||
|
||||
$pushService->sendNotification($invoice, 'paid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a job failure.
|
||||
*
|
||||
* @param ContactMailer $mailer
|
||||
* @param Logger $logger
|
||||
*/
|
||||
/*
|
||||
public function failed(ContactMailer $mailer, Logger $logger)
|
||||
{
|
||||
$this->jobName = $this->job->getName();
|
||||
|
||||
parent::failed($mailer, $logger);
|
||||
}
|
||||
*/
|
||||
}
|
@ -9,6 +9,7 @@ use App\Events\QuoteInvitationWasViewed;
|
||||
use App\Events\QuoteInvitationWasApproved;
|
||||
use App\Events\PaymentWasCreated;
|
||||
use App\Services\PushService;
|
||||
use App\Jobs\SendPaymentEmail;
|
||||
|
||||
/**
|
||||
* Class NotificationListener
|
||||
@ -120,10 +121,7 @@ class NotificationListener
|
||||
return;
|
||||
}
|
||||
|
||||
$this->contactMailer->sendPaymentConfirmation($event->payment);
|
||||
$this->sendEmails($event->payment->invoice, 'paid', $event->payment);
|
||||
|
||||
$this->pushService->sendNotification($event->payment->invoice, 'paid');
|
||||
dispatch(new SendPaymentEmail($event->payment));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class ContactMailer extends Mailer
|
||||
* @throws \Laracasts\Presenter\Exceptions\PresenterException
|
||||
*/
|
||||
private function sendInvitation(
|
||||
Invitation$invitation,
|
||||
Invitation $invitation,
|
||||
Invoice $invoice,
|
||||
$body,
|
||||
$subject,
|
||||
|
Loading…
x
Reference in New Issue
Block a user