Software Licensing

Latest ReleaseCurrent VersionIncluded in WHMCS
N/AN/ANo

The WHMCS licensing addon module allows you to license your own web applications for selling to end users. You can generate local license keys and configure periodic remote checking to ensure secure licensing for your products.

Make certain that you are using the correct licensing addon module:

  • The Software Licensing addon allows you to generate and check licenses for software products that you develop.
  • The cPanel Licensing addon automates purchases of cPanel & WHM licenses through Manage2.

Activation

You must first purchase this addon. Then, you can activate it through the Admin Area.

To do this:

  1. Purchase the addon in the WHMCS Marketplace.
  2. Go to Configuration () > System Settings > Addon Modules.
  3. Click Activate for the addon.
  4. Click Configure.
  5. Configure the following settings:
    • Public License Verification Tool — Check to enable a verification page that visitors can use to check whether a domain is licensed to use your software.
      • You can customize the appearance of the page using the /modules/addons/licensing/licenseverify.tpl file.
      • This page will be available at http://www.example.com/whmcs/index.php?m=licensing, where http://www.example.com/whmcs/ is the location of your WHMCS installation.
    • Maximum Allowed Reissues — Enter the maximum number of times that a client can reissue a license.
    • Auto Logs Prune — Set the length of time to retain license access logs.
  6. Select the admin role groups that will have access to this addon.
  7. Click Save Changes.

Using this Addon

To set up a licensing product:

  1. Create a product at Configuration () > System Settings > Products/Services.
  2. In the Module Settings tab, choose License Software.
  3. Configure the following options:
    • Key Length — The length of the randomly generated key.
    • Key Prefix — The beginning of the license key. You can use this to validate an applicable key.
    • Allow Reissue — Whether a client can reissue the license from the Client Area.
    • Allow Domain Conflict, Allow IP Conflict, and Allow Directory Conflict — Check to disable location verification for matching domains, IP addresses, or directories, respectively. If you do not disable them, WHMCS will use the valid values in the service record to verify the license’s location.
    • Support/Updates AddonSee below.
    • Free Trial — Check to prevent clients from using more than one licence of this product on the same domain. If a client tries to order a second copy of this product and use it on the same domain as a previous service, the system will automatically suspend it with the reason Duplicate Free Trial Use.
Your clients can receive the software products that they order by downloading them after purchase. For more information, see Product Downloads Distribution

License Statuses

Licenses use the following statuses:

  • Reissued — The license is ready to use.
    If a license’s status is Reissued, the system will save the domain, IP adddress, and directory during the next license check.
  • Suspended — The license is suspended and the user cannot use it.
  • Active — The license is in use with a valid domain, IP address, and installation path.
  • Expired — The license has reached its expiration date and the user cannot use it.

Module Commands

You can use the following module commands when managing licensing products in the Products/Services tab of the client’s profile:

Module CommandDescriptionSets License Status To
CreateGenerate a license key for the product.
The Create module command does not generate a username or password.
Reissued
SuspendSuspend the license.Suspended
TerminateExpire the license.Expired
ReissueClears the saved license domain, IP address, and directory.Reissued
RevokeRemove the license key and allow reuse of the license number in the future.N/A
ManageView or edit the license’s domain, IP address, and directory.N/A

Managing Licenses

To manage licenses, go to Addons > Licenses Manager. You can view a list of issued license keys, search for keys, and update their associated domains, IP addresses, and directories.

Addons

You can assign addon products to your licensing products for purchase with the initial order or at a later date. For example, you may want to create addons for installation and upgrade services.

For steps to integrate addons into your code, see Using Product Addons below.

Support and Updates Addons

When you check Support/Updates Addon during the creation of a licensing product, the system will require the client to have an active Support/Updates addon in order to receive support and download the related products. You can sell Support/Updates addons using any of WHMCS’s supported billing cycles.

If you check Support/Updates Addon for a licensing product, you must also configure a Support/Updates addon.

For example, you could create a Support/Updates addon that is free with the initial license purchase and requires paid renewal when it expires.

To do this:

  1. Create your licensing product, making sure to check Support/Updates Addon.
  2. Go to Configuration () > System Settings > Product Addons.
  3. Click Add New.
  4. Enter the name, description, price, and recurring cycle.
    Do not check Show on Order.
  5. Check the desired licensing product in the Applicable Products section for the addon.
  6. Go to Configuration () > System Settings > Products/Services.
  7. Edit the licensing product.
  8. In the Module Settings tab, select the addon that you just created for Support/Updates Addon.
  9. Click Save Changes.
If you do not want to include the addon for free with the initial purchase, check Show on Order while creating the addon and leave Support/Updates Addon blank in the product configuration.

Integrating License Check Code

The addon’s license check code is in the /modules/servers/licensing/check_sample_code.php file. You choose how to integrate that code into your software products.

Users can enter their license keys during your installation process or by pasting the key into a file. You can load that key in your software product before calling the check_license function to validate it.

Each time that a license check succeeds, it returns a local key. You can store that local key in your database or a local file for use on subsequent page loads. We recommend storing it in a database for ease of use.

  • The local key is an encrypted version of the license check data that prevents the license check from calling your server on every page load.
  • The local key is always empty on the first check your client makes.

To integrate the license check, perform these steps:

  1. Copy and paste the license check code from the check_sample_code.php file into the top of the file you want to protect.
  2. Enter the system URL from your WHMCS installation in the $whmcsurl variable.
  3. Customize the $licensing_secret_key variable to ensure your local keys are different from other licensing addon users.
  4. Optionally, change the $localkeydays and $allowcheckfaildays variables if you want to change how often a remote license check is made.
  5. Ensure that your code performs the following actions:
    • Retrieve the license key and local key from the database or file storage.
    • Call the check_license function.
    • Perform the desired actions in accordance with the results of the check_license function. For sample if statements, see the check_sample_code.php file.
    • Store the local key that the license check returns.

Using Product Addons

If the licensing product has any purchased addons, the $results array that the check_license function returns will include a pipe-separated addons string with addon details. For example:

[addons] => name=Test Addon;nextduedate=2017-12-26;status=Active

For example, you could use this data to restrict access to certain features or to customize other behavior.

The following code example processes this string into an $addons array:

$tempresults = explode("|",$results["addons"]);
foreach ($tempresults AS $tempresult) {
  $tempresults2 = explode(";",$tempresult);
  $temparr = array();

  foreach ($tempresults2 AS $tempresult) {
  $tempresults3 = explode("=",$tempresult);
    $temparr[$tempresults3[0]] = $tempresults3[1];
  }

  $addons[] = $temparr;
}

Using Configurable Options

If the licensing product has any configurable options, the $results array that the check_license function returns will include a pipe-separated configoptions string with option details. For example:

[configoptions] => Test=0|Test 002=

For example, you could use this data to limit the software to a particular number of users.

The following code example processes this string into a $cconfigoptions array:

$tempresults = explode("|",$results["configoptions"]);
foreach ($tempresults AS $tempresult) {
  $tempresults2 = explode("=",$tempresult);
  $temparr = array();

  foreach ($tempresults2 AS $key => $value) {
    $temparr[$key] = $value;
  }

  $configoptions[] = $temparr;
}

Change Log

Licensing Addon v3.0

Release Date: 9th February 2012

New Features Added:

  • Free Trial Option
  • Public License Verification Tool
  • Banned Domains
  • Intelligent Search Integration
  • Added Maximum Allowed Reissues Limit
  • Auto Logs Prune

Last modified: June 14, 2024