mirror of
https://ghproxy.net/https://github.com/michelve/software-license-manager.git
synced 2025-10-04 02:06:37 +08:00
improved: API endpoint improved: expiration task handler added: sample files for integration
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
require_once 'LicenseAPI.php';
|
|
|
|
class CreateLicense
|
|
{
|
|
private $licenseAPI;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->licenseAPI = new LicenseAPI();
|
|
}
|
|
|
|
/**
|
|
* Create a new license using provided data.
|
|
*
|
|
* @param array $licenseData Data for license creation.
|
|
* @return void Displays success or error message based on response.
|
|
*/
|
|
public function create($licenseData)
|
|
{
|
|
$response = $this->licenseAPI->createLicense($licenseData);
|
|
|
|
if ($response['result'] === 'success') {
|
|
echo "License created successfully. Key: " . $response['data']['key'];
|
|
} else {
|
|
echo "Error creating license: " . $response['message'];
|
|
}
|
|
}
|
|
}
|
|
|
|
// Usage example
|
|
$createLicense = new CreateLicense();
|
|
|
|
$licenseData = [
|
|
'first_name' => 'John',
|
|
'last_name' => 'Doe',
|
|
'email' => 'johndoe@example.com',
|
|
'purchase_id_' => '12345',
|
|
'max_allowed_domains' => 2,
|
|
'max_allowed_devices' => 1,
|
|
'date_created' => date('Y-m-d'),
|
|
'product_ref' => 'ThemePro'
|
|
];
|
|
|
|
$createLicense->create($licenseData);
|
|
|