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']; } }