Cashier-stripe: Can't pass a timestamp of trial end to Stripe

Created on 10 Jul 2015  路  5Comments  路  Source: laravel/cashier-stripe

I'm trying to create a subscription for registered user. He has a trial period in application, while all the subscription plans don't have one. Is it possible to pass the trial end date (_trial_ends_at_ field) to Stripe, when creating first subscription?

Stripe API reference on creating a new subscription says, that the parameter _trial_end_ can be passed in this case. Also Laravel Cashier docs say, that:

If you would like to specify additional customer details, you may do so by passing them as second argument to the create method (...) To learn more about the additional fields supported by Stripe...

I tried to do so in my code..

$user->subscription($plan)->create($creditCardToken, [
    'email' => $user->email, 
    'description' => $user->name,
    'trial_end' => $user->trial_ends_at->timestamp
]);

..but I got the InvalidRequest Exception (Received unknown parameter: trial_end).

Is it possible now? And if it is, what am I doing wrong?

Thanks in advance!

Most helpful comment

How do we do this in 5.3?

All 5 comments

The "additional customer details" would be what you are passing when you are creating the original stripe customer, not the subscription.

Not in the docs for some reason, but you can do:

$user->subscription($plan)->trialFor($user->trial_ends_at)->create($creditCardToken, [
    'email' => $user->email, 
    'description' => $user->name
]);

Thank you!
It worked perfectly.

@Thatplayer

Dude, WHAT. This is the most obscure post ever and it solves ALL my problems with trial dates and creating subscriptions... That should REALLY be in the documentation.

@taylorotwell

This doesn't work on laravel 5.2. I'm using the following code and I'm getting: Call to a member function trialFor() on null

auth()->user()
            ->subscription($subscription_name)
            ->trialFor('now') // I want to end the trial immediately for customers who don't want to trial
            ->create($token);

How do we do this in 5.3?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrianoGaspar picture adrianoGaspar  路  5Comments

borutjures picture borutjures  路  3Comments

MarGul picture MarGul  路  5Comments

peeyush1234 picture peeyush1234  路  4Comments

AnalyzeMe picture AnalyzeMe  路  5Comments