I'm currently building a node application that's using Stripe for payments. I've got webhooks setup and working as I want to create subscribers in my application but require the response from the stripe webhooks to store the data received for different events in different collections in my mongo db.
The issue I'm having is that the order of events sent by Stripe is not always in the same order and in order to create relationships between documents/collections I require that the event handlers are triggered in the following order:
As it stands the event handler for 2 can be executed before 1 and 3 before 2 etc.
What would be the best way to ensure my handlers are executed in the correct order every time? I'm thinking promises of some-sort. If this is the case, what's a good promise module for node?
You can reject hook if an event is missing, stripe will try it later but if you want it to happen quick, you can make a small loop waiting for max 10 seconds and who checks every second if missing event is arrived).
I have same problem when updating a billing plan, the event invoice.updated arrives before invoice.created ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With