php - Laravel Cashier Mollie 事件监听器未触发事件

标签 php laravel mollie

我正在开发一个带有订阅产品的项目。我想在触发某个事件(例如付款失败)时发送通知(例如日志或其他内容)。我尝试通过 EventServiceProvider 和自定义控件触发我的日志,但它仍然没有触发我的事件。有人能帮我吗?这是我的事件

<?php

namespace App\Providers;

use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;

use Laravel\Cashier\Events\OrderPaymentPaid;
use App\Listeners\OrderPaymentsPaidListener;

class EventServiceProvider extends ServiceProvider
{
    /**
    * The event listener mappings for the application.
    *
    * @var array
    */
    protected $listen = [
        OrderPaymentPaid::class => [
    // Your custom listener
            OrderPaymentsPaidListener::class,
        ],

    ];

    /**
    * Register any events for your application.
    *
    * @return void
    */
    public function boot()
    {
        parent::boot();


    }
}

这是我的 Controller

<?php

namespace App\Listeners;

use App\Events\Laravel\Cashier\Events\OrderPaymentPaid;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;

class OrderPaymentsPaidListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }


    /**
     * Handle the event.
     *
     * @param  OrderPaymentPaid  $event
     * @return void
     */
    public function handle(OrderPaymentPaid $event)
    {
        Log::error('test');
    }
}

最佳答案

检查您的VerifyCsrfToken中间件是否具有

protected $except = [
   'webhooks/mollie',
];

这样 Mollie 就可以访问 Webhook。

关于php - Laravel Cashier Mollie 事件监听器未触发事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63599187/

相关文章:

javascript - Laravel PHP 验证对比JavaScript 验证

php - 我如何自定义重置密码验证消息以及表单验证?

php - 如何获取与同一个表中的多个列值匹配的数据

laravel - 多个模型的表单模型绑定(bind)laravel 5.1

php - 如何在 redirecturl 中显示 Mollie 订单状态?

php - 如何删除同一张表中存储的分层父子记录

php - 找不到类 'Breadcrumbs'

laravel - SQLSTATE[42S22] : Column not found: 1054 Unknown column ' title' in 'where clause' (SQL: select count(*)

python - Django CSRF 验证失败。网络钩子(Hook)支付系统

wordpress - WooCommerce:确认订单后付款