Dike Licensing Platform

Author Documentation

Intro & Requirements

First of all, thank you for choosing and trusting Dike to grow together!
This documentaion will guide you through the few steps necessary to empower your products with the Dike licenses manager platform.

Dike is mainly addressed to WordPress products, however you could use it also for other products (eg. javascript plugins) to take advantage of its licenses and support entitlement tracking.

As mandatory requirement, remember you must have a public web space where to upload a PHP file handling validation calls coming from your customer websites.

WHY?

In case Dike services stop (for whatever reason) or you want to stop using them, you will be able to address your customer validation calls and unlock products. Otherwise, Dike codes included in your products will block them and customers wouldn't be happy for sure.

To use the platform systems you must be able to read and manage PHP code. Knowing also HTML and CSS could be handy, but they shouldn't be a problem for any web developer!

The system works on any server running PHP (at least v5.5) and requires WordPress v4 and later.
No extra dependency. Neither jQuery.

First Steps

Once registered, you are moved to the admin dashboard. However your account needs to be set up in order to have the platform ready.

  1. Fill in your platform details:

    in there you must upload your logo, set an operative e-mail address and your color scheme. Optionally specify the support platform link and enable trial licenses. The custom CSS field's aim is to customize your platform aspect.

  2. Create product sections:

    sections are the natural solution to wrap products in case of bundles or specific sections. Even if you have only standalone products, you have to create them

  3. Insert your products:

    Finally insert your products (NB: remember to use referral links!)

Once you do this, the platform will be ready to be used!
Your personal URL is: https://your-username.dikelicensing.com

Remember all Envato calls are signed with your username and app token you entered in the registration phase.
Be careful to not delete it!

Customers Registration

Your customers must be uniquely addressed to your platform URL: it will autonomously handle registration and login.

Here are some infos about the process, in case you get related help requests.

All the e-mails listed in this documentation will be sent using the address you specified in the "Operative e-mail address"

  1. They will need to insert their Envato username, an e-mail and a purchase code related to one of your products
  2. A first e-mail with an e-mail address validation token will be sent, to be sure it truly exists
  3. Once e-mail has been verified, the user will be successfully added to the database and a login token will be e-mailed

In fact, to guarantee the maximum security level, the login system uses a bank-like numerical token expiring in an hour.
No concurrent sessions are allowed.

Customer Dashboard

Everything is projected to be extremely straightforward and easy also for the "most problematic" customers you might have.
Here's the explaination taking LCweb as example:

user dashboard

  1. as first user will be prompted to select a product section
  2. User can add new ones pressing the "plus" button
  3. Each stored license shows the purchase date and the support entitlement status, plus validation tokens
  4. Aside of product's name user can find useful links (new license purchase, product page, changelog, etc)
  5. (optional) Linked buttons to your main and support websites
  6. Expired support entitlements are directly notified
  7. If no license is added, the product block shows a button linked to the trial license request (obviously only if you allow it)
  8. Button launching a lightbox showing the account management form

WP Products Integration

Integrating Dike, your customers will need to follow the validation process in order to get the activation token and use your product. Remember to create a dedicated chapter in your product's documentation to guide them!

Dike creates a strictly personal WordPress dashboard panel related to your products, where customers have to activate their licenses.
Codes are strictly private and tailored on you. Head to this page and follow the step-by-step integration.

Validation Workflow

Is essential to understand how Dike works: you are about to lock your products forcing customers to perform additional steps.
Prior notes:

  1. The whole system complies with Envato license terms
  2. If you already have an automated updates system and are advertising it as "included in the product", you must add a footnote in the Envato description informing about automated updates being bound to support entitlement
  3. Locking down your products, you won't be able to have them published on Envato Elements
  4. is strongly suggested to create a new initial chapter in your products documentation, moving them to your Dike platform and explaining the simple steps to validate and unlock the product

