Example #1
0
/**
 * Requests a transfer for the specified domain
 * @param $params
 * @return array
 */
function domainbox_TransferDomain($params)
{
    $authParameters = getAuthParameters($params);
    $apiEndpoint = $params["TestMode"] ? "https://sandbox.domainbox.net/?WSDL" : "https://live.domainbox.net/?WSDL";
    $transferDomainParameters = new RequestTransferParameters();
    $transferDomainParameters->DomainName = $params["sld"] . '.' . $params["tld"];
    $nameServerParameters = new Nameservers();
    $nameServerParameters->NS1 = $params['ns1'];
    $nameServerParameters->NS2 = $params['ns2'];
    $nameServerParameters->NS3 = $params['ns3'];
    $nameServerParameters->NS4 = $params['ns4'];
    $nameServerParameters->NS5 = $params['ns5'];
    $registrant = new Contact();
    $registrant->City = $params['city'];
    $registrant->CountryCode = $params['country'];
    $registrant->Email = $params['email'];
    $registrant->Name = $params['firstname'] . ' ' . $params['lastname'];
    $registrant->Organization = $params['companyname'];
    $registrant->Street1 = $params['address1'];
    $registrant->Street2 = $params['address2'];
    $registrant->State = $params['state'];
    $registrant->Postcode = $params['postcode'];
    $localTelephone = str_replace(' ', '', $params['phonenumber']);
    if (substr($localTelephone, 0, 1) == "0") {
        $localTelephone = substr($localTelephone, 1);
    }
    $phonePrefix = '+' . $params['phonecc'] . '.';
    $registrant->Telephone = $phonePrefix . $localTelephone;
    $admin = new Contact();
    $admin->City = $params["admincity"];
    $admin->CountryCode = $params['admincountry'];
    $admin->Email = $params['adminemail'];
    $admin->Name = $params['adminfirstname'] . ' ' . $params['adminlastname'];
    $admin->Organization = $params['admincompanyname'];
    $admin->Street1 = $params['adminaddress1'];
    $admin->Street2 = $params['adminaddress2'];
    $admin->State = $params['adminstate'];
    $admin->Postcode = $params['adminpostcode'];
    $localTelephone = $params['adminphonenumber'];
    if (substr($localTelephone, 0, 1) == "0") {
        $localTelephone = substr($localTelephone, 1);
    }
    $admin->Telephone = $localTelephone;
    $billing = new Contact();
    $billing->City = $params["admincity"];
    $billing->CountryCode = $params['admincountry'];
    $billing->Email = $params['adminemail'];
    $billing->Name = $params['adminfirstname'] . ' ' . $params['adminlastname'];
    $billing->Street1 = $params['adminaddress1'];
    $billing->Street2 = $params['adminaddress2'];
    $billing->State = $params['adminstate'];
    $billing->Postcode = $params['adminpostcode'];
    $localTelephone = $params['adminphonenumber'];
    if (substr($localTelephone, 0, 1) == "0") {
        $localTelephone = substr($localTelephone, 1);
    }
    $billing->Telephone = $localTelephone;
    $tech = new Contact();
    $tech->City = $params["admincity"];
    $tech->CountryCode = $params['admincountry'];
    $tech->Email = $params['adminemail'];
    $tech->Name = $params['adminfirstname'] . ' ' . $params['adminlastname'];
    $tech->Street1 = $params['adminaddress1'];
    $tech->Street2 = $params['adminaddress2'];
    $tech->State = $params['adminstate'];
    $tech->Postcode = $params['adminpostcode'];
    $localTelephone = $params['adminphonenumber'];
    if (substr($localTelephone, 0, 1) == "0") {
        $localTelephone = substr($localTelephone, 1);
    }
    $tech->Telephone = $localTelephone;
    $contacts = new Contacts();
    $contacts->Registrant = $registrant;
    $contacts->Admin = $admin;
    $contacts->Billing = $billing;
    $contacts->Tech = $tech;
    $transferDomainParameters->Nameservers = $nameServerParameters;
    $transferDomainParameters->Contacts = $contacts;
    $error = "";
    try {
        $parameters = array('AuthenticationParameters' => $authParameters, 'CommandParameters' => $transferDomainParameters);
        $client = new SoapClient($apiEndpoint, array('soap_version' => SOAP_1_2));
        $result = $client->RequestTransfer($parameters);
        $result = $result->RequestTransferResult;
        if ($result->ResultCode == 100) {
            // We need to store the domainID that comes back in the database.
            $table = "mod_domainbox";
            $values = array("whmcsDomainID" => $params['domainid'], "domainboxDomainID" => $result->DomainId);
            insert_query($table, $values);
        } else {
            $error = $result->ResultMsg;
        }
    } catch (Exception $e) {
        $error = "There was an error communicating with Domainbox";
    }
    # If error, return the error message in the value below
    $values["error"] = $error;
    return $values;
}