mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
payment listeners
This commit is contained in:
parent
7af791a4c4
commit
5cd2ae0dbe
@ -11,8 +11,15 @@
|
||||
|
||||
namespace App\Events\Payment;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
@ -20,7 +27,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
*/
|
||||
class PaymentWasEmailed
|
||||
{
|
||||
use SerializesModels;
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Payment
|
||||
|
@ -11,15 +11,23 @@
|
||||
|
||||
namespace App\Events\Payment;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceWasEmailedAndFailed.
|
||||
* Class PaymentWasEmailedAndFailed.
|
||||
*/
|
||||
class PaymentWasEmailedAndFailed
|
||||
{
|
||||
use SerializesModels;
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Payment
|
||||
@ -39,7 +47,7 @@ class PaymentWasEmailedAndFailed
|
||||
* @param array $errors
|
||||
* @param array $event_vars
|
||||
*/
|
||||
public function __construct(Payment $payment, $company, array $errors, array $event_vars)
|
||||
public function __construct(Payment $payment, Company $company, array $errors, array $event_vars)
|
||||
{
|
||||
$this->payment = $payment;
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
protected $dontReport = [
|
||||
PDOException::class,
|
||||
Swift_TransportException::class,
|
||||
//Swift_TransportException::class,
|
||||
MaxAttemptsExceededException::class,
|
||||
CommandNotFoundException::class,
|
||||
];
|
||||
|
@ -72,7 +72,8 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{info("inside email payment");
|
||||
{
|
||||
|
||||
if($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
@ -85,8 +86,16 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
|
||||
|
||||
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
|
||||
|
||||
$mail = Mail::to($this->contact->email, $this->contact->present()->name());
|
||||
$mail->send(new TemplateEmail($email_builder, $this->contact->user, $this->contact->client));
|
||||
try{
|
||||
|
||||
$mail = Mail::to($this->contact->email, $this->contact->present()->name());
|
||||
$mail->send(new TemplateEmail($email_builder, $this->contact->user, $this->contact->client));
|
||||
|
||||
}catch(\Exception $e) {
|
||||
|
||||
info("mailing failed with message " . $e->getMessage());
|
||||
|
||||
}
|
||||
|
||||
if (count(Mail::failures()) > 0) {
|
||||
event(new PaymentWasEmailedAndFailed($this->payment, Mail::failures(), Ninja::eventVars()));
|
||||
|
57
app/Listeners/Payment/PaymentEmailFailureActivity.php
Normal file
57
app/Listeners/Payment/PaymentEmailFailureActivity.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Listeners\Payment;
|
||||
|
||||
use App\Jobs\Mail\EntityPaidMailer;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Notifications\Admin\NewPaymentNotification;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class PaymentEmailFailureActivity implements ShouldQueue
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return bool
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$payment = $event->payment;
|
||||
|
||||
info("i failed emailing {$payment->number}");
|
||||
// info(print_r($event->errors,1));
|
||||
|
||||
}
|
||||
}
|
||||
|
55
app/Listeners/Payment/PaymentEmailedActivity.php
Normal file
55
app/Listeners/Payment/PaymentEmailedActivity.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Listeners\Payment;
|
||||
|
||||
use App\Jobs\Mail\EntityPaidMailer;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Notifications\Admin\NewPaymentNotification;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class PaymentEmailedActivity implements ShouldQueue
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return bool
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$payment = $event->payment;
|
||||
|
||||
info("i succeeded in emailing payment {$payment->number}");
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ use App\Events\Misc\InvitationWasViewed;
|
||||
use App\Events\Payment\PaymentWasArchived;
|
||||
use App\Events\Payment\PaymentWasCreated;
|
||||
use App\Events\Payment\PaymentWasDeleted;
|
||||
use App\Events\Payment\PaymentWasEmailed;
|
||||
use App\Events\Payment\PaymentWasEmailedAndFailed;
|
||||
use App\Events\Payment\PaymentWasRefunded;
|
||||
use App\Events\Payment\PaymentWasRestored;
|
||||
use App\Events\Payment\PaymentWasUpdated;
|
||||
@ -129,6 +131,8 @@ use App\Listeners\Invoice\InvoiceViewedActivity;
|
||||
use App\Listeners\Invoice\UpdateInvoiceActivity;
|
||||
use App\Listeners\Invoice\UpdateInvoiceInvitations;
|
||||
use App\Listeners\Misc\InvitationViewedListener;
|
||||
use App\Listeners\Payment\PaymentEmailFailureActivity;
|
||||
use App\Listeners\Payment\PaymentEmailedActivity;
|
||||
use App\Listeners\Payment\PaymentNotification;
|
||||
use App\Listeners\Payment\PaymentRestoredActivity;
|
||||
use App\Listeners\Quote\QuoteApprovedActivity;
|
||||
@ -310,6 +314,12 @@ class EventServiceProvider extends ServiceProvider
|
||||
InvitationWasViewed::class => [
|
||||
InvitationViewedListener::class,
|
||||
],
|
||||
PaymentWasEmailed::class => [
|
||||
PaymentEmailedActivity::class,
|
||||
],
|
||||
PaymentWasEmailedAndFailed::class => [
|
||||
PaymentEmailFailureActivity::class,
|
||||
],
|
||||
CompanyDocumentsDeleted::class => [
|
||||
DeleteCompanyDocuments::class,
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user