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

编程入门 行业动态 更新时间:2024-10-14 06:18:39

无法恢复已取消的<a href=https://www.elefans.com/category/jswz/34/1756572.html style=条带订阅吗?"/>

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

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

我的取消代码如下:

// 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

更多推荐

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

本文发布于:2024-05-06 21:57:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1753885.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条带

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!