条纹webhooks事件顺序 [英] Stripe webhooks events order

查看:105
本文介绍了条纹webhooks事件顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个使用Stripe付款的节点应用程序.我已经设置好webhooks并可以正常工作,因为我想在应用程序中创建订户,但是需要条带化webhooks的响应才能将收到的针对不同事件的数据存储在mongo数据库的不同集合中.

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.

我遇到的问题是,Stripe发送的事件的顺序并不总是相同的,并且为了在文档/集合之间建立关系,我要求事件处理程序以以下顺序触发:

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:

  1. customer.created
  2. customer.card.created(与客户有关)
  3. 已创建发票(与客户有关)

就目前而言,2的事件处理程序可以在1之前执行,3可以在2之前执行,等等.

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?

推荐答案

如果事件丢失,您可以拒绝钩子,stripe会稍后尝试,但是如果您希望它快速发生,您可以进行一个小循环以等待max 10秒,然后谁每秒检查一次缺少的事件).

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).

更新剪裁计划时遇到相同的问题,invoice.updated事件在invoice.created出现之前到达...

I have same problem when updating a nilling plan, the event invoice.updated arrives before invoice.created ...

这篇关于条纹webhooks事件顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