Пример #1
0
function makeDomainPayment($func_domainid, $type = "")
{
    global $whmcs;
    $result = select_query("tbldomains", "", array("id" => $func_domainid));
    $data = mysql_fetch_array($result);
    $userid = $data['userid'];
    $orderid = $data['orderid'];
    $registrationperiod = $data['registrationperiod'];
    $registrationdate = $data['registrationdate'];
    $nextduedate = $data['nextduedate'];
    $recurringamount = $data['recurringamount'];
    $domain = $data['domain'];
    $paymentmethod = $data['paymentmethod'];
    $registrar = $data['registrar'];
    $status = $data['status'];
    $year = substr($nextduedate, 0, 4);
    $month = substr($nextduedate, 5, 2);
    $day = substr($nextduedate, 8, 2);
    $newnextduedate = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year + $registrationperiod));
    update_query("tbldomains", array("nextduedate" => $newnextduedate), array("id" => $func_domainid));
    $domaintype = substr($type, 6);
    $domainparts = explode(".", $domain, 2);
    $sld = $domainparts[0];
    $tld = $domainparts[1];
    $params = array();
    $params['domainid'] = $func_domainid;
    $params['sld'] = $sld;
    $params['tld'] = $tld;
    if (!function_exists("getRegistrarConfigOptions")) {
        require ROOTDIR . "/includes/registrarfunctions.php";
    }
    if ($domaintype == "Register" || $domaintype == "Transfer") {
        $result = select_query("tbldomainpricing", "autoreg", array("extension" => "." . $tld));
        $data = mysql_fetch_array($result);
        $autoreg = $data[0];
        if ($status == "Pending") {
            if (getNewClientAutoProvisionStatus($userid)) {
                if ($autoreg) {
                    update_query("tbldomains", array("registrar" => $autoreg), array("id" => $func_domainid));
                    $params['registrar'] = $autoreg;
                    if ($domaintype == "Register") {
                        logActivity("Running Automatic Domain Registration on Payment", $userid);
                        $result = RegRegisterDomain($params);
                        $emailmessage = "Domain Registration Confirmation";
                    } else {
                        if ($domaintype == "Transfer") {
                            logActivity("Running Automatic Domain Transfer on Payment", $userid);
                            $result = RegTransferDomain($params);
                            $emailmessage = "Domain Transfer Initiated";
                        }
                    }
                    $result = $result['error'];
                    if ($result) {
                        sendAdminMessage("Automatic Setup Failed", array("client_id" => $userid, "domain_id" => $func_domainid, "domain_type" => $domaintype, "domain_name" => $domain, "error_msg" => $result), "account");
                        if ($whmcs->get_config("DomainToDoListEntries")) {
                            if ($domaintype == "Register") {
                                addToDoItem("Manual Domain Registration", "Client ID " . $userid . " has paid for the registration of domain " . $domain . " and the automated registration attempt has failed with the following error: " . $result);
                                return null;
                            }
                            if ($domaintype == "Transfer") {
                                addToDoItem("Manual Domain Transfer", "Client ID " . $userid . " has paid for the transfer of domain " . $domain . " and the automated transfer attempt has failed with the following error: " . $result);
                                return null;
                            }
                        }
                    } else {
                        sendMessage($emailmessage, $func_domainid);
                        sendAdminMessage("Automatic Setup Successful", array("client_id" => $userid, "domain_id" => $func_domainid, "domain_type" => $domaintype, "domain_name" => $domain, "error_msg" => ""), "account");
                        return null;
                    }
                }
                if ($whmcs->get_config("DomainToDoListEntries")) {
                    if ($domaintype == "Register") {
                        addToDoItem("Manual Domain Registration", "Client ID " . $userid . " has paid for the registration of domain " . $domain);
                        return null;
                    }
                    if ($domaintype == "Transfer") {
                        addToDoItem("Manual Domain Transfer", "Client ID " . $userid . " has paid for the transfer of domain " . $domain);
                        return null;
                    }
                }
            } else {
                logActivity("Automatic Domain Registration on Payment Suppressed for New Client", $userid);
                return null;
            }
        }
        if ($autoreg) {
            logActivity("Automatic Domain Registration Suppressed as Domain Is Already Active", $userid);
            return null;
        }
    } else {
        if ($status != "Pending" && $status != "Cancelled" && $status != "Fraud") {
            if ($whmcs->get_config("AutoRenewDomainsonPayment") && $registrar) {
                if ($whmcs->get_config("FreeDomainAutoRenewRequiresProduct") && $recurringamount <= 0 && !get_query_val("tblhosting", "COUNT(*)", array("userid" => $userid, "domain" => $domain, "domainstatus" => "Active"))) {
                    logActivity("Surpressed Automatic Domain Renewal on Payment Due to Domain Being Free and having No Active Associated Product", $userid);
                    sendAdminNotification("account", "Free Domain Renewal Manual Action Required", "The domain " . $domain . " (ID: " . $func_domainid . ") was just invoiced for renewal and automatically marked paid due to it being free, but because no active Product/Service matching the domain was found in order to qualify for the free domain offer, the renewal has not been automatically submitted to the registrar.  You must login to review & process this renewal manually should it be desired.");
                    return null;
                }
                logActivity("Running Automatic Domain Renewal on Payment", $userid);
                $params['registrar'] = $registrar;
                $result = RegRenewDomain($params);
                $result = $result['error'];
                if ($result) {
                    sendAdminMessage("Domain Renewal Failed", array("client_id" => $userid, "domain_id" => $func_domainid, "domain_name" => $domain, "error_msg" => $result), "account");
                    if ($whmcs->get_config("DomainToDoListEntries")) {
                        addToDoItem("Manual Domain Renewal", "Client ID " . $userid . " has paid for the renewal of domain " . $domain . " and the automated renewal attempt has failed with the following error: " . $result);
                        return null;
                    }
                } else {
                    sendMessage("Domain Renewal Confirmation", $func_domainid);
                    sendAdminMessage("Domain Renewal Successful", array("client_id" => $userid, "domain_id" => $func_domainid, "domain_name" => $domain, "error_msg" => ""), "account");
                    return null;
                }
            }
            if ($whmcs->get_config("DomainToDoListEntries")) {
                addToDoItem("Manual Domain Renewal", "Client ID " . $userid . " has paid for the renewal of domain " . $domain);
            }
        }
    }
}
Пример #2
0
     $paymentmethod = $data['paymentmethod'];
     $status = $data['status'];
     if (!$invoiceid) {
         exit("Invalid Invoice ID");
     }
     $clientsdetails = getClientsDetails($_SESSION['uid']);
 }
 $paymentmethod = WHMCS_Gateways::makesafename($paymentmethod);
 if (!$paymentmethod) {
     exit("Unexpected payment method value. Exiting.");
 }
 $result = select_query("tblhosting", "tblhosting.id,tblproducts.servertype", array("tblhosting.orderid" => $orderid, "tblhosting.domainstatus" => "Pending", "tblproducts.autosetup" => "order"), "", "", "", "tblproducts ON tblproducts.id=tblhosting.packageid");
 while ($data = mysql_fetch_array($result)) {
     $id = $data['id'];
     $servertype = $data['servertype'];
     if (getNewClientAutoProvisionStatus($_SESSION['uid'])) {
         logActivity("Running Module Create on Order");
         if (!isValidforPath($servertype)) {
             exit("Invalid Server Module Name");
         }
         include_once ROOTDIR . ("/modules/servers/" . $servertype . "/" . $servertype . ".php");
         $moduleresult = ServerCreateAccount($id);
         if ($moduleresult == "success") {
             sendMessage("defaultnewacc", $id);
         }
     }
     logActivity("Module Create on Order Suppressed for New Client");
 }
 loadGatewayModule($paymentmethod);
 if ($invoiceid && $status == "Unpaid" && function_exists($paymentmethod . "_orderformcheckout")) {
     $params = getGatewayVariables($paymentmethod, $invoiceid, $total);