Christian Giupponi
Christian Giupponi

Reputation: 7618

Laravel cashier do not set trial and ends date

I've just update my project to Laravel 5.2 and Cashier 6.0.
I've followed the documentation and added the new subscriptions table but when I test it Cashier do not set the trial ends column.

In my stripe plan I have 14 days of trial and in my stripe account I can see that if I add today a new costumer the first billing is set 14 days after.

This is my subscription code:

// Create the user
$user = $this->create( $request->all() );

// Find the plan in the DB
$plan = Plan::find( $request->get( 'plan' ) );

// Charge the user ( 14 days trial )
$user->newSubscription( $plan->slug , $plan->stripe_id )->create( $request->get( 'stripeToken' ), 
[
     'email'       => $request->get( 'email' ),
     'description' => ''
] );

The $plan->slug is the name I have associated to my plan, for example annual while the $plan->stripe_id is the same I have set on Stripe dashboard.

If I register a new customer all but trials_ends_at and ands_at are set.

What am I doing wrong?

Upvotes: 0

Views: 999

Answers (1)

Christian Giupponi
Christian Giupponi

Reputation: 7618

I figured out by myself.
The new Casher code needs to set manually the trial period with:

trialDays($trialDays)

So my code should be:

$user->newSubscription( $plan->slug , $plan->stripe_id )->trialDays(14)->create( $request->get( 'stripeToken' ), 
[
     'email'       => $request->get( 'email' ),
     'description' => ''
] );

Upvotes: 3

Related Questions