Service Lifecycle Hooks
The 97 hooks opened across a sold service's life: setting up, suspending, cancelling, renewing, changing plan, and talking to the provider module.
Overview
A service is the thing a customer bought: a hosting package, a server, a software licence. The hooks here follow its life. Most come in pairs: a gate in front of an action and an event behind it.
Another part is about the module actually providing the service. The code opening an account on a server, suspending it or changing a password lives there. These hooks let you touch that call's input and output.
Reference
Life events
Gates
Eighteen gates. Two of them split one job in two. A module action called from the panel passes one gate, and the same action from the customer panel passes another. Where your rule holds for both, bind to both.
The provider module
The detail screen's data
A gate and an event together
// A GATE: do not suspend a service under review (ask us first).
Hook::add('gate:service.suspend', 10, function ($service) {
if (Acme::onHold((int) ($service['id'] ?? 0)))
return 'This service is under review; the suspend was stopped.';
return null;
});
// AN EVENT: tell the outside once it was suspended.
Hook::add('action:service.suspended', 10, function ($id, $service) {
Crm::suspended((int) $id);
});
Pitfalls
Suspending, terminating and renewing also run from scheduled tasks. A gate saying "the operator should not do this" also lands on the job running overnight, and the system cannot do its own work. Write a gate thinking about who it stops.
The status hook runs when our record changes. Whether the provider module truly closed the account on the server is a separate question, and the record can change even where the module call failed. Where the server side matters, read the filter carrying the module result.
Module actions pass two separate gates: one for the operator in the panel, one for the customer in theirs. Binding to only one means your rule can be walked around by the other path. The customer path is also narrower: only the methods a module openly allows can be called.
A renewal can come from an invoice being paid or from a manual action, and a subscription collection takes the same path. Writing work that follows a renewal, be ready to run twice for one period and weed out the repeat on your side.
Related Articles
- Order Flow Hooks
- Invoice and Payment Hooks
- Module Lifecycle Hooks
Thanks for your feedback!
Our support team is here around the clock for anything you can't find above.