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

beyondelayer's avatar

Cashier Cant Start Subscription

Hey, I've been dealing with this for 1 week, I've looked at the document 40 times, but for some reason I don't understand it, I can't solve it. After making all the settings mentioned in the document, I created a controller. With the code below, I am redirected to stripe's own site and write the card information.

public function checkout(Request $request, SubscriptionPlan $plan)
{
    $checkout = $request->user()->newSubscription('default', $plan->stripe_id)->checkout([
        'success_url' => route('success', ['plan' => $plan->id]),
        'cancel_url' => route('error', ['plan' => $plan->id]),
    ]);

    return $checkout;
}

The payment was completed successfully and I was redirected to the success page. My Stripe subscription has already started when I checked it on their site. But I need to be able to start it on my own site on the payment return. The following command works to start the subscription.

    $request->user()->newSubscription('default', $plan->stripe_id)
        ->quantity(null)
        ->create($request->token);

But I can't figure out where to use this code. Cashier told me to create a StripeEventListener and it looks like this

public function handle(WebhookReceived $event): void
{
    \Log::info('Webhook event received', $event->payload);

    if (isset($event->payload['type']) && $event->payload['type'] === 'invoice.payment_succeeded') {
        \Log::info('Invoice payment succeeded event handled');
        // Handle the invoice.payment_succeeded event
    }
}

Whats wrong? Please help :/

0 likes
9 replies
martinbean's avatar

@beyondelayer You need to set up the webhook in Stripe. Stripe will then “ping” your server, and Cashier’s webhook controller will automatically update the status of subscriptions in your database based on changes happening within Stripe.

1 like
beyondelayer's avatar

@martinbean How can I do this? Can you give me a source? I made the webhook settings on the Laravel cashier page, but I did not make a setting in stripe, If the payment is successful, I just need to start the subscription

beyondelayer's avatar

@martinbean I reviewed it and created all of them, went to stripe to pay and when I checked again, this is what came to the dashboard:

customer.subscription.created customer.subscription.updated invoice.payment_succeeded customer.subscription.updated customer.subscription.created

So far so good. But the event listener did not work again. There was log text inside but laravel.log is empty. Will it be a problem if I work on localhost? Can you share sample code with me? I've been dealing with this for 1 week and I couldn't overcome it :(

martinbean's avatar
Level 80

@beyondelayer Well if you’re on localhost then Stripe’s not going to be able to reach your site.

You need to make your site publicly accessible some how, such as using something like Laravel Sail sharing or ngrok, and then add the URL of your webhook endpoint in your Stripe account so Stripe knows where to deliver webhook events. Otherwise subscription records are never going to be updated in your database.

2 likes
beyondelayer's avatar

@martinbean Hello again, sir. I think I figured it out, if I make the subscription name something other than 'default' like mine (bronze, silver, gold) it doesn't work. More precisely, it is saved to the database but $user->subscribed() returns false. But if I make the subscription name 'default', it starts returning true. What is the reason for this? Why can't I use other names?

1 like
abdullahabid04's avatar

@martinbean I am also facing this issue for a while. I am also testing my website on localhost, to be notified about webhooks events, I used stripe CLI. The stripe CLI was successfully configured and It is running fine now, I even get the events on the CLI. But, the subscription is not started. The checkout also proceeds successful. Still, the subscription is not starting. For another verification test, I checked the database, cashier comes with 3 migrations, 2 creates 2 new tables and 1 adds additional columns to the users table. So, I checked the 2 tables named 'subscriptions' and 'subscription_items', these 2 tables were empty, no records updated and the 3 out of 4 additional columns, that cashier migration created in the users table, were also empty, only the column named 'stripe_id' was filled. And the result was again, subscription isn't started yet. I'm still working on it.

1 like
abdullahabid04's avatar

Subscription Not Starting Problem Resolved

Determined the need to extract subscription types from the Stripe webhook payload and review the newSubscriptionType function's role. Updated the function to check both type and name metadata keys to ensure compatibility with varying metadata structures. Despite these modifications, the issue remained unresolved.

Created lookup keys in Stripe for each price that matches the subscription names. Edited metadata for each price to include a type key with the subscription name, aligning metadata with the expected values. This approach did not rectify the problem.

Discovered that Laravel Cashier manages its own webhook routes. Removed the custom webhook route from web routes and rely on Cashier’s built-in routing. This adjustment successfully resolved the issue, enabling subscriptions to function correctly and ensuring accurate data storage.

Please or to participate in this conversation.