maxAttempts - $this->attemptNumber; return (new MailMessage) ->subject('Payment retry scheduled - action required') ->greeting('Payment attempt '.$this->attemptNumber.' failed') ->line('We attempted to charge your payment method for invoice '.$this->invoice->invoice_number.', but the payment was declined.') ->line('We will automatically retry the payment in a few days.') ->when($remainingAttempts > 0, function ($message) use ($remainingAttempts) { return $message->line('You have '.$remainingAttempts.' automatic retry attempts remaining.'); }) ->when($remainingAttempts === 0, function ($message) { return $message->line('This was our final automatic retry. Please update your payment method to avoid service interruption.'); }) ->action('Update Payment Method', route('hub.billing.payment-methods')) ->line('If you believe this is an error, please contact our support team.') ->salutation('Host UK'); } public function toArray(object $notifiable): array { return [ 'invoice_id' => $this->invoice->id, 'invoice_number' => $this->invoice->invoice_number, 'attempt_number' => $this->attemptNumber, 'max_attempts' => $this->maxAttempts, ]; } }