Esempio n. 1
0
        $transInfo['bankaccountnumber'] = eteldec($transInfo['bankaccountnumber']);
    }
    if (!is_numeric($transInfo['CCnumber'])) {
        $transInfo['CCnumber'] = eteldec($transInfo['CCnumber']);
    }
    $ss_account_status = 'inactive';
    $ss_rebill_status = 'inactive';
    $ss_rebill_status_text = 'Rebill Subscription Canceled/Inactive';
    if ($transInfo['td_enable_rebill']) {
        $ss_rebill_status = 'active';
    }
    if ($transInfo['td_enable_rebill']) {
        $ss_rebill_status_text = '';
    }
    if (!$transInfo['td_subscription_id']) {
        $transInfo['td_subscription_id'] = genRefId("subscription", "S");
    }
    $expDate = explode("/", $transInfo['validupto']);
    $expYear = substr($expDate[0], -2, 2);
    $expMonth = $expDate[1];
    $sql = "\r\n\tinsert into `cs_subscription`  set \r\n\t `ss_subscription_ID`='" . $transInfo['td_subscription_id'] . "',\r\n\t `ss_billing_firstname`='" . $transInfo['name'] . "',\r\n\t `ss_billing_mi`='" . $transInfo[''] . "',\r\n\t `ss_billing_lastname`='" . $transInfo['surname'] . "',\r\n\t `ss_billing_address`='" . $transInfo['address'] . "',\r\n\t `ss_billing_address2`='" . $transInfo[''] . "',\r\n\t `ss_billing_city`='" . $transInfo['city'] . "',\r\n\t `ss_billing_state`='" . $transInfo['state'] . "',\r\n\t `ss_billing_country`='" . $transInfo['country'] . "',\r\n\t `ss_billing_zipcode`='" . $transInfo['zipcode'] . "',\r\n\t `ss_billing_last_ip`='" . $transInfo['ipaddress'] . "',\r\n\t `ss_billing_card`='" . transaction::etelEncSalted($transInfo['CCnumber'], $salt) . "',\r\n\t `ss_billing_card_type`='" . $ss_billing_card_type . "',\r\n\t `ss_billing_gkard`='" . transaction::etelEncSalted($transInfo['td_gcard'], $salt) . "',\r\n\t `ss_billing_type`='" . $ss_billing_type . "',\r\n\t `ss_billing_exp`='" . date("Y-m-d", mktime(0, 0, 0, $expMonth, 1, $expYear)) . "',\r\n\t `ss_billing_cvv2`='" . transaction::etelEncSalted($transInfo['cvv'], $salt) . "',\r\n\t `ss_billing_check_account`='" . transaction::etelEncSalted($transInfo['bankaccountnumber'], $salt) . "',\r\n\t `ss_billing_check_routing`='" . transaction::etelEncSalted($transInfo['bankroutingcode'], $salt) . "',\r\n\t `ss_salt`='" . $salt . "',\r\n\t `ss_cust_email`='" . $transInfo['email'] . "',\r\n\t `ss_cust_phone`='" . $transInfo['phonenumber'] . "',\r\n\t `ss_cust_username`='" . $transInfo['td_username'] . "',\r\n\t `ss_cust_password`='" . $transInfo['td_password'] . "',\r\n\t `ss_rebill_ID`='" . $transInfo['td_rebillingID'] . "',\r\n\t `ss_rebill_next_date`='" . $transInfo['td_recur_next_date'] . "',\r\n\t `ss_rebill_amount`='" . $transInfo['chargeAmount'] . "',\r\n\t `ss_rebill_status`='" . $ss_rebill_status . "',\r\n\t `ss_rebill_status_text`='" . $ss_rebill_status_text . "',\r\n\t `ss_rebill_attempts`='" . $transInfo['td_recur_attempts'] . "',\r\n\t `ss_rebill_count`='" . $transInfo['td_recur_num'] . "',\r\n\t `ss_account_status`='" . $ss_account_status . "',\r\n\t `ss_account_start_date`='" . $transInfo['transactionDate'] . "',\r\n\t `ss_account_expire_date`='" . $transInfo['td_recur_next_date'] . "',\r\n\t `ss_transaction_id`='" . $transInfo['transactionId'] . "',\r\n\t `ss_last_rebill`='" . $transInfo['transactionDate'] . "',\r\n\t `ss_productdescription`='" . $transInfo['productdescription'] . "',\r\n\t `ss_site_ID` ='" . $transInfo['td_site_ID'] . "',\r\n\t `ss_user_ID` ='" . $transInfo['userId'] . "'\r\n\t\r\n\t";
    die($sql);
}
/*
set_time_limit(0);
	$sql="SELECT CCnumber,transactionId
FROM cs_transactiondetails
";
	$result = mysql_query($sql) or dieLog(mysql_errno().": ".mysql_error()."<BR>");
while($transInfo = mysql_fetch_assoc($result))
{
Esempio n. 2
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;
}
Esempio n. 3
0
 function createSubscription()
 {
     if ($this->transInfo['ss_account_status'] == 'inactive' && $this->transInfo['ss_rebill_status'] == 'inactive') {
         return $this->transInfo;
     }
     $expD = explode("/", $this->transInfo['validupto']);
     $expYear = $expD[0];
     $expMonth = $expD[1];
     $salt = md5(mt_rand(1, 2000000000));
     //if($this->transInfo['checkorcard']=='C') $ss_billing_type = 'Check';
     //else if($this->transInfo['cardtype'] == 'Visa') $ss_billing_type = 'Visa';
     //else if($this->transInfo['cardtype'] == 'Master') $ss_billing_type = 'Mastercard';
     //else
     $ss_billing_type = $this->transInfo['cardtype'];
     $ss_subscription_ID = $this->transInfo['td_subscription_id'];
     if (!$ss_subscription_ID) {
         $ss_subscription_ID = genRefId("subscription", "S");
     }
     $this->transInfo['td_subscription_id'] = $ss_subscription_ID;
     if (!$this->transInfo['ss_account_status']) {
         $this->transInfo['ss_account_status'] = 'active';
     }
     if (!$this->transInfo['ss_account_expire_date']) {
         $this->transInfo['ss_account_expire_date'] = $this->transInfo['td_recur_next_date'];
     }
     if (!$this->transInfo['ss_rebill_status']) {
         $this->transInfo['ss_rebill_status'] = $this->transInfo['td_enable_rebill'] == 1 ? "active" : "inactive";
     }
     if (!$this->transInfo['ss_rebill_status_text']) {
         $this->transInfo['ss_rebill_status_text'] = '';
     }
     if (!$this->transInfo['ss_rebill_amount']) {
         $this->transInfo['ss_rebill_amount'] = $this->transInfo['td_recur_charge'];
     }
     if (!$this->transInfo['ss_rebill_next_date']) {
         $this->transInfo['ss_rebill_next_date'] = $this->transInfo['td_recur_next_date'];
     }
     //$exists = $this->subscription_exists($this->transInfo['transactionId']);
     //if($exists) 																		// Why would this happen? -Ari
     //{
     //	$sql_action = "UPDATE";
     //	$sql_where = "WHERE ss_transaction_id = '" . $this->transInfo['transactionId']."'";
     //}
     //else
     //{
     $sql_action = "INSERT INTO";
     $sql_where = "";
     //}
     $ss_rebill_status = 'active';
     $subscription = "{$sql_action}\r\n\t\t\t\t\t\t\t`cs_subscription`\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t `ss_subscription_ID`='" . quote_smart($ss_subscription_ID) . "',\r\n\t\t\t\t\t\t\t `ss_billing_firstname` = '" . quote_smart($this->transInfo['name']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_mi` = '',\r\n\t\t\t\t\t\t\t `ss_billing_lastname` = '" . quote_smart($this->transInfo['surname']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_address` = '" . quote_smart($this->transInfo['address']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_address2` =  '',\r\n\t\t\t\t\t\t\t `ss_billing_city` = '" . quote_smart($this->transInfo['city']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_state` = '" . quote_smart($this->transInfo['state']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_country` = '" . quote_smart($this->transInfo['country']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_zipcode` = '" . quote_smart($this->transInfo['zipcode']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_last_ip` = '" . quote_smart($this->transInfo['ipaddress']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_type` = '" . $ss_billing_type . "',\r\n\t\t\t\t\t\t\t `ss_billing_card` = '" . transaction_class::etelEncSalted($this->transInfo['CCnumber'], $salt) . "',\r\n\t\t\t\t\t\t\t `ss_billing_exp` = '" . ($this->transInfo['checkorcard'] == 'H' ? date("Y-m-d", strtotime($expYear . "-" . $expMonth . "-01")) : "") . "',\r\n\t\t\t\t\t\t\t `ss_billing_cvv2` = '" . transaction_class::etelEncSalted($this->transInfo['cvv'], $salt) . "',\r\n\t\t\t\t\t\t\t `ss_billing_check_account` = '" . transaction_class::etelEncSalted($this->transInfo['bankaccountnumber'], $salt) . "',\r\n\t\t\t\t\t\t\t `ss_billing_check_routing` = '" . transaction_class::etelEncSalted($this->transInfo['bankroutingcode'], $salt) . "',\r\n\t\t\t\t\t\t\t `ss_salt` = '{$salt}',\r\n\t\t\t\t\t\t\t `ss_cust_email` = '" . quote_smart($this->transInfo['email']) . "',\r\n\t\t\t\t\t\t\t `ss_cust_phone` = '" . quote_smart($this->transInfo['phonenumber']) . "',\r\n\t\t\t\t\t\t\t `ss_cust_username` = '" . quote_smart($this->transInfo['td_username']) . "',\r\n\t\t\t\t\t\t\t `ss_cust_password` = '" . quote_smart($this->transInfo['td_password']) . "',\r\n\t\t\t\t\t\t\t `ss_rebill_ID` = '" . quote_smart($this->transInfo['td_rebillingID']) . "',\r\n\t\t\t\t\t\t\t `ss_rebill_next_date` = '" . $this->transInfo['ss_rebill_next_date'] . "',\r\n\t\t\t\t\t\t\t `ss_rebill_amount` = '" . $this->transInfo['td_recur_charge'] . "',\r\n\t\t\t\t\t\t\t `ss_rebill_status` = '" . $this->transInfo['ss_rebill_status'] . "',\r\n\t\t\t\t\t\t\t `ss_rebill_status_text` = '" . $this->transInfo['ss_rebill_status_text'] . "',\r\n\t\t\t\t\t\t\t `ss_rebill_attempts` = 0,\r\n\t\t\t\t\t\t\t `ss_rebill_count` = 0,\r\n\t\t\t\t\t\t\t `ss_account_status` = '" . $this->transInfo['ss_account_status'] . "',\r\n\t\t\t\t\t\t\t `ss_account_start_date` = now(),\r\n\t\t\t\t\t\t\t `ss_account_notes` = CONCAT(NOW(), ': Transaction (" . $this->transInfo['reference_number'] . ") Approved. Creating Subscription...\nNext Rebill Date: " . $this->transInfo['td_recur_next_date'] . "'),\r\n\t\t\t\t\t\t\t `ss_account_expire_date` = '" . $this->transInfo['ss_account_expire_date'] . "',\r\n\t\t\t\t\t\t\t `ss_transaction_id` = '" . $this->transInfo['transactionId'] . "',\r\n\t\t\t\t\t\t\t `ss_productdescription` = '" . quote_smart($this->transInfo['productdescription']) . "',\r\n\t\t\t\t\t\t\t `ss_site_ID` = '" . $this->transInfo['td_site_ID'] . "',\r\n\t\t\t\t\t\t\t `ss_user_id` ='" . $this->transInfo['userId'] . "',\r\n\t\t\t\t\t\t\t `ss_bank_id` ='" . $this->transInfo['bank_id'] . "'\r\n\t\t\t\t\t\t\t {$sql_where} \r\n\t\t\t\t\t\t\t";
     sql_query_write($subscription) or dieLog(mysql_error());
     $this->transInfo['td_ss_ID'] = mysql_insert_id();
     return $this->transInfo;
 }
 $transaction['transactionId'] = "";
 $transaction['td_process_query'] = "";
 $transaction['td_process_result'] = "";
 $transaction['td_recur_attempts'] = 0;
 $transaction['CCnumber'] = etelDec($transaction['CCnumber']);
 if ($transaction['td_gcard']) {
     $transaction['td_gcard'] = etelDec($transaction['td_gcard']);
 }
 if ($transaction['bankroutingcode']) {
     $transaction['bankroutingcode'] = etelDec($transaction['bankroutingcode']);
 }
 if ($transaction['bankaccountnumber']) {
     $transaction['bankaccountnumber'] = etelDec($transaction['bankaccountnumber']);
 }
 $transaction['amount'] = $nextRecurCharge;
 $transaction['reference_number'] = genRefId("transaction", $transaction['checkorcard']);
 if ($transaction['checkorcard'] == 'H') {
     $transaction['bank_id'] = $transactionInfo['bank_Creditcard'];
 }
 //TODO BANK SELECTION
 foreach ($transaction as $key => $data) {
     $transaction[$key] = quote_smart($data);
 }
 $sql = "UPDATE `cs_transactiondetails` SET `td_recur_processed` = '2' WHERE `transactionId` = '{$oldTransId}' LIMIT 1";
 if (!$testonly) {
     $result = mysql_query($sql, $cnn_cs) or dieLog(mysql_errno() . ": " . mysql_error() . "<br>Cannot execute query");
 }
 $etel_fraud_limit = 2.5;
 $transaction['td_recur_num']++;
 if (!$testonly) {
     $response = execute_transaction(&$transaction, "Live");