dongzan0108 2016-07-15 12:55 采纳率: 0%
浏览 22
已采纳

在付费方案上创建新的条带用户,设置试用期,不使用信用卡

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.

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
);

Which returns the error:

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.

  1. 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.
  2. 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?

  • 写回答

2条回答 默认 最新

  • dsgdf45654 2016-07-15 13:14
    关注

    Just tried the following which worked.

    $customer = \Stripe\Customer::create(array(
        "plan" => 'PROFESSIONAL',
        "email" => $email_address,
        "trial_end" => $unix_timestamp
    );
    

    Basically I just removed the source key/value completely. It then created the user on the paid plan with the trial.

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?