47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications\Customer;
|
|
|
|
use App\Models\PackagePurchase;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class RefundReceipt extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
private readonly PackagePurchase $purchase,
|
|
private readonly ?string $reason = null,
|
|
) {}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$tenant = $this->purchase->tenant;
|
|
$package = $this->purchase->package;
|
|
$amount = number_format((float) $this->purchase->price, 2);
|
|
|
|
$mail = (new MailMessage)
|
|
->subject(__('emails.refund.subject', ['package' => $package?->name ?? __('emails.package_limits.package_fallback')]))
|
|
->greeting(__('emails.refund.greeting', ['name' => $tenant?->name ?? __('emails.package_limits.team_fallback')]))
|
|
->line(__('emails.refund.body', [
|
|
'amount' => $amount,
|
|
'currency' => '€',
|
|
'provider_id' => $this->purchase->provider_id ?? '—',
|
|
]));
|
|
|
|
if ($this->reason) {
|
|
$mail->line(__('emails.refund.reason', ['reason' => $this->reason]));
|
|
}
|
|
|
|
return $mail->line(__('emails.refund.footer'));
|
|
}
|
|
}
|