Product design v3 · 4 of 6

Invoicing

rochen-api owns every Dedicated invoice. Nothing is charged in advance: compute, storage, IOPS, throughput and data transfer are metered per hour from the change log and billed at the end of each month. Sites on the pool and the included software never appear on an invoice. WHMCS skips pools and the sites under them in code, and rochen-api also owns overdue suspension.

TimelineAt order timeMonthly invoiceUsage from the change logStorage tiersWorked exampleLine rulesResizes, suspensionFinal invoiceKeeping WHMCS out

Timeline

  1. Order · 3 Octno invoice: nothing is charged in advance. The gate is a stored card and no overdue invoices.
  2. Deployed · activation 3 Oct 10:00the create change is applied; billing starts here, not at launchusage accrues hourly from this point · every applied billable change starts a new span
  3. Resize · 18 Oct 14:00new span at the new template rate; no invoice
  4. Disk grow · 25 Oct 09:00new span at the new allocation; no invoice
  5. Sites added, licences re-tieredlogged in the change log, never billed
  6. Monthly invoice · generated 1 Novall of October's usage for every pool the client owns, one invoice, due on the account's usual termsbilled_through → 31 Oct · WHMCS skips pools and their sites in code
  7. Every month aftereach run bills the complete calendar months since billed_through
  8. Terminationfinal invoice: usage from billed_through to terminated_at, including the partial data-transfer month

Usage is billed by complete calendar months, as Fully Managed Services does today. A run on 1 Nov bills all of October; the days of November wait for the next run.

At order time

No invoice

Orders now invoice only what they buy up front (domains). A pool buys nothing up front, so no invoice is created and no due date moves. The pool's tblhosting.amount is 0.00 like every Rochen One service.

The gate instead

A stored card, no overdue invoices, and a small authorisation hold that is released at once and never appears on an invoice. Stripe's risk level on that hold decides: normal deploys, elevated or highest sends the order to staff review first (Deployment page).

Indian mandates

For INR clients the card mandate ceiling must cover the pool's monthly maximum, so the order adds the pool's estimate to the ceiling calculation and asks for a new mandate when the current one is too small, as Rochen One orders do.

Monthly invoice — dedicated:invoice-renewals

Runs
daily at 00:30 UTC; a --report mode prints what it would invoice without writing, and the first production run is done in that mode
Selects
every client with a pool in active, suspended or terminating whose billed_through is before the last complete calendar month
Builds
one invoice per client covering all their pools. Under a per-client lock it notes the current last invoice item, inserts its own usage items, and invoices only the items created since (CreateInvoice::itemMarker() / itemsCreatedSince()). It never runs the full client sweep, which would pull every other renewal forward
Items
Hosting-type lines with the pool as the related service, so the app and the admin show them under the pool. WHMCS's payment code skips pools, so paying the invoice never moves dates or starts an instance there
Advances
billed_through to the end of the last month billed; the pool's next due date is set to the next run for display only
Captures
dispatches the existing card-capture job, but only for clients whose automatic charging is on (the job itself does not check that flag). Indian mandate captures can stay processing for about a day
Alerts
failures and anomalies go by mail to the department admins: the scheduler's own output is discarded. It also alerts if WHMCS wrote any invoice item for a pool or a pool site

Overdue: dedicated:suspend-overdue

WHMCS no longer suspends pools, so rochen-api does. Daily, a pool with a Dedicated invoice unpaid 5 days past its due date is suspended: instance stopped, pool and every site under it marked Suspended, client mailed. When the invoices are paid the same command (and the capture path) unsuspends it and restores the sites the suspension took down. Usage accrues while suspended. Termination for long non-payment follows the business's overdue policy through the same termination job as a cancellation.

Usage from the change log

No separate billing table. Every applied change that affects price (create, resize_instance, resize_disk, resize_iops_throughput, terminate) is billable and stores the complete configuration in to. Its immutable applied_at is the boundary of a usage span. Licence re-tiers and site events are logged with billable = false and never start a span.

  1. Load the billable changesfor the pool, ordered by applied_at, plus the last one before the month starts (carried forward so the month opens with a known configuration).
  2. Cut spans at month edgesspan = max(applied_at, month start) → min(next applied_at, month end). Hours are the real elapsed time as a fraction, with an exclusive month end, as the MCS calculation does since October 2026; they are rounded only in the line description.
  3. Price each span from the pool's own sub-option pricescompute: monthly ÷ 744 × hours · IOPS: (IOPS − 3000) ÷ 100 × monthly ÷ 744 × hours · throughput: (MiB/s − 125) ÷ 25 × monthly ÷ 744 × hours.
  4. Price storage across the client's poolssee Storage tiers below; hours-prorated the same way.
  5. Add data transferfrom dedicated_instances.data_transfer["YYYY-MM"]: the 500 GB allowance (msetupfee) plus (out − 500) × monthly above it.
  6. Group into linesconsecutive spans with the same template merge into one line; the same for each storage allocation. Descriptions follow the Rochen One style.

Storage tiers

