Laravel 队列,作业不存在

问题描述

在项目中使用 Laravel 8,

我有一个从 Stripe 配置的 webhook,它在付款时命中我的应用程序中的端点,并将作业发送到队列。但是,作业没有被处理,我收到以下错误

Spatie\StripeWebhooks\Exceptions\WebhookFailed: Could not process webhook id '5' of type ' because the configured jobclass 'App\Jobs\StripeWebhooks\HandleChargeableSource' does not exist. in /Users...

但是这个类确实存在:

谁能看出我做错了什么?

//app/Jobs/StripeWebhooks.PHP (example copied from https://github.com/spatie/laravel-stripe-webhooks#handling-webhook-requests-using-jobs)

<?PHP

namespace App\Jobs\StripeWebhooks;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Spatie\WebhookClient\Models\WebhookCall;

class HandleChargeableSource implements ShouldQueue
{
    use InteractsWithQueue,Queueable,SerializesModels;

    /** @var \Spatie\WebhookClient\Models\WebhookCall */
    public $webhookCall;

    public function __construct(WebhookCall $webhookCall)
    {
        $this->webhookCall = $webhookCall;
    }

    public function handle()
    {
        // do your work here

        // you can access the payload of the webhook call with `$this->webhookCall->payload`
    }
}

然后在 config/stripe-webhooks.PHP:

//config/stripe-webhooks.PHP

<?PHP

return [
    /*
     * Stripe will sign each webhook using a secret. You can find the used secret at the
     * webhook configuration settings: https://dashboard.stripe.com/account/webhooks.
     */
    'signing_secret' => env('STRIPE_WEBHOOK_SECRET'),/*
     * You can define the job that should be run when a certain webhook hits your application
     * here. The key is the name of the Stripe event type with the `.` replaced by a `_`.
     *
     * You can find a list of Stripe webhook types here:
     * https://stripe.com/docs/api#event_types.
     */
    'jobs' => [
        'invoice_payment_succeeded' => \App\Jobs\StripeWebhooks\HandleChargeableSource::class,],/*
     * The classname of the model to be used. The class should equal or extend
     * Spatie\StripeWebhooks\ProcessstripeWebhookJob.
     */
    'model' => \Spatie\StripeWebhooks\ProcessstripeWebhookJob::class,/*
     * When disabled,the package will not verify if the signature is valid.
     * This can be handy in local environments.
     */
    'verify_signature' => env('STRIPE_SIGNATURE_VERIFY',true),];

还应该补充一点,我已经尝试过 composer dump-autoload,它提出了以下内容,不确定它是否相关 Class App\Jobs\HandleChargeableSource located in ./app/Jobs/StripeWebhooks.PHP does not comply with psr-4 autoloading standard. Skipping.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)