Kundenwunsch 06.10.2026: Ein Kunde kam über die Stripe-Rechnungsseite nicht an seine Rechnung und fragte nach Belegen und einer Rechnungs-E-Mail. - Profil ▸ Rechnungsadresse ▸ Rechnungsversand: Schalter „Rechnungs-PDF an die Konto-E-Mail" (Standard an), optionale „E-Mail für Rechnungen" mit Schalter „Rechnungen als PDF an diese Adresse senden" (Standard an). Neue Spalten an billing_addresses (klein, ohne FULLTEXT). - InvoiceDelivery entscheidet Empfänger und Anhang; gleiche Adresse wie das Konto ergibt eine Mail mit PDF. - Zahlungsbestätigung (STR) und Bestandskunden-Rechnung/-Erinnerung (MAN) folgen der Einstellung; die Fassung an die Rechnungs-E-Mail nennt das Konto, ohne Blindkopie und ohne Login-Button. - StripeInvoicePdf holt das Stripe-PDF einmal und legt es lokal ab (storage/app/private/invoices/stripe); Mailversand wiederholt bei Stripe-Ausfall (5 Versuche). - Rechnungsseite: „PDF öffnen" aus pressekonto, „Beleg bei Stripe" für den Zahlungsbeleg auf der Stripe-Seite. Suite 2.340 grün, einer übersprungen; Larastan und Pint ohne Meldung. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
2.8 KiB
PHP
86 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\Invoice;
|
|
use App\Models\User;
|
|
use App\Services\Billing\StripeInvoicePdf;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Mail\Attachment;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
/**
|
|
* Zahlungs-/Buchungsbestätigung an den Kunden, sobald eine bezahlte
|
|
* Stripe-Rechnung in den STR-Kreis gespiegelt wurde — greift damit für
|
|
* jede Buchungsart (Tarif inkl. Verlängerung, Einzel-PM, Credits).
|
|
*
|
|
* Transaktionsmail: bewusst ohne Opt-out (analog Kündigungs-/
|
|
* Widerrufsbestätigungen, siehe EmailNotificationType-Doku).
|
|
*
|
|
* Rechnungsversand (06.10.2026): Mit `attachPdf` hängt das Stripe-PDF an;
|
|
* `forInvoiceRecipient` ist die Fassung an die Rechnungs-E-Mail aus dem
|
|
* Profil (siehe InvoiceDelivery). Das PDF wird erst beim Versand geholt —
|
|
* ist Stripe nicht erreichbar, wiederholt die Queue den Versand.
|
|
*/
|
|
class BookingPaymentConfirmed extends Mailable implements ShouldQueue
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public int $tries = 5;
|
|
|
|
/** @var list<int> */
|
|
public array $backoff = [60, 300, 900, 3600];
|
|
|
|
public string $invoicesUrl;
|
|
|
|
public function __construct(
|
|
public readonly User $user,
|
|
public readonly Invoice $invoice,
|
|
public readonly bool $attachPdf = false,
|
|
public readonly bool $forInvoiceRecipient = false,
|
|
) {
|
|
$this->invoicesUrl = route('me.invoices.index');
|
|
}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
// Blindkopie an das Rechts-/Service-Postfach: interner Beleg über
|
|
// jede versendete Zahlungsbestätigung.
|
|
// Die Fassung an die Rechnungs-E-Mail ist ein Duplikat derselben
|
|
// Rechnung — eine Blindkopie davon braucht das Postfach nicht.
|
|
$bcc = $this->forInvoiceRecipient ? '' : (string) config('legal.contact_email');
|
|
|
|
return new Envelope(
|
|
subject: $this->forInvoiceRecipient
|
|
? 'Rechnung '.$this->invoice->number.' — pressekonto'
|
|
: 'Zahlungsbestätigung für Ihre Buchung — Rechnung '.$this->invoice->number,
|
|
bcc: $bcc !== '' ? [$bcc] : [],
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
return new Content(view: 'emails.billing.payment-confirmed');
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Attachment>
|
|
*/
|
|
public function attachments(): array
|
|
{
|
|
if (! $this->attachPdf || blank($this->invoice->stripe_invoice_id)) {
|
|
return [];
|
|
}
|
|
|
|
$pdf = app(StripeInvoicePdf::class);
|
|
|
|
return [
|
|
Attachment::fromData(fn (): string => $pdf->contents($this->invoice), $pdf->filename($this->invoice))
|
|
->withMime('application/pdf'),
|
|
];
|
|
}
|
|
}
|