【发布时间】: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