bound("webhook.verifier.{$source}") ? app("webhook.verifier.{$source}") : null; if ($verifier instanceof WebhookVerifier) { $secret = config("webhook.secrets.{$source}", ''); $signatureValid = $verifier->verify($request, $secret); } // Extract event type from common payload patterns $payload = $request->json()->all(); $eventType = $payload['type'] ?? $payload['event_type'] ?? $payload['event'] ?? null; $call = WebhookCall::create([ 'source' => $source, 'event_type' => is_string($eventType) ? $eventType : null, 'headers' => $request->headers->all(), 'payload' => $payload, 'signature_valid' => $signatureValid, ]); event(new WebhookReceived($source, $call->id)); return response()->json(['ok' => true]); } }