Understanding Web Hooks (and how to consume them)

31 01 2016

Hello all. In this round of posting, I will be explaining a little bit about what web hooks are and how you can consume them within your own application. According to PBWorks, web hooks are simply HTTP callbacks or HTTP POST requests that occurs when something happens. Another important point to note is that a web application implementing web hooks will POST a message to a URL when certain things happen.

understanding web hooks

Imagine having the flexibility of sending a customised email when a customer has being added or updating your own application when the failed payment web hook is fired. All this can be done simply through simple HTTP web hook calls which may have been provided by Ezypay or any other software as a service (SaaS) applications online.

Earlier last year, Ezypay has also released some web hooks to allow developers to customise their application and receive notifications whenever something occurs on our end. Therefore, I am going to use examples of how you can use consume web hooks which are provided by Ezypay for explanation purposes.

The first step in getting your web hooks running is to always subscribe to the web hook to the URL that you have control over. In the case of Ezypay, you can do that by accessing the Developer Center (for organisation level log in only). At the bottom of the screen under the API tab, you should be able to view the web hooks section which will allow you to set up the URL for the notification that you want.

understanding web hooks One of the best places to test if a web hook works would be a free site known asRequestBin. RequestBin provides a FREE (YES It’s FREE!) temporary URL for developers to check out HTTP responses from any particular website especially web hooks. To test it out, head to the RequestBin website and create your own RequestBin URL. Upon entering the website, hit the understanding web hooks to create your own temporary URL. Once the URL is created, RequestBin should prompt you with a screen which looks something like below:understanding web hooks Using the URL that RequestBin has generated, use it as the URL that you would like Ezypay to notify you with of any event. For simplicity of testing, we would like to get a notification when a customer is created, and therefore I will add the URL into the CreateCustomer web hook as shown below. Complete the step by clicking on the understanding web hooks button. understanding web hooks   That would be all to do to run your web hook test. It’s that simple! To check if the web hook work, simply create a customer via the Secure Site, API or the Online Signup form and refresh your RequestBin page. If you have followed the steps correctly, you should be prompted with a different looking page on the same RequestBin URL as shown below on refresh: understanding web hooksInspecting the POST request that came through, you can see that Ezypay is just simply returning a JSON string in which you can parse on your code for your own manipulation. By passing in more requests, you will get more results displayed on the same RequestBin page. Do note that a RequestBin URL only stored 20 requests and lasts for 48 hours only! By using our favourite JSON parser JSON.NET, a .NET developer should have no issue understanding and using the data that has been passed through. As JSON is a commonly understood markup language, it should be parseable by any form of modern software development language. Enjoyed what you have read or learnt something new? Please stay tuned for more weekly articles from the iconnect360 Engineering Blog. If you are interested in learning how to consume Ezypay’s APIs, there was also a tutorial created by me on how to Integrate with Ezypay’s Direct Debit API Using C#. Cheers!


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: