So I am trying to implement a stripe webhook to listen to various events. Basically I have my php application running live, say on "http://example.com". I have installed the stripe CLI and have all the classes. I already have created a webhook on stripe dashboard. But when I test a webhook it gives me this error :
"Test webhook error: Unable to connect. Timed out connecting to remote host"
I am coding on PhpStorm from where I save the files and they get reflected on my website "abc.com". Here is my php file code
require_once 'abc.com/httpdocs/includes/classes/stripe-sdk/vendor/stripe/stripe-php/configuration.php'; require_once 'abc.com/httpdocs/includes/classes/stripe-sdk/vendor/stripe/stripe-php/init.php'; $endpoint_secret = 'whsec_...'; $payload = file_get_contents('php://input'); $event = null; $sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE']; try { $event = \Stripe\Webhook::constructEvent( $payload, $sig_header, $endpoint_secret ); } catch(\Stripe\Exception\SignatureVerificationException $e) { // Invalid signature echo '⚠️ Webhook error while validating signature.'; http_response_code(400); exit(); } // Handle the event switch ($event->type) { case 'account.updated': $paymentIntent = $event->data->object; break; default: // Unexpected event type error_log('Received unknown event type'); } http_response_code(200); I don't think I have to run the php server on a local host. And do I need to "stripe listen .."? Hoping to get an answer! Thanks in advance :) Let me know if you need any other information.