schickere bestellbestätigung und user role detaults auf "user" gesetzt.

This commit is contained in:
Codex Agent
2025-12-23 10:33:06 +01:00
parent ed5c1918fc
commit 886b24b06b
8 changed files with 409 additions and 12 deletions

View File

@@ -35,6 +35,13 @@ class PurchaseConfirmation extends Mailable
'package' => $this->purchase->package,
'packageName' => $this->localizedPackageName(),
'priceFormatted' => $this->formattedTotal(),
'purchaseDate' => $this->formattedPurchaseDate(),
'providerLabel' => $this->providerLabel(),
'orderId' => $this->purchase->provider_id,
'packageTypeLabel' => $this->packageTypeLabel(),
'limits' => $this->packageLimits(),
'invoiceUrl' => $this->resolveInvoiceUrl(),
'ctaUrl' => route('tenant.admin.dashboard'),
],
);
}
@@ -81,6 +88,18 @@ class PurchaseConfirmation extends Mailable
return number_format($amount, 2, ',', '.').' '.$symbol;
}
private function formattedPurchaseDate(): string
{
$locale = $this->locale ?? app()->getLocale();
$date = $this->purchase->purchased_at ?? now();
if (str_starts_with($locale, 'en')) {
return $date->translatedFormat('F j, Y');
}
return $date->translatedFormat('d. F Y');
}
private function mapLocale(string $locale): string
{
$normalized = strtolower(str_replace('_', '-', $locale));
@@ -91,4 +110,81 @@ class PurchaseConfirmation extends Mailable
default => 'de_DE',
};
}
private function providerLabel(): string
{
$provider = $this->purchase->provider ?? 'paddle';
$labelKey = 'emails.purchase.provider.'.$provider;
$label = __($labelKey);
if ($label === $labelKey) {
return ucfirst((string) $provider);
}
return $label;
}
private function packageTypeLabel(): string
{
$type = $this->purchase->package?->type ?? 'endcustomer';
$labelKey = 'emails.purchase.package_type.'.$type;
$label = __($labelKey);
if ($label === $labelKey) {
return ucfirst((string) $type);
}
return $label;
}
/**
* @return array<int, array{label: string, value: string}>
*/
private function packageLimits(): array
{
$package = $this->purchase->package;
if (! $package) {
return [];
}
$limits = [
'max_photos' => $package->max_photos,
'max_guests' => $package->max_guests,
'gallery_days' => $package->gallery_days,
'max_tasks' => $package->max_tasks,
'max_events_per_year' => $package->max_events_per_year,
];
$result = [];
foreach ($limits as $key => $value) {
if (! is_numeric($value) || (int) $value <= 0) {
continue;
}
$result[] = [
'label' => __('emails.purchase.limits.'.$key),
'value' => number_format((int) $value, 0, ',', '.'),
];
}
return $result;
}
private function resolveInvoiceUrl(): ?string
{
$payload = $this->purchase->metadata['payload'] ?? [];
$invoiceUrl = $payload['invoice_url'] ?? null;
if (is_string($invoiceUrl) && $invoiceUrl !== '') {
return $invoiceUrl;
}
$receiptUrl = $payload['receipt_url'] ?? null;
if (is_string($receiptUrl) && $receiptUrl !== '') {
return $receiptUrl;
}
return null;
}
}