> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dezerx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Hooks

> The class names and method signatures core calls. Copy names from here, then run module:doctor.

![Which service module method runs for which event](https://mintcdn.com/dezerx/dVNBM3sq4VCh7CKa/public/extensions/hooks/top.webp?fit=max\&auto=format\&n=dVNBM3sq4VCh7CKa\&q=85\&s=276eac75e3a36747e981da870152adc8)

Core builds a class name from a string, so a typo means the feature silently does not exist. `{M}` below is the `name` from `module.json`, for example `PterodactylService`. `module:doctor` checks all of this.

> [accordion] Service modules
>
> Only `ModuleServiceActions` and the three `Actions\*` classes are needed. The rest gate optional features.
>
> | Class under `Modules\{M}\` | Signature | Static |
> | - | - | - |
> | `Services\ModuleServiceActions` | `createServerForService(Service $s, array $cfg = []): void` and `hasExistingConfiguration(Service $s): bool` | no |
> | `Services\Actions\SuspendServerService` | `suspendServer(int $serviceId): array` | yes |
> | `Services\Actions\UnsuspendServerService` | `unsuspendServer(int $serviceId): array` | yes |
> | `Services\Actions\DeleteServerService` | `deleteServer(int $serviceId, bool $force = false): array` | yes |
> | `Services\RenewService` | Extend `BaseRenewService`, override `onAfterRenewal(Service $s, string $cycle): void` | no |
> | `Services\CancelService` | Extend `BaseCancelService`, implement `remoteResourceId()` and `deleteRemoteResource()` | no |
> | `Services\UpgradeService` | `processUpgrade(Service $s, Invoice $i): bool` | no |
> | `Services\DowngradeService` | `processDowngrade(Service $s, Invoice $i): bool` | no |
> | `Services\AddonService` | `applyAddon(Service $s, array $addon, int $qty = 1): array` and `removeAddon(...)` | no |
> | `Services\MarketCheckoutConfig` | `getCheckoutFields()`, `getServiceConfigFields()`, `validateCheckoutData(array $d)` returning `['validated' => [], 'errors' => []]` | yes |
> | `Services\ServiceControlsService` | `getServiceControls($serviceConfig = null, $serviceId = null): array` | no |
> | `Services\ServiceDetails` | `getSections()`, `getTabConfig()`, `getServiceData()`, `getAvailableActions()`, `updateAccount()`, `changeOwner()` | no |
>
> `ServiceControlLoader` always passes two arguments to `getServiceControls()`, so declare both.

> [accordion] Gateway modules
>
> | Class under `Modules\{M}\` | Notes |
> | - | - |
> | `Services\{M}PaymentService` | Required. Extend `BasePaymentService` |
> | `Http\Controllers\PaymentController` | Extend `ModulePaymentController`. Set `$paymentServiceClass` and `$gatewayName` |
> | `Http\Controllers\SettingsController` | Extend `ModuleSettingsController` |
> | `Services\CheckoutHandler` | Optional. `shouldHandleCheckout()` and `handleCheckout()` (23 arguments) |
> | `Services\RenewalHandler` | Optional. `shouldHandleRenewal()` and `handleRenewal()` (7 arguments) |
> | `Services\InvoicePaymentHandler` | Optional. `shouldHandleInvoicePayment()` and `handleInvoicePayment()` (6 arguments) |
> | `Services\{M}VaultProvider` | Optional. Saved payment methods, implements `VaultProviderInterface` |
> | `Services\{M}SubscriptionProvider` | Optional. Implements `GatewaySubscriptionProvider` |
>
> The gateway key is `Str::lower(Str::before($moduleName, 'Gateway'))`, so `AcmeGateway` gives `acme`. `getGatewayName()` must return it.
>
> ```php theme={null}
> createPayment(float $amount, string $currency, array $metadata = []): array
> executePayment(string $paymentId, ?string $payerId = null): bool
> getPaymentDetails(string $paymentId): array
> getApprovalUrl(string $paymentId, array $paymentDetails): ?string
> getConfig(): array
> validateNotification(array $data): bool
> getVerificationMethod(): string
> protected getGatewayName(): string
> ```
>
> `getConfig()` returns `name`, `display_name`, `description`, `logo`, `enabled` and optionally `mode`. `$paymentData['type']` in `handlePaymentSuccess()` is `market`, `renewal`, `invoice`, `upgrade`, `downgrade`, `configurable_options_change`, `addon`, `balance` or `standalone`.

> [accordion] Optional gateway interfaces
>
> | Interface | Adds |
> | - | - |
> | `App\Services\Payment\HandlesGatewayWebhook` | `handleWebhook(Request $r): Response` |
> | `App\Services\Payment\GatewayVariantInterface` | `getGatewayVariants(): ?array`, `resolveVariant(string $k): bool`, `getModuleName(): string` |
> | `App\Services\Payment\GatewayFlowProviderInterface` | `getGatewayFlowHandler(): object` |
> | `App\Services\Payment\Vault\VaultProviderInterface` | `displayName`, `description`, `methodType`, `logo`, `isAvailable`, `clientConfig`, `beginSetup`, `completeSetup`, `charge`, `remove` |
> | `App\Services\Payment\Subscriptions\GatewaySubscriptionProvider` | `gatewayName`, `managesRenewal`, `describeActiveSubscription`, `hasCancellableSubscription`, `cancelSubscriptions` |
>
> Vault providers can also implement `LooksUpCharges`, `HandlesCustomerAction` and `ImportsExistingPaymentMethods`. Build charge results with `ChargeResult::succeeded()`, `pending()`, `requiresAction()`, `failed()` or `unknown()`.

> [accordion] Login providers
>
> `App\Modules\OAuthProviderRegistry` scans enabled modules whose name contains `Provider`.
>
> | Concern | Where |
> | - | - |
> | Required manifest keys | `link_url`, `link_column`, `logo` |
> | Button colours | `colors` in `module.json` (`bg`, `text`, `hover`) |
> | Driver registration | `$socialiteDriver` and `$socialiteProvider` on the provider |
> | New accounts | `UserRegistrationService::registerViaOAuth($oauthUser, $key, $label, $linkColumn, $avatar, $extra)` |
> | Consumers | `LoginController` and `MarketController` use `forLogin()`. `ProfileController` uses `forUser()` |

> [accordion] Registrar modules
>
> `RegistrarManager` resolves `Modules\{M}\Services\Registrar`. It must implement `App\Domains\Contracts\DomainRegistrar`, usually by extending `AbstractRegistrar`. Required methods are `key()`, `displayName()`, `capabilities()`, `isConfigured()`, `checkAvailability()`, `register()`, `renew()` and `getInfo()`. The generator also writes thin subclasses of the registrar service actions, renew, cancel, controls and suspend classes. Leave them as generated.

## Which route file does what

| File | Loaded by | Prefix and middleware |
| - | - | - |
| `web.php` | The route provider | `web` |
| `api.php` | The route provider | prefix `api`, names `api.`, middleware `api` |
| `settings.php` | `require` from `web.php` | admin stack, `/admin/{module}/...` |
| `panel.php` | `require` from `web.php` | `service/{serviceId}` plus service middleware |
| `payment.php` | `require` from `web.php` | `auth`, `verified` |
| `console.php` | The provider, after boot | `Schedule::` calls |

## Core jobs that call your classes

| Job | Resolves |
| - | - |
| `CreateServiceJob` | `ModuleServiceActions` |
| `HandleUpgradeService`, `HandleDowngradeService` | `UpgradeService`, `DowngradeService` |
| `HandleAddonService` | `AddonService` |
| `HandleConfigurableOptionsChangeService` | `ModuleServiceActions` |
| `SubscriptionJob` | `RenewService`, `Services\Actions\*` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.