Laravel Cashier Mollie事件侦听器未触发事件

时间:2020-08-26 13:52:27

标签: 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();


    }
}

这是我的控制器

<?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');
    }
}

1 个答案:

答案 0 :(得分:2)

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

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

因此 Mollie 可以访问 Webhook。