Back to top

Post 

Expected parameters

Below is a list of expected parameters that must be included in your Post. Including “domain_limit” here will override the software level domain_limit or Activation Limit.

"ctransreceipt": "LE-kaf994844",
"ctransaction" : "SALE",
"cproditem" : "19898",
"cprodtitle" : "My Awesome Plugin",
"ccustname" : "Bob Smith",
"ccustemail" : "Bob@example.com",
"domain_limit" : "2", (optional)
"cverify' : "6BGC6C"

Post 

A SALE will create a license key in License Engine, using the key provided and other information provided by your $_POST. The cverify value will be calculated using the secret key value and will be unique to each user. We will decode this value when we receive your post to authenticate your application.

A RFND will disable the specified license key.

Create New License Key
/leipn

Create a new license key

  • Request
  • Headers
    Content-Type: application/json
    Body
    {
        "ctransreceipt": "LE-kaf994844",
        "ctransaction" : "SALE",
        "cproditem" : "19898",
        "cprodtitle" : "My Awesome Plugin",
        "ccustname" : "Bob Smith",
        "ccustemail" : "Bob@example.com",
        "domain_limit" : "2", (optional)
        "cverify' : "6BGC6C"
    }
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "success": "License Key Created Successfully",
    }
    
  • Response  400
  • Headers
    Content-Type: application/json
    Body
    {
        "error": "invalid parameters"
    }
    

Sample Code 

The code below is just a sample of how a Post can be made to LicenseEngine. To use this code, replace the “YOUR SECRET KEY” with the LE IPN Secret Key code you create in your LicenseEngine Account. The cverify value will be calculated using the secret key value and will be unique to each user. We will decode this value when we receive your post to authenticate your application.

    function test_ipn()
    {


        $post_url = 'http://www.licenseengine.com/ipn';

        $info['ccustemail'] = 'testuser@example.com';
        $info['ccustname'] = 'Test User';
        $info['cproditem'] = '991234';
        $info['cprodtitle'] = 'My product title';
        $info['ctransaction'] = 'SALE';
        $info['ctransreceipt'] = '5TK17302TA291604S';
        $info['domain_limit'] = '2';
        $info['cverify'] = get_cverify($info,'YOUR SECRET KEY');

        // get all values
        $values = array();
        foreach($info AS $field => $v)
        {
            $values[$field] = urlencode($info[$field]);
        }

        //url-ify the data for the POST
        $fields_string = NULL;
        ksort($values);
        foreach($values as $key => $value)
        {
            $fields_string .= $key.'='.$value.'&';
        }
        $fields_string = substr($fields_string,0,-1);
        //open connection
        $ch = curl_init();

        //set the url, number of POST vars, POST data
        curl_setopt($ch,CURLOPT_URL,$post_url);
        curl_setopt($ch,CURLOPT_POST,TRUE);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
        curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);
        curl_setopt($ch,CURLOPT_SSLVERSION,3);

        //execute post
        $result = curl_exec($ch);

        echo $result;

    }

    function get_cverify($info,$secretKey)
    {

        $pop = "";
        $ipnFields = array();
        foreach ($info as $key => $value) {
            if ($key == "cverify") {
                continue;
            }
            $ipnFields[] = $key;
        }

        $tf = NULL;
        foreach ($ipnFields as $field)
        {
            if($field == 'ccustname')
            {
                $info[$field] = urldecode($info[$field]);
            }
            // un-escaped before being appended to $pop
            $pop = $pop . $info[$field] . "|";
            $tf .= "$field|";
        }
        $pop = $pop . $secretKey;

        $calcedVerify = sha1(mb_convert_encoding($pop, "UTF-8"));
        $calcedVerify = strtoupper(substr($calcedVerify,0,8));
        return $calcedVerify;
    }

    test_ipn();

Desktop Software Check License 

Required to determine the status of a License Engine license key.

  • Parameters

    • license (required, string, LE-933847dBF88) … Your users license key
    • item_name (required, string, sample-software) … Your software slug
    • domain (optional, string, some-site.com) … Your users domain name
    • hash (optional, string, somehash) … Your hardware hash
    • product_id (required, string, 123456…Your product id
    • action = check_license (required, string, activate_license) … Desired action

      • Values
        • activate_license
        • check_license

Resources 

/licenses/b/

Check the status of a license key or activate a license key.

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "license": "valid",
        "item_name": "some-item",
        "message": "message"
    }
    

Web Based Software Check License 

Required to determine the status of a License Engine license key.

  • Parameters

    • license (required, string, LE-933847dBF88) … Your users license key
    • item_name (required, string, sample-software) … Your software slug
    • domain (optional, string, some-site.com) … Your users domain name
    • product_id (required, string, 123456…Your product id
    • action = check_license (required, string, activate_license) … Desired action

      • Values
        • activate_license
        • check_license

Resources 

/licenses/a/

Check the status of a license key or activate a license key.

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "license": "valid",
        "item_name": "some-item",
        "message": "message"
    }
    

