Skip to content
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

Allow subscribed and other methods to check for any active subscription and not just one with the name "default" #1619

Closed
wants to merge 1 commit into from

Conversation

joelwmale
Copy link

Currently the code always expects a subscription called "default" when checking any of the subscribed, or on trial methods without passing an argument.

For my specific use case (and I do believe many others), we have a few products all with ids prod_xxxx with meaningful names like Monthly Subscription, and Annual Subscription, and we only want to know if a user is subscribed to any one of these by default (i.e to hide links to subscribe, and show subscription functionality) and don't want to do multiple if checks, checking if they are subscribed to one of our specific plans.

We have already solved this on our project, by simply copying the changes in this PR into the User model, to override the Cashier functions, but to me in 2023 it makes no sense to always assume it is titled default.

This should not break any existing implementations, unless they have multiple subscriptions, with one called default. In this case, the code may or may not return the right subscription with no arguments.

@driesvints driesvints marked this pull request as draft December 18, 2023 14:27
@driesvints
Copy link
Member

Hi @joelwmale. This unfortunately is a breaking change so we can't do this in 14.x. I'm working on 15.x and am already making a change here as well: #1620

As for your specific use case I believe you're mis-using products. You should use products as a "plan" type like a Basic, Business and/or Premium subscription. Each of these products can have "monthly" and "yearly" prices.

I do understand a need to check if a customer is subscribed to any subscription at all. I'll try to see if I can add a few general checks to Cashier Stripe in v15

@driesvints driesvints closed this Dec 18, 2023
@driesvints
Copy link
Member

Actually you got me thinking and I started working on refactoring these in a similar fashion as your PR heh. Just need to crack the trialEndsAt method.

@driesvints
Copy link
Member

See #1621

@joelwmale
Copy link
Author

Actually you got me thinking and I started working on refactoring these in a similar fashion as your PR heh. Just need to crack the trialEndsAt method.

Haha beautiful. I do see your point as well that we may be using stripe wrong, but happy to actually just have another method as an attribute that is subscribed if that is possible as well?

Attribute - subscribed = yes if any active plan or trial
Method - subscribed = defaults to "default" or takes the name and checks.

But either way it all works (and also not sure if a method/attribute named the same is possible/works)!

@driesvints
Copy link
Member

Heh, I think I'd rather avoid attributes right now as well as naming two things the same but have different outcomes. I'm close to a solution just need to dig in a little more.

@driesvints
Copy link
Member

@joelwmale looks like we won't be making this change after all sorry.

@joelwmale
Copy link
Author

@joelwmale looks like we won't be making this change after all sorry.

All good @driesvints. It is a really big breaking change and is a fundamental change to the package so I do understand Taylor's position of getting more community feedback first.

My change would only affect those who do this already because they have a product titled "default" so it is a more low risk change but nonetheless it is breaking.

I've just extended the functions to change the logic in my user class, so this issue isn't actively affecting me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants