Plan Manager - SellPlan

Version: 1

HCnix Build: 3.00 and later

API Build: 1.00 and later

 

Plan Manager - SellPlan sells provided plan to a specified user. This web service call can be made as http://your-domain.com/HCnixAPI/PlanManager.php?op=SellPlan.

 

Input Parameters

 

Output Parameters

 

 

Sample Optional Parameters

 

<Parameters>

<Parameter Name = "Language">French</Parameter>

</Parameters>

 

Sample SOAP Request

 

 

POST /HCnixAPI/PlanManager.php HTTP/1.1

Host: your-domain.com

Content-Type: text/xml; charset=utf-8

Content-Length: length

SOAPAction: "http://tempuri.org/SellPlan"

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

  <soap:Body>

    <SellPlan xmlns="http://tempuri.org/">

      <HostUserName>host</HostUserName>

      <HostPassword>host123</HostPassword>

      <PlanName>MyPlan</PlanName>

      <CustomerName>john</CustomerName>

      <Quantity>1</Quantity>

      <OwnerName>abc</OwnerName>

      <OptionalParam>xml</OptionalParam>

    </SellPlan>

  </soap:Body>

</soap:Envelope>

 

 

Sample HTTP Request

 

 

POST /HCnixAPI/PlanManager.php/SellPlan HTTP/1.1

Host: your-domain.com

Content-Type: application/x-www-form-urlencoded

Content-Length: length

HostUserName=host&HostPassword=host123&PlanName=MyPlan&CustomerName=john&

Quantity=1&OptionalParam=xml

 

 

Sample PHP Code

 

 

function SellPlan($strHostUserName, $strHostPassword, $strPlanName, $strCustomerName, $strQuantity, $strOwnerName, $OptionalParam)

{

       $response="";

       $soapPacket = "<?xml version=\"1.0\" encoding=\"utf-8\"?>

       <soap:Envelope

           xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"

           xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"

           xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">

           <soap:Body>

                 <SellPlan xmlns=\"http://tempuri.org/\">

                  <HostUserName>$strHostUserName</HostUserName>

                  <HostPassword>$strHostPassword</HostPassword>

                  <PlanName>$strPlanName</PlanName>

                  <CustomerName>$strCustomerName</CustomerName>

                  <Quantity>$strQuantity</Quantity>

                  <OwnerName>$strOwnerName</OwnerName>      

                  <OptionalParam>$OptionalParam</OptionalParam>

                 </SellPlan>

            </soap:Body>

        </soap:Envelope>";

        // where $domain_name is where HCnix APIs are installed

        $fp = fsockopen($domain_name, 80, $errNo, $errString, 90);

        if($fp)  

        {

            // where $name is the Virtual Directory name for HCnix APIs

            $header = "POST /$name/UserManager.php HTTP/1.1\r\n";

            $header .= "HOST: $domain_name\n";

            $header .= "Content-Type: text/xml;charset=\"utf-8\"\r\n";

            $header .= "Content-Length: ".strlen($soapPacket)."\r\n\r\n";

            fwrite($fp, $header.$soapPacket);

        

            while (true)

            {  

                  $buffer = fread($fp, 1000);

                  if( $buffer != "" )

                      $response .= $buffer;  

                  if(strstr($response, '</SOAP-ENV:Envelope>') || $buffer == "" )  

                      break;

                  $buffer = "";  

              }

            fclose($fp);

            $result = explode("<?xml",$response);

            return "<?xml".$result[1];

        }

}

 

 

Sample Response

 

 

<Response>

    <Method>SellPlan</Method>

    <Status>false</Status>

    <ErrorCode>70100060</ErrorCode>

    <ErrorDescription>You have not enough resource quota to sell this plan.</ErrorDescription>

    <Result>

        <ResultReport xmlns="">

            <ViolatedResources>

                <RecordRow>

                    <ResourceName>User Accounts</ResourceName>

                    <DesiredQuantity>Unlimited</DesiredQuantity>

                    <AllocatedQuantity>10</AllocatedQuantity>

                    <SoldQuantity>3 + 1 (Reseller's)</SoldQuantity>

                    <RemainingQuantity>6</RemainingQuantity>

                 </RecordRow>

                  .......

                  .......

                  .......

            </ViolatedResources>

        </ResultReport>

    </Result>

</Response>