Laravel-Stripe-webhooks 一切正常,但处理代码未到达

问题描述 投票:0回答:2

我有一个 Laravel 6 应用程序,并且正在从 Stripe 旧版客户端结帐转移到当前的服务器端结帐。一切工作正常,除了我的 webhook 处理代码,它看起来没有运行。我为此使用了 Spatie

laravel-stripe-webhooks
包,但它不起作用,至少是我将 Stripe 有效负载交还给我的代码以进行客户端处理的最后一个重要部分。过去几天我确实花了很多时间来解决这个问题,测试所有内容并寻找答案,但无济于事。

使用 Stripe CLI,我可以测试我的端点,并观察事务步骤和 200 个响应。 Stripe 仪表板还记录完整且无错误的交易。在此阶段,我在两端都没有收到任何错误,但将日志消息放置在作业处理程序中表明未到达代码。

Stripe 秘密/API 密钥很好并且可以工作。 Stripe 端正在处理费用,没有任何问题。只需从 Stripe 获取有效负载即可完成该过程。

这是我在

\config\stripe-webhooks.php
的终点。

<?php

return [

    'signing_secret' => env('STRIPE_WEBHOOK_SECRET'),

    'jobs' => [
        'invoice_payment_succeeded' => \App\Jobs\StripeWebhooks\InvoicePaymentSucceededJob::class,
        "payment_intent_succeeded" => \App\Jobs\StripeWebhooks\PaymentIntentSucceeded::class,
    ],
    'model' => \Spatie\StripeWebhooks\ProcessStripeWebhookJob::class,
];

这是我的

\App\Jobs\StripeWebhooks\PaymentIntentSucceeded.php
工作:

<?php

namespace App\Jobs\StripeWebhooks;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Spatie\WebhookClient\Models\WebhookCall;
use Illuminate\Support\Facades\Log;
use IlluminateSupportFacadesLog;

class PaymentIntentSucceeded implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

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

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

    public function handle()
    {
        Log::info("Job Started");

        $charge = $this->webhookCall->payload['data']['object'];

        Log::info("Job Ended");
    }
}

我的日志记录工作正常,因为我可以从其他地方记录事件,但未到达上述日志调用。

这令人困惑,因为它应该根据我读过的所有内容起作用。非常欢迎任何和所有建议。

stripe-payments webhooks laravel-6
2个回答
0
投票

我也面临同样的问题: 以下命令解决了我的问题:

php artisan cache:clear
php artisan config:clear
php artisan queue:clear

您也可以尝试

php artisan queue:listen
,看看是否有效。


0
投票

您的 Webhook 处理程序类默认扩展 ShouldQueue,您的有效负载将在 .env 文件中当前的 QUEUE_CONNECTION 中进行处理

QUEUE_CONNECTION=database 

因此,如果您需要处理当前的有效负载而不等待调度,您可以切换到

QUEUE_CONNECTION=sync 
© www.soinside.com 2019 - 2024. All rights reserved.