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.

EventFired whenExtra properties
OrderCreatedAn order row is created (before provisioning)—
OrderUpdatedAny order change is saved—
OrderDeletedAn order is deleted—
OrderActivatedProvisioning succeeded and the order is active—
OrderSuspendedThe suspend job succeeded—
OrderUnsuspendedThe unsuspend job succeeded—
OrderTerminatedThe terminate job succeeded—
OrderRenewedA customer renewal was applied$renewal_days

Provisioning failures

Namespace App\Events\Orders\Errors. Each has $order and $exception.

EventFired when
OrderActivationFailedcreate() threw. The order is now failed
OrderSuspensionFailedsuspend() threw
OrderUnsuspensionFailedunsuspend() threw
OrderTerminationFailedterminate() 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.

EventFired whenExtra properties
PaymentCreatedA payment/invoice is created—
PaymentUpdatedA payment is saved—
PaymentDeletedA payment is deleted—
PaymentCompletedA payment is marked paid, after its handler has run—
PaymentRefundedA 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',
]);

On this page