Platform modules
Plans, invoices and wallets
Understand the application's billing records, invoice transitions and wallet top-up workflow.
Scope of the billing module
Billing provides plans, subscriptions, usage snapshots, invoices, wallets and top-up requests for applications built with GhaylStack. GhaylStack itself remains free and open source. The module's routes start with /api/v1/billing and distinguish Permissions.Billing.View from Permissions.Billing.Manage.
Tenant creation and renewal publish integration events that Billing consumes to maintain subscriptions and term invoices. Monthly usage invoices are a separate stream. An invoice's purpose identifies subscription, usage or top-up work; this separation prevents those streams from sharing the same business identity.
Configure a plan and inspect usage
Use /plans to list, create or update plans, and /subscriptions to inspect or assign subscriptions with the appropriate permissions. The /subscriptions/me and /invoices/me routes provide current-workspace views.
Usage snapshots are read through GET /api/v1/billing/usage and captured through POST /api/v1/billing/usage/snapshots/capture. The billing-monthly-invoices job is registered for 00:05 UTC on the first day of each month and bills the previous period. Check the job result and relevant source period before manually generating another invoice.
Follow the invoice lifecycle
| State or operation | Rule |
|---|---|
| Draft | Line items can be added and totals are recalculated |
| Issue | Draft becomes Issued; the default due date is 14 days after issue |
| Mark paid | An Issued invoice becomes Paid; repeating Paid is idempotent |
| Void | A paid invoice cannot be voided; repeating Void does not add another reason |
The operation routes are /invoices/{id}/issue, /invoices/{id}/pay and /invoices/{id}/void. Read the current state first. An internal mark-paid operation records the application's decision; it is not evidence that an external payment provider collected money.
Invoice PDF is available through /invoices/{id}/pdf and uses the same print engine as reports. Follow the PDF guide when configuring the server runtime.
Wallet top-ups and currency
The tenant can inspect /wallet/me, submit /wallet/topup-requests and review its requests under /wallet/topup-requests/me. Approval and rejection have separate management routes. Approval creates a top-up invoice; the payment handling path credits the wallet for a paid top-up invoice.
Billing:DefaultCurrency sets the default for new seed plans and previously unbound wallets. It must be a three-letter uppercase code. Changing it does not convert existing monetary records. The service checks wallet and invoice currencies before crediting, so a currency mismatch requires investigation rather than changing display formatting.
Verify and troubleshoot
In development, follow one top-up from request to approved invoice, then mark the issued invoice paid and inspect the wallet transaction. Repeat the same payment action to check that no duplicate credit is produced. Keep this exercise separate from any external payment integration.
For missing invoices, verify the tenant, subscription events, outbox and job execution. For a rejected transition, inspect the invoice's current state. For absent wallet credit, confirm the invoice purpose and currency as well as its payment state. The Billing report summarizes permitted billing data; it does not override Billing access checks.