RuleA pool's allocation is priced with the Rochen One storage bands (DiskSize [1-5], [6-20], [21-50], [51-100], [101-200], [201-*], in the client's currency), walked over the client's total dedicated allocation for that hour. With two pools of 200 GB and 300 GB, the first 200 GB fill the lower bands and the next 300 GB continue from where they left off; each pool's line shows its own GB at the rate it landed in.

Shared-site storage keeps being billed by WHMCS on the R1 invoice. Rolling it into the same band as dedicated storage would need either WHMCS billing code or rochen-api reproducing WHMCS's bands, so v1 tiers dedicated storage on its own. This is flagged as an open point to confirm with Chris.

Worked example (London, example prices, USD)

One pool, activated 3 Oct 10:00 on r1d.m7i.large with 200 GB. Resized to r1d.m7i.xlarge on 18 Oct 14:00. Storage grown to 300 GB on 25 Oct 09:00. Twelve sites added during the month (free). Invoice generated 1 Nov.

SpanFrom → toHoursTemplateStorageComputeStorage
103 Oct 10:00 → 18 Oct 14:00364m7i.large · 86.35/mo200 GB · 23.60/mo42.2511.55
218 Oct 14:00 → 25 Oct 09:00163m7i.xlarge · 161.95/mo200 GB · 23.60/mo35.485.17
325 Oct 09:00 → 01 Nov 00:00159m7i.xlarge · 161.95/mo300 GB · 31.60/mo34.616.75
Invoice generated 1 NovTypeAmount
Rochen One Dedicated – r1d.m7i.large – srv1.directrouter.com (03/10 – 18/10, 364 Hours)Hosting · compute42.25
Rochen One Dedicated – r1d.m7i.xlarge – srv1.directrouter.com (18/10 – 01/11, 322 Hours)Hosting · compute70.09
200GB SSD (Storage) – srv1.directrouter.com (03/10 – 25/10, 527 Hours)Hosting · storage16.72
300GB SSD (Storage) – srv1.directrouter.com (25/10 – 01/11, 159 Hours)Hosting · storage6.75
Data Transfer – 320GB of 500GB allowance – October 2026Hosting · transfer64.80
Subtotal before tax200.61

Hours in October from 3 Oct 10:00 add up to 686, matching the three spans. Compute: 79.95 × 1.08 region factor. Storage bands (example): 0.20 / 0.16 / 0.14 / 0.12 / 0.10 / 0.08 per GB per month, so 200 GB = 23.60 and 300 GB = 31.60. No lines for the twelve sites, cPanel Pro, Imunify360 30 users or LiteSpeed Web Host Essential: all included.

Line rules

Compute

One Hosting-type line per template run per month, hours-prorated from the region's Templates price.

Storage

One line per allocation per month at the band rate it landed in across the client's pools.

Extras

IOPS and throughput only when above the gp3 baseline; data transfer as the allowance plus overage from Cost Explorer via dedicated:log-data-transfer (daily 01:30; a new account reports roughly a day late).

Never

Sites, software licences, management, DNS, backups, monitoring: all included in the compute rate.

Costs card in the app

Dedicated::costs() runs the same maths over the current month for "spend so far" and "estimated end of month", per pool and for the account.

Currency

Prices resolve from the pool's stored sub-option ids and the R1 storage sub-options in the client's currency. A currency with the −1 sentinel is refused at order.

Resizes, suspension

EventEffect on billing
Template changethe applied change opens a new span at the new compute rate
Storage grownew span at the new allocation; allocations never shrink
IOPS / throughput changenew span; only the amount above baseline is charged
Site added or removed, licence re-tierednone
Suspension (overdue) or client stopusage keeps accruing: the instance and volumes stay reserved. The app states this next to Stop.

Final invoice at termination

The termination job's last step marks the terminate change applied (the end of the timeline) and runs the same routine for billed_through → terminated_at, including the partial data-transfer month, then sets the pool and its site rows Terminated. If nothing is owed, no invoice is created.

Keeping WHMCS out

Advancing due dates is not enough: WHMCS would write a zero-value line and auto-pay it, mail an upcoming-invoice reminder, suspend from unpaid invoice items and advance dates again on payment. So WHMCS skips pools and their sites in code. The full list of edits is on the Maintenance page.

Invoice run and reminders

Product 464 is skipped beside the existing skip for Rochen One Sites, in the invoice run and in the upcoming-invoice reminder. Pool sites are product 466, so they are already skipped.

Payment processing

When a Dedicated invoice is paid, WHMCS's per-service payment step does nothing for a pool: no date advance, no unsuspend, no renew. rochen-api reacts to the payment itself.

Suspension and termination

The suspension cron, the termination queries and the overdue-termination list exclude pools and pool sites. rochen-api's own commands take their place.

Legacy aws checks

The daily "active service without a tracking row" mail excludes pools, which by design have no rows in the legacy aws table. The legacy arrears routine finds nothing to add.

Shared billing untouched

Pool sites have a pool as parent and no billing-log rows, so the Shared plan's arrears routine never counts them. The one module's admin hooks are guarded so they cannot write log rows for a pool site.

Detection

The monthly command alerts if any invoice item for a pool or pool site was created by something other than itself.

Rochen One Dedicated · invoicing v3 · September 2026