- Removido README.md padrão do Laravel (backend) - Removidos scripts de deploy (não mais necessários) - Atualizado copilot-instructions.md para novo fluxo - Adicionada documentação de auditoria do servidor - Sincronizado código de produção com repositório Novo workflow: - Trabalhamos diretamente em /root/webmoney (symlink para /var/www/webmoney) - Mudanças PHP são instantâneas - Mudanças React requerem 'npm run build' - Commit após validação funcional
123 lines
3.5 KiB
PHP
Executable File
123 lines
3.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\User;
|
|
use App\Models\Subscription;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Mail\Mailables\Address;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\App;
|
|
|
|
class SubscriptionCancelledMail extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public User $user;
|
|
public string $planName;
|
|
public bool $wasRefunded;
|
|
public ?string $refundAmount;
|
|
public string $userLocale;
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*/
|
|
public function __construct(
|
|
User $user,
|
|
string $planName,
|
|
bool $wasRefunded = false,
|
|
?string $refundAmount = null
|
|
) {
|
|
$this->user = $user;
|
|
$this->planName = $planName;
|
|
$this->wasRefunded = $wasRefunded;
|
|
$this->refundAmount = $refundAmount;
|
|
$this->userLocale = $user->locale ?? $user->language ?? 'es';
|
|
}
|
|
|
|
/**
|
|
* Get the message envelope.
|
|
*/
|
|
public function envelope(): Envelope
|
|
{
|
|
// Set locale for translations
|
|
App::setLocale($this->userLocale);
|
|
|
|
$subject = $this->getSubject();
|
|
|
|
return new Envelope(
|
|
from: new Address('no-reply@cnxifly.com', 'WEBMoney - ConneXiFly'),
|
|
replyTo: [
|
|
new Address('support@cnxifly.com', $this->getSupportName()),
|
|
],
|
|
subject: $subject,
|
|
tags: ['subscription', 'cancellation', $this->wasRefunded ? 'refund' : 'no-refund'],
|
|
metadata: [
|
|
'user_id' => $this->user->id,
|
|
'user_email' => $this->user->email,
|
|
'plan' => $this->planName,
|
|
'refunded' => $this->wasRefunded,
|
|
],
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the message content definition.
|
|
*/
|
|
public function content(): Content
|
|
{
|
|
// Set locale for translations
|
|
App::setLocale($this->userLocale);
|
|
|
|
return new Content(
|
|
view: 'emails.subscription-cancelled',
|
|
text: 'emails.subscription-cancelled-text',
|
|
with: [
|
|
'userName' => $this->user->name,
|
|
'userEmail' => $this->user->email,
|
|
'planName' => $this->planName,
|
|
'wasRefunded' => $this->wasRefunded,
|
|
'refundAmount' => $this->refundAmount,
|
|
'locale' => $this->userLocale,
|
|
],
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the subject based on locale
|
|
*/
|
|
private function getSubject(): string
|
|
{
|
|
$subjects = [
|
|
'es' => $this->wasRefunded
|
|
? 'Confirmación de cancelación y reembolso - WEBMoney'
|
|
: 'Confirmación de cancelación de suscripción - WEBMoney',
|
|
'pt-BR' => $this->wasRefunded
|
|
? 'Confirmação de cancelamento e reembolso - WEBMoney'
|
|
: 'Confirmação de cancelamento de assinatura - WEBMoney',
|
|
'en' => $this->wasRefunded
|
|
? 'Cancellation and Refund Confirmation - WEBMoney'
|
|
: 'Subscription Cancellation Confirmation - WEBMoney',
|
|
];
|
|
|
|
return $subjects[$this->userLocale] ?? $subjects['es'];
|
|
}
|
|
|
|
/**
|
|
* Get support name based on locale
|
|
*/
|
|
private function getSupportName(): string
|
|
{
|
|
$names = [
|
|
'es' => 'Soporte WEBMoney',
|
|
'pt-BR' => 'Suporte WEBMoney',
|
|
'en' => 'WEBMoney Support',
|
|
];
|
|
|
|
return $names[$this->userLocale] ?? $names['es'];
|
|
}
|
|
}
|