微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Laravel 队列,作业不存在

如何解决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 举报,一经查实,本站将立刻删除。