Checkout: Stripe-Tax-Adressanforderung erfüllen

Stripe Tax verlangt eine gültige Kundenadresse. Beide Checkout-Sessions
erfassen jetzt die Rechnungsadresse verpflichtend und speichern sie am
Stripe-Customer (customer_update address/name = auto; Name ist Pflicht
bei aktivierter USt-ID-Abfrage). Zusätzlich liefert User::stripeAddress()
die lokale Rechnungsadresse bei der Customer-Anlage mit (Cashier-Hook).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-06-12 13:33:58 +00:00
parent 6a82e2a2a8
commit 8f3261d0b4
3 changed files with 191 additions and 133 deletions

View file

@ -80,6 +80,31 @@ class User extends Authenticatable
];
}
/**
* Adresse für die Stripe-Customer-Anlage (Cashier-Hook). Stripe Tax
* braucht eine gültige Kundenadresse falls lokal eine
* Rechnungsadresse gepflegt ist, wird sie direkt mitgegeben; sonst
* speichert der Checkout die dort erfasste Adresse (customer_update).
*
* @return array<string, string|null>|null
*/
public function stripeAddress(): ?array
{
$address = $this->billingAddress;
if (! $address) {
return null;
}
return [
'line1' => $address->address1,
'line2' => $address->address2,
'postal_code' => $address->postal_code,
'city' => $address->city,
'country' => $address->country_code,
];
}
/**
* Der Tarif des aktiven Stripe-Abos, aufgelöst über die in `plans`
* gepflegten Stripe-Preis-IDs. Null ohne (gültiges) Abo.

View file

@ -29,10 +29,28 @@ class StripeCheckoutService
return $user
->newSubscription('default', $priceId)
->checkout([
->checkout($this->sessionOptions());
}
/**
* Gemeinsame Session-Optionen: Stripe Tax braucht eine gültige
* Kundenadresse die im Checkout erfasste Rechnungsadresse (und der
* Name, Pflicht bei USt-ID-Abfrage) wird darum am Stripe-Customer
* gespeichert (`customer_update: auto`).
*
* @return array<string, mixed>
*/
private function sessionOptions(): array
{
return [
'success_url' => route('me.bookings.index', ['checkout' => 'erfolg']),
'cancel_url' => route('me.bookings.index', ['checkout' => 'abbruch']),
]);
'billing_address_collection' => 'required',
'customer_update' => [
'address' => 'auto',
'name' => 'auto',
],
];
}
/**
@ -52,8 +70,7 @@ class StripeCheckoutService
public function forSinglePurchase(User $user, SinglePurchase $purchase): Checkout
{
return $user->checkout([config('billing.single_pm_stripe_price_id') => 1], [
'success_url' => route('me.bookings.index', ['checkout' => 'erfolg']),
'cancel_url' => route('me.bookings.index', ['checkout' => 'abbruch']),
...$this->sessionOptions(),
'metadata' => ['single_purchase_id' => (string) $purchase->id],
]);
}

View file

@ -13,8 +13,7 @@ use Livewire\Volt\Component;
* echte Buchungsdaten. Launch-Credits (Extra-PM, Boost, Nachweis-PDF)
* folgen mit Phase 9I, das Credit-Wallet mit Phase 2.
*/
new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class extends Component
{
new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class extends Component {
public function formatEuro(int $cents): string
{
return number_format($cents / 100, $cents % 100 === 0 ? 0 : 2, ',', '.') . ' €';
@ -39,9 +38,7 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
$currentInterval = null;
if ($currentPlan && $subscription) {
$currentInterval = $subscription->stripe_price === $currentPlan->stripe_price_id_yearly
? 'yearly'
: 'monthly';
$currentInterval = $subscription->stripe_price === $currentPlan->stripe_price_id_yearly ? 'yearly' : 'monthly';
}
return [
@ -57,24 +54,14 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
// Bestandstarife: laufende Legacy-Vereinbarungen (MAN-Kreis,
// unbegrenzte PMs — Entscheidung 12.06.2026).
'legacyOptions' => $user->userPaymentOptions()
->whereIn('status', [
UserPaymentOptionStatus::Active->value,
UserPaymentOptionStatus::Grandfathered->value,
])
'legacyOptions' => $user
->userPaymentOptions()
->whereIn('status', [UserPaymentOptionStatus::Active->value, UserPaymentOptionStatus::Grandfathered->value])
->orderBy('current_period_end')
->get(),
'openPurchases' => $user->singlePurchases()
->grantingSubmission()
->orderBy('paid_at')
->get(),
'consumedPurchases' => $user->singlePurchases()
->where('status', SinglePurchaseStatus::Consumed->value)
->with('pressRelease')
->latest('consumed_at')
->limit(10)
->get(),
'openPurchases' => $user->singlePurchases()->grantingSubmission()->orderBy('paid_at')->get(),
'consumedPurchases' => $user->singlePurchases()->where('status', SinglePurchaseStatus::Consumed->value)->with('pressRelease')->latest('consumed_at')->limit(10)->get(),
'quotaRemaining' => $user->pressReleaseQuotaRemaining(),
'quotaTotal' => $user->pressReleaseQuotaTotal(),
@ -87,16 +74,19 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
<div class="space-y-8">
{{-- ============== CHECKOUT-RÜCKMELDUNG ============== --}}
@if ($checkoutResult === 'erfolg')
<div class="px-4 py-3 rounded-[5px] border text-[13px] flex items-start gap-3
<div
class="px-4 py-3 rounded-[5px] border text-[13px] flex items-start gap-3
bg-[color:var(--color-hub-soft)] border-[color:var(--color-hub-soft-2)] text-[color:var(--color-ink-2)]">
<flux:icon.check-circle class="size-[16px] flex-shrink-0 mt-0.5 text-[color:var(--color-hub)]" />
<div class="flex-1">
<span class="font-semibold text-[color:var(--color-ink)]">{{ __('Vielen Dank für Ihre Buchung!') }}</span>
<span
class="font-semibold text-[color:var(--color-ink)]">{{ __('Vielen Dank für Ihre Buchung!') }}</span>
{{ __('Die Zahlung wird von Stripe bestätigt — die Buchung erscheint hier in wenigen Augenblicken. Die Rechnung finden Sie anschließend unter Rechnungen.') }}
</div>
</div>
@elseif ($checkoutResult === 'abbruch')
<div class="px-4 py-3 rounded-[5px] border text-[13px] flex items-start gap-3
<div
class="px-4 py-3 rounded-[5px] border text-[13px] flex items-start gap-3
bg-[color:var(--color-bg-subtle)] border-[color:var(--color-bg-rule)] text-[color:var(--color-ink-2)]">
<flux:icon.information-circle class="size-[16px] flex-shrink-0 mt-0.5 text-[color:var(--color-ink-3)]" />
<div class="flex-1">
@ -106,7 +96,8 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
@endif
@if ($checkoutNotice)
<div class="px-4 py-3 rounded-[5px] border text-[13px] flex items-start gap-3
<div
class="px-4 py-3 rounded-[5px] border text-[13px] flex items-start gap-3
bg-[color:var(--color-bg-subtle)] border-[color:var(--color-bg-rule)] text-[color:var(--color-ink-2)]">
<flux:icon.information-circle class="size-[16px] flex-shrink-0 mt-0.5 text-[color:var(--color-ink-3)]" />
<div class="flex-1">{{ $checkoutNotice }}</div>
@ -129,7 +120,8 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
</div>
<div class="flex items-center gap-2 flex-shrink-0">
<flux:button size="sm" variant="filled" icon="document-text" href="{{ route('me.invoices.index') }}" wire:navigate>
<flux:button size="sm" variant="filled" icon="document-text" href="{{ route('me.invoices.index') }}"
wire:navigate>
{{ __('Rechnungen') }}
</flux:button>
</div>
@ -157,12 +149,14 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
{{ $currentInterval === 'yearly'
? $this->formatEuro($currentPlan->yearly_price_cents) . ' / ' . __('Jahr')
: $this->formatEuro($currentPlan->monthly_price_cents) . ' / ' . __('Monat') }}
<span class="text-[13px] font-normal text-[color:var(--color-ink-3)]">{{ __('netto') }}</span>
<span
class="text-[13px] font-normal text-[color:var(--color-ink-3)]">{{ __('netto') }}</span>
</div>
<p class="text-[12.5px] text-[color:var(--color-ink-2)] m-0">
{{ __(':quota Pressemitteilungen pro Monat', ['quota' => $currentPlan->press_release_quota]) }}
@if ($currentPlan->daily_limit)
· {{ __('max. :limit Veröffentlichungen pro Tag', ['limit' => $currentPlan->daily_limit]) }}
·
{{ __('max. :limit Veröffentlichungen pro Tag', ['limit' => $currentPlan->daily_limit]) }}
@endif
</p>
@if ($subscription?->onGracePeriod())
@ -174,7 +168,7 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
@foreach ($legacyOptions as $option)
<div>
<div class="text-[15px] font-semibold text-[color:var(--color-ink)]">
{{ data_get($option->legacy_conditions, 'name') ?? $option->paymentOption?->article_number ?? __('Bestehende Vereinbarung') }}
{{ data_get($option->legacy_conditions, 'name') ?? ($option->paymentOption?->article_number ?? __('Bestehende Vereinbarung')) }}
</div>
<p class="text-[12.5px] text-[color:var(--color-ink-2)] mt-1 mb-0">
{{ __('Unbegrenzte Pressemitteilungen (Bestandsschutz).') }}
@ -201,8 +195,10 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
{{-- Kontingent nur als echte Zahl „unbegrenzt" wäre vor dem
Launch-Schalter inhaltlich falsch. --}}
@if (!is_null($quotaRemaining))
<div class="rounded-[6px] border border-[color:var(--color-bg-rule)] p-4 bg-[color:var(--color-bg-subtle)]">
<div class="text-[12px] text-[color:var(--color-ink-3)]">{{ __('PM-Kontingent diesen Monat') }}</div>
<div
class="rounded-[6px] border border-[color:var(--color-bg-rule)] p-4 bg-[color:var(--color-bg-subtle)]">
<div class="text-[12px] text-[color:var(--color-ink-3)]">
{{ __('PM-Kontingent diesen Monat') }}</div>
<div class="text-[22px] font-semibold text-[color:var(--color-ink)]">
{{ $quotaRemaining }} / {{ $quotaTotal }}
</div>
@ -238,15 +234,20 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
</p>
</div>
<div class="flex items-center gap-1 rounded-[6px] border border-[color:var(--color-bg-rule)] p-1 bg-[color:var(--color-bg-subtle)]">
<div
class="flex items-center gap-1 rounded-[6px] border border-[color:var(--color-bg-rule)] p-1 bg-[color:var(--color-bg-subtle)]">
<button type="button" @click="interval = 'monthly'"
class="px-3 py-1.5 rounded-[4px] text-[12.5px] font-semibold transition-colors"
:class="interval === 'monthly' ? 'bg-[color:var(--color-bg-elev)] text-[color:var(--color-ink)] shadow-sm' : 'text-[color:var(--color-ink-3)]'">
:class="interval === 'monthly' ?
'bg-[color:var(--color-bg-elev)] text-[color:var(--color-ink)] shadow-sm' :
'text-[color:var(--color-ink-3)]'">
{{ __('Monatlich') }}
</button>
<button type="button" @click="interval = 'yearly'"
class="px-3 py-1.5 rounded-[4px] text-[12.5px] font-semibold transition-colors"
:class="interval === 'yearly' ? 'bg-[color:var(--color-bg-elev)] text-[color:var(--color-ink)] shadow-sm' : 'text-[color:var(--color-ink-3)]'">
:class="interval === 'yearly' ?
'bg-[color:var(--color-bg-elev)] text-[color:var(--color-ink)] shadow-sm' :
'text-[color:var(--color-ink-3)]'">
{{ __('Jährlich') }} <span class="badge ok ms-1">{{ __('2 Monate gratis') }}</span>
</button>
</div>
@ -255,15 +256,20 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
<div class="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
@foreach ($plans as $plan)
@php($isCurrent = $currentPlan && $plan->is($currentPlan))
<article @class(['panel', 'ring-2 ring-[color:var(--color-hub)]' => $isCurrent]) wire:key="plan-{{ $plan->slug }}">
<article @class([
'panel',
'ring-2 ring-[color:var(--color-hub)]' => $isCurrent,
]) wire:key="plan-{{ $plan->slug }}">
<div class="p-6 space-y-5 flex flex-col h-full">
<div class="flex items-start justify-between gap-2">
<div class="flex items-center gap-3">
<div class="w-11 h-11 rounded-[6px] flex items-center justify-center flex-shrink-0
<div
class="w-11 h-11 rounded-[6px] flex items-center justify-center flex-shrink-0
bg-[color:var(--color-hub-soft)] border border-[color:var(--color-hub-soft-2)] text-[color:var(--color-hub)]">
<flux:icon :name="$this->planIcon($plan)" class="size-5" />
</div>
<h3 class="text-[17px] font-bold tracking-[-0.3px] text-[color:var(--color-ink)] m-0">{{ $plan->name }}</h3>
<h3 class="text-[17px] font-bold tracking-[-0.3px] text-[color:var(--color-ink)] m-0">
{{ $plan->name }}</h3>
</div>
@if ($isCurrent)
<span class="badge hub dot">{{ __('Aktuell') }}</span>
@ -272,20 +278,28 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
<div>
<div x-show="interval === 'monthly'">
<span class="text-[32px] font-bold tracking-[-0.8px] leading-none text-[color:var(--color-ink)]">{{ $this->formatEuro($plan->monthly_price_cents) }}</span>
<span class="text-[12.5px] text-[color:var(--color-ink-3)]">/ {{ __('Monat') }}</span>
<span
class="text-[32px] font-bold tracking-[-0.8px] leading-none text-[color:var(--color-ink)]">{{ $this->formatEuro($plan->monthly_price_cents) }}</span>
<span class="text-[12.5px] text-[color:var(--color-ink-3)]">/
{{ __('Monat') }}</span>
</div>
<div x-show="interval === 'yearly'" x-cloak>
<span class="text-[32px] font-bold tracking-[-0.8px] leading-none text-[color:var(--color-ink)]">{{ $this->formatEuro($plan->yearly_price_cents) }}</span>
<span class="text-[12.5px] text-[color:var(--color-ink-3)]">/ {{ __('Jahr') }}</span>
<span
class="text-[32px] font-bold tracking-[-0.8px] leading-none text-[color:var(--color-ink)]">{{ $this->formatEuro($plan->yearly_price_cents) }}</span>
<span class="text-[12.5px] text-[color:var(--color-ink-3)]">/
{{ __('Jahr') }}</span>
</div>
<div class="text-[11px] text-[color:var(--color-ink-3)] mt-1.5">{{ __('netto zzgl. USt.') }}</div>
<div class="text-[11px] text-[color:var(--color-ink-3)] mt-1.5">
{{ __('netto zzgl. USt.') }}</div>
</div>
<ul class="m-0 p-0 list-none space-y-2.5 text-[12.5px] text-[color:var(--color-ink-2)] flex-1 border-t border-[color:var(--color-bg-rule)] pt-4">
<ul
class="m-0 p-0 list-none space-y-2.5 text-[12.5px] text-[color:var(--color-ink-2)] flex-1 border-t border-[color:var(--color-bg-rule)] pt-4">
<li class="flex items-start gap-2">
<flux:icon.check class="size-4 flex-shrink-0 mt-0.5 text-[color:var(--color-hub)]" />
<span><strong class="text-[color:var(--color-ink)]">{{ $plan->press_release_quota }}</strong> {{ __('Pressemitteilungen pro Monat') }}</span>
<span><strong
class="text-[color:var(--color-ink)]">{{ $plan->press_release_quota }}</strong>
{{ __('Pressemitteilungen pro Monat') }}</span>
</li>
<li class="flex items-start gap-2">
<flux:icon.check class="size-4 flex-shrink-0 mt-0.5 text-[color:var(--color-hub)]" />
@ -327,7 +341,7 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
</div>
<p class="text-[12px] text-[color:var(--color-ink-3)] m-0">
{{ __('Mehr als 60 Pressemitteilungen pro Monat, mehrere Teams oder Sonderkonditionen? Enterprise-Konditionen erhalten Sie auf Anfrage über den Support.') }}
{{ __('Mehr als 60 Pressemitteilungen pro Monat, mehrere Teams oder Sonderkonditionen? Enterprise-Konditionen erhalten Sie auf Anfrage über den Support. Inklusive KI-Prüfung und Veröffentlichung.info@pressekonto.com') }}
</p>
</section>
@ -335,7 +349,8 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
<article class="panel">
<div class="p-5 grid gap-5 md:grid-cols-[1fr_auto] md:items-center">
<div class="flex items-start gap-4">
<div class="w-10 h-10 rounded-[6px] flex items-center justify-center flex-shrink-0 bg-[color:var(--color-hub-soft)] text-[color:var(--color-hub)]">
<div
class="w-10 h-10 rounded-[6px] flex items-center justify-center flex-shrink-0 bg-[color:var(--color-hub-soft)] text-[color:var(--color-hub)]">
<flux:icon.document-plus class="size-5" />
</div>
<div>
@ -343,7 +358,7 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
{{ __('Einzel-Pressemitteilung — ohne Abo') }}
</h3>
<p class="text-[12.5px] text-[color:var(--color-ink-2)] mt-1 mb-0 max-w-[560px]">
{{ __('Genau eine Veröffentlichung inklusive KI-Prüfung. Eingelöst wird der Kauf erst, wenn die Pressemitteilung live geht — Ablehnungen kosten nichts.') }}
{{ __('Genau eine Veröffentlichung inklusive Prüfung und Veröffentlichung. Eingelöst wird der Kauf erst, wenn die Pressemitteilung live geht — Ablehnungen kosten nichts.') }}
@if ($openPurchases->isNotEmpty())
<span class="font-semibold text-[color:var(--color-ink)]">
{{ trans_choice('Aktuell :count offener Kauf.|Aktuell :count offene Käufe.', $openPurchases->count(), ['count' => $openPurchases->count()]) }}
@ -357,8 +372,7 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
<div class="text-[22px] font-bold text-[color:var(--color-ink)]">{{ $singlePmPrice }}</div>
<div class="text-[11px] text-[color:var(--color-ink-3)]">{{ __('netto zzgl. USt.') }}</div>
</div>
<flux:button size="sm" variant="primary"
href="{{ route('me.checkout.single-pm') }}"
<flux:button size="sm" variant="primary" href="{{ route('me.checkout.single-pm') }}"
:disabled="!$singlePmAvailable">
{{ __('Jetzt buchen') }}
</flux:button>
@ -385,7 +399,8 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
@if ($consumedPurchases->isNotEmpty())
<div class="divide-y divide-[color:var(--color-bg-rule)]">
@foreach ($consumedPurchases as $purchase)
<div class="py-3 first:pt-0 last:pb-0 flex items-center justify-between gap-4" wire:key="consumed-purchase-{{ $purchase->id }}">
<div class="py-3 first:pt-0 last:pb-0 flex items-center justify-between gap-4"
wire:key="consumed-purchase-{{ $purchase->id }}">
<div class="min-w-0">
<div class="text-[13px] font-semibold text-[color:var(--color-ink)] truncate">
{{ $purchase->pressRelease?->title ?? $purchase->type->label() }}
@ -400,7 +415,8 @@ new #[Layout('components.layouts.app'), Title('Buchungen & Add-ons')] class exte
</div>
@else
<div class="flex flex-col items-center justify-center px-4 py-10 text-center">
<div class="w-14 h-14 rounded-[6px] flex items-center justify-center mb-3
<div
class="w-14 h-14 rounded-[6px] flex items-center justify-center mb-3
bg-[color:var(--color-bg-subtle)] border border-[color:var(--color-bg-rule)] text-[color:var(--color-ink-3)]">
<flux:icon.clock class="size-6" />
</div>