Skip to content

subscription($type) method on Billable can return canceled subscriptions #1779

@ignaciocunado

Description

@ignaciocunado

Cashier Stripe Version

16.0

Laravel Version

11.44

PHP Version

8.2

Database Driver & Version

MariaDB

Description

When a user has an old (and canceled) subscription of a particular type and a new one which is active, this method under ManagesSubscriptions will return the canceled subscription.

    /**
     * Get a subscription instance by $type.
     *
     * @param  string  $type
     * @return \Laravel\Cashier\Subscription|null
     */
    public function subscription(string $type = 'default'): ?Subscription
    {
        return $this->subscriptions->where('type', $type)->first();
    }

I'm not sure whether this is the intended behaviour, but it is inconvenient at least.

Steps To Reproduce

  1. Subscribe to a product.
  2. Cancel the subscription today.
  3. Subscribe again to the same product.
  4. Call $user->susbcription($type).
  5. The old and canceled one is returned.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions