stripe-payments - Stripe 在特定日期取消订阅

标签 stripe-payments

我正在使用 StripeAPI在 PHP 中,我不知道如何在特定日期停止客户订阅。

我知道有一个选项可以立即取消订阅:

$subscription = \Stripe\Subscription::retrieve('sub_49ty4767H20z6a');
$subscription->cancel();

或者在当前计费周期结束时取消订阅(在客户已经支付的时间段内):
$subscription->cancel(['at_period_end' => true]);

使用此选项,将安排取消。

但是如何在特定日期取消订阅?在我的系统中,用户可以要求取消,但他必须等待特定日期(例如至少作为订阅者停留 X 个月)

你知道我该怎么做吗?谢谢!

最佳答案

Stripe 刚刚将其添加到他们的 API 中,而我偶然发现了它。他们有一个名为“cancel_at”的字段,可以设置为 future 的日期。他们的文档中没有列出这个属性,因为它太新了。您可以在此处查看响应对象中的值:

https://stripe.com/docs/api/subscriptions/create?lang=php

我已经使用 .NET 对此进行了测试,并且可以确认它将订阅设置为按您提供的值到期。

关于stripe-payments - Stripe 在特定日期取消订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49431030/

相关文章:

stripe-payments - Stripe费用计算公式

php - 正确支付后如何单独放入购物车的商品?

php - Stripe 在 PHP 中创建客户和经常性费用

payment - 处理付款时验证信用卡所有权

stripe-payments - stripe.createToken() 不是函数

javascript - Stripe .js : stripeToken not sent

ruby-on-rails - Stripe - 在测试模式下向客户添加无效卡?

ios - 从 iPhone 通过的 Stripe 卡身份验证在服务器上失败

stripe-payments - 在 Stripe CLI 中使用 fixtures

ios - 并非所有 Stripe 占位符同时在我的屏幕上可见