Cashier-stripe: newSubscription get ends_at = null

Created on 20 Nov 2016  ·  13Comments  ·  Source: laravel/cashier-stripe

When I call new Subscription always get ends_at with null value.

needs more info

Most helpful comment

If your interested, I made a console command which synchronises the renewal date for all your subscription (e.g. the start of when Stripe when next create an invoice/bill the customer). It's a shame Cashier doesn't set this internally when creating a subscription, as you often rely on it to know when to downgrade an account / stop services to a user. Hopefully this helps you 👍

https://gist.github.com/garygreen/fb4dc0288e2c57f9af015968ff7019bb

All 13 comments

@marcoapferegrino can you please provide some code sample?

ping @marcoapferegrino

I solved it adding some code in the library function. I obtained from subscription you get I. The service because the attr ends_at was null I dont know why. Later I will add my code here. Thanks for replying

I solve it Editing the file
LaravelCashierSubscriptionBuilder

Original

return $this->owner->subscriptions()->create([
            'name' => $this->name,
            'stripe_id' => $subscription->id,
            'stripe_plan' => $this->plan,
            'quantity' => $this->quantity,
            'trial_ends_at' => $trialEndsAt,
            'ends_at' => null,
        ]);

Editing

return $this->owner->subscriptions()->create([
            'name' => $this->name,
            'stripe_id' => $subscription->id,
            'stripe_plan' => $this->plan,
            'quantity' => $this->quantity,
            'trial_ends_at' => $trialEndsAt,
            'ends_at' => $subscription->current_period_end,
        ]);

Maybe there is a cleaner and better solution but meanwhile I found this. Let me know if oyou fin other please

The column is used when the subscription is cancelled, check the docs here: https://laravel.com/docs/5.3/billing#cancelling-subscriptions

You shouldn't fill that key while creating a new subscription.

And it won't be called ended_at?. Ok I understand so where should be stored
this field : date when subscription ends?? I don't find it.

El vie., 25 de nov. de 2016 11:50 AM, Mohamed Said notifications@github.com
escribió:

You shouldn't fill that key while creating a new subscription.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/laravel/cashier/issues/353#issuecomment-263004473,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHJ96G-rn9jHuw80TB9kSIYBd5H-WFwSks5rBx_lgaJpZM4K3cBl
.

It never ends until it's cancelled, it's auto-renewed.

Sorry I am new using cashier. So where can I find the date when the
susbcription will be renewed?

El vie., 25 de nov. de 2016 11:53 AM, Mohamed Said notifications@github.com
escribió:

It never ends until it's cancelled, it's auto-renewed.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/laravel/cashier/issues/353#issuecomment-263004833,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHJ96IDNhJDhdOlEE3nK_Jkhvf6J6nWrks5rByCZgaJpZM4K3cBl
.

The renewal date changes every billing cycle, so we don't store it in cashier.

You can use Stripe webhooks to store that date on every renewal if you want.

Nice now I understand better what is happening sorry for the misundertood.
Thanks a lot

El vie., 25 de nov. de 2016 11:57 AM, Mohamed Said notifications@github.com
escribió:

You can use Stripe webhooks to store that date on every renewal if you
want.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/laravel/cashier/issues/353#issuecomment-263005238,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHJ96CbusVpb1gwbsuq-2gKfhDcEhWYqks5rByF_gaJpZM4K3cBl
.

If your interested, I made a console command which synchronises the renewal date for all your subscription (e.g. the start of when Stripe when next create an invoice/bill the customer). It's a shame Cashier doesn't set this internally when creating a subscription, as you often rely on it to know when to downgrade an account / stop services to a user. Hopefully this helps you 👍

https://gist.github.com/garygreen/fb4dc0288e2c57f9af015968ff7019bb

Was this page helpful?
0 / 5 - 0 ratings