lasthourcloud/app/Jobs/SubscriptionInvoiceFailedJob.php

42 lines
1.4 KiB
PHP
Raw Normal View History

2023-08-24 14:14:09 +00:00
<?php
namespace App\Jobs;
use App\Models\Team;
use Illuminate\Bus\Queueable;
2023-09-14 08:12:44 +00:00
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
2023-08-24 14:14:09 +00:00
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
2024-06-10 20:43:34 +00:00
class SubscriptionInvoiceFailedJob implements ShouldBeEncrypted, ShouldQueue
2023-08-24 14:14:09 +00:00
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
2024-06-19 06:59:46 +00:00
public function __construct(protected Team $team) {}
2023-08-24 14:14:09 +00:00
public function handle()
{
try {
$session = getStripeCustomerPortalSession($this->team);
$mail = new MailMessage();
$mail->view('emails.subscription-invoice-failed', [
'stripeCustomerPortal' => $session->url,
]);
$mail->subject('Your last payment was failed for Coolify Cloud.');
$this->team->members()->each(function ($member) use ($mail) {
ray($member);
if ($member->isAdmin()) {
send_user_an_email($mail, $member->email);
}
});
2023-09-11 15:36:30 +00:00
} catch (\Throwable $e) {
2024-06-10 20:43:34 +00:00
send_internal_notification('SubscriptionInvoiceFailedJob failed with: '.$e->getMessage());
2023-09-11 15:36:30 +00:00
ray($e->getMessage());
throw $e;
2023-08-24 14:14:09 +00:00
}
}
}