Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
September 22, 2022 11:54 am GMT

Delivering 100% of Webhooks

If something is important for your customers, you should fix it. Webhooks are one of the core features of Woovi, and even a single webhook failed causes frustration for our customers, and also reduce our trust. For this reason, we build a reliable system to ensure we always deliver at least once every webhook.

Woovi

Woovi is a Startup that enables shoppers to pay as they like. To make this possible, Woovi provides instant payment solutions for merchants to accept orders.
To provide real-time capability for our e-commerce plugins, we send webhooks when a new charge is paid.

What is a Webhook/Postback URL

A Webhook/Postback URL is an HTTP endpoint that receives a new request when a new event happens.

Woovi Charge

A Woovi Charge represents a payment request. It requests a payment of a given amount from a merchant customer. Usually an e-commerce order has 1 charge to receive an instant payment.

Building a reliable system

To build a more reliable system, we used a state machine in conjunction with a fallback cron job to ensure we always deliver any webhook at least once.

State Machine to track Webhook Delivery

Webhook State Machine

For every charge paid, we emit a charge paid event.
Then the chargePaid event processor will send a webhook for the e-commerce plugin.
We noticed that some webhooks failed, and we decide to use a state machine to keep track of webhook delivering.
The state machine has 4 status:

  • PENDING - the webhook was not sent yet
  • SUCCESS - the webhook was delivered with success
  • FAILED - the webhook tried to deliver 7 times and the e-commerce plugin didn't return a success response
  • NOT_APPLY - when the merchant do not have any Webhook setup at Woovi.

Fallback cron job

We also added a fallback cron job, that runs every 5 minutes to reprocess charges that did not deliver the webhook yet (PENDING state). Charges in PENDING state.
This fallback also solves the problem when Woovi system is having some problems.

Conclusion

State machines are a great tool to make sure your system reaches the state that it was supposed to be. And fallback job can fix a wrong system state to a desired one.

If you wanna work with us, we are hiring!


Original Link: https://dev.to/woovi/delivering-100-of-webhooks-1hn1

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To