Check License Sample Code 

The code below is just a sample of how a Post can be made to LicenseEngine.

<?php

//test key = LE-5505f0bf7db01

//test product = 18922015

//this code version requires that you create a file called data.txt in the includes folder, but of course that can be changed.

if(isset($_POST['save_key']))
{

    //check license key in License Engine
    check_remote_license($_POST['license_key']);

}


function check_remote_license($license_key)
{

    //url for web based software
    $url = 'http://www.licenseengine.com/licenses/a/?action=check_license&item_name=sample-code-product&license='.$license_key.'&domain='.$_SERVER['SERVER_NAME'].'&product_id=18922015';

    $json = file_get_contents($url);

    $obj = json_decode($json);

    $keyFile = fopen("includes/data.txt","w") or die("Unable to open file!");

    //set timestamp and licnese key in data.txt
    $data = array('timestamp' => time(),'license_key' => $license_key);

    fwrite($keyFile,serialize($data));

    fclose($keyFile);

    //if the licnese key is valid, return true;
    if($obj->license_key=='valid')
    {
        return TRUE;
    }

    return FALSE;
}


function check_license()
{

    $keyFile = file_get_contents('includes/data.txt');

    $data = unserialize($keyFile);

    //check to see if timestamp is > 24 hours old
    if($data['timestamp']>time()-24*60*60)
    {
        //timestamp is less that 24 hours old
        return TRUE;
    }
    else
    {
        //timestamp is greater, so call license engine again and check status
        check_remote_license($data['license_key']);
    }

}

if(!check_license())
{
    ?>

    <div style="padding: 15px; font-size: 14px;; background-color: #e6e6e6;width:390px;margin: 20px 0">
        <div class="alert alert-error" style="margin-bottom:5px;padding:5px 0;color:red;">
            Your License Key is NOT Valid.
        </div>
        <h4 style="margin-bottom:5px;margin-top:5px;">Registration</h4>

        <form method="post" action="index.php" enctype="multipart/form-data" id="license_key">

            <div class="button-container">
                <input style="height: 35px; border-width: 1px; border-color: #CCC; border-style: solid; padding: 8px;" id="license_key" name="heat_map_options[license_key]" type="text" class="input-xlarge" placeholder="Enter Your License Key" value=""/>
                <input style="-webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0px; font-family: Arial; color: #ffffff; font-size: 15px; background: #3498db; padding: 8px 20px 10px 20px; text-decoration: none; border-style: none; " type="submit" value="Save" id="save_button"/>

                <p style="margin-top:5px;">Can't find your key? Login to
                    <a href="//www.licenseengine.com/my-keys" target="_blank">License Engine</a> to retrieve your key.
                </p>
            </div>
        </form>
        <div style="margin-top:10px;margin-left:185px;">
            <img src="//www.licenseengine.com/assets2/img/licensingpoweredbyLE.png"></div>
    </div>


    <?php
    die();
}

?>

<h1>Your software is here!</h1>

Retrieve License 

Required to determine the status of a License Engine license key.

  • Parameters

    • email (required, string, user@email.com) … Your users email
    • product_id (required, string, 55555) … Your License Engine product id

Resources 

/api/v1/retrieve/{product_id}/{email}

Check a license key by email and product ID.

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "license_key": "SomeLicenseKey",
    }
    

Retrieve License Sample Code 

The code below is just a sample of how a request can be made to LicenseEngine.

<?php
    $url = 'http://www.licenseengine.com/api/v1/retrieve/product_id/email@sample.com';
    $username = 'YOUR_LICENSEENGINE_USERNAME';
    $password = 'YOUR_LICENSEENGINE_PASSWORD';

    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
    curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
    $output = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);


    print_r($output);
?>

Set License Status 

Set the status of a License Key

  • Parameters

    • license_key (required, string, 8E814086TU925310Y) … Your users license key
    • status (required, string, 1 or 2) … 1 for Active, 2 for Inactive

Resources 

/api/v1/set_license_status/{license_key}/{status}

Set the status of a license key by license key.

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "License key deactivated/activated"
    }
    

Set Instance Status 

Set the status of an instance. Useful if you want to remove an instance when a user removes your software from their machine.

  • Parameters

    • license_key (required, string, 8E814086TU925310Y) … Your users license key
    • status (required, string, 1 or 2) … 1 for Active, 2 for Inactive

Resources 

/api/v1/set_instance_status/{hash}/{status}

Set the status of instance by machine hash.

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "Instance deactivated/activated"
    }
    

Set Expiration Date 

Set the expiration date of a license key.

  • Parameters

    • license_key (required, string, 8E814086TU925310Y) … Your users license key
    • date (required, string, 2014-02-01 08:09:00) … Your expiration date

Resources 

/api/v1/set_expiration_date/{license_key}/{date}

Set the status of instance by machine hash.

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "Expiration Date Set"
    }
    

