Merge branch 'feature/stripe-fehlermeldung' into develop
Deploy Test / test (push) Successful in 1m54s
Deploy Test / deploy (push) Successful in 28s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
StommerandClaude Sonnet 5.5 committed 2026-11-22 08:16:02 +01:00
commit 2094961b6e
2 files changed
+12 -2

No files matched your search

+4 -1
View File
@@ -133,11 +133,14 @@ private function assertOk(Response $response, string $what): void
return;
}
// Nur Statuscode und Fehlertyp ins Log, nie Schlüssel oder Kundendaten.
// Statuscode, Fehlertyp, Code, betroffener Parameter und Begründung von Stripe, damit die Ursache lesbar ist.
// Nie Schlüssel oder Kundendaten; die Begründung wird gekürzt.
Log::warning('Stripe-Anfrage fehlgeschlagen', [
'status' => $response->status(),
'type' => $response->json('error.type'),
'code' => $response->json('error.code'),
'param' => $response->json('error.param'),
'message' => mb_substr((string) $response->json('error.message'), 0, 300),
]);
throw new DomainRuleException('Die Zahlung konnte bei Stripe nicht '.$what.' werden. Bitte versuche es später noch einmal.');
+8 -1
View File
@@ -8,6 +8,7 @@
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Client\Request as HttpRequest;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Testing\TestResponse;
use Tests\Support\BuildsShop;
use Tests\TestCase;
@@ -137,12 +138,18 @@ public function test_only_test_keys_reach_stripe(): void
public function test_a_stripe_error_leaves_the_order_open_and_shows_a_plain_message(): void
{
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
Http::fake(['stripe.test/*' => Http::response(['error' => ['type' => 'api_error']], 500)]);
Log::spy();
Http::fake(['stripe.test/*' => Http::response(['error' => ['type' => 'invalid_request_error', 'param' => 'success_url', 'message' => 'Not a valid URL']], 400)]);
$this->actingAs($this->tina())->post(route('member.order.pay', $order))
->assertSessionHasErrors(['payment' => 'Die Zahlung konnte bei Stripe nicht angelegt werden. Bitte versuche es später noch einmal.']);
$this->assertSame('offen', $order->fresh()->status);
$this->assertSame(0, $order->payments()->count());
Log::shouldHaveReceived('warning')->withArgs(fn (string $message, array $context): bool => $message === 'Stripe-Anfrage fehlgeschlagen'
&& $context['status'] === 400
&& $context['param'] === 'success_url'
&& $context['message'] === 'Not a valid URL'
&& ! str_contains(json_encode($context), 'sk_test'))->once();
}
public function test_a_signed_paid_event_grants_every_line_once_even_when_repeated(): void