add debug to try/catch block Controller

This commit is contained in:
Cyprian Beauvois 2019-07-16 15:52:48 +02:00
parent a80d52d8ee
commit eac5a76a30
2 changed files with 9 additions and 7 deletions

View File

@ -6,11 +6,10 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class BillingController extends AbstractController class BillingController extends AbstractController
{ {
public function webhook() public function webhook(LoggerInterface $logger)
{ {
\Stripe\Stripe::setApiKey($this->getParameter('stripe_api_key_secret')); \Stripe\Stripe::setApiKey($this->getParameter('stripe_api_key_secret'));
// You can find your endpoint's secret in your webhook settings
$endpoint_secret = $this->container->get('stripe_webhook_key'); $endpoint_secret = $this->container->get('stripe_webhook_key');
$payload = @file_get_contents('php://input'); $payload = @file_get_contents('php://input');
@ -21,16 +20,13 @@ class BillingController extends AbstractController
$event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret); $event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);
} catch(\UnexpectedValueException $e) { } catch(\UnexpectedValueException $e) {
// Invalid payload $logger->error($e->getMessage());
file_put_contents("/tmp/test_stripe", json_encode($e->getMessage()));
exit(); exit();
} catch(\Stripe\Error\SignatureVerification $e) { } catch(\Stripe\Error\SignatureVerification $e) {
// Invalid signature $logger->error($e->getMessage());
file_put_contents("/tmp/test_stripe", json_encode($e->getMessage()));
exit(); exit();
} }
// Handle the checkout.session.completed event
if ($event->type == 'checkout.session.completed') { if ($event->type == 'checkout.session.completed') {
$session = $event->data->object; $session = $event->data->object;

View File

@ -4,3 +4,9 @@ services:
arguments: arguments:
$container: "@service_container" $container: "@service_container"
Bluesquare\Controller\:
resource: "../../Controller/*"
arguments:
$container: "@service_container"
$logger: "@logger"