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 syst…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Sibelius Seraphini

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!


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Sibelius Seraphini


Print Share Comment Cite Upload Translate Updates
APA

Sibelius Seraphini | Sciencx (2022-09-22T11:54:41+00:00) Delivering 100% of Webhooks. Retrieved from https://www.scien.cx/2022/09/22/delivering-100-of-webhooks/

MLA
" » Delivering 100% of Webhooks." Sibelius Seraphini | Sciencx - Thursday September 22, 2022, https://www.scien.cx/2022/09/22/delivering-100-of-webhooks/
HARVARD
Sibelius Seraphini | Sciencx Thursday September 22, 2022 » Delivering 100% of Webhooks., viewed ,<https://www.scien.cx/2022/09/22/delivering-100-of-webhooks/>
VANCOUVER
Sibelius Seraphini | Sciencx - » Delivering 100% of Webhooks. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/09/22/delivering-100-of-webhooks/
CHICAGO
" » Delivering 100% of Webhooks." Sibelius Seraphini | Sciencx - Accessed . https://www.scien.cx/2022/09/22/delivering-100-of-webhooks/
IEEE
" » Delivering 100% of Webhooks." Sibelius Seraphini | Sciencx [Online]. Available: https://www.scien.cx/2022/09/22/delivering-100-of-webhooks/. [Accessed: ]
rf:citation
» Delivering 100% of Webhooks | Sibelius Seraphini | Sciencx | https://www.scien.cx/2022/09/22/delivering-100-of-webhooks/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.