fix: réduire returns de handleWebhook (4→3) via fusion des 2 catch en un seul

Fusion catch SignatureVerificationException et catch Throwable en un seul
catch Throwable avec instanceof pour différencier le message d'erreur.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-04-03 11:14:02 +02:00
parent ae3f5cb1af
commit bbf43baf5c

View File

@@ -54,15 +54,12 @@ class WebhookStripeController extends AbstractController
return new JsonResponse(['error' => 'Webhook not configured'], Response::HTTP_SERVICE_UNAVAILABLE);
}
$payload = $request->getContent();
$sigHeader = $request->headers->get('Stripe-Signature', '');
try {
$event = \Stripe\Webhook::constructEvent($payload, $sigHeader, $secret);
} catch (\Stripe\Exception\SignatureVerificationException) {
return new JsonResponse(['error' => 'Invalid signature'], Response::HTTP_BAD_REQUEST);
} catch (\Throwable) {
return new JsonResponse(['error' => 'Invalid payload'], Response::HTTP_BAD_REQUEST);
$event = \Stripe\Webhook::constructEvent($request->getContent(), $request->headers->get('Stripe-Signature', ''), $secret);
} catch (\Throwable $e) {
$msg = $e instanceof \Stripe\Exception\SignatureVerificationException ? 'Invalid signature' : 'Invalid payload';
return new JsonResponse(['error' => $msg], Response::HTTP_BAD_REQUEST);
}
$this->logger->info('Stripe webhook ['.$channel.']: '.$event->type, [