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

subscribed() returns incorrect result #113

Open
cihantas opened this issue Dec 19, 2024 · 0 comments
Open

subscribed() returns incorrect result #113

cihantas opened this issue Dec 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@cihantas
Copy link

Lemon Squeezy for Laravel Version

1.7

Laravel Version

10

PHP Version

8.3

Description

The documentation states the following for $user->subscribed():

This method, as well as the subscribed method, will return true if your subscription is active, on trial, past due, paused for free or on >> its cancelled grace period <<.

However, neither subscribed() nor $subscription->valid() actually check if the grace period is over.

public function subscribed(string $type = Subscription::DEFAULT_TYPE, ?string $variant = null): bool
    {
        $subscription = $this->subscription($type);

        if (! $subscription || ! $subscription->valid()) {
            return false;
        }

        return $variant ? $subscription->hasVariant($variant) : true;
    }
public function valid(): bool
    {
        return $this->active() ||
            $this->onTrial() ||
            $this->pastDue() ||
            $this->cancelled() ||
            ($this->paused() && $this->pause_mode === 'free');
    }

cancelled() needs to check if the grace period is over, otherwise subscribed() returns true, even if the user is already completely cancelled.

Steps To Reproduce

  1. Subscribe
  2. Cancel Now
  3. Set ends at to a date in the past in the db
  4. See that user can still access if you're relying on subscribed()
@cihantas cihantas added the bug Something isn't working label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant