function update_account_status() { $ss_account_status = 'active'; if (strtotime($this->row['subscriptionTable']['ss_account_expire_date']) < time()) { $ss_account_status = 'inactive'; } $ss_account_notes = "\n\n" . date('Y-m-d G:i:s') . ": Account " . ucfirst($ss_account_status); $upd = "UPDATE\n\t\t\t\t\tcs_subscription\n\t\t\t\t\tSET\n\t\t\t\t\tss_account_status = '{$ss_account_status}',\n\t\t\t\t\tss_account_notes = CONCAT(`ss_account_notes`, '{$ss_account_notes}' )\n\t\t\t\t\tWHERE\n\t\t\t\t\tss_ID = {$this->row['subscriptionTable']['ss_ID']}"; sql_query_write($upd) or dieLog(mysql_error() . "<pre>{$upd}</pre>"); $this->row['subscriptionTable']['ss_account_status'] = $ss_account_status; $this->row['subscriptionTable']['ss_account_notes'] .= $ss_account_notes; if ($ss_account_status == 'inactive') { return Process_Transaction($this->row['subscriptionTable']['ss_transaction_id'], "expiration", $this->test, "transactionId"); } return Process_Transaction($this->row['subscriptionTable']['ss_transaction_id'], "approve", $this->test, "transactionId"); }
function process_transactions($params) { set_time_limit(0); if (!$params['Format']) { $params['Format'] = "TXT"; } if (!$params['Incremental']) { $params['Incremental'] = "True"; } $RF = new rates_fees(); $trans = $this->Status_Download($params); $return_affected_rows = 0; $approve_affected_rows = 0; $log = ""; foreach ($trans as $tran) { $update = false; $chargeback = false; $refund = false; $status = ""; switch (strtolower($tran['ResponseType'])) { case "processed": $update = false; break; case "b": $update = false; break; case "f": $update = true; $status = 'A'; break; case "r": $update = true; $status = 'D'; break; case "nsf": $update = true; $status = 'D'; break; case "chargeback": $update = true; $status = 'D'; $chargeback = true; break; case "invalid": $update = true; $status = 'D'; break; case "declined": $update = true; $status = 'D'; break; case "refund": $update = true; $status = 'D'; $refund = true; break; case "credit": $update = true; $status = 'D'; $refund = true; break; case "incomplete": $update = true; $status = 'D'; break; case "cancelled": $update = true; $status = 'D'; break; case "bo exception": $update = true; $status = 'D'; break; case "downloaded": $update = false; break; case "credit originated": $update = false; break; case "credit downloaded": $update = false; break; case "credit return": $update = true; $status = 'D'; $chargeback = true; break; case "credit funded": $update = true; $status = 'A'; break; } $refid = substr($tran['ExternalClientID'], 0, 50); if (!$refid) { continue; } $sql = "\n\t\t\t\tselect * from \n\t\t\t\t\tcs_transactiondetails left join \n\t\t\t\t\tcs_subscription on \n\t\t\t\t\ttd_ss_ID = ss_ID\n\t\t\t\tWHERE\n\t\t\t\t\treference_number = '{$refid}'\n\t\t\t\t\tAND checkorcard='C'\t\t\n\t\t\t\tLIMIT 1\n\t\t\t"; $tranResult = mysql_query($sql) or dieLog(mysql_error() . " ~ {$sql}"); $transInfo = mysql_fetch_assoc($tranResult); $transId = $transInfo['transactionId']; if ($transInfo['status'] != 'P' && $update == true) { $update = false; } if (!$transId) { $log .= " Transaction ID Not Found!! " . print_r($tran, true); toLog('erroralert', 'misc', "Transaction ID Not Found!! {$transId} {$sql}"); $update = false; } if ($update) { $log .= " Found Response Type (" . $tran['ResponseType'] . ") For ({$refid}):\n"; $notify = 'decline'; $bank_transid = $tran['TransID']; if ($tran['ResponseDate']) { $billingDate = date('Y-m-d', strtotime($tran['ResponseDate'])); } else { $billingDate = ""; } if ($chargeback) { //is_chargeback $sql = "\n\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\tcs_transactiondetails left join \n\t\t\t\t\t\t\tcs_subscription on \n\t\t\t\t\t\t\ttd_ss_ID = ss_ID\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tstatus='A',\n\t\t\t\t\t\t\ttd_is_chargeback = 1,\n\t\t\t\t\t\t\ttd_bank_transaction_id = '{$bank_transid}',\n\t\t\t\t\t\t\tbillingDate = '{$billingDate}',\n\t\t\t\t\t\t\ttd_merchant_deducted=0,\n\t\t\t\t\t\t\tss_rebill_status = 'inactive',\n\t\t\t\t\t\t\tss_rebill_status_text = 'Subscription Inactive due to Chargeback'\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ttransactionId = '{$transId}'\n\t\t\t\t\t\t\tAND checkorcard='C'\t\t\n\t\t\t\t\t"; $log .= " This transaction is a chargeback.\n"; $notify = 'chargeback'; $r = $RF->update_transaction_profit($transId); } else { if ($refund) { // cancel_status = y, cancel subscription $sql = "\n\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\tcs_transactiondetails left join \n\t\t\t\t\t\t\tcs_subscription on \n\t\t\t\t\t\t\ttd_ss_ID = ss_ID\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tstatus='A',\n\t\t\t\t\t\t\tcancelstatus = 'Y',\n\t\t\t\t\t\t\ttd_bank_transaction_id = '{$bank_transid}',\n\t\t\t\t\t\t\tbillingDate = '{$billingDate}',\n\t\t\t\t\t\t\ttd_merchant_deducted=0,\n\t\t\t\t\t\t\tss_rebill_status = 'inactive',\n\t\t\t\t\t\t\tss_rebill_status_text = 'Subscription Inactive due to Refund'\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ttransactionId = '{$transId}'\n\t\t\t\t\t\t\tAND checkorcard='C'\t\t\t\n\t\t\t\t\t"; $log .= " This transaction is a refund.\n"; $notify = 'refund'; $r = $RF->update_transaction_profit($transId); } else { $ss_rebill_status_sql = $status == 'D' ? "ss_rebill_status = 'inactive', " : ''; $ss_rebill_status_text = $status == 'D' ? 'Subscription Inactive due to decline (' . $this->ach_status[$tran['ResponseType']] . ')' : 'Subscription Active'; $sql = "\n\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\tcs_transactiondetails left join \n\t\t\t\t\t\t\tcs_subscription on \n\t\t\t\t\t\t\ttd_ss_ID = ss_ID\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\ttd_bank_transaction_id = '{$bank_transid}',\n\t\t\t\t\t\t\tstatus = '{$status}',\n\t\t\t\t\t\t\tbillingDate = '{$billingDate}',\n\t\t\t\t\t\t\ttd_merchant_deducted=0,\n\t\t\t\t\t\t\ttd_merchant_paid=0,\n\t\t\t\t\t\t\t{$ss_rebill_status_sql}\n\t\t\t\t\t\t\tss_rebill_status_text = '{$ss_rebill_status_text}'\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\ttransactionId = '{$transId}'\n\t\t\t\t\t\t\tAND checkorcard='C'\tAND status='P'\t\n\t\t\t\t\t"; $log .= " This transaction's status is (" . $this->ach_status[$tran['ResponseType']] . ").\n"; $r = $RF->update_transaction_profit($transId); } } sql_query_write($sql) or dieLog(mysql_error() . "<pre>{$sql}</pre>"); $affected = mysql_affected_rows(); if ($status != 'A') { $return_affected_rows += $affected; } else { $approve_affected_rows += $affected; } if ($status == 'A') { if ($transInfo['td_is_a_rebill']) { $notify = 'rebill'; } else { $notify = 'approve'; } } if ($affected) { Process_Transaction($transId, $notify, 0, 'transactionId'); } } else { $log .= " Ignoring Transaction.\n"; } } $log .= "CheckGateway Result: ({$return_affected_rows}) Returns, ({$approve_affected_rows}) Approves.\n"; return $log; }
<?php include 'includes/sessioncheckuser.php'; require_once "includes/dbconnection.php"; $headerInclude = "transactions"; include 'includes/header.php'; require_once 'includes/function.php'; beginTable(); ?> <table border="1" cellspacing="0" width="100%" class="report" cellpadding="3"> <?php $sessionlogin = $companyInfo['userId']; $str_company_id = $companyInfo['userId']; if ($_POST['action'] && $_POST['refid']) { $res = Process_Transaction(trim($_POST['refid']), $_POST['action'], intval($_POST['testmode']), 'reference_number'); echo "<tr><td align='center' colspan='2'>"; echo "<p>POST Notification Results ( " . $res[0]['response']['url'] . " )<br>"; //echo "<textarea rows=5 cols=60>" . $res[0]['response']['head'] . "</textarea><br>"; echo "<textarea rows=10 cols=60>" . $res[0]['response']['body'] . "</textarea></p>"; echo "<p>Variables Sent<br>"; echo "<textarea rows=10 cols=60>"; print_r($res[0]['response']['data']); echo "</textarea></p>"; //echo "<p>Password Management Results ( " . $res[1]['response']['url'] . " )<br>"; //echo "<textarea rows=5 cols=60>" . $res[1]['response']['head'] . "</textarea><br>"; //echo "<textarea rows=10 cols=60>" . $res[1]['response']['body'] . "</textarea></p>"; echo "</td></tr>"; } ?> <tr>
function smart_setRefund($values, $action) { global $curUserInfo; if (!$curUserInfo['en_access'][ACCESS_AUTH_TRANS_MOD]) { return array("action" => "Invalid Access.", "status" => "Fail"); } $transID = $values['append']; $qry_details = "UPDATE cs_transactiondetails SET cancellationDate=COALESCE(cancellationDate,now()), `cancelstatus` = 'Y',status='A',`td_bank_deducted`=0,`td_merchant_deducted`=0,`td_reseller_deducted`=0 WHERE `transactionId` = '{$transID}'"; $rst_details = sql_query_write($qry_details) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>Cannot execute query"); smart_cancelRebill($values, $action); Process_Transaction($values['append'], 'refund', false, 'transactionId'); $RF = new rates_fees(); $r = $RF->update_transaction_profit($transID); return array("action" => "Transaction ID " . $values['append'] . " marked as Refunded.", "status" => "success"); }
function execute_transaction() { global $cnn_cs; global $etel_fraud_limit; ignore_user_abort(true); set_time_limit(500); if (!$_SESSION['tmpl_language']) { $_SESSION['tmpl_language'] = 'eng'; } $rates = new rates_fees(); $gw_emails_sales = $_SESSION['gw_emails_sales']; if (!$etel_fraud_limit) { $etel_fraud_limit = floatval($this->companyInfo['cd_fraudscore_limit']); } $this->transInfo['td_bank_recieved'] = 'no'; $this->transInfo['companyname'] = $this->companyInfo['companyname']; $this->transInfo['cs_enable_passmgmt'] = $this->companyInfo['cs_enable_passmgmt']; if (!$this->transInfo['billing_descriptor']) { $this->transInfo['billing_descriptor'] = $this->bankInfo['bk_descriptor_visa']; } $this->transInfo['cardtype'] = $this->bankInfo['bk_trans_types']; if (!$this->transInfo['td_send_email'] == 'no') { $this->transInfo['td_send_email'] = 'yes'; } if (!$this->transInfo['td_gcard']) { $this->transInfo['td_gcard'] = "NULL"; } $this->transInfo['td_fraud_score'] = -1; //if($this->transInfo['td_customer_fee']) $this->transInfo['amount'] += $this->transInfo['td_customer_fee']; // INCORRECT. customer fee is already included in amount $_SESSION['etel_trans_pending'] = true; $_SESSION['etel_trans_pending_ref'] = $this->transInfo['reference_number']; $start_transaction = microtime_float(); if ($this->mode == "Live") { $this->response = $this->fraud->execute_scrub_tests($this->transInfo, $this->bankInfo, $this->companyInfo); if ($this->response == -1) { $int_func = $this->int_function; $int_func_response = $int_func($this->transInfo, $this->bankInfo, $this->companyInfo); $log = "Transaction '" . $this->transInfo['reference_number'] . "' Integration Response: " . $int_func_response['td_process_result'] . " ~ Integration Query: " . $int_func_response['td_process_query'] . " ~ Response Info: " . serialize($int_func_response); $this->sanitizeChargeInfo($log); toLog('order', 'customer', $log, $this->trans_id); $this->response = $int_func_response; } $this->response['success'] = true; $this->transInfo['td_process_result'] = $int_func_response['td_process_result']; $this->transInfo['td_process_query'] = $int_func_response['td_process_query']; $this->transInfo['td_bank_transaction_id'] = $int_func_response['td_bank_transaction_id']; if ($int_func_response['td_gcard']) { $this->transInfo['td_gcard'] = $int_func_response['td_gcard']; } if (!$this->transInfo['td_gcard']) { $this->transInfo['td_gcard'] = "NULL"; } $this->transInfo['td_bank_recieved'] = $int_func_response['td_bank_recieved']; } else { $this->response['errormsg'] = "Success"; $this->response['success'] = true; $this->response['status'] = "A"; $this->transInfo['td_process_result'] = "test"; $this->transInfo['td_process_query'] = "test"; $this->transInfo['td_bank_recieved'] = 'no'; } $this->transInfo['status'] = $this->response['status']; $this->transInfo['td_process_msg'] = $this->response['td_process_msg']; if (!$this->transInfo['td_process_msg']) { $this->transInfo['td_process_msg'] = $this->response['errormsg']; } if ($this->transInfo['status'] == "D") { $this->transInfo['td_username'] = ""; $this->transInfo['td_password'] = ""; } else { if (!$this->transInfo['td_ss_ID'] && $this->transInfo['td_rebillingID'] > 1 && $this->mode == "Live" && $this->transInfo['status'] != "D") { $this->createSubscription(); $this->set_transaction_subid(); //$this->transInfo['td_ss_ID'] = $subsciption->transInfo['td_ss_ID']; } } $int_table = "cs_test_transactiondetails"; if ($this->mode == "Live") { $int_table = "cs_transactiondetails"; } $this->transInfo['td_process_duration'] = microtime_float() - $start_transaction; $this->transInfo['td_non_unique'] = $this->fraud->check_unique($int_table, $this->transInfo); $this->sanitizeChargeInfo($this->transInfo['td_process_query']); $this->sanitizeChargeInfo($this->transInfo['td_process_result']); $qrt_update_details = "\r\n\t\t\tupdate \r\n\t\t\t\t{$int_table} \r\n\t\t\tset \r\n\t\t\t\t`td_gcard` = '" . $this->transInfo['td_gcard'] . "', \r\n\t\t\t\t`td_bank_recieved` = '" . $this->transInfo['td_bank_recieved'] . "',\r\n\t\t\t\t`td_fraud_score` = '" . $this->transInfo['td_fraud_score'] . "',\r\n\t\t\t\t`status` = '" . $this->transInfo['status'] . "',\r\n\t\t\t\t`td_username` = '" . $this->transInfo['td_username'] . "',\r\n\t\t\t\t`td_process_msg` = '" . quote_smart($this->transInfo['td_process_msg']) . "',\r\n\t\t\t\t`td_password` = '" . $this->transInfo['td_password'] . "',\r\n\t\t\t\t`td_bank_transaction_id` = '" . $this->transInfo['td_bank_transaction_id'] . "',\r\n\t\t\t\t`td_process_query` = '" . quote_smart($this->transInfo['td_process_query']) . "',\r\n\t\t\t\t`td_process_result` = '" . quote_smart($this->transInfo['td_process_result']) . "',\r\n\t\t\t\t`td_process_duration` = '" . quote_smart($this->transInfo['td_process_duration']) . "',\r\n\t\t\t\t`td_non_unique` = '" . quote_smart($this->transInfo['td_non_unique']) . "',\r\n\t\t\t\t`td_ss_ID` = '" . quote_smart($this->transInfo['td_ss_ID']) . "'\r\n\t\t\twhere \r\n\t\t\t\ttransactionId = '" . $this->trans_id . "'\r\n\t\t\tLIMIT 1\t\r\n\t\t\t;\r\n\t\t\t"; toLog('order', 'customer', "Transaction '" . $this->transInfo['reference_number'] . "' Update Query: " . $qrt_update_details, $this->trans_id); $show_insert_run = sql_query_write($qrt_update_details) or dieLog(mysql_errno() . ": " . mysql_error() . "<pre>{$qrt_update_details}</pre>"); $rates->update_transaction_profit($this->trans_id, true); if ($this->response['success'] == true) { $this->response['transactionId'] = $this->trans_id; if ($this->transInfo['status'] == 'A' || $this->transInfo['status'] == 'P' && $this->transInfo['checkorcard'] == 'C') { if ($this->transInfo['td_send_email'] == 'yes') { // Email $email_to = $this->transInfo['email']; //$useEmailTemplate = "customer_recur_subscription_confirmation_cc"; $useEmailTemplate = "customer_order_confirmation_cc"; //if($this->transInfo['td_one_time_subscription']) $useEmailTemplate = "customer_subscription_confirmation_cc"; //if($this->transInfo['td_is_a_rebill'] == 1) $useEmailTemplate = "customer_rebill_confirmation_cc"; $data = array(); $data['payment_type'] = $this->payment_type; $data['billing_descriptor'] = $this->transInfo['billing_descriptor']; $data['site_URL'] = $this->companyInfo['cs_URL']; $data['reference_number'] = $this->transInfo['reference_number']; $data['subscription_id'] = $this->transInfo['td_subscription_id']; $data['full_name'] = $this->transInfo['surname'] . ", " . $this->transInfo['name']; $pInfo = $this->transInfo['td_product_id']; $data['product_info'] = $pInfo . ($pInfo ? ": " : '') . $this->transInfo['productdescription']; $data['email'] = $email_to; $data['customer_email'] = $email_to; $data['credit_card_formatted'] = $this->credit_card_formatted; $data['amount'] = "\$" . formatMoney($this->transInfo['amount'] - $this->transInfo['td_customer_fee']) . " USD"; $data['customer_fee'] = "\$" . formatMoney($this->transInfo['td_customer_fee']) . " USD"; $data['final_amount'] = "\$" . formatMoney($this->transInfo['amount']) . " USD"; $data['username'] = $this->transInfo['td_username']; $data['password'] = $this->transInfo['td_password']; $data['payment_schedule'] = $this->transInfo['payment_schedule']; if (!$data['payment_schedule']) { $data['payment_schedule'] = 'No Schedule'; } $data['transaction_date'] = date("F j, Y G:i:s", strtotime($this->transInfo['transactionDate'])); $data['next_bill_date'] = $this->transInfo['nextDateInfo']; $data['site_access_URL'] = $this->companyInfo['cs_member_url']; $data['customer_support_email'] = $this->companyInfo['cs_support_email']; $data['tmpl_language'] = $_SESSION['tmpl_language']; $data['gateway_select'] = $this->companyInfo['gateway_id']; $str_is_test = "THIS IS A TEST TRANSACTION "; if ($this->mode == "Live") { $str_is_test = ""; } if ($this->transInfo['td_is_a_rebill']) { $useEmailTemplate = "customer_recur_subscription_confirmation_cc"; } if (!$this->transInfo['td_is_a_rebill']) { send_email_template($useEmailTemplate, $data, $str_is_test); } // Send Customer Email. if ($this->mode == "Live" && $this->bankInfo['bk_cc_bank_enabled'] == 1) { $data['email'] = $this->bankInfo['bank_email']; send_email_template($useEmailTemplate, $data, "(Bank Copy) "); } if ($this->companyInfo['cd_recieve_order_confirmations']) { $data['email'] = $this->companyInfo['cd_recieve_order_confirmations']; send_email_template($useEmailTemplate, $data, $str_is_test . "(Merchant Copy) "); } } } if ($mode != "Live") { $sql = "\r\n\t\t\t\t\tUPDATE \r\n\t\t\t\t\t\tcs_companydetails \r\n\t\t\t\t\tset \r\n\t\t\t\t\t\t`cd_completion` = 7 \r\n\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t`cd_completion` = 6 \r\n\t\t\t\t\t\tAND `userId` = '" . $this->transInfo['userId'] . "'\r\n\t\t\t\t\t"; if ($this->companyInfo['cd_completion'] == 6) { sql_query_write($sql) or dieLog(mysql_error() . "<pre>{$sql}</pre>"); } $this->transInfo['td_product_id'] = "TEST MODE"; $this->transInfo['amount'] = "TEST MODE"; } $_SESSION['etel_trans_pending'] = true; // Post Notification $notify = 'decline'; if ($this->transInfo['status'] == 'A' || $this->transInfo['status'] == 'P' && $this->transInfo['checkorcard'] == 'C') { if ($this->transInfo['td_is_a_rebill']) { $notify = 'rebill'; } else { $notify = 'approve'; } } Process_Transaction($this->transInfo['reference_number'], $notify, $this->mode != "Live"); //approved or declined } $this->transInfo['transactionId'] = $this->trans_id; $this->response['transactionId'] = $this->transInfo['transactionId']; $this->response['reference_number'] = $this->transInfo['reference_number']; $this->response['td_subscription_id'] = $this->transInfo['td_subscription_id']; $this->response['watchInfo'] = $this->fraud->check_watchlist($this->transInfo); $_SESSION['etel_trans_pending'] = false; }
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; }
$suboutput .= "Transaction Cannot be Processed. Ignoring this Transaction. Charge=" . $transactionInfo['chargeAmount'] . "\n\r"; $sql = "UPDATE `cs_transactiondetails` SET `td_enable_rebill` = '0', `td_recur_processed` = '1' WHERE `transactionId` = '{$oldTransId}' LIMIT 1"; if (!$testonly) { $result = mysql_query($sql, $cnn_cs) or dieLog(mysql_errno() . ": " . mysql_error() . "<br>Cannot execute query"); } //toLog('erroralert','customer',"Shouldn't happen: ".$suboutput); } else { if (!$transactionInfo['td_enable_rebill']) { $suboutput .= "Transaction has expired on '" . $transactionInfo['td_recur_next_date'] . "'\n\r"; $sql = "UPDATE `cs_transactiondetails` SET `td_recur_processed` = '1' WHERE `transactionId` = '{$oldTransId}' LIMIT 1"; if (!$testonly) { $result = mysql_query($sql, $cnn_cs) or dieLog(mysql_errno() . ": " . mysql_error() . "<br>Cannot execute query"); } // Expiration Notification if (!$testonly) { Process_Transaction($transactionInfo['transactionId'], "expiration"); } // Email sendTransactionEmail($transactionInfo['transactionId'], "customer_expire_confirmation", $testonly); /* $useEmailTemplate = "customer_expire_confirmation"; $data['site_URL'] = $transactionInfo['cs_URL']; $data['reference_number'] = $transactionInfo['reference_number']; $data['full_name'] = $transactionInfo['surname'].", ".$transactionInfo['name']; $data['customer_email'] = $transactionInfo['email']; $data['email'] = $transactionInfo['email']; $data['amount'] = "$".formatMoney($transactionInfo['amount']-$transactionInfo['td_customer_fee'])." USD"; $data['customer_fee'] = "$".formatMoney($transactionInfo['td_customer_fee'])." USD"; $data['final_amount'] = "$".formatMoney($transactionInfo['amount'])." USD"; $data['transaction_date'] = date("F j, Y",strtotime($transactionInfo['transactionDate']));