php webhook不是有效的进程webhook作业类,有效的类应该实现'Spatie\WebhookClient\ProcessWebhookJob'

hwazgwia  于 2023-03-11  发布在  PHP
关注(0)|答案(2)|浏览(141)

我收到webhook时遇到此错误,我正在尝试解决它,我在存储/日志中发现了错误。
错误生产。错误:app\Handler\WebhookHandler不是有效的进程webhook作业类。有效的类应实现Spatie\WebhookClient\ProcessWebhookJob
配置文件:webhook-client.php

<?php

return [
    'configs' => [
        [
            'name' => 'default',
            'signing_secret' => env('CLIENT_SECRET'),
            'signature_header_name' => 'Signature', \Spatie\WebhookClient\SignatureValidator\SignatureValidator
             */
            'signature_validator' => \Spatie\WebhookClient\SignatureValidator\DefaultSignatureValidator::class,
            'webhook_profile' => \Spatie\WebhookClient\WebhookProfile\ProcessEverythingWebhookProfile::class,
            'webhook_response' => \Spatie\WebhookClient\WebhookResponse\DefaultRespondsTo::class,
            'webhook_model' => \Spatie\WebhookClient\Models\WebhookCall::class,
            'process_webhook_job' => app\Handler\WebhookHandler::class,
        ],
    ],
];

类:网页浏览器. php

<?php

namespace app\Handler;

use Spatie\WebhookClient\ProcessWebhookJob;

class WebhookHandler extends ProcessWebhookJob
{

    public function handle()
    {
        error_log('test');
    }
}
oug3syen

oug3syen1#

它应该是\App\Handler\WebhookHandler::class。由于编写器自动加载,它位于App的命名空间中,而不是文件夹结构app中。类似地,您在Webhook中的命名空间应该是namespace App\Handler;
相反,更安全的解决方案是编写WebhookHandler::class,并让您的IDE或类似设备将其作为use语句自动包含。

use App\Handler\WebhookHandler;

...

'process_webhook_job' => WebhookHandler::class,
xpszyzbs

xpszyzbs2#

适用于laravel 9及以上版本,而不是:

Spatie\WebhookClient\ProcessWebhookJob

用途:

Spatie\WebhookClient\Jobs\ProcessWebhookJob

相关问题