如何真正暂停条带订阅 [英] How to really pause a stripe subscription

查看:24
本文介绍了如何真正暂停条带订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 stripe 的 php 包装器为其 api 管理客户订阅.我们需要为订阅提供暂停选项,时间范围从 3 个月到一年不等.暂停选项将是 1 个月、3 个月和 6 个月三个选项之一.我使用的方法是在暂停期间为他们的 Stripe 帐户设置试用版,但问题是一旦试用期结束,他们就会被收取费用,尽管按比例收取,但这不是我们的暂停类型寻找.我们需要它让我们的客户看起来实际上已经暂停,然后当它取消暂停时,它剩余的时间与他们暂停时没有预付费用的时间相同.我一直在试图弄清楚如何做到这一点,但无法想出一种方法让这一切都发生在条纹上.我的任何其他想法都涉及在我们的服务器上使用 cron 作业或某种时间触发器来处理暂停期的结束.到目前为止我所拥有的示例:

I'm using stripe's php wrapper for its api to manage customers subscriptions. We need to have a pause option for subscriptions which range in time from 3 months to a year. The pause option would be one of three options 1 month 3 months and 6 months. The method I was using was to set a trial version for their Stripe account for the duration of the pause but the problem with that is once the trial ends they are charged, albeit at a prorated amount, but thats not the type of pause we are looking for. We need it to our customers seem actually paused then when it un pauses it has the same amount of time on it left as when they paused it with no upfront charge. I have been trying to figure out how to do this but cant figure out a way to have it all happen on stripe. any of my other ideas involve having a cron job or some kind of time trigger on our server to handle the end of their pause period. example of what I have so far:

pause_sub($sub_id){
            $sub = Subscription::retrieve($sub_id);
            $sub->trial_end = time() + (31556952 / 12);
            $sub->save();
    return "Subscription Paused";
    }

也许有一种方法可以在试用期结束时使用带有 webhook 的条带事件?感谢您的帮助.

Maybe there is a way to use a stripe event with a webhook when the trial ends? Thanks for the help.

推荐答案

按照您的方法,您需要禁用按比例分配,因为它在您修改订阅时默认启用:https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior

With your approach, you need to disable proration as it is enabled by default when you modify a Subscription: https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior

Stripe 订阅没有原生的暂停"功能,但您可以使用其他方法来获得所需的行为(例如切换到免费计划):https://stripe.com/docs/billing/subscriptions/canceling-pausing#pausing-a-subscription

There is no native "pausing" of Stripe Subscription but you can use alternative approaches to get the desired behavior (like switching to a free plan): https://stripe.com/docs/billing/subscriptions/canceling-pausing#pausing-a-subscription

这篇关于如何真正暂停条带订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