Stripe 在特定日期取消订阅 [英] Stripe cancel subscription at specific date
问题描述
我在 PHP 中使用 StripeAPI,但我不知道如何使用我可以在特定日期停止客户订阅吗?
I'm using StripeAPI in PHP and I don't know how can I stop a customer subscription at a specific date.
我知道有立即取消订阅的选项:
I know there is an option for cancel subscription immediatly :
$subscription = \Stripe\Subscription::retrieve('sub_49ty4767H20z6a');
$subscription->cancel();
或者在当前计费周期结束时取消订阅(客户已经付款的持续时间):
Or for cancel subscription at the end of the current billing period (for the duration of time the customer has already paid for) with :
$subscription->cancel(['at_period_end' => true]);
使用此选项,将安排取消.
With this option, the cancellation is scheduled.
但是如何在特定日期取消订阅?在我的系统中,用户可以要求取消,但他必须等待特定日期(例如至少作为订阅者停留 X 个月)
But how can I cancel a subscription at a specific date? In my system, a user can ask for a cancellation but he has to wait for a specific date (something like at least stay X months as a subscriber)
你知道我该怎么做吗?谢谢!
Do you know how can I do that? Thanks!
推荐答案
Stripe 刚刚将这个添加到他们的 API 中,我偶然发现了它.他们有一个名为cancel_at"的字段,可以设置为未来的日期.他们的文档中没有列出这个属性,因为它太新了.您可以在此处查看响应对象中的值:
Stripe just added this to their API and I happened to stumble upon it. They have a field called "cancel_at" that can be set to a date in the future. They don't have this attribute listed in their documentation since it is so new. You can see the value in the response object here:
https://stripe.com/docs/api/subscriptions/create?lang=php
我已经使用 .NET 对此进行了测试,并且可以确认它将订阅设置为按您提供的值到期.
I've tested this using .NET and can confirm it sets the subscription to expire at value you provide.
这篇关于Stripe 在特定日期取消订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!