How to configure your own URL for agent and/or feature purchase or account upgrade

Hosted accounts configuration
Step 1: configuration setup in your reseller panel
Go to Menu->Configuration->Hosted accounts
In case of hosted accounts, you can configure external reseller URL - this URL will be used as the main URL on "My account" screen in every hosted account.
You can even use these variables in URL to identify your customer:
{$accountid} - id of customer account
{$totalPrice} - price computed for new variation selected by customer during upgrade
{$usdTotalPrice}- same as before but always in USD
{$totalAgents} - total active agents count in new variation
{$variation}- id of new variation selected by customer during upgrade
Example url:
https://www.mypages.com/upgrade.php?accountid={$accountid}&totalAgents={$totalAgents}&upgradeTo={$variation}
 
Setup feature/agent purchase url:
go menu->Configuration->Owned licenses
Here you can setup agent/feature purchase page.
agents URL can contain these variables:
{$totalPrice} - total price for one agent (can be in local currency)
{$usdTotalPrice} - same as above but in USD
{$accountid} - id of customer hosted account
{$variation} - id of customer active variation
Example URL:
https://www.mypages.com/byuagents.php?accountid={$accountid}&price={$totalPrice}&variation={$variation}
 
Note: You will handle exact agents count on your purchase page by some appropriate mechanism.
 
feature URL can contain these variables:
{$totalPrice} - total price for one agent (can be in local currency)
{$usdTotalPrice} - same as above but in USD
{$accountid} - id of customer hosted account
{$variation} - id of customer active variation
{$featuresList} - list of features that should be activated. This list has special format:
code:feature_code,price:price_in_usd,localPrice:price_in_local_currency|code:feature_code2,price:price_in_usd2,localPrice:price_in_local_currency2|...
 
 
Step 1/a (optional) configure your listening PHP script
Go to Menu->Configuration->URL notifications
Enter valid URL there and hit save.
 
Note: PHP script should be listening (be accessible using common browser) at this URL. Here is an example:
<?php
//basic listener which will log every received message into log file
$post_data = file_get_contents('php://input');
file_put_contents('recievedData.log', 'Recieved at ' . time() . ': ' . var_export($post_data, true)) . "\n", FILE_APPEND);
?>
 
Step 2: controlling hosted accounts using REST API
Go to Menu->Configuration->Api key to obtain your REST API key.
Now you can use various API calls to control your hosted accounts (complete API reference). You can also listen to various notifications about your hosted accounts.
 
Example use:
You want to sell feature "Branding free" to your hosted customers using your customers.
Follow instructions in step 1 and step 1/a. Now the customer wants to acstep 1step 1step 1step 1step 1step 1tivate Branding free feature in his account:
 
Customer will be redirected to URL you entered in step 1 after clicking on the activation link. Redirect URL should look like this:
https://www.mypages.com/byuagents.php?accountid=g4df56g4df56g4d654gsd56g&price=99&variation=d5s8a5d4&featuresList=code:laBrandingFree,price:199,localPrice:199
 
Now you should offer him some form where he can confirm his purchase and/or can add more features if possible. Example:
 
After that, you can analyze customer preferences and use our REST API call to adjust his account.
Here is an example code that will add one feature to hosted account:
<?php
//EXAMPLE code: add new addon to hosted account
$myApiKey = 'your_API_key';
$myResellerIdentifier = urlencode('reseller@example.com');
 
$service_url = 'https://members.qualityunit.com/api/resellers/'.$myResellerIdentifier.'/accounts/{put_customer_account_id_here}/addons.xml&apikey=' . $myApiKey;
 
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
 
$data = array(
        'valid_to' => '2015-11-10 09:08:07',
        'addon_id' => '{put_valid_addon_id_here}');
 
curl_setopt($curl, CURLOPT_POSTFIELDS,http_build_query($data));
$curl_response = curl_exec($curl);
if ($curl_response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('error occured during curl exec. Additioanl info: ' . var_export($info));
}
header('Content-type: ' . curl_getinfo($curl, CURLINFO_CONTENT_TYPE));
curl_close($curl);
echo $curl_response;
?>
 
Note: your reseller account will be charged for feature price after this call!
 
Standalone licenses setup
Step 1: configuration setup in your reseller panel
You should set up only feature/agent purchase URL. 
Optionally you can setup also External reseller URL - this URL will be used as upgrade link if the customer will be forced to upgrade (if he has a hard limit for agents count in his license).
go menu->Configuration->Owned licenses
(see description above in hosted setup...)
But there is one difference:
in this case, you do not have accounted identifier of the customer account.
You can use variable {$licenseCode} instead.
 
And also REST API call to activate feature will be different. Example code:
<?php
//EXAMPLE code: add new addon to standalone license
$myApiKey = 'your_API_key';
$myResellerIdentifier = urlencode('reseller@example.com');
 
$service_url = 'https://members.qualityunit.com/api/resellers/'.$myResellerIdentifier.'/licenses/{put_customer_license_id_here}/addons.xml&apikey=' . $myApiKey;
 
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
 
$data = array(
        'valid_to' => '2015-11-10 09:08:07',
        'addon_id' => '{put_valid_addon_id_here}');
 
curl_setopt($curl, CURLOPT_POSTFIELDS,http_build_query($data));
$curl_response = curl_exec($curl);
if ($curl_response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('error occured during curl exec. Additioanl info: ' . var_export($info));
}
header('Content-type: ' . curl_getinfo($curl, CURLINFO_CONTENT_TYPE));
curl_close($curl);
echo $curl_response;
?>
 
This call currently supports only one attribute type:
max_agents - maximum agents allowed by license
 
 
×