Skip to content

Deactivating a License

Michel edited this page Nov 4, 2024 · 1 revision

Deactivating a License

The DeactivateLicense.php file allows you to deactivate a license from a specific domain or device. This action is useful when freeing up a license for use elsewhere. This guide will walk you through configuring and using DeactivateLicense.php to manage license deactivation.

Prerequisites

  • Ensure CoreConfig.php is configured with your API URL and secret key.
  • Verify that LicenseAPI.php is included in your project, as it provides the core method for deactivating licenses.

How to Use DeactivateLicense.php

Step 1: Set Up the Deactivation Data

  1. Open DeactivateLicense.php.

  2. Define the deactivation data as an associative array. Here’s an example with basic fields:

    $deactivationData = [ 'license_key' => 'YOUR_LICENSE_KEY', // License key to deactivate 'registered_domain' => 'example.com', // Optional: Domain to deactivate 'registered_devices' => 'Device12345' // Optional: Device identifier ];

    Use either registered_domain, registered_devices, or both, depending on where the license is registered and needs to be deactivated.

Step 2: Call the deactivate Method

  1. Instantiate DeactivateLicense.

  2. Call the deactivate() method with the $deactivationData array. Here’s how:

    require_once 'DeactivateLicense.php';

    $deactivateLicense = new DeactivateLicense(); $deactivateLicense->deactivate($deactivationData);

    This sends a request to deactivate the license from the specified domain and/or device.

Step 3: Handle the Response

DeactivateLicense.php provides a response indicating the success or failure of the deactivation. Here’s what to expect:

  • Success: If deactivation is successful, you’ll see a message confirming that the license was removed from the specified domain or device.
  • Error: If there’s an issue (e.g., the license is already inactive), an error message will be displayed.

Example Usage

Below is a complete example of using DeactivateLicense.php to deactivate a license:

require_once 'DeactivateLicense.php';

$deactivationData = [ 'license_key' => 'YOUR_LICENSE_KEY', 'registered_domain' => 'example.com', 'registered_devices' => 'Device12345' ];

$deactivateLicense = new DeactivateLicense(); $deactivateLicense->deactivate($deactivationData);

Deactivation Error Handling

The DeactivateLicense.php script includes error handling for the following scenarios:

  • Already Inactive: Notifies the user if the license is already inactive on the specified domain or device.
  • Missing Domain or Device: Alerts the user if the specified domain or device is not found.

For detailed response handling, review the code in DeactivateLicense.php.

Next Steps

After configuring and testing license deactivation, you can proceed to additional actions: