在付费计划中创建新的 Stripe 用户,设置试用期,无需信用卡 [英] Create a new Stripe user on a paid plan, setting a trial period, without a Credit Card
问题描述
使用 Stripe API,在没有信用卡令牌的情况下,在付费计划和试用期中创建新用户似乎无法正常工作.
Using the Stripe API, Creating a new user on a paid plan with a trial period doesn't seem to work without a credit card token.
我正在使用 PHP SDK 并执行以下操作:
I am using the PHP SDK and doing the following:
$customer = \Stripe\Customer::create(array(
"source" => NULL,
"plan" => 'PROFESSIONAL',
"email" => $email_address,
"trial_end" => $unix_timestamp
);
返回错误:
错误:无效的源对象:必须是字典或非空字符串.
Error: Invalid source object: must be a dictionary or a non-empty string.
我认为这应该起作用有两个原因,这就是为什么我认为我做错了什么.
There are two reasons I think this should work, which is why I think I am doing something wrong.
- 添加
trial_end
会为订阅添加试用版,因此无需付款,这意味着在那个时间点不需要信用卡. - 使用 Stripe 在线门户,您可以在付费订阅中创建用户,并在指定试用期时将现有用户转移到付费订阅,而无需信用卡.如果您可以在门户中完成,为什么不能通过 API 完成?
- Adding
trial_end
adds a trial to the subscription, so no payment is needed which means it doesn't need a Credit Card at that point in time. - Using the Stripe online Portal, you can create a user on a paid subscription, and also move existing users on to a paid subscription without the need for a Credit Card, when you specify a trial period. If you can do it in the portal, why can't you do it via the API?
文档中是否有遗漏的内容允许我执行此操作?
Is there something I have missed in the Documentation to allow me to do this?
推荐答案
刚刚尝试了以下有效.
$customer = \Stripe\Customer::create(array(
"plan" => 'PROFESSIONAL',
"email" => $email_address,
"trial_end" => $unix_timestamp
);
基本上我只是完全删除了 source
键/值.然后它通过试用在付费计划中创建了用户.
Basically I just removed the source
key/value completely. It then created the user on the paid plan with the trial.
奇怪的行为,当您在免费计划中创建用户时,您可以在那里使用 source
键,其值为 NULL
并且它可以工作.据我所知,也没有记录.
Odd behaviour as when you create a user on a FREE plan, you can have the source
key there with a value of NULL
and it works. Also not documented as far as I can see.
这篇关于在付费计划中创建新的 Stripe 用户,设置试用期,无需信用卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!