What is a Webhook
Do you know what SaaS stands for ?
Yes it means Software as a Service. You may know some products that are like SaaS For example Twilio, PayPall, Zuora, Stripe and many others
The platforms that i mentioned above are services that we can integrate our Applications
Before we explain what is a Webhook it is important to know the above
Webhook or Callout is a user defined HTTP callback. What does that mean ?
If some Event take place in a SaaS platform that your App is using, then that Event may trigger a http call to your App, which will be a call to endpoint that you created on your App
long answer (with example):
Imagine that you have an online ebooks store and customers can buy your ebooks by PayPall
lets imagine a Synchronous flow without using Webhook
This solution have some problems:
- How will your App know how long to wait for a payment confirmation? Can we guarantee a fixed max time ?
- What if the user refresh the page during that flow or lose the connection ?
- What if the payment confirmation takes a long time and your App will timeout during that flow? That may result with: you’re client not getting the ebook but being charged anyway. Isn’t that Scary !?
This is were Webhooks and Callouts comes into play!
Thy will help you to implement the flow in a more Asynchronous manner
lets imagine a Asynchronous flow:
Here the flow ends on your app and will continue on the SaaS platform where the Payment Confirmed Event will trigger a Webhook
That flow is much more reliable and solves one of the scary scenarios: when client paid for the product but due to latency the synchronous flow may decide that the payment was unsuccessful
Payment is one of the examples, there are many more examples where our App is using some external SaaS platform and we would like to consume some Events form those platforms in our Apps
What do you think ? Let me know in comments below to help me improve this article
Thanks for reading!