How Dike works:

  1. Prevents your products usage unless user inserts a valid activation token in its website, strictly linked to the domain name
  2. Integrates the automated updates system, requiring a valid support entitlement
  3. Activation tokens are given by your platform and their usage its tracked

    • PRODUCTION: the definitive domain the license has been purchased for. To give a bit of flexibility, Dike allows a 6-months period to change it from its redemption date
    • STAGING: developer-friendly token usable only once for the staging website. Once redeemed cannot be chaged and lasts 6 months
    • OFFLINE: validation token reserved to extreme cases (eg. where customer server is not able to communicate with your endpoint or Dike server). Does not expire and does not unlock automated updates
  4. Validation calls are always performed from customer's website against your endpoint URL (for the reason explained in the introduction chapter) acting as a bridge to the Dike endpoint.
  5. You will be able to edit/wipe tokens and redemption dates related to a purchase code, directly in your admin dashboard

The validation engine supports also localhost setups.
It's mandatory to have this URL structure though: localhost:PORT-NUMBER (eg. https://localhost:8888/ )

Trial licenses

One of the best Dike advantages is the ability to give 7-days free trials to potential customers. This brings two big pros:

  • Attracts more customers
  • Discourages piracy (often illegal copies are used just to test the product)

Trias are totally optional though.
You can enable them in your Account Settings page. Is also possible to disable trials for specific products, in the "edit product" form.

Trial licenses can be requested in your Dike platform area: https://your-username.dikelicensing.com/trial-license-request.
You can also add specific URL parameters in order to pre-fill and/or disable fields, in order to create specific, straightforward, landing pages.

Parameter name Description
prod Selects a product by default. Use the Envato marketplace
domain Fills the domain field. Use a domain name (eg. dikelicensing.com)
email Fills the e-mail field. Use a valid e-mail address
disabled Disables one or more fields (to avoid data edit). Value is a string composed by one or more (comma split) field names. Available field names to use: prod, domain, email

Dike API

The Dike platform offers also an API endpoint to retrieve or validate specific data.
It is related to your account: https://your-username.dikelicensing.com/bridge.php

  • To call these API you must perform a POST call
  • The api_key parameter is mandatory. You can get it in your account settings page
  • The action parameter is mandatory and will specify which API is addressing the call.
    Check the following sub-chapters to know more
  • The endpoint returns an error string along with an HTTP error code or a JSON string containing response data

Here's an example using a cURL call, written as function to be quickly used 😉

<?php          
/*
 * Call Dike API endpoint 
 * @return (string|array) 
 *  - a string if cURL or data decode error is found
 *  - an array containing response data
 */
function call_dike_api($action, $params) {            
    $params = array_merge(
        array(
            "action"    => $action,
            "api_key"   => "YOUR-DIKE-API-KEY"
        ),
        $params
    );   
    

    $ch = curl_init();
    curl_setopt_array($ch, array(
        CURLOPT_URL             => "YOUR-DIKE-PLATFORM-URL/bridge.php",
        CURLOPT_RETURNTRANSFER  => true,
        CURLOPT_POSTFIELDS      => http_build_query($params),
        CURLOPT_TIMEOUT         => 5
    )); 

    if(curl_errno($ch) > 0) {
        return curl_error($ch);
    }
    
    // return response
    $response = @curl_exec($ch);
    if(curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200) {
        return (string)$response;
    }
    
    // decode
    $decoded_response = json_decode($response, true);
    
    if(json_last_error() !== JSON_ERROR_NONE) {
        return $response;
    }
    return $decoded_response;
}

Get customer licenses

Passing the customer username, returns an array containing licenses stored on your Dike platform, split by product ID

<?php
$params = array(
    "username" => "THE-CUSTOMER-USERNAME"
);
$response = call_dike_api("user_licenses", $params);

if(is_string($response)) {
    trigger_error($response); // error case
}
else {
    $licenses = $response["licenses"];
    
    /*
    data structure
    
    array(
        PRODUCT_ID_1 => array(
            array(.. license 1 data ..),
            array(.. license 2 data ..),
            array(.. license 3 data ..),
        ),
        PRODUCT_ID_2 => array(
            array(.. license 1 data ..),
            array(.. license 2 data ..),
            array(.. license 3 data ..),
        ),
    );
    */
}

Validate domain token

Passing the Envato product ID, domain and token customer username, returns specific license data or specific errors.
By default a successfull check also redeems the token on the checked token, use the related parameter to avoid this.

