简体   繁体   中英

Laravel Cashier webhook doesn't work

I have followed the Laravel docs for adding Stripe webhooks and have created an endpoint in my Stripe webhook setting but still I get emails from Stripe saying they can't deliver data to webhook.

Below is the code i've added to my project for the webhook.

Route without middleware:

Route::post(
    'stripe/webhook',
    '\Laravel\Cashier\Http\Controllers\WebhookController@handleWebhook'
);

In verifyCsfToken.php:

protected $except = [
    'stripe/*',
];

Have I missed something or is this a common problem?

Official documentation says:

Cashier automatically handles subscription cancellation on failed charges, but if you have additional Stripe webhook events you would like to handle, simply extend the Webhook controller. Your method names should correspond to Cashier's expected convention, specifically, methods should be prefixed with handle and the "camel case" name of the Stripe webhook you wish to handle. For example, if you wish to handle the invoice.payment_succeeded webhook, you should add a handleInvoicePaymentSucceeded method to the controller.

I believe you are trying to handle custom webhook and that's the reason it is not working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM