Usage Billing

From WHMCS Documentation

This page describes a feature available in version 7.9 and above

Usage billing in WHMCS allows you to set up products that contain variable-priced items whose price is determined at the time of invoicing based on usage data provided to WHMCS.

The following are some example use cases for Usage Billing:

  • A hosting company charges for bandwidth usage
  • A hosting company charges a fixed amount per Addon Domain that is added
  • A hosting company offers a hosting package with 10GB of bandwidth included and charges $1.00 per GB used over that
  • A hosting company offers reseller hosting that allows you to create 10 cPanel Accounts as standard, but charges you $0.20 per account after that

Usage Formats

Usage can be reported in one of two formats:

  • Snapshot — The usage can be measured and billed for at any given point in time, but for which usage never resets.
  • Time Based — The usage is measured over a given period of time and resets to 0 at the end of the billing period. Bandwidth is an example of a measurement that is typically measured by month, and resets to zero at the end of each month.

Tip
We recommend using the Snapshot Metric Type on products with a monthly billing cycle.

Configuring Usage Billing and Metrics

Products associated with capable provisioning modules can capture metrics. These metrics can be can be priced and billed or simply enabled for display purposes.

You can enable metrics for a product in the Module Settings tab at Configuration () > System Settings > Products/Services or, prior to WHMCS 8.0, Setup > Products/Services > Products/Services.

Usage-billing-module-settings-metric-config.png

If a metric is enabled, it will appear within the client's product details view of the client area. An admin will always see all metrics, enabled or disabled, within the admin area when viewing a service belonging to a product which reports metrics.

More Information

  • Check out our blog article on Usage Billing for an in-depth look into how Usage Billing works here.
  • Check out our step-by-step guide to get started here.

Configuring Metric Pricing

To configure metric pricing, click Configure Pricing for that metric in the Module Settings tab at Configuration () > System Settings > Products/Services or, prior to WHMCS 8.0, Setup > Products/Services > Products/Services.

Usage-billing-metric-pricing-config.png

Metric pricing can be configured using any of the following pricing schemes:

  • Per Unit — Charge the same amount for each unit.
  • Total Volume — Charge a per-unit price based on the total volume consumed.
  • Graduated — Charge a per-unit price based on the consumption range. The total charge is the sum of the range calculations.

For Total Volume and Graduated pricing schemes, you must enter pricing in the text boxes.

You can create as many different pricing brackets as you wish.

The examples below illustrate how the price billed can vary using different schemes.

Per Unit Pricing

Per unit pricing is the simplest pricing mode we offer. Enter a cost per unit and you’re done.

In a per-unit pricing scheme, prices are defined as per-unit costs, and all units cost the same. Thus, only 1 price bracket may be defined. For example if you used Per Unit pricing for "Addon Domains" and defined a cost of $1/each/period and a customer buys 3, then a $3 charge would be added at the end of the period.

Total Volume Pricing

In the total volume pricing scheme, multiple price brackets define the prices at different quantity levels. The price per unit for all units is determined by the prevailing price for the total used quantity. An example can illustrate this the best. Say you allow your customers to use an unlimited number of MySQL Databases with a pricing structure defined as follows:

Starting QuantityPrice per Database
0$2.00
10$1.00
20$0.50

If a customer uses 8 MySQL Databases, they will pay $2 per database, for a total of $16.
If a customer uses 25 MySQL Databases, they will pay $0.50 per database, for a total of $12.50.

Graduated Pricing

In the graduated pricing scheme, multiple price brackets define the prices at different quantity levels, much like in the Total Volume scheme. However, unlike the total volume scheme, your customers will pay the defined price per unit for each allocated unit. Let's see how this changes the price a customer pays using the same pricing brackets as pictured above.

If a customer uses 8 MySQL Databases, they will pay $2 per database, for a total of $16.
If a customer uses 25 MySQL Databases, they will pay $2 per database for the first 9 databases, plus $1 per database for the next 10 databases, plus $0.50 per database for the final 6 databases, for a total of $31 (9 x $2 + 10 x $1 + 6 x $0.50).

Admin Area

Services that are associated with products which have metrics will display the latest available usage data collected for all metrics when a service is viewed within the admin area, regardless of the metric state.

The Enabled column provides an indication of whether the metric is enabled for billing at the product configuration level. A check indicates that the metric usage will be billed for periodically.

You can manually poll for the latest values at any time by clicking the "Refresh Now" button located in the bottom right of the Metric Statistics panel.

Usage-billing-admin-metric-view.png

Client Area

The product details view of services in the client area provides an information panel similar to that of the one found in client's service within the admin area.

The screenshot below shows how this information appears for a product assigned to the cPanel module.

The notable difference is any disabled metrics will not appear here. Only metrics that are enabled for billing will be displayed.

Invoicing and Billing

You can enable usage billing using the Enable Metric Usage Invoicing setting in the Invoice tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings.

Usage Data Collection

Usage data is updated twice a day via the TenantUsageMetrics cron task.

This task will run before the CreateInvoices routine of the daily cron.

Custom cron invocations can use the option "--TenantUsageMetrics" to fire or suppress its execution.

Server Timezones
Your server's timezone must match the WHMCS server's timezone to prevent incorrect reporting. For more information, see Server Time.

Extensibility

Module developers can define metrics and collection routines for metrics that are to be made available for display and usage billing by a provisioning module.

To learn more, see our Provisioning Module documentation.