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

GotExx's avatar

SubscriptionCreated event not fired

Hello, I can't get the SubscriptionCreated event from Spark 4 I want to send an email (via Notification) to my customer when a subscription is taken out. I do receive Stripe events:

2023-10-15 20:20:33   --> customer.created [evt_1O1YvVAOB2Kii74ErOtQR5Y8]
2023-10-15 20:20:34  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvVAOB2Kii74ErOtQR5Y8]
2023-10-15 20:20:49   --> charge.succeeded [evt_3O1YviAOB2Kii74E0r1anC1x]
2023-10-15 20:20:49  <--  [200] POST http://localhost/stripe/webhook [evt_3O1YviAOB2Kii74E0r1anC1x]
2023-10-15 20:20:49   --> payment_method.attached [evt_1O1YvlAOB2Kii74ETq9ogMSP]
2023-10-15 20:20:49  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvlAOB2Kii74ETq9ogMSP]
2023-10-15 20:20:49   --> customer.updated [evt_1O1YvlAOB2Kii74Ef0o5qa8F]
2023-10-15 20:20:49   --> customer.updated [evt_1O1YvlAOB2Kii74EVhQt8esn]
2023-10-15 20:20:49   --> customer.subscription.created [evt_1O1YvlAOB2Kii74EjMK1Iezo]
2023-10-15 20:20:49   --> customer.subscription.updated [evt_1O1YvlAOB2Kii74EffjrgrQb]
2023-10-15 20:20:49   --> payment_intent.succeeded [evt_3O1YviAOB2Kii74E0tQXbQUS]
2023-10-15 20:20:50   --> payment_intent.created [evt_3O1YviAOB2Kii74E06ZTs0nR]
2023-10-15 20:20:50  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvlAOB2Kii74Ef0o5qa8F]
2023-10-15 20:20:50   --> invoice.created [evt_1O1YvlAOB2Kii74EV8ig69dd]
2023-10-15 20:20:50   --> invoice.finalized [evt_1O1YvmAOB2Kii74Emt6o9SOv]
2023-10-15 20:20:50   --> invoice.updated [evt_1O1YvmAOB2Kii74EI1tg9Zlj]
2023-10-15 20:20:50  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvlAOB2Kii74EVhQt8esn]
2023-10-15 20:20:50   --> invoice.payment_succeeded [evt_1O1YvmAOB2Kii74EAfmz0nhm]
2023-10-15 20:20:51   --> checkout.session.completed [evt_1O1YvnAOB2Kii74EEyiA9RFl]
2023-10-15 20:20:51   --> invoice.paid [evt_1O1YvmAOB2Kii74EGUJfDLpg]
2023-10-15 20:20:51  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvlAOB2Kii74EjMK1Iezo]
2023-10-15 20:20:51   --> customer.updated [evt_1O1YvnAOB2Kii74EIVpuQXoh]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvlAOB2Kii74EffjrgrQb]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_3O1YviAOB2Kii74E0tQXbQUS]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_3O1YviAOB2Kii74E06ZTs0nR]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvlAOB2Kii74EV8ig69dd]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvmAOB2Kii74Emt6o9SOv]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvmAOB2Kii74EI1tg9Zlj]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvmAOB2Kii74EAfmz0nhm]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvnAOB2Kii74EEyiA9RFl]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvmAOB2Kii74EGUJfDLpg]
2023-10-15 20:20:52  <--  [200] POST http://localhost/stripe/webhook [evt_1O1YvnAOB2Kii74EIVpuQXoh]

Here is my EventServiceProvider

<?php

namespace App\Providers;

use App\Events\OrganizationCreated;
use App\Listeners\CreateStripeCustomer;
use App\Listeners\GenerateGodchildDiscountCode;
use App\Listeners\GenerateSponsorDiscountCode;
use App\Listeners\SendTrustpilotInvitation;
use App\Listeners\StoreLoginInformations;
use Illuminate\Auth\Events\Login;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Spark\Events\PaymentSucceeded;
use Spark\Events\SubscriptionCreated;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array<class-string, array<int, class-string>>
     */
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
            GenerateGodchildDiscountCode::class
        ],
        Login::class => [
            StoreLoginInformations::class
        ],
        PaymentSucceeded::class => [
            GenerateSponsorDiscountCode::class
        ],
        SubscriptionCreated::class => [
            SendTrustpilotInvitation::class
        ],
        OrganizationCreated::class => [
            CreateStripeCustomer::class
        ]
    ];

My Listener:

<?php

namespace App\Listeners;

use App\Notifications\ThankingForSubscribing;
use Spark\Events\SubscriptionCreated;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class SendTrustpilotInvitation implements ShouldQueue
{
    /**
     * Create the event listener.
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     */
    public function handle(SubscriptionCreated $event): void
    {
        $event->organization->notify(new ThankingForSubscribing());
    }
}

PS: the PaymentSucceeded Event is not fired too

0 likes
2 replies
GotExx's avatar

Hello, Yes! I didn't start my local queue worker... In production and staging, you also have to remember to relaunch the queue worker to make sure they're up to date.

Please or to participate in this conversation.