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.
NOTE: This tutorial can be use on any system or web app that provides webhooks event deriving..
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. .
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..
replace your real domain name with ngrok domain name / the fullpath of your laravel roure example as shown below
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.
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 ... :)