Skip to content

feat(core): webhook registry for addon events - #655

Merged
mckenziearts merged 1 commit into
3.xfrom
feat/webhook-event-registry
Aug 14, 2026
Merged

feat(core): webhook registry for addon events#655
mckenziearts merged 1 commit into
3.xfrom
feat/webhook-event-registry

Conversation

@mckenziearts

Copy link
Copy Markdown
Collaborator

What

Adds a WebhookRegistry so packages and addons can register their own webhook events and payload serializers at runtime, instead of relying on config()->set writes.

use Shopper\Core\Webhooks\Facades\Webhooks;

Webhooks::register(SubscriptionRenewed::class, 'subscription.renewed', SubscriptionPayloadSerializer::class);

The serializer is optional (class implementing WebhookPayloadSerializer or a closure). Without one, the event falls back to the bound default serializer. Registered events automatically appear in the admin subscription form and are dispatched through the existing delivery pipeline (signature, retries, auto-disable).

How

  • The registry seeds the core events from shopper.webhooks.events lazily and treats them as defaults: code can override their public name and attach a serializer to them without conflict.
  • Conflicts between two code registrations fail fast with a LogicException; a duplicate public name is logged and ignored so an addon collision never prevents the store from booting.
  • Listeners are attached once the application has booted, so webhook payloads always snapshot the state after the application's own listeners ran. Events registered after boot are attached immediately.
  • The listener attach is idempotent against the dispatcher, so recycled registry instances (Octane) can never stack duplicate deliveries.
  • Malformed config entries and empty payloads are logged once instead of failing the request, and a registered serializer returning a malformed shape is normalised so the delivery is never silently lost.
  • CartServiceProvider now registers cart.completed through the facade.

@mckenziearts mckenziearts added this to the v3 milestone Aug 14, 2026
@mckenziearts mckenziearts added enhancement New feature or request php Pull requests that update php code labels Aug 14, 2026
@mckenziearts mckenziearts self-assigned this Aug 14, 2026
@mckenziearts
mckenziearts force-pushed the feat/webhook-event-registry branch from d1b2731 to 773acb9 Compare August 14, 2026 09:11
@mckenziearts mckenziearts moved this to In Progress in Roadmap Aug 14, 2026
@mckenziearts
mckenziearts merged commit 5f54558 into 3.x Aug 14, 2026
50 checks passed
@mckenziearts
mckenziearts deleted the feat/webhook-event-registry branch August 14, 2026 10:31
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Roadmap Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request php Pull requests that update php code

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant