1 Create a License
Michel edited this page 2024-11-04 19:04:37 -05:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Creating a License

The CreateLicense.php file allows you to securely create a new license in your application by sending a request to the SLM Plus API. This guide explains how to configure and use CreateLicense.php to generate new licenses.

Prerequisites

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

How to Use CreateLicense.php

Step 1: Set Up the License Data

  1. Open CreateLicense.php.

  2. Define the license data as an associative array with the necessary fields. Heres an example of basic fields you may need:

    $licenseData = [ 'first_name' => 'John', 'last_name' => 'Doe', 'email' => 'johndoe@example.com', 'purchase_id_' => '12345', // Unique ID for tracking the purchase 'max_allowed_domains' => 2, // Maximum number of domains for this license 'max_allowed_devices' => 1, // Maximum number of devices for this license 'date_created' => date('Y-m-d'), // License creation date 'product_ref' => 'YourProduct' // Reference name for the product ];

    Adjust these fields as needed to match your product or user data.

Step 2: Call the create Method

  1. Instantiate CreateLicense.

  2. Call the create() method with the $licenseData array. Heres how:

    require_once 'CreateLicense.php';

    $createLicense = new CreateLicense(); $createLicense->create($licenseData);

    This sends a request to create the license using the SLM Plus API.

Step 3: Handle the Response

CreateLicense.php provides a response indicating the success or failure of the license creation. Heres what to expect:

  • Success: If the license is created successfully, youll see a message with the generated license key.
  • Error: If theres an issue (e.g., missing fields or invalid data), an error message will be displayed.

Example Usage

Below is a complete example of using CreateLicense.php to create a new license:

   require_once 'CreateLicense.php';

   $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' => 'YourProduct'
   ];

   $createLicense = new CreateLicense();
   $createLicense->create($licenseData);

Next Steps

Once youve configured and tested license creation, you can proceed to other actions: