哪些 Stripe webhook 确认订阅和产品付款?

Which Stripe webhooks confirm Subscription and Product payments?

The Stripe API 是相当压倒性的。我发现,由于向后兼容,存在一些 webhook(即:Plan、Charge..)

我的意图很“简单”:

我的应用应该允许用户在成功支付订阅或产品费用后做一些事情。我卖的东西有些是订阅,有些是“一次性”付款。

我不知道应该使用哪些 webhook,以免错过任何付款。

有:

当然还有支付失败时的回调:

我目前的假设是

可能是“正确的”钩子

我的第二个假设是

我的方向正确吗?

编辑:

我添加Webhooks的内容:

Webhook status contains recurring products product contains one-time products plan customer address
customer.subscription.created incomplete yes id yes customer
customer.subscription.updated active yes id yes customer
payment_intent.created requires_payment_method id customer
payment_intent.succeeded succeeded id customer billing_details.address
invoice.finalized open yes (lines) yes yes yes customer customer_address
invoice.updated (contains "previous_attributes") paid yes (lines) yes yes yes customer customer_address
invoice.paid paid yes (lines) yes yes yes customer customer_address
invoice.payment_succeeded paid yes (lines) yes yes yes customer customer_address
checkout.session.completed complete customer billing_details.address

对于经常性付款,简短的回答是您当前的假设是正确的 doc 您应该倾听 invoice.paidinvoice.payment_failed 来处理经常性付款。您可能还需要收听 customer.subscription.updated 以了解订阅更改,并收听 invoice.payment_action_required 以了解需要 3DS (SCA) 之类的情况并且您可能需要让您的客户回来确认付款on-session.

关于 one-off 付款,如果您使用 Checkout than you should listen to checkout.session.completed, on the other hand if you’re using the Payment Intent API,那么您应该听取 payment_intent.succeededpayment_intent.payment_failedpayment_intent.requires_action.

请记住,如果您正在收听 payment_intent.*invoice.* 事件,则付款意向事件也可能会因定期付款而触发。如果 invoice field 在该事件中收到的付款意向中不为空,则忽略此事件,因为它将在 invoice.* 事件中处理。

您可以找到所有事件类型和描述 here