Bonjour les amis,
J'essaie d'installer webhook de stripe sur un projet symfony 4 pour écouter (En back-end) les évenements notamment le succès d'un paiement.
Et executer du code apres la recéption de l'évenement.
Voici le code de ma méthode
/**
*
* @Route("/confirmation_paiement", name="confirmation_paiement")
*
*/
public function confirmationPaiement(Request $request){
$endpoint_secret = self::WEBHOOK_TEST_KEY;
$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = null;
try {
$event = \Stripe\Webhook::constructEvent(
$payload, $endpoint_secret
);
//, $sig_header
} catch(\UnexpectedValueException $e) {
// Invalid payload
return new Response(Response::HTTP_BAD_REQUEST);
exit();
} catch(\Stripe\Exception\SignatureVerificationException $e) {
// Invalid signature
return new Response(Response::HTTP_BAD_REQUEST);
exit();
}
// Handle the event
switch ($event->type) {
case 'payment_intent.succeeded':
$paymentIntent = $event->data->object; // contains a StripePaymentIntent
handlePaymentIntentSucceeded($paymentIntent);
break;
case 'payment_method.attached':
$paymentMethod = $event->data->object; // contains a StripePaymentMethod
handlePaymentMethodAttached($paymentMethod);
break;
// ... handle other event types
default:
// Unexpected event type
return new Response(Response::HTTP_BAD_REQUEST);
exit();
}
return new Response(Response::HTTP_OK);
}
Le problème est que Stripe reconnais bien l'url mais ne reçois aucune réponse de la méthode appelé, alors que je lui envoie bien une réponse http de type de 200.
Et deuxièment où et comment je doit configurer la variable 'HTTP_STRIPE_SIGNATURE'