Dreamz Posted April 17, 2010 Share Posted April 17, 2010 <?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. 0 Quote Link to comment Share on other sites More sharing options...
apignard Posted April 17, 2010 Share Posted April 17, 2010 thanks, will be usefull 0 Quote Link to comment Share on other sites More sharing options...
Dreamz Posted April 17, 2010 Author Share Posted April 17, 2010 Not a problem, It has already been used on my end quite a few times and worked flawlessly. Only issue with it though however is for adding items like dedicated IP addresses, you still must allocate IP addresses within DNP. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.