From 5453a6931222d21a19185ac5b120e056e546a867 Mon Sep 17 00:00:00 2001 From: cbeauvoi Date: Tue, 16 Jul 2019 17:08:03 +0200 Subject: [PATCH] add debug to try/catch block Controller --- BillingBundle/Controller/BillingController.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/BillingBundle/Controller/BillingController.php b/BillingBundle/Controller/BillingController.php index 3b3df1f..0184922 100644 --- a/BillingBundle/Controller/BillingController.php +++ b/BillingBundle/Controller/BillingController.php @@ -30,6 +30,15 @@ class BillingController extends AbstractController try { $event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret); + if ($event->type == 'checkout.session.completed') { + $session = $event->data->object; + + // Fulfill the purchase... + if (file_put_contents("/tmp/return_stripe_session", json_encode($session)) !== false) + return $this->json("OK", 200); + return $this->json("KO", 500); + } + } catch(\UnexpectedValueException $e) { $this->logger->error($e->getMessage()); exit(); @@ -38,14 +47,6 @@ class BillingController extends AbstractController exit(); } - if ($event->type == 'checkout.session.completed') { - $session = $event->data->object; - - // Fulfill the purchase... - file_put_contents("/tmp/return_stripe_session", json_encode($session)); - //handle_checkout_session($session); - } - - return $this->json("OK", 200); + return $this->json("KO", 500); } }