最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

无法恢复已取消的条带订阅吗?

网站源码admin20浏览0评论

无法恢复已取消的条带订阅吗?

无法恢复已取消的条带订阅吗?

我正在尝试恢复已取消的条带订阅。我正在遵循以下指南:

我的取消代码如下:

// Update to cancel at the end of the period
await stripe.subscriptions.update(subscription.id, { cancel_at_period_end: true });

// Cancel the subscription
await stripe.subscriptions.del(subscription.id)

然后我恢复以下内容:

// Grab the subscription
const subscription = await stripe.subscriptions.retrieve(subId);

// Resume
await stripe.subscriptions.update(subscription .id, {
      cancel_at_period_end: false,
      items: [{ id: subscription.items.data[0].id, plan: subscription.plan.id }],
    });

但是我得到的错误是:

StripeInvalidRequestError:没有这样的订阅:sub_GFmbrVQihHoD6P

我立即在一个集成测试中一个接一个地运行它们。我不知道这是否与它有关。

有什么想法吗?

回答如下:

我想在下面两行告诉您。我认为您正在同时同时使用一个接一个]

 // Update to cancel at the end of the period
await stripe.subscriptions.update(subscription.id, { cancel_at_period_end: true });

// Cancel the subscription
await stripe.subscriptions.del(subscription.id)

仅当您要在当前计费周期结束后取消订阅时,才需要在下面的行中使用。

  await stripe.subscriptions.update(subscription.id, { cancel_at_period_end: true });

仅在以上语句中,如果要在当前计费周期结束之前重新激活,则可以通过将cancel_at_period_end的值更新为false来重新激活订阅。请记住,订阅尚未到结算期末。只有这样才能重新激活它,否则您需要为该用户创建一个新的订阅。

如果要立即取消订阅,则只需要使用以下行。您无法重新激活订阅。您需要为该用户创建一个新的订阅。

await stripe.subscriptions.del(subscription.id)

有关更多信息,请阅读此内容。

https://stripe/docs/billing/subscriptions/canceling-pausing#reactivating-canceled-subscriptions

发布评论

评论列表(0)

  1. 暂无评论