Example #1
0
/**
 * Transfer a domainname with all of the parameters
 * given in $params.
 * @param $params
 * @return mixed
 */
function hostcontrol_TransferDomain($params)
{
    $api_client = new HostControlAPIClient(HostControlHelper::getApiUrl($params), $params['ApiKey']);
    $domainname = strtolower($params["sld"] . "." . $params["tld"]);
    /* Get or create HostControl customer ID */
    try {
        $hostcontrol_customer_id = HostControlHelper::get_or_create_hostcontrol_customer_id($params, $api_client);
    } catch (HostControlHelperError $e) {
        return array('error' => $e->getMessage());
    }
    $interval = $params["regperiod"] * 12;
    $privacy_protect = empty($params["idprotection"]) ? false : true;
    $authcode = empty($params["transfersecret"]) ? '' : $params["transfersecret"];
    $domain_id = $params["domainid"];
    try {
        $transfer = $api_client->domain->transfer($hostcontrol_customer_id, $domainname, $authcode, $interval, $privacy_protect);
    } catch (HostControlAPIClientError $e) {
        $request = array($hostcontrol_customer_id, $domainname, $authcode, $interval, $privacy_protect);
        HostControlHelper::debugLog($params, 'transfer-domain', $request, $e);
        return array('error' => $e->getMessage());
    }
    HostControlHelper::store_transfer_id($domain_id, $transfer->id);
    return true;
}