Comment by cyberax

5 hours ago

Just treat webhooks as a hint.

Write your code to work as a "reconciler" that checks the state of the remote system and reconciles it with the local view of that system. Run reconciliation for the full state periodically using a scheduler, and then treat webhooks as a hint to run the reconciler immediately.

This way, you will have a robust system that can survive logical bugs and outages because you don't store the synchronization state per se.

In the case of Stripe, for example, have a process that polls every open checkout session every couple of minutes. A webhook then just triggers the run earlier. If you're worried about DDoS, have an exponential backoff for the poll period.

Theoretically polling doesn't scale, but in practice it works just fine.