【问题标题】:Stripe: 'payment_intent.succeeded' is also triggered when subscription gets renewedStripe:订阅续订时也会触发“payment_intent.succeeded”
【发布时间】:2022-01-06 07:44:50
【问题描述】:

我的后端 (Django) 中有两个用于 Stripe webhook 的 API。

  • “订阅”网络钩子:/api/subscriptions/webhook/
  • “将余额添加到钱包”网络挂钩:/api/wallet/webhook/

在订阅 webhook 中,我监听 invoice.paidinvoice.payment_failed 事件,在钱包 webhook 中,我监听 payment_intent.succeeded 事件。问题是,每当调用订阅 webhook 时,也会为钱包 webhook 触发 payment_intent.succeeded 事件。我认为这是因为还为订阅创建了支付意图。我需要一种方法来区分这两者(一次性付款 [aka add balance to wallet] 和订阅),这样当他们的订阅续订时,我最终不会在用户的钱包中获得额外的信用。

【问题讨论】:

    标签: python django stripe-payments


    【解决方案1】:

    我最终为两个 webhook 使用了 invoice.paid 事件并检查了 data.object.lines.data[0].price.type 字段,该字段可以是 one_timerecurring。您可以在https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-type了解更多信息

    【讨论】:

      猜你喜欢
      • 2019-12-30
      • 2021-05-22
      • 2014-05-01
      • 2023-03-11
      • 2018-01-02
      • 2017-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多