The license product type lets you create and manage software licenses that your application can validate against FOSSBilling over the API.
How It Works
Section titled “How It Works”- Customer purchases a license product
- FOSSBilling generates a unique license key
- Your application calls FOSSBilling's API to validate the license
- FOSSBilling checks the license against your rules (IP, hostname, path, version)
- Your application grants or denies access based on the response
Setting Up License Products
Section titled “Setting Up License Products”1. Enable the Extension
Section titled “1. Enable the Extension”Go to Extensions and install "Service License".
2. Create a License Product
Section titled “2. Create a License Product”When creating the product, configure these options:
| Option | Description |
|---|---|
plugin | Which validation plugin to use (default: Simple) |
prefix | Optional prefix for license keys (e.g., MYAPP-) |
length | Length of the generated key (default: 25) |
validate_ip | Check the IP address |
validate_host | Check the hostname |
validate_path | Check the installation path |
validate_version | Check the software version |
3. Distribute and Validate
Section titled “3. Distribute and Validate”Give customers their license key, then have your application validate it using the API.
API Endpoints
Section titled “API Endpoints”| Endpoint | Access | Description |
|---|---|---|
/admin/servicelicense/plugin_get_pairs | Admin | List available license plugins |
/admin/servicelicense/update | Admin | Update license validation rules |
/admin/servicelicense/reset | Admin | Reset license to defaults |
/guest/servicelicense/check | Guest | Validate a license |
Validating a License
Section titled “Validating a License”Call /guest/servicelicense/check with these parameters:
license— the license keyhost— the hostnameversion— the software versionpath— 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 }}Custom License Plugins
Section titled “Custom License Plugins”You can create your own license generation and validation logic.
Creating a Plugin
Section titled “Creating a Plugin”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']]; }}Plugin Requirements
Section titled “Plugin Requirements”- Class name must be
License_PluginName - File must be
PluginName.phpin thePlugin/directory - Must implement a
generate()method - Optional: implement a
validate()method for custom rules
The Simple Plugin (Built-in)
Section titled “The Simple Plugin (Built-in)”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.