factory->create($request->getAttribute('gateway')); // Handle the webhook request... $handler = $gateway->getWebhookHandler(); if (is_string($handler)) { $handler = $this->container->get($handler); } try { $handler->handle($request); } catch (WebhookException $th) { return new JsonResponse(['error' => $th->getMessage()], StatusCode::BAD_REQUEST); } return new EmptyResponse(); } }