DEV Community

Cover image for Test Webhook on localhost serve using Laragon
EJEH
EJEH

Posted on • Edited on

Test Webhook on localhost serve using Laragon

Webhooks are a simple way to communicate different services, So if you are a web developer, you will need to understand how Webhooks work to use it in your web applications. Now, taking Paystack Nigeria as cast study you will see the integration and how to handle Webhooks with Laravel (PHP) and Largaon . Without taking much of our time I'm let get started.

dont miss out how to improve the performance on laravel web app

NOTE: This tutorial can be use on any system or web app that provides webhooks event deriving..

Requirements:

=> Largaon
=> Paystack Account

Step 1: if you have Download and install laragon, by default it comes ngrok per-installed. ngrok provides a real-time web UI where you can introspect all HTTP traffic running over your tunnels.

Step 2: open your laravel project on your laragon, and then we are going to use ngrok and expose of localhost host to live by I simply right click on the laragon icon then go to the following: , www ,share, share your project. Alt Text.

ngrok expose your laragon local tunneling
Alt Text

Copy the SSL url provided by ngrok and keep it some where safe.

Step 3: Goto your paystack dashboard under settings or any web application you are working with that has webhooks event as shown below using paystack webhooks as example..

Alt Text

replace your real domain name with ngrok domain name / the fullpath of your laravel roure example as shown below

https://example.com/payment/webhooks

with

https://12ad5fbf1740.ngrok.io/payment/webhooks

As a step 3, you must disable the CSRF token validation for the route we just configured. Because the request comes out of the session and does not contain the CSRF token. We add the path to exceptions where validation is not necessary. Open the VerifyCsrfToken.php file from app/Http/Middleware and add the path to the $ except property.

Alt Text

The webhooks will send requests to the URL (endpoint) that you indicated via your route which you will hander the payload and take a proper action on it.

I think that it's, for comment and questioning you can drop it below else share and like ... :)

**

UPDATE 21/092023

**

IF YOU CAN NOT EXPOSE DIRECTLY VIA LARAGON AS OF THIS DATE, THEN YOU CAN DOWNLOAD ngrok AND RUN THIS COMMAND BELOW
ngrok http --host-header=<your_domain_name> 80

NOTE: don't include http eg ngrok http --host-header=laravelbackend.test 80

Top comments (0)