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:
parent
6a82e2a2a8
commit
8f3261d0b4
3 changed files with 191 additions and 133 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -29,10 +29,28 @@ class StripeCheckoutService
|
|||
|
||||
return $user
|
||||
->newSubscription('default', $priceId)
|
||||
->checkout([
|
||||
'success_url' => route('me.bookings.index', ['checkout' => 'erfolg']),
|
||||
'cancel_url' => route('me.bookings.index', ['checkout' => 'abbruch']),
|
||||
]);
|
||||
->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],
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue