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

Check all subscriptions when running $user->subscribed('name') #1575

Closed
wants to merge 4 commits into from

Conversation

maxheckel
Copy link

@maxheckel maxheckel commented Sep 26, 2023

Currently, if a user has multiple subscriptions with the same name where one is canceled and another is active and the canceled subscription was created after the active subscription cashier will return that the user is not subscribed. This is due to the subscription pulling just the first() model out of the database. Instead we should check every subscription with the same name and return if any of them are active.

As an example, cashier was returning false for subscribed('unlimited') with the following database state:
image

@driesvints
Copy link
Member

The current behavior is the correct behavior. The latest created subscription is always the one you should check. All the ones before need to be canceled/handled before starting a new one. These records are purely held for historic purposes. Please check the docs: https://laravel.com/docs/10.x/billing#checking-subscription-status

Screenshot 2023-09-26 at 14 04 37

@driesvints driesvints closed this Sep 26, 2023
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