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
@@ -26,6 +26,7 @@ public function checkoutFor(Order $order): array
|
||||
{
|
||||
$this->assertSandbox();
|
||||
$order->loadMissing('lines', 'user');
|
||||
$taxRate = $this->taxRate();
|
||||
|
||||
if ($order->status !== 'offen') {
|
||||
throw new DomainRuleException('Diese Bestellung nimmt keine Zahlung mehr an.');
|
||||
@@ -58,6 +59,10 @@ public function checkoutFor(Order $order): array
|
||||
'product_data' => ['name' => filled($line->offer_name) ? (string) $line->offer_name : 'Lizenz'],
|
||||
],
|
||||
];
|
||||
|
||||
if ($taxRate !== null) {
|
||||
$params['line_items'][$index]['tax_rates'] = [$taxRate];
|
||||
}
|
||||
}
|
||||
|
||||
$response = $this->request()
|
||||
@@ -94,6 +99,22 @@ public function assertSandbox(): void
|
||||
}
|
||||
}
|
||||
|
||||
/** Konfigurierter Steuersatz oder null; eine ungültige ID wird abgewiesen, statt geraten zu werden. */
|
||||
private function taxRate(): ?string
|
||||
{
|
||||
$id = trim((string) config('services.stripe.tax_rate'));
|
||||
|
||||
if ($id === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! preg_match('/^txr_[A-Za-z0-9]+$/', $id)) {
|
||||
throw new DomainRuleException('Die Steuersatz-ID für Stripe ist ungültig (erwartet txr_...).');
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{id: string, url: string}|null
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user