Jump to content

DotNetPanel Addon Automation (Adding Only)


Dreamz

Recommended Posts

<?php
/**
* ActivateClientAddon DotNetPanel Edition
* This hook utilizes the DotNetPanel API and WHMCS hooks to provide an automated
* way to create addons (like dedicated IP addresses, extra bandwidth etc.) within
* DotNetPanel.
* 
* 
* @author Christopher York
* @name ActivateClientAddon
* @version 1.0.0
*/

/**
* DotNetPanel API username / password / Enterprise Server URL
* Since WHMCS does not directly provide this information we need to provide this.
* Enterprise server, remember to include the trailing slash (/).
*/
define('DNP_API_USERNAME', 'serveradmin');
define('DNP_API_PASSWORD', 'password');
define('DNP_ES_URL', 'http://127.0.0.1:9002/');

/**
* WHMCS => DNP Addon IDs
* Change this to match your WHMCS Addon => DNP Addon ID
*/
$addon_ids = array(1 => 15, 2 => 16, 4 => 16, 5 => 17);

/*************************************************\
* NOTHING TO EDIT BELOW...
\*************************************************/

/**
* Issues the remote API calls to DotNetPanel to handle the addon automation
*
* @param Array $params Parameters provided by WHMCS (id, userid, serviceid, addonid)
* @return Null
*/
function activate_client_addon_purchase($params)
{
global $addon_ids;

// Insure we have a DNP Addon for the WHMCS request
if (!array_key_exists($params['addonid'], $addon_ids))
{
	return;
}

// Get the username associated with the addons parent WHMCS product
$result = select_query('tblhosting', 'username', array('userid' => $params['userid'], 'id' => $params['serviceid']));
$data = mysql_fetch_array($result);
$username = $data['username'];

// Get the DNP userid associated with the WHMCS product / username
$sClient = new SoapClient(DNP_ES_URL . 'esusers.asmx?WSDL', array('login' => DNP_API_USERNAME, 'password' => DNP_API_PASSWORD));
$result = (array)($sClient->GetUserByUsername(array('username' => $username))->GetUserByUsernameResult);
$userId = $result['UserId'];

// Get the DNP package id associated with the clients WHMCS product
$sClient = new SoapClient(DNP_ES_URL . 'espackages.asmx?WSDL', array('login' => DNP_API_USERNAME, 'password' => DNP_API_PASSWORD));
$result = (array)($sClient->GetMyPackages(array('userId' => $userId))->GetMyPackagesResult->PackageInfo);
$packId = $result['PackageId'];

// Assign the addon to the clients hostingspace
$sClient = new SoapClient(DNP_ES_URL . 'espackages.asmx?WSDL', array('login' => DNP_API_USERNAME, 'password' => DNP_API_PASSWORD));
$sClient->AddPackageAddonById(array('packageId' => $packId, 'addonPlanId' => $addon_ids[$params['addonid']], 'quantity' => 1));
}

/**
* Register the add-on hook with WHMCS
*/
add_hook('AddonActivation', 1, 'activate_client_addon_purchase');

 

create a file called activate_addon.php and place this into includes/hooks and setup the valudes about the NOTHING TO EDIT BELOW... text.

 

Once a users purchases an addon WHMCS will initiate the activate_client_addon_purchase method and call the DNP API to assign the addon to the users hostingspace. This DOES NOT automate removal as DNP does not have a hook for this, however it will automate adding of the addons.

 

I have tested this with WHMCS 4.2.1 & DNP 2.8.14.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated