Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mithrandir69's avatar

i cannot receive Payments data on database stripe webhook

im testing charge.succeeded on stripe webhooks , i get 200(ok) as successful payment , but when i try to check my database , i cannot receive any payments data My ChargeSucceededJob.php:

<?php

namespace App\Jobs\StripeWebhooks;
use App\Models\Payment;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Spatie\WebhookClient\Models\WebhookCall;

class ChargeSucceededJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    public $webhookCall;
    /**
     * Create a new job instance.
     *
     * @return void
     */

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

    public function handle()
    {
$charge = $this->webhookCall->payload['data']['object'];
$user = auth()->user();
if($user) {
      Payment::create([
          'user_id' => $user->id,
          'stripe_id' =>$charge['id'],
          'product_id' =>$charge['currency'],
          'amount' => $charge['amount'],


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

}

any idea how to fix that ?

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

This is your problem.

$user = auth()->user();
if($user) {

The webhook is not the user's session; it is a separate request coming directly from Stripe. You don't have an authenticated user, so you never create a Payment.

You will need to find another way to connect to incoming webhook payload to the User that was charged.

Mithrandir69's avatar

@tykus another question please, does Pabby connect has an option to capture each product charge.succeed then send an email to each user

Please or to participate in this conversation.