Gib Stripe auf Wunsch einen im Preis enthaltenen Steuersatz je Position mit
CI Feature / test (push) Successful in 1m54s
CI Feature / test (push) Successful in 1m54s
Stripe lehnte die Checkout Session mit „Invalid line_items[0]: the product tax code is missing“ ab. Neue optionale Einstellung STRIPE_TAX_RATE_ID (txr_...): Der Steuersatz wird jeder Position mitgegeben. Eine ungültige ID wird vor jedem Aufruf abgewiesen. Der Satz muss in Stripe inklusiv angelegt sein, damit der gezahlte Betrag der Bestellsumme entspricht (die Betragsprüfung bleibt). Die Anwendung wählt keinen Satz; das entscheiden Steuer und Finance. Doku und env-Beispiel ergänzt. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2094961b6e
commit
4bc2e5871b
5 files changed
+62
No files matched your search
@@ -85,6 +85,40 @@ public function test_paying_creates_a_checkout_session_with_the_order_amounts_an
|
||||
$this->assertSame('offen', $order->fresh()->status, 'Bezahlt wird erst durch die signierte Meldung.');
|
||||
}
|
||||
|
||||
public function test_a_configured_tax_rate_is_sent_with_every_line_and_otherwise_none(): void
|
||||
{
|
||||
$order = $this->orderOf($this->tina(), [$this->privateKonflikte(), $this->privateGrenzen()]);
|
||||
Http::fake(['stripe.test/v1/checkout/sessions' => Http::response(['id' => 'cs_test_s', 'url' => 'https://checkout.stripe.test/s'])]);
|
||||
|
||||
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertRedirect();
|
||||
Http::assertSent(function (HttpRequest $request): bool {
|
||||
parse_str($request->body(), $body);
|
||||
|
||||
return ! isset($body['line_items'][0]['tax_rates']) && ! isset($body['line_items'][1]['tax_rates']);
|
||||
});
|
||||
|
||||
$order->payments()->delete();
|
||||
config(['services.stripe.tax_rate' => 'txr_Testsatz123']);
|
||||
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertRedirect();
|
||||
Http::assertSent(function (HttpRequest $request): bool {
|
||||
parse_str($request->body(), $body);
|
||||
|
||||
return ($body['line_items'][0]['tax_rates'] ?? null) === ['txr_Testsatz123']
|
||||
&& ($body['line_items'][1]['tax_rates'] ?? null) === ['txr_Testsatz123'];
|
||||
});
|
||||
}
|
||||
|
||||
public function test_an_invalid_tax_rate_id_is_refused_before_any_call(): void
|
||||
{
|
||||
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||
config(['services.stripe.tax_rate' => 'txcd_99999999']);
|
||||
Http::fake();
|
||||
|
||||
$this->actingAs($this->tina())->post(route('member.order.pay', $order))
|
||||
->assertSessionHasErrors(['payment' => 'Die Steuersatz-ID für Stripe ist ungültig (erwartet txr_...).']);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_an_open_session_is_reused(): void
|
||||
{
|
||||
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||
|
||||
Reference in new issue
Block a user