Show License 

Shows all data for a specified License Key.

  • Parameters

    • license_key (required, string, 8E814086TU925310Y) … Your users license key

Resources 

/api/v1/show/{license_key}

Shows all data for a specified License Key.

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
            "data":
            {
                "id": 206,
                "plugin_id": 584422,
                "product_id": "19995958",
                "name": "User Name",
                "email": "email@user.com",
                "license_key": "LE-553e329d99p0",
                "expires": "2014-02-01 08:09:00",
                "active": 1,
                "reason": "",
                "notes": "test key",
                "domain_limit": 2,
                "created_at": "2015-04-27 12:59:03",
                "updated_at": "2015-04-27 14:38:23"
            }
    }
    

Show License Stats 

Shows all stats for a specified License Key, ie., software_instance_count.

  • Parameters

    • license_key (required, string, 8E814086TU925310Y) … Your users license key

Resources 

/api/v1/show/stats/{license_key}

Shows all data for a specified License Key.

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
            "data":
             {
                "id": 9,
                "plugin_id": 9,
                "product_id": "156699",
                "name": "bob jones",
                "email": "name@example.com",
                "license_key": "LE-999999999999",
                "expires": null,
                "active": 1,
                "reason": "",
                "notes": "test",
                "created_at": "2014-11-05 19:41:20",
                "updated_at": "2015-03-02 22:18:50",
                "user_id": 1,
                "software_name": "Software Name",
                "software_description": "Software Description",
                "software_slug": "software-slug",
                "software_status": 1,
                "software_domain_limit": 2,
                "software_instance_count": 4
                }
    }
    

Transfer License Key 

Transfer a License Key from one product to another

  • Parameters

    • license_key (required, string, 8E814086TU925310Y) … Your users license key
    • product_id (required, string, 100000) … Your new product id

Resources 

/api/v1/transfer/license/{license_key}/product/{product_id}

Shows all data for a specified License Key.

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "data": {
            "id": 9,
            "plugin_id": 9,
            "product_id": "1000000",
            "name": "Russell Hudson",
            "email": "russell@smallfri.com",
            "license_key": "8E814086TU925310Y",
            "expires": null,
            "active": 1,
            "reason": null,
            "notes": null,
            "domain_limit": 2,
            "created_at": "2014-11-05 19:42:30",
            "updated_at": "2015-06-17 20:45:31"
        }
    }
    

Error Codes 

Possible Error Codes

Code Message Meaning
1001 Missing item_name 1001 The item name value is not included in your GET parameters.
1002 License Key Not Found 1002 The license key was not found in LicenseEngine.
1003 Product Not Found 1003 The product id was not found in LicenseEngine.
1004 Software Not Found 1004 The software was not found in LicenseEngine. Check the product id.
1005 User Account Not Found 1005 Your user account was not found in LicenseEngine. Check the product id.
1006 License Expired 1006. IP & Domain Recorded: The license key has expired and is no longer active.
1007 License Check Failed 1007. IP & Domain Recorded: The license key is inactive in LicenseEngine.
1008 JVZoo Status Failed 1008 The JVZoo Transaction has a status that is not Complete. This transaction may have been refunded.
1009 Wrong Product ID 1009 The product id included in the GET parameters is not associated with this software.
1010 License Check Passed 1010 License is vaild and active.
1011 Over allowed instances 1011 This license key has reached its limit of allowed activations. This can be at the software level or the license level.
1012 License Key Not Found 1012 The license key was not found in LicenseEngine.
1013 Key Not Activated - Run activate_license First The license key is not active, use action=activate_license first.
1014 License Key Active 1014 The license key is valid.
2001 Missing item_name 2001 The item name value is not included in your GET parameters.
2002 License Key Not Found 2002 The license key was not found in LicenseEngine.
2003 Product Not Found 2003 The product id was not found in LicenseEngine.
2004 Software Not Found 2004 The software was not found in LicenseEngine. Check the product id.
2005 User Account Not Found 2005 Your user account was not found in LicenseEngine. Check the product id.
2006 License Expired 2006. IP & Domain Recorded: The license key has expired and is no longer active.
2007 License Check Failed 2007. IP & Domain Recorded: The license key is inactive in LicenseEngine.
2008 JVZoo Status Failed 2008 The JVZoo Transaction has a status that is not Complete. This transaction may have been refunded.
2009 Wrong Product ID 2009 The product id included in the GET parameters is not associated with this software.
2020 License Check Passed 2020 License is vaild and active.
2011 Over allowed instances 2011 This license key has reached its limit of allowed activations. This can be at the software level or the license level.
2012 License Key Not Found 2012 The license key was not found in LicenseEngine.
2013 Key Not Activated - Run activate_license First The license key is not active, use action=activate_license first.
2014 License Key Active 2014 The license key is valid.
2015 Hash Passed Check 2015 The hash matches the users machine hash.

Generated by aglio on 11 Sep 2015