Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MB's avatar
Level 2

Cashier: Keep failing when I check if user is subscribed

I'm trying to get Cashier to work with Stripe for subscription.

New users are added to the Stripe Dashboard just fine. Subscriptions are added to the Dashboard as well, same goes with creditcard charges (test). Stripe show the Subscription as Active for the user.

I can see the subscription and subscription_item fine in my database table. My user model have the stripe_id value added as well, and it match the one displayed in the Stripe Dashboard.

But when I try to run this in my user model, then it keeps failing:

    public function show(string $id)
    {

        $user = User::find($id);

        if($user->subscribed()) {
           // User is subscribed
           dd('User is subscribed');
        } else {
            // User is not subscribed or subscription is inactive
            dd('User is not subscribed or subscription is inactive');
        }
        
    }

Tells me "User is not subscribed or subscription is inactive". What am I doing wrong? Did I forget something?

DB table data:

table "users":
id = 1
name = Kenneth
email = [email protected]
email_verified_at = NULL
password = hash
two_factor_secret = NULL
two_factor_rec... = NULL
lang = NULL
country_id = NULL
active = 1
remember_token = NULL
created_at = sometime
updated_at = sometime
stripe_id = cus_randomStuff
pm_type = NULL
pm_last_four = NULL
trial_ends_At = NULL


table "subscriptions":
id = 1
user_id = 1
type = prod_Pud-randomStuff
stripe_id = sub_1P-randomStuff
stripe_status = active
stripe_price = price_1-randomStuff
quantity = 1
trial_ends_at = NULL
ends_at = NULL
created_at = sometime
updated_at = sometime

table "subscription_items":
id = 1
subscription_id = 1
stripe_id = si_Pus-randomStuff
stripe_product = prod_Pud-randomStuff
stripe_price = price_1P-randomstuff
quantity = 1
created_at = sometime
updated_at = sometime

Not sure what to do next :/

Hope one of you might be able to point me in the right direction.

0 likes
4 replies
LaryAI's avatar
Level 58

It seems like you have set up your Stripe and database correctly, but there might be an issue with how you're checking the subscription status. Here's a checklist to ensure you're doing everything correctly:

  1. Make sure you're using the correct plan name when checking if a user is subscribed. The subscribed method can take the name of the plan as an argument to check if the user is subscribed to a specific plan.

  2. Ensure that the Billable trait is properly used in your User model. This trait provides the methods for subscriptions, such as subscribed.

  3. Check if there are any local or session caches that might be causing the subscribed method to return outdated information.

  4. Verify that the stripe_status in your database is set to 'active' for the user's subscription. If it's not, the subscribed method will consider the subscription as inactive.

  5. If you're using multiple subscriptions, make sure you're checking the correct one.

Here's an example of how you might check for a subscription using Laravel Cashier:

public function show(string $id)
{
    $user = User::find($id);

    // Replace 'plan_name' with the actual name of your plan
    if ($user->subscribed('plan_name')) {
        // User is subscribed to the plan
        dd('User is subscribed to the plan');
    } else {
        // User is not subscribed to the plan or subscription is inactive
        dd('User is not subscribed to the plan or subscription is inactive');
    }
}

If you're still having trouble, you can also try to debug by retrieving the subscription directly and inspecting its properties:

public function show(string $id)
{
    $user = User::find($id);

    // Get the user's subscription
    $subscription = $user->subscription('plan_name'); // Replace 'plan_name' with the actual name of your plan

    if ($subscription && $subscription->active()) {
        // User is subscribed and the subscription is active
        dd('User is subscribed and the subscription is active');
    } else {
        // User is not subscribed or subscription is inactive
        dd('User is not subscribed or subscription is inactive');
    }
}

If none of these solutions work, you may want to check the official Laravel Cashier documentation or the Stripe API documentation for more details on how subscriptions are managed and verified.

MB's avatar
Level 2

damn, if I add the product ID (upper left corner of the Dashboard Product page), then it finally show subscription as active...

Think I read in the Laravel Cashier Docs, that doing $user->subscribed() is fine.

This works though:

if($user->subscribed('prod_Pudblaablabla')) {
           // User is subscribed
           dd('User is subscribed');
        } else {
            // User is not subscribed or subscription is inactive
            dd('User is not subscribed or subscription is inactive');
        }
MB's avatar
Level 2

But what if you just wanna check if they have a subscription active, not a specific one? Like if you have more than 1 product/sub (monthly, yearly)

According to the L11 Documentation, this should work (but it keep failing):

@if ($user->subscribed())
    <p>You are subscribed.</p>
@endif

This works for me, but why?

@auth
                @if (Auth::user()->subscribed('prod_PudMVHygFds6fY'))
                    <p>
                        You have an active subscription.
                        <a target="_blank" href="{{ route('billing-portal') }}" class="btn btn-success">Manage your subscription</a>
                    </p>
                    
                @else
                    <div class="alert alert-warning">You do not have an active subscription, <a href="{{ route('subscription-checkout') }}">subscribe here</a>.</div>
                @endif
            @endauth
1 like
squashjedi's avatar

@MB I'm having the same issue. Did you manage to resolve it? If so, what steps did you take?

Please or to participate in this conversation.