【问题标题】:Stripe: no webhook event when subscription updatedStripe:订阅更新时没有 webhook 事件
【发布时间】:2023-03-19 13:40:02
【问题描述】:

我的目标

当客户想要降级到更便宜的订阅时,让他/她使用当前订阅直到当前计费周期结束,然后自动切换到更便宜的订阅。此外,我需要收到有关更改的通知,以便我可以运行一些内部逻辑。

我尝试过的

我已使用订阅时间表来安排订阅在当前期间结束时的价格变化。使用 Stripe 仪表板,我可以看到价格已在正确的时间成功更改,但是:

  • 没有 webhook 事件。我期待 customer.subscription.updated 事件,并且还尝试收听 subscription_schedule.updated 事件但没有成功。
  • 即使等了几个小时,客户也没有收到新价格的费用。

以下是详细步骤:

  • 客户订阅每日价格。
  • 客户希望将订阅更改为更便宜的价格。
  • 我使用以下订阅创建订阅计划:
stripe.subscriptionSchedules.create({ from_subscription: subId }).
  • 然后我更新了时间表:
stripe.subscriptionSchedules.update(schedule.id, {
  phases: [
    {
      start_date, // billing_cycle_anchor of current subscription
      items: [
        { price: currentPriceId, quantity: 1 }, // current plan to be used until period end
      ],
      iterations: 1, // 'iterations' is set to 1, this is important because we want current phase to end at the end of current period
    },
    {
      proration_behavior: 'none', // no proration when transition to this phase
      items: [
        { price: nextPriceId, quantity: 1 }, // new plan to be switched to after current period
      ],
      iterations: 1, // 'iterations' is set to 1 and 'end_behavior' need to be set to 'release'
    },
  ],
  end_behavior: 'release', // release this schedule after last phase, so that subscription will continue as normal
});

编辑:这种奇怪的行为是因为我们使用的信用卡有问题,我们的 Stripe 帐户被列入黑名单。解决信用卡问题,一切恢复正常。

【问题讨论】:

    标签: stripe-payments


    【解决方案1】:

    移动到新阶段时,您不会收到 updated 事件,因为订阅在技术上并未更新。

    相反,您应该收听invoice.created event。当订阅计划进入新阶段时,意味着它进入了一个新的计费周期,即创建了一张发票。

    【讨论】:

    • 感谢您的回答!明天我会尝试你的建议并发布结果。通常我认为应该触发订阅更新事件或计划更新事件(如果不是两者)。 Stripe 文档确实缺乏这方面的信息……
    • 所以我已经尝试了你的建议,但仍然没有运气......没有发票事件,并且通过 Stripe Dashboard 验证根本没有发票。更新后订阅卡住了,没有进一步的发票,也没有任何错误消息。
    • 你应该写信给 Stripe 支持,他们可以调查看看发生了什么:support.stripe.com/contact
    猜你喜欢
    • 2014-05-01
    • 2021-01-19
    • 2013-10-24
    • 2017-03-04
    • 2016-10-18
    • 2017-08-20
    • 2023-03-11
    • 2021-02-16
    • 2019-02-15
    相关资源
    最近更新 更多