Skip to content

License

The license product type lets you create and manage software licenses that your application can validate against FOSSBilling over the API.

  1. Customer purchases a license product
  2. FOSSBilling generates a unique license key
  3. Your application calls FOSSBilling's API to validate the license
  4. FOSSBilling checks the license against your rules (IP, hostname, path, version)
  5. Your application grants or denies access based on the response

Go to Extensions and install "Service License".

When creating the product, configure these options:

OptionDescription
pluginWhich validation plugin to use (default: Simple)
prefixOptional prefix for license keys (e.g., MYAPP-)
lengthLength of the generated key (default: 25)
validate_ipCheck the IP address
validate_hostCheck the hostname
validate_pathCheck the installation path
validate_versionCheck the software version

Give customers their license key, then have your application validate it using the API.

EndpointAccessDescription
/admin/servicelicense/plugin_get_pairsAdminList available license plugins
/admin/servicelicense/updateAdminUpdate license validation rules
/admin/servicelicense/resetAdminReset license to defaults
/guest/servicelicense/checkGuestValidate a license

Call /guest/servicelicense/check with these parameters:

  • license — the license key
  • host — the hostname
  • version — the software version
  • path — the installation path

Success response:

{
"result": {
"licensed_to": "Client Name",
"created_at": "2025-01-01 12:00:00",
"expires_at": null,
"valid": true
},
"error": null
}

Error response:

{
"result": null,
"error": {
"message": "Your license key is invalid.",
"code": 1005
}
}

You can create your own license generation and validation logic.

Place your plugin in /modules/Servicelicense/Plugin/YourPlugin.php:

class License_YourPlugin
{
public function generate(array $data): string
{
return 'YOUR-KEY-HERE';
}
public function validate(\Model_ServiceLicense $service, array $data): array
{
if (empty($data['host'])) {
throw new \LogicException('Host is required', 1020);
}
return ['host' => $data['host']];
}
}
  • Class name must be License_PluginName
  • File must be PluginName.php in the Plugin/ directory
  • Must implement a generate() method
  • Optional: implement a validate() method for custom rules

The default Simple plugin generates keys like:

MYAPP-ABCD1-EFGH2-IJKL3-MNOP4
  • 25 characters by default
  • Optional prefix
  • Dashes every 5 characters
  • Uppercase letters and digits 1–9

See src/modules/Servicelicense/Plugin/Simple.php for the implementation.