Admin and support
Audit trail
Every money movement and entitlement change is recorded on an append-only audit ledger with who did it — the specific actor and its category (customer / admin / webhook / system), not just what happened. So "why is this customer on Free?" has an answer: the plan was revoked by a past-due webhook, or canceled by a support agent, or by the customer themselves.
use Pushery\Billing\Models\BillingEvent;
BillingEvent::query()
->where('subject_type', $user->getMorphClass())->where('subject_id', $user->getKey())
->latest()->get(); // this owner's billing history, newest first
The ledger is append-only: the package never updates a row, and removes one only in the retention prune
or on an erasure request. An update or a delete made through the model throws, which keeps application code
from changing the trail by accident; a query against the table is not stopped by it. The default level (money)
records every money and entitlement event and is never noisy; set billing.audit.level to all to also
record navigational and high-volume events (checkout opened, card added). billing:prune ages the ledger out
on its own retention window (billing.retention.audit_days, default 10 years — the bookkeeping window; weigh
it against GDPR storage limitation for your case), and billing:export includes an owner's audit history in
their subject-access export.
Metrics
A point-in-time snapshot for your own admin dashboard — MRR and the subscription counts — computed from the local rows, with no provider round-trip:
$metrics = app(Pushery\Billing\Reporting\BillingMetricsReporter::class)->compute();
$metrics->mrr; // Money — monthly-recurring revenue
$metrics->activeSubscriptions; // int
$metrics->trials; // int — on trial now
$metrics->inDunning; // int — past due / walking the dunning ladder
$metrics->canceledInWindow; // int — churned within the trailing window ($metrics->windowDays, default 30)
$metrics->startedInWindow; // int — began within the same window
$metrics->activeByTier; // array<string, int> — the active subscriptions by tier key
MRR is declared list price, monthly-normalized (a yearly tier ÷ 12), summed in billing.currency — what
your catalog says you charge, deliberately independent of a provider coupon or mid-cycle proration. A
subscription the package bills itself counts once per seat it carries, as its cycle charges it; a Stripe
subscription counts once, because its quantity lives at the provider. It assumes a single billing currency; a
free tier (no price_display) contributes nothing. Pass a window to
compute($days) to measure churn and starts over a different span. An active subscription with no tier is in
activeSubscriptions but not in activeByTier.
Admin console (optional Livewire UI)
Those metrics, the recent audit log and the comp-a-tier action are also surfaced as an optional,
publishable Livewire console — the UI counterpart of BillingMetricsReporter and BillingAdmin, for when
support wants a screen instead of the CLI. It mounts under config('billing.admin.prefix') (default
admin/billing) behind config('billing.admin.middleware') (default web + auth), is plain
framework-agnostic Blade (publish billing-views to reskin it), and — like the account hub — renders only
when Livewire is installed, so the billing core stays UI-free. A back office with billing screens of its own turns
it off with BILLING_ADMIN_ENABLED=false (billing.admin.enabled), and its route and component are then not
registered.
It is admin-gated, fail-closed: every request (mount, render and the comp action) is authorized against
the config('billing.admin.ability') Gate (default billing-admin) — an ability your app defines. Until
you define it the Gate denies everyone, so the console is never open by accident:
// A support agent, not the account's own user. Define the ability your app already uses for staff.
Gate::define('billing-admin', fn ($user) => $user->is_staff);
For the CLI form of a support comp, see billing:tier:grant in the Command reference.
Declarations that wait for a person
The console also lists every cancellation and withdrawal through the cancellation button and the withdrawal
function that was not carried out, the oldest first, each line by line with the reason a failure left on it. A person
resolves one once they have dealt with it, a cancellation with the day the contract ends where they set one: the
contract then ends at the close of that day in billing.consumer_rights.declaration_timezone.
The list is a component of its own. A back office without the console mounts it on a page of its own, behind the
same billing.admin.ability:
<livewire:billing.declarations-awaiting-review />
and names that page's route in billing.consumer_rights.declaration_review_route, so the mail to
billing.consumer_rights.declaration_review_address leads there rather than to the console.
Where WireKit 2.73.0 or newer is installed, the oldest release the list is proven against, the
list is drawn with WireKit's components: its cards, its date field, its buttons and its callouts. An older WireKit
counts as none. The list sets no class of its own, so a WireKit application's build styles it
from WireKit's views, and the package's views need no @source line of their own. Without WireKit the list keeps
its plain markup, and so does the console, which is plain markup throughout. A page of yours asks for the plain
markup with plain:
<livewire:billing.declarations-awaiting-review plain />
A page that carries a heading of its own leaves the list's heading out with headless. Each declaration's heading
then moves up a level, so the outline of the page keeps no gap:
<livewire:billing.declarations-awaiting-review headless />
A copy of the list you published with billing-views stays in use as long as no copy of the WireKit variant,
livewire/wirekit/declarations-awaiting-review.blade.php, stands beside it. A list you changed before the variant
existed is not replaced that way. Publishing the views again brings the variant along.