header('Stripe-Signature'); try { $event = Webhook::constructEvent( $request->getContent(), $stripeSig, $secret ); } catch (UnexpectedValueException|SignatureVerificationException $e) { \Illuminate\Support\Facades\Log::error('Stripe webhook signature verification failed', [ 'signature_header' => $stripeSig, 'secret_prefix' => substr((string) $secret, 0, 12), 'secret_length' => strlen((string) $secret), 'body_length' => strlen($request->getContent()), 'body_sha256' => hash('sha256', $request->getContent()), 'body_raw' => $request->getContent(), 'content_type' => $request->header('Content-Type'), 'content_encoding' => $request->header('Content-Encoding'), ]); abort(400, $e->getMessage()); } if (! in_array( $event->type, [ 'payment_intent.payment_failed', 'payment_intent.succeeded', ] )) { return response('', 200); } return $next($request); } }