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

bufferoverflow's avatar

Cashier with Stripe webhook not updating the model

I create a checkout session, complete the payment and get redirected to the success URL.

Then, I'm expecting Stripe to hit the endpoint i defined at the Stripe dashboard (using ngrok since its in my local machine), but it never hits and the code doesn't get exectued.

Also I tried to send a test request inside the Stripe's webhook dashboard and it says: "Success. Webhook Handled" but it never hits my code since I have a log inside the method.

I'm kind of new with webhooks. Am I missing something?

0 likes
7 replies
bugsysha's avatar

It is better that you explain what you did instead of us guessing what you've missed.

bufferoverflow's avatar

Yes, sorry. I should have given some code.

After investigating more about it, I think I've found the problem. Seems like the method I extended can not be found.

Basically Stripe is posting to this endpoint: Route::post('/stripe/inbox', [CashierWebhookController::class, 'handleWebhook']); which has the following code:

<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Laravel\Cashier\Events\WebhookHandled;
use Laravel\Cashier\Events\WebhookReceived;
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;

class CashierWebhookController extends CashierController
{
    public function handleWebhook(Request $request)
    {
        $payload = json_decode($request->getContent(), true);
        $method = 'handle'.Str::studly(str_replace('.', '_', $payload['type']));

        WebhookReceived::dispatch($payload);

        if (method_exists($this, $method)) {
            $response = $this->{$method}($payload);

            WebhookHandled::dispatch($payload);

            return $response;
        } else {
            info('method doent exits: ' . $method);
        }

        return $this->missingMethod();
    }

    // this method is not found!
    public function handleCheckoutSessionCompleted(array $payload)
    {
        info('stripe is posting');
    }
}

For some reason the method_exists($this, 'handleCheckoutSessionCompleted') returns false.

Sinnbeck's avatar

Can you post the exact string from your log? The info('method doent exits: ' . $method);

bufferoverflow's avatar

Yes.

[2020-08-09 14:33:13] local.INFO: method doent exits: handleCheckoutSessionCompleted

Sinnbeck's avatar

Strange. Does this work?

if (method_exists(get_class($this), $method)) {
bufferoverflow's avatar

Same result.

I thought maybe some other method, file or route overriding or something. But I can not find anything that makes sense for now.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Does it change anything if you don't extend the original class?

bufferoverflow's avatar

Thank you so much. I've solved the problem now.

Not extending the original class I've realized that the original one was still hit. That's because my endpoint was /stripe/inbox since i changed many times for testing and i forgot to update it in Stripe's dashboard so it was still using the old /stripe/webhook endpoint.

Please or to participate in this conversation.