Checkout: Profil-Rechnungsadresse als Stripe-Rechnungsempfaenger
Die lokal gepflegte Rechnungsadresse stand nur bei der Erstanlage am Stripe-Customer; der Checkout erzwang die Neueingabe und ueberschrieb sie — auf der Rechnung stand die getippte Adresse statt der Profildaten (QA-Befund 07.07.). Jetzt: Customer-Sync (Name/Firma, Adresse, USt-ID) vor jedem Checkout, stripeName()-Hook liefert Firma bzw. Rechnungsname statt Login-Anzeigename, billing_address_collection auf 'auto' (keine Zwangs-Neueingabe bei hinterlegter Adresse). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
5166fc7b40
commit
304c5817b5
3 changed files with 98 additions and 5 deletions
52
tests/Feature/Billing/StripeCustomerHooksTest.php
Normal file
52
tests/Feature/Billing/StripeCustomerHooksTest.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
use App\Models\BillingAddress;
|
||||
use App\Models\User;
|
||||
|
||||
test('the stripe recipient name prefers the billing company over names', function () {
|
||||
$user = User::factory()->create(['name' => 'Login Anzeigename']);
|
||||
BillingAddress::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'company' => 'Beispiel GmbH',
|
||||
'name' => 'Max Mustermann',
|
||||
]);
|
||||
|
||||
expect($user->fresh()->stripeName())->toBe('Beispiel GmbH');
|
||||
});
|
||||
|
||||
test('the stripe recipient name falls back to the billing name, then the display name', function () {
|
||||
$user = User::factory()->create(['name' => 'Login Anzeigename']);
|
||||
BillingAddress::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'company' => null,
|
||||
'name' => 'Max Mustermann',
|
||||
]);
|
||||
|
||||
expect($user->fresh()->stripeName())->toBe('Max Mustermann');
|
||||
|
||||
$withoutAddress = User::factory()->create(['name' => 'Nur Anzeigename']);
|
||||
|
||||
expect($withoutAddress->stripeName())->toBe('Nur Anzeigename');
|
||||
});
|
||||
|
||||
test('the stripe address mirrors the billing address', function () {
|
||||
$user = User::factory()->create();
|
||||
BillingAddress::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'address1' => 'Rechnungsweg 12',
|
||||
'address2' => 'Hinterhaus',
|
||||
'postal_code' => '33739',
|
||||
'city' => 'Bielefeld',
|
||||
'country_code' => 'DE',
|
||||
]);
|
||||
|
||||
expect($user->fresh()->stripeAddress())->toBe([
|
||||
'line1' => 'Rechnungsweg 12',
|
||||
'line2' => 'Hinterhaus',
|
||||
'postal_code' => '33739',
|
||||
'city' => 'Bielefeld',
|
||||
'country' => 'DE',
|
||||
]);
|
||||
|
||||
expect(User::factory()->create()->stripeAddress())->toBeNull();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue