From 06726829fe18dfb1c15e1005e5b4efbcbb464835 Mon Sep 17 00:00:00 2001 From: cbeauvoi Date: Wed, 17 Jul 2019 16:27:54 +0200 Subject: [PATCH] add func personnalisation on redirect from webhook --- BillingBundle/Controller/BillingController.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/BillingBundle/Controller/BillingController.php b/BillingBundle/Controller/BillingController.php index 6e4e2c0..b88d170 100644 --- a/BillingBundle/Controller/BillingController.php +++ b/BillingBundle/Controller/BillingController.php @@ -35,9 +35,19 @@ class BillingController extends AbstractController $serviceToCall = $this->container->getParameter('payment_confirmation_service'); - $srv = new $serviceToCall(); + list($service, $function) = str_split($serviceToCall, '::'); - $srv->handlePayment($session); + $srv = null; + + if (class_exists($service)) + $srv = new $service(); + else + $this->logger->error("Can't find your class to redirect webhook"); + + if (method_exists($srv, $function)) + $srv->{$function}($session); + else + $this->logger->error("Can't find your method in class " . $service); return $this->json("OK", 200); }