Events
Domain events fired by WemX for orders, payments, users and server accounts, and how to listen to them.
WemX dispatches standard Laravel events at key points in the billing lifecycle. Listen to them from your extension to sync external systems, send notifications or run custom logic, without touching core code.
Listening
Register listeners in a service provider returned by your extension's providers() method:
namespace Extensions\Modules\Discord\Providers;
use App\Events\Orders\OrderActivated;
use App\Events\Payments\PaymentCompleted;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
public function boot(): void
{
Event::listen(PaymentCompleted::class, function (PaymentCompleted $event) {
// $event->payment
});
Event::listen(OrderActivated::class, SendDiscordWelcome::class);
}
}For slow work (HTTP calls, emails), use a queued listener (implements ShouldQueue) so checkouts and webhooks stay fast.
Order events
Namespace App\Events\Orders. Every event has a public $order property.
| Event | Fired when | Extra properties |
|---|---|---|
OrderCreated | An order row is created (before provisioning) | — |
OrderUpdated | Any order change is saved | — |
OrderDeleted | An order is deleted | — |
OrderActivated | Provisioning succeeded and the order is active | — |
OrderSuspended | The suspend job succeeded | — |
OrderUnsuspended | The unsuspend job succeeded | — |
OrderTerminated | The terminate job succeeded | — |
OrderRenewed | A customer renewal was applied | $renewal_days |
Provisioning failures
Namespace App\Events\Orders\Errors. Each has $order and $exception.
| Event | Fired when |
|---|---|
OrderActivationFailed | create() threw. The order is now failed |
OrderSuspensionFailed | suspend() threw |
OrderUnsuspensionFailed | unsuspend() threw |
OrderTerminationFailed | terminate() threw |
These are ideal for alerting your team, for example in Slack or Discord.
Payment events
Namespace App\Events\Payments. Every event has a public $payment property.
| Event | Fired when | Extra properties |
|---|---|---|
PaymentCreated | A payment/invoice is created | — |
PaymentUpdated | A payment is saved | — |
PaymentDeleted | A payment is deleted | — |
PaymentCompleted | A payment is marked paid, after its handler has run | — |
PaymentRefunded | A refund was issued | $refund_amount |
User events
Namespace App\Events\Users, with a $user property: UserCreated, UserUpdated, UserDeleted.
Server account events
Namespace App\Events\ServerAccounts, fired when panel credentials (ServerAccount) change: AccountCreated, AccountUpdated, AccountDeleted.
Audit logs
Besides events, WemX records:
OrderLog: human-readable order actions ($order->log([...])),ActivityLog: field-level changes, with old and new values, for orders and users,AppTaskLog: scheduler runs, shown under Admin → Schedule Logs.
Write to them from your extension so staff see your actions in the same timelines:
$order->log([
'user_id' => auth()->id(),
'action' => 'backup_created',
'description' => 'Backup created by the Backups module',
]);