Example #1
0
function emailIsUnsubscribed($email)
{
    $info = infoListEmail($email);
    return $info['cnt'] > 0;
}
 function check_errors()
 {
     if (!$this->transInfo['checkorcard']) {
         dieLog("Error. No Transaction Type Selected. " . serialize($this->transInfo));
     }
     if (!$this->transInfo['reference_number']) {
         $this->response['errormsg'] = "Invalid Reference Number";
     }
     if (!$this->transInfo['userId']) {
         $this->response['errormsg'] = "Invalid Merchant Id #" . $this->transInfo['userId'];
     }
     if (!$this->transInfo['checkorcard']) {
         $this->response['errormsg'] = "Invalid Payment Type";
     }
     if (!$this->verify_username($this->transInfo['td_username'])) {
         $this->response['errormsg'] = "Invalid Username '" . $this->transInfo['td_username'] . "': Only numbers and letters are allowed.";
     }
     if (!$this->transInfo['td_is_a_rebill']) {
         if ($this->transInfo['cs_enable_passmgmt'] && $this->transInfo['td_rebillingID'] != -1) {
             if (strlen($this->transInfo['td_username']) < 6) {
                 $this->response['errormsg'] = "Invalid UserName (Must be greater than 5 characters)";
             }
             if (strlen($this->transInfo['td_password']) < 6) {
                 $this->response['errormsg'] = "Invalid Password (Must be greater than 5 characters)";
             }
         }
         if (!$this->transInfo['name']) {
             $this->response['errormsg'] = "Invalid Name";
         }
         if (!$this->transInfo['surname']) {
             $this->response['errormsg'] = "Invalid Last Name";
         }
         if (!$this->transInfo['address']) {
             $this->response['errormsg'] = "Invalid Address";
         }
         if (!$this->transInfo['city']) {
             $this->response['errormsg'] = "Invalid City";
         }
         if (!$this->transInfo['phonenumber']) {
             $this->response['errormsg'] = "Invalid Phone Number";
         }
         if (!$this->transInfo['zipcode']) {
             $this->response['errormsg'] = "Invalid ZipCode";
         }
         if (!$this->transInfo['country']) {
             $this->response['errormsg'] = "Invalid Country";
         }
         if (!$this->transInfo['email']) {
             $this->response['errormsg'] = "Invalid Email";
         }
         $this->email_info = infoListEmail($this->transInfo['email']);
         if ($this->email_info['cnt'] > 0) {
             $this->response['errormsg'] = "Unsubscribed Email Address " . $this->transInfo['email'] . ".<BR>Reason: " . $this->email_info['ec_reason'] . ".<BR>Please use a different email address.";
         }
         if (!$this->transInfo['amount']) {
             $this->response['errormsg'] = "Invalid Charge Amount";
         }
         if (!$this->transInfo['ipaddress']) {
             $this->response['errormsg'] = "Invalid IP Address";
         }
         //			if(!$this->transInfo['productdescription']) $this->response['errormsg'] = "Invalid Product Description";
     }
     if (!$this->trans_mode) {
         $this->response['errormsg'] = "Invalid Payment Method.";
     }
     if ($this->transInfo['amount'] > $this->companyInfo['cd_max_transaction'] && $this->companyInfo['cd_max_transaction'] > 0) {
         $this->response['errormsg'] = "Invalid Charge Amount. Charges may be no higher than " . $this->companyInfo['cd_max_transaction'] . ".";
     }
     $ap_limit = intval($this->companyInfo['cd_approve_timelimit']);
     if ($ap_limit) {
         if ($this->fraud->check_previous_24h_approve(&$this->transInfo, $ap_limit)) {
             $this->response['errormsg'] = "Credit Card has been used in the last {$ap_limit} hour(s). The order was successful. If you did not get an order confirmation email, or you have any other questions about your order, please contact " . $_SESSION['gw_title'] . " Customer Service. Otherwise, please wait until {$ap_limit} hour(s) has passed since your last purchase.";
         }
     }
     if ($_SESSION['etel_trans_pending'] == true && !$this->transInfo['td_is_a_rebill']) {
         $this->response['errormsg'] = "Error: Transaction Pending. Please wait until current transaction has completed.";
     }
 }
 if (!$phone) {
     $errormsg = "Invalid Phone";
 }
 if (!$cvv2) {
     $errormsg = "Invalid cvv2";
 }
 if (!$cardtype) {
     $errormsg = "Invalid Card Type";
 }
 if (!$CCnumber) {
     $errormsg = "Invalid Credit Card";
 }
 if (!$yyyy || !$mm) {
     $errormsg = "Invalid Expiration Date";
 }
 $email_info = infoListEmail($email);
 if ($email_info['cnt'] > 0) {
     $errormsg = "Unsubscribed Email Address " . $email . ".<BR>Reason: " . $email_info['ec_reason'] . ".<BR>Please use a different email address.";
 }
 $acc_MD5 = md5($email . $password);
 $sql .= "`cs_customeraccount` set \n\tca_email = '{$email}', \n\tca_password='******',\n\tca_name='{$name}',\n\tca_surname='{$surname}',\n\tca_address='{$address}',\n\tca_address2='{$address2}',\n\tca_city='{$city}',\n\tca_state='{$state}',\n\tca_zipcode='{$zipcode}',\n\tca_country='{$country}',\n\tca_phone='{$phone}',\n\tca_cvv2='{$cvv2}',\n\tca_cardtype='{$cardtype}',\n\tca_CCNumber='{$CCnumber}',\n\tca_validto='{$validupto}',\n\tca_bankPhone='{$td_bank_number}'\t\n\t{$sql_end}";
 if ($_SESSION['ca_ID'] && $edit_mode) {
 }
 if (!$errormsg) {
     $result = mysql_query($sql);
     if (!$result) {
         $errormsg = "This Email Address is already in use, Please try a different one.";
     }
     $ca_ID = mysql_insert_id();
 }
 if ($errormsg) {
Example #4
0
function execute_transaction($transInfo, $mode)
{
    global $cnn_cs;
    global $etel_fraud_limit;
    $process_trans = new rates_fees();
    ignore_user_abort(true);
    set_time_limit(500);
    if (!$_SESSION['tmpl_language']) {
        $_SESSION['tmpl_language'] = 'eng';
    }
    $response = "";
    $response['errormsg'] = "No Error";
    $response['success'] = false;
    $gw_emails_sales = $_SESSION['gw_emails_sales'];
    foreach ($transInfo as $key => $data) {
        $transInfo[$key] = str_replace("'", "`", urldecode($data));
    }
    if (!$transInfo['checkorcard']) {
        dieLog("Error. No Transaction Type Selected. " . serialize($transInfo));
    }
    if (!$transInfo['reference_number']) {
        $transInfo['reference_number'] = genRefId("transaction", $transInfo['checkorcard']);
    }
    if (!$transInfo['td_subscription_id']) {
        $transInfo['td_subscription_id'] = genRefId("subscription", "S");
    }
    if (!$transInfo['reference_number']) {
        $response['errormsg'] = "Invalid Reference Number";
        return $response;
    }
    if (!$transInfo['userId']) {
        $response['errormsg'] = "Invalid Merchant Id #" . $transInfo['userId'];
        return $response;
    }
    if (!$transInfo['checkorcard']) {
        $response['errormsg'] = "Invalid Payment Type";
        return $response;
    }
    $sql = "SELECT * FROM `cs_companydetails` as c left join `etel_dbsmain`.`cs_company_sites` as s on s.cs_company_id = c.`userId` WHERE c.`userId` = '" . $transInfo['userId'] . "' and s.`cs_ID` = '" . $transInfo['td_site_ID'] . "'";
    $result = mysql_query($sql, $cnn_cs) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>Cannot execute query");
    if (mysql_num_rows($result) < 1 && $mode == "Live") {
        $response['errormsg'] = "Invalid Company/Website";
        return $response;
    }
    $companyInfo = mysql_fetch_assoc($result);
    ////// find a valid bank that the merchant is using that can process for the cardtype
    $bank_ids = merchant_getBanksForTransType($transInfo['userId'], $transInfo['cardtype']);
    if (sizeof($bank_ids) == 0) {
        $response['errormsg'] = "Invalid Card Type";
        return $response;
    }
    $company_bank_id = $bank_ids[0];
    $transInfo['bank_id'] = $company_bank_id;
    ///////////
    //todo:
    if (isset($transInfo['wallet_additional_funds'])) {
        //addtowallet $transInfo['wallet_additional_funds'] $transInfo['wallet_id'] $transInfo['wallet_pass']
    }
    //
    if (!$etel_fraud_limit) {
        $etel_fraud_limit = floatval($companyInfo['cd_fraudscore_limit']);
    }
    $sql = "SELECT b.* FROM `cs_bank` as b where b.bank_id = {$company_bank_id} ";
    $result = mysql_query($sql, $cnn_cs) or dieLog(mysql_errno() . ": " . mysql_error() . "User: "******", checkorcard=" . $transInfo['checkorcard']);
    if (mysql_num_rows($result) < 1 && $mode == "Live") {
        $response['errormsg'] = "Invalid Bank. Use Credit Card Ordering instead.";
        toLog('erroralert', 'misc', $sql . "User: "******", checkorcard=" . $transInfo['checkorcard']);
        return $response;
    }
    $bankInfo = mysql_fetch_assoc($result);
    if (!$bankInfo['bk_int_function'] && $mode == "Live") {
        $response['errormsg'] = "Invalid Bank Integration";
        return $response;
    }
    $transInfo['companyname'] = $companyInfo['companyname'];
    $transInfo['cs_enable_passmgmt'] = $companyInfo['cs_enable_passmgmt'];
    $transInfo['billing_descriptor'] = $bankInfo['bk_descriptor_visa'];
    if ($transInfo['cardtype'] == "Master") {
        $transInfo['billing_descriptor'] = $bankInfo['bk_descriptor_master'];
    }
    if (!$transInfo['td_is_a_rebill']) {
        if ($transInfo['cs_enable_passmgmt'] && $transInfo['td_rebillingID'] != -1) {
            if (strlen($transInfo['td_username']) < 6) {
                $response['errormsg'] = "Invalid UserName (Must be greater than 5 characters)";
                return $response;
            }
            if (strlen($transInfo['td_password']) < 6) {
                $response['errormsg'] = "Invalid Password (Must be greater than 5 characters)";
                return $response;
            }
        }
        if (!$transInfo['name']) {
            $response['errormsg'] = "Invalid Name";
            return $response;
        }
        if (!$transInfo['surname']) {
            $response['errormsg'] = "Invalid Last Name";
            return $response;
        }
        if (!$transInfo['address']) {
            $response['errormsg'] = "Invalid Address";
            return $response;
        }
        if (!$transInfo['city']) {
            $response['errormsg'] = "Invalid City";
            return $response;
        }
        if (!$transInfo['phonenumber']) {
            $response['errormsg'] = "Invalid Phone Number";
            return $response;
        }
        //if(!$transInfo['state']) {$response['errormsg'] = "Invalid State"; return $response;}
        if (!$transInfo['zipcode']) {
            $response['errormsg'] = "Invalid ZipCode";
            return $response;
        }
        if (!$transInfo['country']) {
            $response['errormsg'] = "Invalid Country";
            return $response;
        }
        if (!$transInfo['email']) {
            $response['errormsg'] = "Invalid Email";
            return $response;
        }
        $email_info = infoListEmail($transInfo['email']);
        if ($email_info['cnt'] > 0) {
            $response['errormsg'] = "Unsubscribed Email Address " . $transInfo['email'] . ".<BR>Reason: " . $email_info['ec_reason'] . ".<BR>Please use a different email address.";
            return $response;
        }
        if (!$transInfo['amount']) {
            $response['errormsg'] = "Invalid Charge Amount";
            return $response;
        }
        if (!$transInfo['ipaddress']) {
            $response['errormsg'] = "Invalid IP Address";
            return $response;
        }
        if (!$transInfo['productdescription']) {
            $response['errormsg'] = "Invalid Product Description";
            return $response;
        }
        //if(!$transInfo['td_product_id']) {$response['errormsg'] = "Invalid Transaction Tracking ID"; return $response;}
    }
    $credit_card_formatted = "Payment";
    $payment_type = "-";
    //Credit Card
    $trans_mode = NULL;
    //$process_trans->array_print($transInfo);
    if ($transInfo['checkorcard'] == 'H') {
        $trans_mode = 'cc';
        if ($transInfo['cardtype'] != 'wallet') {
            $credit_card_formatted = substr($transInfo['CCnumber'], -4, 4);
            $payment_type = "Credit Card (Last 4 Digits)";
            if (!$transInfo['td_is_a_rebill']) {
                if (!$transInfo['td_bank_number'] && $transInfo['country'] == "US") {
                    $response['errormsg'] = "Invalid Bank Phone Number";
                    return $response;
                }
                if (!$transInfo['CCnumber']) {
                    $response['errormsg'] = "Invalid Credit Card Number";
                    return $response;
                }
                if (!$transInfo['validupto']) {
                    $response['errormsg'] = "Invalid cvv Number";
                    return $response;
                }
            }
        }
    }
    //Check
    if ($transInfo['checkorcard'] == 'C') {
        $trans_mode = 'ch';
        $credit_card_formatted = substr($transInfo['bankaccountnumber'], -4, 4);
        $payment_type = "Account Number (Last 4 Digits)";
        if (!$transInfo['td_is_a_rebill']) {
            if (!$transInfo['bankname']) {
                $response['errormsg'] = "Invalid Name on Account";
                return $response;
            }
            if (!$transInfo['bankaccountnumber']) {
                $response['errormsg'] = "Invalid Bank Account Number";
                return $response;
            }
            if (!$transInfo['bankroutingcode']) {
                $response['errormsg'] = "Invalid Routing Code";
                return $response;
            }
        }
    }
    if (!$trans_mode) {
        $response['errormsg'] = "Invalid Payment Method. ";
        return $response;
    }
    if ($transInfo['amount'] > $companyInfo['cd_max_transaction'] && $companyInfo['cd_max_transaction'] > 0) {
        $response['errormsg'] = "Invalid Charge Amount. Charges may be no higher than " . $companyInfo['cd_max_transaction'] . ".";
        return $response;
    }
    if (!$transInfo['td_send_email'] == 'no') {
        $transInfo['td_send_email'] = 'yes';
    }
    if (!$transInfo['td_gcard']) {
        $transInfo['td_gcard'] = "NULL";
    }
    $transInfo['td_fraud_score'] = -1;
    if ($transInfo['td_customer_fee']) {
        $transInfo['amount'] += $transInfo['td_customer_fee'];
    }
    $response = array();
    $ap_limit = intval($companyInfo['cd_approve_timelimit']);
    if ($ap_limit < 1) {
        $ap_limit = 1;
    }
    if (cc_check_previous_24h_approve(&$transInfo, $ap_limit)) {
        //$response['errormsg'] = "Credit Card has been used in the last ".$companyInfo['cd_approve_timelimit']." hours. The order was successful. If you did not get an order confirmation email, or you have any other questions about your order, please contact Etelegate Customer Service. Otherwise, please wait until ".$companyInfo['cd_approve_timelimit']." hours has passed since your last purchase.";
        //$response['success'] = true;
        //$response['td_process_result']="Credit Card Previously Approved in the last ".$companyInfo['cd_approve_timelimit']." hours. Will not try again so soon.";
        //$response['td_process_query']="Checking for Previous Approves";
        //$response['status'] = "D";
        //$response['td_bank_recieved'] = 'approvelimit';
        $response['errormsg'] = "Credit Card has been used in the last {$ap_limit} hour(s). The order was successful. If you did not get an order confirmation email, or you have any other questions about your order, please contact Etelegate Customer Service. Otherwise, please wait until {$ap_limit} hour(s) has passed since your last purchase.";
        return $response;
    }
    if ($_SESSION['etel_trans_pending'] == true && !$transInfo['td_is_a_rebill']) {
        $response['errormsg'] = "Error: Transaction Pending. Please wait until current transaction has completed.";
        return $response;
    }
    $_SESSION['etel_trans_pending'] = true;
    $_SESSION['etel_trans_pending_ref'] = $transInfo['reference_number'];
    // Start Pending Trans
    $transInfo = $process_trans->update_TransactionRates($transInfo['userId'], $transInfo, $trans_mode, $mode);
    $trans_id = $process_trans->insert_TransactionWithRates($transInfo, $mode);
    $int_table = "cs_test_transactiondetails";
    if ($mode == "Live") {
        $int_table = "cs_transactiondetails";
    }
    /*	
    	$qrt_insert_details = "insert into $int_table set `status` = 'P',`Invoiceid` = '".$transInfo['Invoiceid']."', `transactionDate` = NOW(), `name` = '".$transInfo['name']."', `surname` = '".$transInfo['surname']."', `phonenumber` = '".$transInfo['phonenumber']."', `address` = '".$transInfo['address']."', `CCnumber` = '".etelEnc($transInfo['CCnumber'])."', `cvv` = '".$transInfo['cvv']."', `checkorcard` = '".$transInfo['checkorcard']."', `country` = '".$transInfo['country']."', `city` = '".$transInfo['city']."', `td_bank_number` = '".$transInfo['td_bank_number']."',
    		 `state` = '".$transInfo['state']."', `zipcode` = '".$transInfo['zipcode']."', `amount` = '".$transInfo['amount']."', `memodet` = '".$transInfo['memodet']."', `signature` = '".$transInfo['signature']."', `bankname` = '".$transInfo['bankname']."', `bankroutingcode` = '".$transInfo['bankroutingcode']."', `bankaccountnumber` = '".etelEnc($transInfo['bankaccountnumber'])."', `accounttype` = '".$transInfo['accounttype']."', `misc` = '".$transInfo['misc']."', `email` = '".$transInfo['email']."', `cancelstatus` = '".$transInfo['cancelstatus']."', 
    		  `userId` = '".$transInfo['userId']."', `Checkto` = '".$transInfo['Checkto']."', `cardtype` = '".$transInfo['cardtype']."', `checktype` = '".$transInfo['checktype']."', `validupto` = '".$transInfo['validupto']."', `reason` = '".$transInfo['reason']."', `other` = '".$transInfo['other']."', `ipaddress` = '".$transInfo['ipaddress']."', `cancellationDate` = NULL, `voiceAuthorizationno` = '".$transInfo['voiceAuthorizationno']."', `shippingTrackingno` = '".$transInfo['shippingTrackingno']."', `socialSecurity` = '".$transInfo['socialSecurity']."',
    		   `driversLicense` = '".$transInfo['driversLicense']."', `billingDate` = NOW(), `passStatus` = '".$transInfo['passStatus']."', `chequedate` = '".$transInfo['chequedate']."', `pass_count` = '".$transInfo['pass_count']."', `approvaldate` = '".$transInfo['approvaldate']."', `nopasscomments` = '".$transInfo['nopasscomments']."', `licensestate` = '".$transInfo['licensestate']."', `approval_count` = '".$transInfo['approval_count']."', `declinedReason` = '".$transInfo['declinedReason']."', `service_user_id` = '".$transInfo['service_user_id']."',
    		    `admin_approval_for_cancellation` = '".$transInfo['admin_approval_for_cancellation']."', `company_usertype` = '".$transInfo['company_usertype']."', `company_user_id` = '".$transInfo['company_user_id']."', `callcenter_id` = '".$transInfo['callcenter_id']."', `productdescription` = '".$transInfo['productdescription']."', `reference_number` = '".$transInfo['reference_number']."', `currencytype` = '".$transInfo['currencytype']."', `r_reseller_discount_rate` = '".$transInfo['r_reseller_discount_rate']."', `r_total_discount_rate` = '".$transInfo['r_total_discount_rate']."',
    			 `td_ca_ID` = '".$transInfo['td_ca_ID']."', `td_fraud_score` = '".$transInfo['td_fraud_score']."',`r_chargeback` = '".$transInfo['r_chargeback']."', `r_credit` = '".$transInfo['r_credit']."', `r_transactionfee` = '".$transInfo['r_transactionfee']."', `r_reserve` = '".$transInfo['r_reserve']."', `r_merchant_discount_rate` = '".$transInfo['r_merchant_discount_rate']."', `r_total_trans_fees` = '".$transInfo['r_total_trans_fees']."', `r_reseller_trans_fees` = '".$transInfo['r_reseller_trans_fees']."', `r_discountrate` = '".$transInfo['r_discountrate']."', `r_merchant_trans_fees` = '".$transInfo['r_merchant_trans_fees']."', `cancel_refer_num` = '".$transInfo['cancel_refer_num']."',
    			  `cancel_count` = '".$transInfo['cancel_count']."', `return_url` = '".$transInfo['return_url']."', `from_url` = '".$transInfo['from_url']."', `bank_id` = '".$transInfo['bank_id']."', `td_rebillingID` = '".$transInfo['td_rebillingID']."', `td_is_a_rebill` = '".$transInfo['td_is_a_rebill']."', `td_enable_rebill` = '".$transInfo['td_enable_rebill']."', `td_voided_check` = '".$transInfo['td_voided_check']."', `td_returned_checks` = '".$transInfo['td_returned_checks']."', `td_site_ID` = '".$transInfo['td_site_ID']."', `td_is_affiliate` = '".$transInfo['td_is_affiliate']."',
    			   `td_send_email` = '".$transInfo['td_send_email']."', `td_customer_fee` = '".$transInfo['td_customer_fee']."', `td_is_pending_check` = '".$transInfo['td_is_pending_check']."', `td_is_chargeback` = '".$transInfo['td_is_chargeback']."', `td_recur_processed` = '".$transInfo['td_recur_processed']."', `td_recur_next_date` = '".$transInfo['td_recur_next_date']."', `td_username` = '".$transInfo['td_username']."', `td_password` = '".$transInfo['td_password']."', `td_product_id` = '".$transInfo['td_product_id']."', `td_non_unique` = '".$transInfo['td_non_unique']."',
    			   td_merchant_fields = '" . $transInfo['td_merchant_fields'] . "', td_subscription_id = '" . $transInfo['td_subscription_id'] . "' ;";
    		
    	//die($qrt_insert_details);
    	$show_insert_run =mysql_query($qrt_insert_details) or dieLog(mysql_errno().": ".mysql_error()."<BR>".$qrt_insert_details);
    
    	$trans_id = mysql_insert_id();
    	$transInfo['transactionId'] = $trans_id;
    	func_update_rate($transInfo['userId'],&$transInfo,$cnn_cs,$trans_mode,$mode);
    */
    toLog('order', 'customer', "Pending Transaction '" . $transInfo['reference_number'] . "' Created.", $trans_id);
    // End Pending Trans
    if ($mode == "Live") {
        $start_transaction = microtime_float();
        $int_op = $bankInfo['bk_int_function'];
        if (function_exists($int_op)) {
            $response = $int_op($transInfo, $bankInfo, $companyInfo);
        } else {
            $response['errormsg'] = "Integration Function '{$int_op}' not found";
            $response['success'] = false;
        }
        toLog('order', 'customer', "Transaction '" . $transInfo['reference_number'] . "' Integration Response: " . $response['td_process_result'] . " ~ Integration Query: " . $response['td_process_query'] . " ~ Response Info: " . serialize($response), $trans_id);
        $transInfo['status'] = $response['status'];
        $transInfo['td_process_result'] = $response['td_process_result'];
        $transInfo['td_process_query'] = $response['td_process_query'];
        $transInfo['td_bank_transaction_id'] = $response['td_bank_transaction_id'];
        if ($response['td_gcard']) {
            $transInfo['td_gcard'] = $response['td_gcard'];
        }
        //$transInfo['td_gcard'] = $transInfo['td_gcard'];
        if (!$transInfo['td_gcard']) {
            $transInfo['td_gcard'] = "NULL";
        }
        $transInfo['td_bank_recieved'] = $response['td_bank_recieved'];
    } else {
        $response['errormsg'] = "Success";
        $response['success'] = true;
        $transInfo['Invoiceid'] = $response['Invoiceid'];
        $transInfo['td_process_result'] = $response['td_process_result'];
        $transInfo['td_process_query'] = $response['td_process_query'];
        $response['status'] = "A";
        $transInfo['td_bank_recieved'] = 'no';
        //$transInfo['td_gcard'] = substr($transInfo['td_gcard'],0,4)."********".substr($transInfo['td_gcard'],0,-4);
    }
    $transInfo['status'] = $response['status'];
    $transInfo['td_process_msg'] = $response['errormsg'];
    if ($transInfo['status'] != "A") {
        $transInfo['td_username'] = "";
        $transInfo['td_password'] = "";
    }
    $transInfo['td_process_duration'] = microtime_float() - $start_transaction;
    $transInfo['td_non_unique'] = cc_check_unique($int_table, &$transInfo);
    $transInfo['declinedReason'] = $transInfo['errormsg'];
    $qrt_update_details = "update {$int_table} set \n\t\t\t`td_gcard` = " . $transInfo['td_gcard'] . ", \n\t\t\t`td_bank_recieved` = '" . $transInfo['td_bank_recieved'] . "',\n\t\t\t`td_fraud_score` = '" . $transInfo['td_fraud_score'] . "',\n\t\t\t`status` = '" . $transInfo['status'] . "',\n\t\t\t`td_username` = '" . $transInfo['td_username'] . "',\n\t\t\t`td_process_msg` = '" . $transInfo['td_process_msg'] . "',\n\t\t\t`td_password` = '" . $transInfo['td_password'] . "',\n\t\t\t`td_bank_transaction_id` = '" . $transInfo['td_bank_transaction_id'] . "',\n\t\t\t`td_process_query` = '" . quote_smart($transInfo['td_process_query']) . "',\n\t\t\t`td_process_result` = '" . quote_smart($transInfo['td_process_result']) . "',\n\t\t\t`td_process_duration` = '" . quote_smart($transInfo['td_process_duration']) . "' \n\t\t\twhere transactionId = '{$trans_id}';";
    //die($qrt_insert_details);
    toLog('order', 'customer', "Transaction '" . $transInfo['reference_number'] . "' Update Query: " . $qrt_update_details, $trans_id);
    $show_insert_run = mysql_query($qrt_update_details) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>" . $qrt_update_details);
    if ($response['success'] == true) {
        //if($transInfo['status'] != 'A') $transInfo['status'] = 'D';
        //func_ins_bankrates($trans_id,$bank_CreditcardId,$cnn_cs);
        $response['transactionId'] = $trans_id;
        // Update Rates here?
        if (!$trans_id) {
            $response['errormsg'] = "Failed to store Transaction in Database";
            $response['success'] = false;
        }
        $email_to = $transInfo['email'];
        if ($transInfo['status'] == 'A' || $transInfo['status'] == 'P' && $transInfo['checkorcard'] == 'C') {
            // Email
            $useEmailTemplate = "customer_recur_subscription_confirmation_cc";
            if ($transInfo['td_enable_rebill'] == 0) {
                $useEmailTemplate = "customer_order_confirmation_cc";
            }
            if ($transInfo['td_one_time_subscription']) {
                $useEmailTemplate = "customer_subscription_confirmation_cc";
            }
            if ($transInfo['td_is_a_rebill'] == 1) {
                $useEmailTemplate = "customer_rebill_confirmation_cc";
            }
            $data = array();
            $data['payment_type'] = $payment_type;
            $data['billing_descriptor'] = $transInfo['billing_descriptor'];
            $data['site_URL'] = $companyInfo['cs_URL'];
            $data['reference_number'] = $transInfo['reference_number'];
            $data['full_name'] = $transInfo['surname'] . ", " . $transInfo['name'];
            $data['product_info'] = $transInfo['td_product_id'] . ": " . $transInfo['productdescription'];
            $data['email'] = $email_to;
            $data['customer_email'] = $email_to;
            $data['credit_card_formatted'] = $credit_card_formatted;
            $data['amount'] = "\$" . formatMoney($transInfo['amount'] - $transInfo['td_customer_fee']) . " USD";
            $data['customer_fee'] = "\$" . formatMoney($transInfo['td_customer_fee']) . " USD";
            $data['final_amount'] = "\$" . formatMoney($transInfo['amount']) . " USD";
            $data['username'] = $transInfo['td_username'];
            $data['password'] = $transInfo['td_password'];
            $data['payment_schedule'] = $transInfo['payment_schedule'];
            $data['transaction_date'] = date("F j, Y", strtotime($transInfo['transactionDate']));
            $data['next_bill_date'] = $transInfo['nextDateInfo'];
            $data['site_access_URL'] = $companyInfo['cs_member_url'];
            $data['customer_support_email'] = $companyInfo['cs_support_email'];
            $data['tmpl_language'] = $_SESSION['tmpl_language'];
            $data['gateway_select'] = $companyInfo['gateway_id'];
            if ($transInfo['td_send_email'] == 'yes') {
                $str_is_test = "THIS IS A TEST TRANSACTION ";
                if ($mode == "Live") {
                    $str_is_test = "";
                }
                if (!$transInfo['td_is_a_rebill']) {
                    send_email_template($useEmailTemplate, $data, $str_is_test);
                }
                // Send Customer Email.
                if ($mode == "Live" && $bankInfo['bk_cc_bank_enabled'] == 1) {
                    $data['email'] = $bankInfo['bank_email'];
                    send_email_template($useEmailTemplate, $data, "(Bank Copy) ");
                }
                if ($companyInfo['cd_recieve_order_confirmations']) {
                    $data['email'] = $companyInfo['cd_recieve_order_confirmations'];
                    send_email_template($useEmailTemplate, $data, $str_is_test . "(Merchant Copy) ");
                }
            }
            // End Email
        }
        if ($mode != "Live") {
            $sql = "UPDATE cs_companydetails set `cd_completion` = 7 WHERE `cd_completion` = 6 AND `userId` = '" . $transInfo['userId'] . "'";
            if ($companyInfo['cd_completion'] == 6) {
                mysql_query($sql) or dieLog(mysql_error());
            }
            $transInfo['td_product_id'] = "TEST MODE";
            $transInfo['amount'] = "TEST MODE";
        }
        $_SESSION['etel_trans_pending'] = true;
        // Post Notification
        $notify = 'decline';
        if ($transInfo['status'] == 'A' || $transInfo['status'] == 'P' && $transInfo['checkorcard'] == 'C') {
            $notify = 'approve';
            if ($transInfo['td_is_a_rebill']) {
                $notify = 'rebill';
            }
        }
        Process_Transaction($transInfo['reference_number'], $notify, $mode != "Live");
        //approved or declined
    }
    $response['transactionId'] = $transInfo['transactionId'];
    $_SESSION['etel_trans_pending'] = false;
    return $response;
}