DEV Community

Sibelius Seraphini for Woovi

Posted on

9 3

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!

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay