-
Notifications
You must be signed in to change notification settings - Fork 680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need current_period_end and current_period_start column in subscriptions table #515
Comments
You can compare the cancels at column to the current date/time using
carbon's difference methods.
…On Thu., 10 May 2018, 6:16 pm Tareq Mahmood, ***@***.***> wrote:
After a user cancels the subscription, I need to show the user how many
days remaining for the current period. There is no column for those values
in the subscriptions table.
How can I achieve this?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#515>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFLO7ro2JXNBl4JkNd3yxd1zsUAgEvNTks5tw_dcgaJpZM4T5iAB>
.
|
Ok, that will solve my initial issue. What if I want to show the next billing date to the user (when the subscription is not canceled)? |
Basically, I need to know, is there any way to add any additional fields to the subscriptions table, if I feel the need for any additional data (Which is available in Stripe Subscription model)? |
Hi @tareqtms I'm sure you've moved on from this issue but I found it searching for the same thing. It's actually simpler than expected. Simply add a field to the subscriptions table using a new migration (or even manually works). You can then update the field like so:
|
Think this issue can be closed by using the examples provided here. Feel free to provide additional feedback if you want. |
Sorry to ressurect this but the above examples don't actually solve much as far as I can tell.
If people want to get the actual subscription from Stripe you can do:
|
@stueynet you can do |
Oh wow thanks @driesvints thats the method I need. |
@driesvints This would mean my app has to connect to the Stripe API every time a user wants to see the end of their subscription. Using @NassimRehali15 solution means the date is incorrect until the command is run. What's the reason for not putting this in a column on the subscriptions table? It's a value used in almost every app. I was going to issue a PR until I saw this thread. |
I've never had to use this in my apps and neither do we use this in Spark afaik. I think this is a bit of an objective opinion. You're free to add the code from your PR to your own app. But I think adding this to the core isn't interesting to everyone out there. It's just not feasible to add every single field of a subscription to the subscriptions table. Try the following code snippet by @coryrose1 after creating a subscription and then overwrite the webhook in our own controller. $user->subscription('main')->new_field_name = 'new_value';
$user->subscription('main')->save(); |
@driesvints We are in need for this to be in the database, so that we are able to do a join query with our other tables to quickly count how many credits a customer has until next billing cycle. What do you suggest would be the best way of getting this value updated when the billing cycle updates in stripe? You mention overwriting the webhook, have a quick example of this? Do you know what webhook we'd need to subscribe to in Stripe to get updated on each new billing cycle? |
$user->asStripeSubscription()->current_period_end |
After a user cancels the subscription, I need to show the user how many days remaining for the current period. There is no column for those values in the subscriptions table.
How can I achieve this?
The text was updated successfully, but these errors were encountered: