我对 Cashier/Stripe 订阅在无卡预试用的情况下如何工作感到困惑。 我已经在 Stripe 上设定了试用期并制定了计划。 我已将 no card up front 模型特征设置为 false。
$user = User::find(1);
// This doesn't seem to do anything. No sub created in Stripe.
$user->subscription('yearly_uk');
// This throws an error as I am not passing through a card token.
$user->subscription('yearly_uk')->create();
// This throws an nasty api error but strangely does create a customer in Stripe.
$user->subscription('yearly_uk')->create(null);
有什么想法吗?
最佳答案
根据您的评论,您似乎已经回答了这个问题,但对于 future 的读者,我遇到了类似的问题,用户可以从几个计划中进行选择,其中一个是免费的。
要解决此问题,请将其添加到您的用户
模型中:
protected $cardUpFront = false;
protected $trial_ends_at = null;
然后您可以使用空 token 订阅用户:
$user->subscription('yearly_uk')->create(null);
我还没有检查过,但我认为如果/当你转向付费计划时,它不会抛出同样类型的错误 - 即他们将能够更改,但我猜 Stripe 会返回错误因为它会在没有信用卡详细信息的情况下向用户收费。
关于laravel - 使用 Laravel Cashier & Stripe 启动无卡预订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26161468/