<?php
$params = array(
    "product_id"    => (int)THE-PRODUCT-ID,
    "domain"        => "THE-DOMAIN", // must be a clean domain, for "https://dikelicensing.com" you must use "dikelicensing.com"
    "token"         => "THE-TOKEN",
    "redeem_it"     => false, // to not redeem, otherwise true or omit the parameter
);
$response = call_dike_api("validate_domain_token", $params);

if(is_string($response)) {
    trigger_error($response); // error case
}
else {
    
    // error found
    if(!$response["response"]) {
        switch($response["err_code"]) {
                    
            case "token_not_found" : 
                echo  "Token not found"; 
                break;

           case "domain_not_matching" : 
                echo  "Token not linked to this domain"; 
                break;

            case "product_not_matching" : 
                echo  "Token not linked to this product"; 
                break; 

            case "token_expired" : 
                echo  "Token expired"; 
                break;

            default :
                echo "Unknown error ..";
                break;
        }     
    }

    
    // valid license data
    else {
        $license_data = $response;
    
        /*
        output structure

        array(
            "token_subj"    // production, staging or trial
            "support_expir" // support expiration datetime as returned by Envato API. Zero if token_subj == "trial"
            "token_exp"     // token expiration time (GMT) in case of trial or staging
            "username"      // if token_subj == "trial", it's the applicant e-mail, otherwise the customer username
        );
        */
    }
}

Validate user account token

Dike assigns a user token strictly related to the customer. It could come handy to perform extra operations such as quick user recognition just passing the username. For example it is used to register users in the LCweb support website just using username + token and being sure they already registered on the platform.

The account token can be found in the account management popup.
If validation is successful, returns also user e-mail.

The token is dynamic, don't worry if you notice it changing over time 😉

<?php
$params = array(
    "username"  => "THE-CUSTOMER-USERNAME",
    "token"     => "USER-ACCOUNT-TOKEN"
);
$response = call_dike_api("user_token_check", $params);

if(is_string($response)) {
    trigger_error($response); // error case
}
else {

    if(!$response["test_passed"]) {
        // wrong token
    }
    else {
        // valid token
        echo $response["user_email"];
    }
}

Search customers and related licenses

A true search engine for your customers and their data.
Please check carefully available parameters and the returned array structure

<?php
$params = array(
    "search"    => "whatever", // (string) search among username, e-mail or purchase code. Use the "*" char to target any user
    "page"      => 1, // (int) search results page 
    "params"    => array( // (array|false) defining search parameters array or use false to use default ones  
        
        "per_page"      => 10, // (int) how many users per page? (max 100)
        "orderby"       => "username", // (string) query sorting column. Available columns `username`, `signup_date`, `validation_date`, `purch_date`, `email`
        "order"         => "ASC", // (string) query sorting method (ASC or DESC)
        "product_ids"   => false, // (array|false) whether to restrict query to specific product IDs. If false is used, will search among all of your products
        "signup_range"  => false, // (array|false) start/end datetime ranges (at least one specified) or false to not restrict query by dike signup date
        "purch_range"   => array("2022-01-01 00:00:00", "2022-07-01 00:00:00"), // (array|false) start/end datetime ranges (at least one specified) or false to not restrict query by product purchase date
    ),
);
$response = call_dike_api("search_users", $params);

if(is_string($response)) {
    trigger_error($response); // error case
}
else {
    $tot_users = $response["tot_users"]; // (int) overall queried customers count
    $tot_pages = $response["tot_pags"]; // (int) search pages
    $curr_page = $response["curr_pags"]; // (int) returned page number
    
    $users = $response["users"]; // (array) query response

    /*
    data structure
    
    array(
        USER-ID => array(
            "username",
            "email",
            "signup_date", // GMT datetime related to customer registration on your platform
            
            "products" => array(
            
                PRODUCT_ID_1 => array(
                    array(.. license 1 data ..),
                    array(.. license 2 data ..),
                    array(.. license 3 data ..),
                ),
                PRODUCT_ID_2 => array(
                    array(.. license 1 data ..),
                    array(.. license 2 data ..),
                    array(.. license 3 data ..),
                ),
            )
        )
    );
    */
}

Need help?

If you need support over Dike systems or its integration