Skip to main content

Hooks and Events

Subscribd fires Laravel events at every significant billing milestone. Listen to them from AppServiceProvider, a dedicated EventServiceProvider, or anywhere you register listeners in your application.

Registering listeners

Or use a dedicated listener class:

Event reference

Subscription lifecycle

Trial events

Payment events

Coupon events

All events namespace

All events live under Pixelworxio\Subscribd\Events\:

Using observers

For more complex scenarios, register a model observer on Subscription or Invoice directly:

Lifecycle hooks

For lightweight callbacks that don’t warrant a full listener, use the action hooks API:
Hook callbacks receive the same arguments as the action’s execute() method. before callbacks can abort execution by returning false. after callbacks receive the action’s return value. Available action hooks:

Testing events

Use Laravel’s Event::fake() to assert events are dispatched in tests:

Next steps

  • Webhooks — Gateway events that trigger these Subscribd events
  • Testing — Testing billing flows with Event::fake()
  • Dunning — Events fired during the payment retry cycle