Reputation: 8074
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.
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.Is there something I have missed in the Documentation to allow me to do this?
Upvotes: 1
Views: 1045
Reputation: 116
Follow these step
Create a customer using
\Stripe\Customer::create(array( "description" => $descriptions, "email" => $email ));
Store the returned customer ID from stripe
Now subscribe the customer for that plan
$customer = \Stripe\Customer::retrieve($customer_id);
$subscriptions = $customer->subscriptions->create(array("plan" => $plan_id));
Please make sure plan is already created on stripe.
Upvotes: 0
Reputation: 8074
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.
Upvotes: 1