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; }
function smart_removeRefund($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 `cancelstatus` = 'N',`td_bank_deducted`=1,`td_merchant_deducted`=1,`td_reseller_deducted`=1 WHERE `transactionId` = '{$transID}'"; $rst_details = sql_query_write($qry_details) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>Cannot execute query"); $qry_details = "DELETE FROM cs_callnotes WHERE `cn_type` = 'refundrequest' AND `transaction_id` = '{$transID}'"; $rst_details = sql_query_write($qry_details) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>Cannot execute query"); $RF = new rates_fees(); $r = $RF->update_transaction_profit($transID); return array("action" => "Transaction ID " . $values['append'] . " refund removed.", "status" => "success"); }
<?php chdir(".."); set_time_limit(500); $gateway_db_select = 3; $etel_disable_https = 1; include "includes/dbconnection.php"; $RF = new rates_fees(); $log .= "Updating Pending Profit Actions.\n"; $sql = "SELECT pa_trans_id FROM `cs_profit_action` WHERE `pa_status` = 'pending' and `pa_type` = 'Transaction' order by pa_ID desc LIMIT 5000"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); if (mysql_num_rows($result) == 0) { $log .= "No Transaction Updates\n"; } else { while ($cs_profit_action = mysql_fetch_assoc($result)) { $log .= " Updating Transaction Profit for '" . $cs_profit_action['pa_trans_id'] . "'.\n"; $r = $RF->update_transaction_profit($cs_profit_action['pa_trans_id']); $log .= " Result: " . $r['msg'] . "\n"; } } //toLog('misc','system', $log); $sql = "SELECT * FROM `cs_profit_action` WHERE `pa_status` = 'pending' and `pa_type` = 'Payout' order by pa_ID desc LIMIT 1000"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); if (mysql_num_rows($result) == 0) { $log .= "No Payout Updates\n"; } else { $log .= "\n Updating Pending Payout Actions.\n"; while ($cs_profit_action = mysql_fetch_assoc($result)) { $log .= " Updating Payout Profit for Entity '" . $cs_profit_action['pa_en_ID'] . "'.\n"; $r = $RF->commit_payout($cs_profit_action['pa_en_ID'], array('date_entered' => $cs_profit_action['pa_date'])); $log .= " Result: " . $r['msg'] . "\n";
function JSON_get_data($qry) { global $etel_completion_array, $etel_entity_search, $etel_transaction_search; global $curUserInfo; $start_time = microtime_float(); $data = NULL; $data['output'] = NULL; $data['func'] = $qry['func']; switch ($qry['func']) { case 'getTransactionSearchOptions': $search_opts = $etel_transaction_search; case 'getEntitySearchOptions': if (!$search_opts) { $search_opts = $etel_entity_search; } foreach ($search_opts['options'] as $k => $s) { $sa[$s['g']]['o'][] = array('k' => $k, 'n' => $s['n'], 't' => $s['t'], 'c' => $s['c']); $sa[$s['g']]['g'] = $search_opts['groups'][$s['g']]['g']; } $data['search_options'] = array_values($sa); $data['search_func'] = $search_opts['search_func']; break; case 'getTransactionList': $search_opts = $etel_transaction_search; case 'getEntityList': if ($qry['silent']) { $data['silent'] = $qry['silent']; } if (!$search_opts) { $search_opts = $etel_entity_search; } $sql_info['join'] = array(); $search_conditions = array(); $sql_info['where'] = ''; foreach ($qry['en_search_by'] as $key => $search_by) { if ($search_by == 'er') { $qry['en_search'][$key] = $_SESSION["gw_user_en_ID"]; } $search_conditions[$key] = array('search' => quote_smart($qry['en_search'][$key]), 'searchby' => quote_smart($search_by)); if ($search_by == 'all') { foreach ($search_opts['options'] as $by => $opt) { if ($opt['allinfo']) { JSON_getEntityList_build_where($search_opts, $sql_info, $by, quote_smart($qry['en_search'][$key]), 'OR'); } } if ($sql_info['where']) { $sql_info['where'] = "( " . $sql_info['where'] . " )"; } } } foreach ($search_conditions as $sc) { JSON_getEntityList_build_where($search_opts, $sql_info, $sc['searchby'], $sc['search'], $qry['logic']); } if ($qry['sortby'] && $search_opts['options'][$qry['sortby']]['f']) { $sql_info['sort'] = " ORDER BY " . $search_opts['options'][$qry['sortby']]['f'] . " " . ($qry['sortdir'] == 'ASC' ? 'ASC ' : 'DESC '); } if (!$sql_info['sort']) { $sql_info['sort'] = " ORDER BY en_ID DESC "; } if ($sql_info['where']) { $sql_info['where'] = " AND ( " . $sql_info['where'] . " )"; } if (!$curUserInfo['en_access'][ACCESS_AUTH_ENTITY_ADMIN]) { $sql_info['where'] .= " AND en_type != 'admin' "; } $data['limit'] = intval($qry['limit']); if ($data['limit'] < 10) { $data['limit'] = 50; } if ($data['limit'] > 300) { $data['limit'] = 300; } $data['limitfrom'] = intval($qry['limitfrom']); if ($data['limitfrom'] < 1) { $data['limitfrom'] = 0; } $data['entity_list'] = array(); if ($sql_info['join']) { $sql_info['group'] = " Group by en_ID "; } $info['TimeOut'] = 5; $sql = "select SQL_CALC_FOUND_ROWS en.en_ID as id,en.en_company as cn,en.en_email as em,en.en_username as un, en.en_password as pw, en.en_type as ty from cs_entities as en " . implode(" ", $sql_info['join']) . " WHERE 1 " . $sql_info['where'] . $sql_info['group'] . $sql_info['sort'] . " limit " . $data['limitfrom'] . ',' . $data['limit']; //etelPrint($sql); if (in_array('wp', $qry['en_search_by'])) { $data['cmd'][] = array('id' => 'all', 'type' => 'ws', 'st' => 'pending'); } if (in_array('dp', $qry['en_search_by'])) { $data['cmd'][] = array('id' => 'all', 'type' => 'ud', 'st' => 'pending'); } if (in_array('pp', $qry['en_search_by'])) { $data['cmd'][] = array('id' => 'all', 'type' => 'pa', 'st' => 'pending'); } if (in_array('ip', $qry['en_search_by'])) { $data['cmd'][] = array('id' => 'all', 'type' => 'is', 'st' => 'Unanswered'); } //$data['sql'] = $sql; $result = sql_query_read($sql, $info) or dieLog(mysql_error() . " ~ {$sql}"); while ($entity = mysql_fetch_assoc($result)) { $entity['il'] = 'editCompanyProfileAccess.php?entity_id=' . $entity['id']; $entity['li'] = 'EntityManager.php?loginas=1&type=' . $entity['ty'] . '&username='******'un'] . '&hash=' . $entity['pw'] . '&entity_id=' . $entity['id']; if (strlen($entity['cn']) > 35) { $entity['cn'] = substr($entity['cn'], 0, 34) . "..."; } $data['entity_list'][] = $entity; } $sql = "select FOUND_ROWS()"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); $data['num_rows'] = mysql_result($result, 0, 0); $data['search_func'] = $search_opts['info_func']; $data['display_fields'] = array(array('k' => 'id', 'chk' => 1), array('k' => 'id', 'n' => 'ID'), array('k' => 'cn', 'n' => 'Company Name', 'ar' => array(array('k' => 'lg', 'n' => '(Login as)', 'btn' => array('li')), array('k' => 'cn', 'dl' => array('il')))), array('k' => 'op', 'n' => 'Options', 'opar' => array('info|(Information)', $curUserInfo['en_access'][ACCESS_AUTH_ENTITY_ADMIN] ? 'ac|(Access Rights)' : NULL, 'pr|(Profit)', 'pa|(Payouts)', 'is|(Issues)', 'ws|(Websites)', 'ud|(Documents)', 'pp|(PricePoints)', 'all|(Open All)'))); //$data['display_options'] = array();//,'em|Email' break; case 'setEntityInfo': $id = $qry['id']; $res = array('msg' => 'Failed to Update', 'status' => false); switch ($qry['f']) { case 'update_general': $update = array('General_Notes' => html_entity_decode(stripslashes($qry['nst']))); unset($qry['nst']); $update_result = etel_update_serialized_field('cs_entities', 'en_info', " en_ID = '" . $id . "'", $update); if (!$update_result) { $res = array('msg' => 'Invalid Entry', 'status' => false); } else { if ($update_result['updated']) { $res = array('msg' => 'Merchant Updated Successfully', 'status' => true); } else { $res = array('msg' => 'No Updates Detected', 'status' => true); } } $res['update'] = array('id' => $id, 'type' => 'info'); $data['result'][] = $res; break; case 'update_site': $conf_array = array('a' => 'approved', 'd' => 'declined', 'i' => 'ignored', 'n' => 'non-compliant'); if ($conf_array[$qry['nvr']]) { $res = en_confirm_website($qry['wi'], $conf_array[$qry['nvr']], $qry['nc']); } else { $res = array('msg' => 'Invalid Entry', 'status' => false); } if ($res['status']) { $res['update'] = array('id' => $id, 'type' => 'ws', 'hl' => $qry['wi'], 'st' => $qry['st']); } $data['result'][] = $res; break; case 'update_doc': $conf_array = array('a' => 'Approved', 'd' => 'Declined'); if ($conf_array[$qry['nst']]) { $res = en_confirm_documents($qry['fi'], $conf_array[$qry['nst']], $qry['nc']); } else { $res = array('msg' => 'Invalid Entry', 'status' => false); } $res['update'] = array('id' => $id, 'type' => 'ud', 'hl' => $qry['fi'], 'st' => $qry['st']); $data['result'][] = $res; break; case 'update_invoice': $res = en_update_invoice($qry['ii'], $qry['nst'], $qry['in'], $qry['em']); if ($res['status']) { $res['update'] = array('id' => $id, 'type' => 'pa', 'hl' => $qry['ii'], 'st' => $qry['st']); } $data['result'][] = $res; break; case 'update_access': $res = en_update_access($id, array($qry['al'] => $qry['nst'])); $data['result'][] = $res; break; case 'add_adjustment': $res = en_adjust_profit($id, $qry['ia'], $qry['ie'], $qry['in'], $qry['ic']); if ($res['status']) { $res['update'] = array('id' => $id, 'type' => 'pr'); } $data['result'][] = $res; break; case 'commit_payout': $RF = new rates_fees(); if ($curUserInfo['en_access'][ACCESS_AUTH_PAYMENTS]) { $res = $RF->commit_payout($id, array('date_entered' => $qry['pd'], 'amount' => $qry['pa'])); } if ($res['status']) { $res['update'] = array('id' => $id, 'type' => 'pa', 'hl' => $res['pa_ID']); } $data['result'][] = $res; break; } break; case 'getEntityInfo': $qry['id'] = explode(',', $qry['id']); $data['num_rows'] = 0; if ($qry['silent']) { $data['silent'] = $qry['silent']; } $highlight_format = array('tr|class|rowhighlight'); foreach ($qry['id'] as $i => $en_ID) { $en_ID = intval($en_ID); if (!is_array($qry['type'])) { $request = $qry['type']; } else { $request = $qry['type'][$i]; } switch ($request) { case 'all': case 'info': $entity = array('id' => $en_ID, 'msg' => 'No General Info Available', 'type' => 'info', 'info' => array(), 'use_tab' => true); $entityInfo = en_get_general_info($en_ID); //$entity['stats'] = array('n'=>"\n".$etel_completion_array[$entityInfo['cd_completion']]['txt']); $entity['display_fields'] = array(array('ar' => array(array('k' => 'st', 'edit' => 'textarea', 'tstamp' => true), array('k' => 'upd', 'edit' => 'button', 'f' => array('s|f|update_general|', 'fld|nst|st'), 'n' => '(Update)')), 'n' => 'General Info')); //,'em|Email' $entity['info'][] = array('sid' => $en_ID, 'st' => $entityInfo['en_info']['General_Notes']); $data['entity_info'][] = $entity; if ($request != 'all') { break; } case 'is': $entity = array('id' => $en_ID, 'msg' => 'No Issues Available', 'type' => 'is', 'info' => array(), 'use_tab' => true); $issues = en_get_issues($en_ID, array('AnsweredStatus' => $qry['st'])); $entity['display_fields'] = array(array('k' => 'sid', 'n' => 'ID', 'dl' => array('il')), array('k' => 'ti', 'n' => 'Summary', 'dl' => array('il')), array('k' => 'is', 'n' => 'Respond', 'pl' => array('el')), array('k' => 'st', 'n' => 'Status'), array('k' => 'cs', 'n' => 'Answered')); foreach ($issues as $id => $issue) { $entity['info'][] = array('sid' => $id, 'ti' => $issue['iss_created_date'] . " - " . $issue['iss_summary'], 'st' => $issue['sta_title'], 'cs' => $issue['iss_control_status'], 'il' => "/ev/view.php?id=" . $issue['iss_id'], 'el' => "/ev/send.php?issue_id=" . $issue['iss_id'] . "&ema_id=" . $issue['ema_id'] . "&id=" . $issue['sup_id']); } $data['entity_info'][] = $entity; if ($request != 'all') { break; } case 'ac': global $etel_access; $entityInfo = en_get_general_info($en_ID); $entity = array('id' => $en_ID, 'msg' => 'No Access Info Available', 'type' => 'ac', 'info' => array(), 'use_tab' => true); $entity['display_fields'] = array(array('k' => 'na', 'n' => 'Access Level'), array('ar' => array(array('k' => 'st', 'edit' => 'checkbox', 'f' => array('s|f|update_access|', 'k|al|sid', 'fld|nst|st'))), 'n' => 'Status')); foreach ($etel_access as $key => $acinfo) { $entity['info'][] = array('sid' => $acinfo['Value'], 'na' => $acinfo['Value'] . ": " . etel_format_variable($key) . ($acinfo['Name'] ? " (" . $acinfo['Name'] . ")" : ''), 'st' => $entityInfo['en_access'][$acinfo['Value']]); } if ($curUserInfo['en_access'][ACCESS_AUTH_ENTITY_ADMIN]) { $data['entity_info'][] = $entity; } if ($request != 'all') { break; } case 'pr': $entity = array('id' => $en_ID, 'msg' => 'No Profit Data Available', 'type' => 'pr', 'info' => array(), 'use_tab' => true); $RF = new rates_fees(); $entityInfo = en_get_general_info($en_ID); $datestamp = $_REQUEST['date'] ? strtotime($_REQUEST['date']) : 0; $date = $datestamp > 1 ? date('Y-m-d', $datestamp) : $entityInfo['PaySchedule']['NextPayDay']; $profit_info = $RF->get_profit(array('EffectiveOnly' => $date), $en_ID); $entity['display_fields'] = array(array('k' => 'tp', 'n' => 'Profit Type'), array('k' => 'am', 'n' => 'Amount')); //,'em|Email' $entity['stats']['opts'] = array('n' => "Actions", 'ar' => array(array('txt' => "Make an Adjustment", 'attrib' => array('obj|style|font-weight:bold;text-align:center;')), array('node' => "hr"), array('txt' => "Amount: "), array('k' => 'ia', 'edit' => 'textfield', 'attrib' => array('obj|style|width:50px;')), array('txt' => "\nEffective: "), array('k' => 'ie', 'edit' => 'textfield', 'attrib' => array('obj|style|width:70px;')), array('txt' => "\nTitle:\n"), array('k' => 'in', 'edit' => 'textfield', 'attrib' => array('obj|style|width:180px;')), array('txt' => "\nComments:\n"), array('k' => 'ic', 'edit' => 'textarea', 'attrib' => array('obj|style|height:45px;width:180px;')), array('txt' => "\n"), array('k' => 'adj', 'edit' => 'button', 'f' => array('s|f|add_adjustment', 'fld|ia|ia', 'fld|ie|ie', 'fld|in|in', 'fld|ic|ic'), 'n' => '(Create)'), array('node' => "hr")), 'attrib' => array('tdcol|align|left')); $entity['stats']['data'] = array('sid' => $en_ID, 'am' => $profit_info['Total']['Amount'], 'ic' => '', 'ia' => '0.00', 'in' => date('Y-m-d') . ' Adjustment', 'ie' => date('Y-m-d')); if (!$curUserInfo['en_access'][ACCESS_AUTH_ADJUSTMENTS]) { unset($entity['stats']); } $total_section_format = array('tr|style|font-weight:bold;font-style:italic;', 'td|class|row0'); $total_format = array('tr|style|font-weight:bold;font-size:11px;font-style:italic;', 'td|class|row0'); //,"td|onclick|" if (sizeof($profit_info['Revenue'])) { foreach ($profit_info['Revenue'] as $type => $val) { $entity['info'][] = array('sid' => 'd_' . $type, 'tp' => "(Revenue) {$type}", 'am' => '$' . formatMoney($val['Amount']) . " (" . $val['Count'] . ")", 'attrib' => $type == 'Total' ? $total_section_format : NULL); } } if (sizeof($profit_info['Deductions'])) { foreach ($profit_info['Deductions'] as $type => $val) { $entity['info'][] = array('sid' => 'd_' . $type, 'tp' => "(Deductions) {$type}", 'am' => '$' . formatMoney($val['Amount']) . " (" . $val['Count'] . ")", 'attrib' => $type == 'Total' ? $total_section_format : NULL); } } $entity['info'][] = array('sid' => $en_ID, 'tp' => "Total Owed (" . $date . ")", 'am' => '$' . formatMoney($profit_info['Total']['Amount']) . " (" . $profit_info['Total']['Count'] . ")", 'attrib' => $total_format, 'opts' => array('tp' => array('k' => 'tp', 'dl' => array('chg', 'Click to Change Date'))), 'chg' => "javascript:en_get_info({'id':'{$en_ID}','type':'pr','date':prompt('Enter New Date','{$date}')})"); $data['num_rows']++; $data['entity_info'][] = $entity; if ($request != 'all') { break; } case 'pa': $entity = array('id' => $en_ID, 'msg' => 'No Payout Data Available', 'type' => 'pa', 'info' => array(), 'use_tab' => true); $RF = new rates_fees(); $payouts = $RF->get_payouts(array('where' => $qry['st'] ? array('pa_status' => $qry['st']) : NULL), $en_ID); $entityInfo = en_get_general_info($en_ID); foreach ($payouts as $key => $payout) { $entity['info'][] = array('sid' => $payout['pa_ID'], 'am' => '$' . formatMoney($payout['balance']), 'in' => $payout['pa_info']['Notes'], 'ti' => ($payout['pa_ID'] == $qry['hl'] ? 'Recently Updated - ' : '') . $payout['pa_desc'], 'nst' => $payout['pa_status'], 'attrib' => $payout['pa_ID'] == $qry['hl'] ? $highlight_format : NULL); } $entity['display_fields'] = array(array('ar' => array(array('k' => 'ti', 'attrib' => array('obj|style|font-weight:bold')), array('node' => "br"), array('k' => 'nst', 'edit' => 'select', 'selopts' => array('payout_pending|Payment Pending', 'payout_sent|Payment Sent', 'success|Successful Payment', 'payout_failed|Payment Failed'), 'n' => 'Status: ')), 'n' => 'Invoice Info'), array('ar' => array(array('k' => 'in', 'edit' => 'textarea', 'attrib' => array('obj|style|height:45px;width:250px;'))), 'n' => 'Comments'), array('ar' => array(array('k' => 'upd', 'edit' => 'button', 'f' => array('s|f|update_invoice', 'k|ii|sid', 'fld|nst|nst', 'fld|in|in', 'fld|em|em', 's|st|' . $qry['st']), 'n' => '(Update)'), array('k' => 'em', 'edit' => 'checkbox', 'n' => ' Email?')), 'n' => 'Update', 'attrib' => array('obj|style|width:50px;'))); //,'em|Email' $entity['stats']['opts'] = array('n' => "Actions", 'ar' => array(array('txt' => "Payout", 'attrib' => array('obj|style|font-weight:bold;text-align:center;', 'tdcol|style|width:40px;')), array('node' => "hr"), array('txt' => "Amount:\n"), array('k' => 'pa', 'edit' => 'textfield', 'attrib' => array('obj|style|width:60px;')), array('txt' => "\nPayday:\n"), array('k' => 'pd', 'edit' => 'textfield', 'attrib' => array('obj|style|width:60px;')), array('txt' => "\n"), array('k' => 'pay', 'edit' => 'button', 'f' => array('s|f|commit_payout', 'fld|pa|pa', 'fld|pd|pd'), 'n' => '(Pay)')), 'attrib' => array('tdcol|align|left')); $entity['stats']['data'] = array('sid' => $en_ID, 'pa' => '0.0', 'pd' => $entityInfo['PaySchedule']['NextPayDay']); if (!$curUserInfo['en_access'][ACCESS_AUTH_PAYMENTS]) { unset($entity['stats']); } $data['entity_info'][] = $entity; if ($request != 'all') { break; } case 'ws': $entity = array('id' => $en_ID, 'msg' => 'No Website Data Available', 'type' => 'ws', 'info' => array(), 'use_tab' => true); $site_list = en_get_websites($en_ID, false, $qry['st']); $entity['display_fields'] = array(array('k' => 'na', 'n' => 'Website'), array('ar' => array(array('k' => 'edt', 'edit' => 'button', 'f' => array('s|f|update_site', 'k|wi|sid', 'p|nvr|Please Enter New Status (a=Approved, d=Declined, i=Ignored, n=Non-Compliant)', 'p|nc|Please Enter Comments (Required for Decline)', 's|st|' . $qry['st']), 'n' => '(Change)'), array('k' => 'vr')), 'n' => 'Status'), array('ar' => array(array('k' => 'cu', 'n' => '(Website)', 'pl' => array('cu')), array('k' => 'op', 'n' => '(Order Page)', 'pl' => array('op')), array('k' => 'rp', 'n' => '(Return Page)', 'pl' => array('rp')), array('k' => 'mem', 'n' => '(Members Section)', 'pl' => array('mu', 'mun', 'mpw')), array('k' => 'ftp', 'n' => '(Ftp)', 'pl' => array('ft', 'fun', 'fpw')), array('k' => '2257', 'n' => '(2257 Page)', 'pl' => array('2257'))), 'n' => 'Links', 'attrib' => array('td|width|144px'))); foreach ($site_list as $key => $site) { $entity['info'][] = array('sid' => $site['cs_ID'], 'rf' => $site['cs_reference_ID'], 'na' => $site['cs_name'], 'cu' => $site['cs_URL'], 'op' => $site['cs_order_page'], 'rp' => $site['cs_return_page'], 'mu' => $site['cs_member_url'], 'mun' => $site['cs_member_username'], 'mpw' => $site['cs_member_password'], 'ft' => $site['cs_ftp'], 'fun' => $site['cs_ftp_user'], 'fpw' => $site['cs_ftp_pass'], 'vr' => ucfirst($site['cs_verified']) . ' (' . $site['cs_reason'] . ')', '2257' => $site['cs_2257_page']); } $data['num_rows']++; $data['entity_info'][] = $entity; if ($request != 'all') { break; } case 'ud': $entity = array('id' => $en_ID, 'msg' => 'No Document Data Available', 'type' => 'ud', 'info' => array(), 'use_tab' => true); $doc_list = en_get_documents($en_ID, $qry['st']); $entity['display_fields'] = array(array('k' => 'ft', 'n' => 'File Type'), array('ar' => array(array('k' => 'fl', 'n' => 'File Link', 'pl' => array('fl')), array('k' => 'up', 'n' => 'Upload New File', 'pl' => array('up')), array('k' => 'fn', 'n' => 'File Name')), 'n' => 'File Name'), array('ar' => array(array('k' => 'edt', 'edit' => 'button', 'f' => array('s|f|update_doc', 'k|fi|sid', 'p|nst|Please Enter New Status (a=Approved, d=Declined)', 'p|nc|Please Enter Comments (Required for Decline)', 's|st|' . $qry['st']), 'n' => '(Change)'), array('k' => 'st'), array('k' => 'rr')), 'n' => 'Status')); foreach ($doc_list as $key => $doc) { $entity['info'][] = array('sid' => $doc['file_id'], 'ft' => $doc['file_type'], 'fn' => $doc['file_name'], 'du' => $doc['date_uploaded'], 'rr' => '(' . $doc['reject_reason'] . ')', 'st' => $doc['status'], 'fl' => "../gateway/" . $_SESSION['gw_folder'] . "UserDocuments/" . $doc['file_type'] . "/" . $doc['file_name'], 'up' => "uploadDocuments.php?company=" . $doc['user_id']); } $data['num_rows']++; $data['entity_info'][] = $entity; if ($request != 'all') { break; } case 'pp': $entity = array('id' => $en_ID, 'msg' => 'No Price Point Data', 'type' => 'pp', 'info' => array(), 'use_tab' => true); $pp_list = en_get_pricepoints($en_ID); foreach ($pp_list as $key => $pp) { $entity['info'][] = array('sid' => $pp['rd_subaccount'], 'sn' => $pp['rd_subName'], 'de' => $pp['rd_description'], 'sc' => $pp['schedule'], 'st' => $pp['active'] . "/" . $pp['total']); } $entity['display_fields'] = array(array('k' => 'sn', 'n' => 'Name'), array('k' => 'de', 'n' => 'Description'), array('k' => 'sc', 'n' => 'Price Point Schedule'), array('k' => 'st', 'n' => 'Active/Total')); $data['entity_info'][] = $entity; if ($request != 'all') { break; } } } $data['entity_ids'] = $qry['id']; break; case 'getCompanyInfo': $sql_info = JSON_getCompanyInfo_build($qry); $limit_to = $sql_info['limit_to']; $sql = $sql_info['sql_full'] . " order by companyname asc limit {$limit_to}"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); $i = 0; $website_search_ids = "-1"; $company_list = array(); while ($company = mysql_fetch_assoc($result)) { $website_search_ids .= "," . $company['ui']; $company_list[] = $company; } $sql = "select FOUND_ROWS()"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); $data['num_rows'] = mysql_result($result, 0, 0); $sql = "select cs_ID as ci,cs_name as cn,cs_company_ID as cui FROM `cs_company_sites` as cs \r\n\t\t\t where cs_company_ID in ({$website_search_ids}) order by cs_name"; // left join cs_transactiondetails td on cd . userId =td . userId // group by cd.userId $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); $site_list = array(); while ($site = mysql_fetch_assoc($result)) { $site_list[] = $site; } $data['company_list'] = $company_list; $data['show_option_all'] = $sql_info['show_option_all']; $data['site_list'] = $site_list; $data['completion'] = $etel_completion_array; break; case 'getEVTransactionResults': $search_array = array('em' => 'email', 'cc' => 'CCNumber', 'rn' => 'reference_number', 'ss' => 'td_ss_ID'); $limit_to = 50; if ($qry['search'] && $qry['searchby'] == 'cc') { $qry['search'] = etelEnc($qry['search']); } if ($qry['search'] && $qry['searchby'] && $search_array[$qry['searchby']]) { $sql_where .= " and " . $search_array[$qry['searchby']] . " = '" . $qry['search'] . "'"; } $sql = "\r\n\t\t\t\tselect \r\n\t\t\t\t\tDate_Format(transactionDate,'%W %b %D %Y %H:%i:%s') as 'Date',\r\n\t\t\t\t\treference_number as 'Reference ID',\r\n\t\t\t\t\tconcat(name,' ',surname) as 'Full Name' ,\r\n\t\t\t\t\temail as 'Email Address',\r\n\t\t\t\t\tCONCAT(\t\r\n\t\t\t\t\t\tif(status!='D',\r\n\t\t\t\t\t\t\tif(status='P','Pending', 'Approved'),\r\n\t\t\t\t\t\t\t'Declined'\r\n\t\t\t\t\t\t)\t\t\r\n\t\t\t\t\t) as 'Status',\r\n\t\t\t\t\tif(td_is_a_rebill=1,' Rebilled Transaction',' New Order') as 'Type'\r\n\t\t\t\tfrom cs_transactiondetails as td\r\n\t\t\t\twhere \r\n\t\t\t\t\t1 {$sql_where} \r\n\t\t\t\torder by transactionDate desc\r\n\t\t\t\tlimit {$limit_to}\r\n\t\t\t\t"; $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ {$sql}"); $data['output'] = "<table >\n"; $i = 0; while ($trans = mysql_fetch_assoc($result)) { if ($i == 0) { $data['output'] .= " <tr class='default'>\n"; foreach ($trans as $field => $value) { $data['output'] .= " <td><b>{$field}</b></td>\n"; } $data['output'] .= " </tr>\n"; } $data['output'] .= " <tr class='default' onclick='td_updateWith(\"" . $trans['Reference ID'] . "\")' onmouseout='td_highlightRow(this,0)' onmousemove='td_highlightRow(this,1)'>\n"; foreach ($trans as $field => $value) { $data['output'] .= " <td>{$value}</td>\n"; } $data['output'] .= " </tr>\n"; $i++; } $data['output'] .= " <tr class='default'>\n <td>({$i}) Results</td>\n </tr>\n</table>"; break; default: $data['func'] = NULL; break; } foreach ($qry as $key => $value) { $data['json_query'] .= ($data['json_query'] ? "&" : "") . $key . '=' . $value; } //print_r($data); if (!$data['output']) { unset($data['output']); } $data['duration'] = round(microtime_float() - $start_time, 4); return $data; }
<?php include 'includes/sessioncheck.php'; require_once "includes/dbconnection.php"; $pageConfig['Title'] = 'Invoice Information'; $headerInclude = "reports"; $periodhead = "Ledgers"; $display_stat_wait = true; include 'includes/header.php'; if (!$_REQUEST['InvoiceID']) { dieLog('No Invoice Selected', 'No Invoice Selected'); } $RF = new rates_fees(); $Payouts = $RF->get_payouts(array('pa_ID' => intval($_REQUEST['InvoiceID'])), $curUserInfo['en_ID']); if ($Payouts['status'] === false) { dieLog($Payouts['msg'], $Payouts['msg']); } $Payouts = array('InvoiceInfo' => array_pop($Payouts)); $time = strtotime($Payouts['InvoiceInfo']['pa_date']); $Payouts['ThisPeriodEnd'] = date('Y-m-d', $time); $Payouts['LastPeriodEnd'] = en_get_payout_period($curUserInfo, 'last', $time); $Payouts['ThisPeriodStart'] = date('Y-m-d', strtotime($Payouts['LastPeriodEnd']) + 60 * 60 * 24); $Payouts['InvoiceProfit'] = $RF->get_profit(array('EffectiveOnly' => false, 'hidepayout' => true, 'date_between' => array('Start' => $Payouts['ThisPeriodStart'], 'End' => $Payouts['ThisPeriodEnd'])), $curUserInfo['en_ID']); //etelPrint($Payouts['InvoiceProfit']); $Payouts['PreviousProfit'] = $RF->get_profit(array('EffectiveOnly' => false, 'hidepayout' => true, 'date_between' => array('Start' => '2000-01-01', 'End' => $Payouts['LastPeriodEnd'])), $curUserInfo['en_ID']); foreach ($Payouts['InvoiceProfit']['Revenue'] as $key => $type) { $Payouts['InvoiceProfit']['Revenue'][$key]['Link'] = "ProfitSmart.php?frm_pt_pt_type%5B%5D=" . $key . "&frm_pt_pt_date_effective_from=" . $Payouts['ThisPeriodStart'] . "&frm_pt_pt_date_effective_to=" . $Payouts['ThisPeriodEnd'] . ""; } foreach ($Payouts['InvoiceProfit']['Deductions'] as $key => $type) { $Payouts['InvoiceProfit']['Deductions'][$key]['Link'] = "ProfitSmart.php?frm_pt_pt_type%5B%5D=" . $key . "&frm_pt_pt_date_effective_from=" . $Payouts['ThisPeriodStart'] . "&frm_pt_pt_date_effective_to=" . $Payouts['ThisPeriodEnd'] . ""; }
$access['Data']['td_tracking_ship_est']['disable'] = false; $access['Data']['td_tracking_info']['disable'] = false; } unset($access['Data']['cd_enable_tracking']); unset($access['Data']['td_enable_tracking']); $access['Data']['ss_cancel_id']['DisplayName'] = 'Cancelation ID'; if (!$access['Data']['ss_cancel_id']['Value']) { unset($access['Data']['ss_cancel_id']); } if (!$access['Data']['ss_billing_state']['Value']) { unset($access['Data']['ss_billing_state']); } if (!$access['Data']['Last_Rebill_Date']['Value']) { unset($access['Data']['Last_Rebill_Date']); } $RF = new rates_fees(); $r = $RF->update_transaction_profit($transactionId); $profit = $RF->get_profit(array('EffectiveOnly' => false, 'where_trans' => array('pa_trans_ID' => $transactionId)), 2); if ($profit['status'] === false) { //$r = $RF->update_transaction_profit($transactionId); //$profit = $RF->get_profit(array('EffectiveOnly'=>false,'where_trans'=>array('pa_trans_ID'=>$transactionId)),2); } $row = 2; $access['Data']['Breakdown']['RowDisplay'] = 'Wide'; $access['Data']['Breakdown']['disable'] = true; $access['Data']['Breakdown']['DisplayName'] = 'Breakdown'; $access['Data']['Breakdown']['AddHtml'] .= $smarty->assign("Profit", $profit); $access['Data']['Breakdown']['AddHtml'] = $smarty->fetch('cp_profitreport.tpl'); if ($_POST['submit_access'] == 'Submit') { $result = processAccessForm(&$access); if ($result) {
$access['Data']['merchant_log']['Style'] = 'width:280px;'; $access['Data']['merchant_log']['Rows'] = '40'; $access['Data']['merchant_log']['ExcludeQuery'] = true; $access['Data']['merchant_log']['disable'] = true; $access['Data']['merchant_log']['Input_Custom'] = "Select lg_ID, \t \r\nconcat( Date_Format(from_unixtime( lg_timestamp ),'%m-%d %H:%i'),' - ',lg_action,': ',if(lg_txt is not null,lg_txt,'')) as log,\r\nlg_txt as title\r\nFrom cs_log where lg_actor = 'merchant' and lg_item_id = '{$company_id}' order by lg_ID desc limit 300"; unset($access['Data']['merchant_log']); // Actions if ($_POST['submit_access'] == 'Submit') { if ($_POST['Email_Contract_Notification']) { send_email_template('contract_notification_email', $emaildata); } if ($_POST['Email_Active_Notification']) { send_email_template('active_notification_email', $emaildata); } if ($_POST['cd_custom_contract'] && !$access['Data']['cd_custom_contract']['Value']) { $Rates = new rates_fees(); $contract = $Rates->get_Merchant_Contract($en_ID); $sql = "insert into cs_email_templates \r\n\t\t\tset et_name='merchant_contract', \r\n\t\t\tet_custom_id='" . $company_id . "', \r\n\t\t\tet_title='" . quote_smart($access['Data']['en_company']['Value']) . " Contract', \r\n\t\t\tet_access='admin', \r\n\t\t\tet_to_title='" . quote_smart($access['Data']['en_company']['Value']) . "', \r\n\t\t\tet_subject='Custom Merchant Contract for " . quote_smart($access['Data']['en_company']['Value']) . "', \r\n\t\t\tet_htmlformat='" . quote_smart($contract['et_htmlformat']) . "', \r\n\t\t\tet_catagory='Merchant'"; $result = sql_query_write($sql) or dieLog(mysql_error() . " ~ sql"); $_POST['cd_custom_contract'] = mysql_insert_id(); } else { if (!$_POST['cd_custom_contract'] && $access['Data']['cd_custom_contract']['Value']) { $sql = "delete from cs_email_templates where et_name='merchant_contract' and et_custom_id='" . $company_id . "'"; $result = sql_query_write($sql) or dieLog(mysql_error() . " ~ sql"); $access['Data']['cd_custom_contract']['AddHtml'] = NULL; } } } $res = check_merchant_conflict($_POST, $en_ID); if (!$res['status']) { $access['HeaderMessage'] .= nl2br($res['msg']);
function get_month_profit($en_ID, $Month_Stamp = NULL) { global $companyInfo; if (!$Month_Stamp) { $Month_Stamp = time(); } $RF = new rates_fees(); $Month_FirstDay_Stamp = strtotime(date('Y-m-01', $Month_Stamp)); $Month_FirstDay_WeekDay = intval(date('w', $Month_FirstDay_Stamp)); $Month_NumberOfDays = intval(date('t', $Month_FirstDay_Stamp)); $Month_Start_Stamp = $Month_FirstDay_Stamp - 60 * 60 * 24 * $Month_FirstDay_WeekDay; $Month_End_Stamp = $Month_FirstDay_Stamp + 60 * 60 * 24 * (ceil($Month_NumberOfDays / 7) * 7); $Current_Stamp = $Month_Start_Stamp; $Calendar = array(); $Calendar['Notes'] = "This Calendar shows how much profit (after fees) is owed on each day.\n"; $Calendar['PayDayInfo'] = en_get_payout_schedule($companyInfo); $PayDays = $Calendar['PayDayInfo']['DayArray']; $Calendar['MonthName'] = date('F', $Month_FirstDay_Stamp); $Profit = $RF->get_profit(array('hidepayout' => true, 'EffectiveOnly' => false, 'group_date' => true, 'date_between' => array('Start' => date('Y-m-d', $Month_Start_Stamp), 'End' => date('Y-m-d', $Month_End_Stamp - 1))), $en_ID); $Calendar['PayoutHistory'] = $RF->get_payouts(array('date_between' => array('Start' => date('Y-m-d', $Month_Start_Stamp), 'End' => date('Y-m-d', $Month_End_Stamp - 1))), $en_ID); $NextPayday = $Calendar['PayDayInfo']['NextPayDay']; $ProjectedPayment = $RF->get_profit(array('EffectiveOnly' => $NextPayday), $en_ID); if ($ProjectedPayment['Total']['Amount'] > 0) { $Calendar['Notes'] .= " Next Projected Settlement Date is on " . date('l F d, Y', strtotime($NextPayday)) . " for \$" . formatMoney($ProjectedPayment['Total']['Amount']) . "\n"; $ProjectedPayment['Title'] = date('l F d, Y', strtotime($NextPayday)) . " Retroactive Projection Breakdown"; foreach ($ProjectedPayment['Revenue'] as $key => $type) { $ProjectedPayment['Revenue'][$key]['Link'] = "ProfitSmart.php?frm_pt_pt_type%5B%5D=" . $key . "&frm_pt_pt_date_effective_from=2000-01-01&frm_pt_pt_date_effective_to=" . $NextPayday . ""; } foreach ($ProjectedPayment['Deductions'] as $key => $type) { $ProjectedPayment['Deductions'][$key]['Link'] = "ProfitSmart.php?frm_pt_pt_type%5B%5D=" . $key . "&frm_pt_pt_date_effective_from=2000-01-01&frm_pt_pt_date_effective_to=" . $NextPayday . ""; } $ProjectedPayment['Link'] = "ProfitSmart.php?frm_pt_pt_date_effective_from=2000-01-01&frm_pt_pt_date_effective_to=" . $NextPayday . ""; } while ($Current_Stamp < $Month_FirstDay_Stamp + 60 * 60 * 24 * $Month_NumberOfDays) { for ($i = 0; $i < 7; $i++) { $Day = array('Date' => date('Y-m-d', $Current_Stamp), 'Num' => date('d', $Current_Stamp), 'CurMonth' => date('m', $Current_Stamp) == date('m', $Month_FirstDay_Stamp)); if ($companyInfo['en_pay_type'] == 'Weekly') { $Day['PayDay'] = $PayDays[intval(date('w', $Current_Stamp))] ? true : false; } if ($companyInfo['en_pay_type'] == 'Monthly') { $Day['PayDay'] = $PayDays[intval(date('d', $Current_Stamp))] ? true : false; } $ProfitDay = $Profit['ByDate'][$Day['Date']]; //$Day['Text'] = '<strong>Revenue</strong>:<br> $'.formatMoney($ProfitDay['Revenue']['Total']['Amount']).'<br>'; //$Day['Text'] .= '<strong>Deductions</strong>:<br> $'.formatMoney($ProfitDay['Deductions']['Total']['Amount']).'<br>'; $Day['Text'] .= "<a href='ProfitSmart.php?hideprofit=1&showdate=" . $Day['Date'] . "'>\$" . formatMoney($ProfitDay['Total']['Amount']) . "</a>"; if ($Calendar['PayoutHistory'][$Day['Date']]) { $Day['Text'] .= '<br><b>Payment: <a href=\'SmartInvoiceView.php?InvoiceID=' . $Calendar['PayoutHistory'][$Day['Date']]['pa_ID'] . '\'>$' . formatMoney($Calendar['PayoutHistory'][$Day['Date']]['Amount']) . '</a></b>'; } else { if ($Day['Date'] == $NextPayday && $ProjectedPayment['Total']['Amount'] > 0) { $Day['Text'] .= '<br><b>Projected Payment: <a href=\'#Projection\'>$' . formatMoney($ProjectedPayment['Total']['Amount']) . '</a></b>'; } else { if (!$ProfitDay['Total']['Count']) { $Day['Text'] = "No Activity"; } } } $Calendar['Week'][date('W', $Current_Stamp + 60 * 60 * 24)]['Day'][$i] = $Day; $Current_Stamp += 60 * 60 * 24; } } $Calendar['Profit'] = $Profit; $Calendar['ProjectedPayment'] = $ProjectedPayment; return $Calendar; }
function en_adjust_profit($en_ID, $amount, $effective_date = NULL, $title = NULL, $details = NULL) { global $curUserInfo; if (!$curUserInfo['en_access'][ACCESS_AUTH_ADJUSTMENTS]) { return array('msg' => 'Invalid Access', 'status' => false); } $amount = preg_replace('/[^0-9.]/', '', $amount); $data['date_effective'] = $effective_date; $data['description'] = $title; if ($details) { $data['information'] = array('Notes' => $details); } $RF = new rates_fees(); $res = $profit_info = $RF->commit_adjustment($en_ID, $amount, $data); return $res; }
$access['Data']['td_tracking_ship_est']['disable'] = false; $access['Data']['td_tracking_info']['disable'] = false; } unset($access['Data']['cd_enable_tracking']); unset($access['Data']['td_enable_tracking']); $access['Data']['ss_cancel_id']['DisplayName'] = 'Cancelation ID'; if (!$access['Data']['ss_cancel_id']['Value']) { unset($access['Data']['ss_cancel_id']); } if (!$access['Data']['ss_billing_state']['Value']) { unset($access['Data']['ss_billing_state']); } if (!$access['Data']['Last_Rebill_Date']['Value']) { unset($access['Data']['Last_Rebill_Date']); } $RF = new rates_fees(); $r = $RF->update_transaction_profit($transactionId, true); etelPrint($r); $profit = $RF->get_profit(array('EffectiveOnly' => false, 'useTransTable' => true, 'where' => array('pa_trans_ID' => $transactionId)), 2); if (!is_array($profit['Revenue'])) { $r = $RF->update_transaction_profit($transactionId); $profit = $RF->get_profit(array('EffectiveOnly' => false, 'useTransTable' => true, 'where' => array('pa_trans_ID' => $transactionId)), 2); } $row = 2; $access['Data']['Breakdown']['RowDisplay'] = 'Wide'; $access['Data']['Breakdown']['Input'] = ''; $access['Data']['Breakdown']['disable'] = true; $access['Data']['Breakdown']['DisplayName'] = false; $access['Data']['Breakdown']['AddHtml'] .= $smarty->assign("Profit", $profit); $access['Data']['Breakdown']['AddHtml'] = $smarty->fetch('cp_profitreport.tpl'); if ($_POST['submit_access'] == 'Submit') {
<?php chdir(".."); set_time_limit(500); $gateway_db_select = 3; $etel_disable_https = 1; include "includes/dbconnection.php"; $time = time(); $weekNum = date('w', $time); $monthNum = date('d', $time); $log = " Updating Profit.\n"; $sql = "\r\nSELECT \r\n\t* \r\nFROM \r\n\t`cs_entities` \r\nWHERE \r\n\t(\r\n\t\t(`en_pay_type` = 'Monthly' and en_pay_data >> '{$monthNum}' & 1) || \r\n\t\t(`en_pay_type` = 'Weekly' and en_pay_data >> '{$weekNum}' & 1)\r\n\t)\r\n\tand en_type in ('merchant','reseller')\r\n"; $RF = new rates_fees(); $result = sql_query_read($sql) or dieLog("{$sql} ~ " . mysql_error()); while ($entityInfo = mysql_fetch_assoc($result)) { //$log .= " Updating Monthly/Setup Fee for '".$entityInfo['en_company']."'.\n"; //$r = $RF->commit_fees($entityInfo['en_ID']); //$log .= " Result: ".$r['msg']."\n"; $log .= " Updating Entity Payout for '" . $entityInfo['en_company'] . "'.\n"; $r = $RF->commit_payout($entityInfo['en_ID'], array('pending_only' => true, 'date_entered' => date('Y-m-d', $time))); $log .= " Result: " . $r['msg'] . "\n"; } toLog('misc', 'system', $log); echo nl2br($log);
$curUserInfo['merchant_contract_agree'] = $agree_contract; if ($agree_contract && $curUserInfo['cd_completion'] <= 4) { $completion = ' cd_completion=6, '; } $str_qry = "update cs_companydetails set {$completion} merchant_contract_agree = '{$agree_contract}',cd_contract_ip='{$cd_contract_ip}',cd_contract_date='{$cd_contract_date}' where userId = '" . $curUserInfo['userId'] . "'"; if ($agree_contract == 1) { sql_query_write($str_qry, $cnn_cs) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>{$str_qry}"); if ($completion) { en_status_change_notify($curUserInfo['en_ID']); } print "<script>document.location.href='Listdetails.php?type=testMode&msg=Merchant+Contract+Completed+Successfully. Please Print, Sign, and Upload your Merchant Contract.';</script>"; die; } } $confirm = $curUserInfo['merchant_contract_agree'] == "1" ? "checked" : ""; $Rates = new rates_fees(); $contract = $Rates->get_Merchant_Contract($curUserInfo['en_ID']); //if($curUserInfo['cd_custom_contract']) $content = $curUserInfo['cd_custom_contract']; $content = $contract['et_htmlformat']; ?> <form name="merchant_contract" method="post" action=""> <table border="0" cellpadding="0" width="100%" cellspacing="0" > <tr> <td width="83%" valign="top" align="center" height="333"> <table border="0" cellpadding="0" cellspacing="0" width="85%" class="disbd"> <tr> <td width="100%" valign="top" align="center"> <table border="0" cellspacing="0" cellpadding="0" width="640" height="61">
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; }
$log .= "{$name} (Old:'" . $value['old'] . "') = '" . $value['new'] . "' "; } toLog('misc', 'merchant', $log, $company_id); } else { $msg = "No Updates Detected"; } } $access['HeaderMessage'] .= $msg; if ($access['Data']['en_pay_data']['Value']) { $Schedule = en_get_payout_schedule(array('en_pay_data' => $access['Data']['en_pay_data']['Value'], 'en_pay_type' => $access['Data']['en_pay_type']['Value'])); $access['Data']['en_pay_data']['Value'] = $Schedule['Days']; } beginTable(); writeAccessForm(&$access); endTable("Update Company - " . $access['Data']['en_company']['Value'], ""); $rates_class = new rates_fees(); if (isset($_POST['frmb_process']) && $curUserInfo['en_access'][ACCESS_AUTH_RATES]) { $new_settings = array(); $banks = $rates_class->get_BanksById(); if (isset($_POST['frmb_bankid'])) { foreach ($_POST['frmb_bankid'] as $index => $bank_id) { $bank_name = $banks[$bank_id]['bank_name']; $new_settings[$bank_name] = array(); $new_settings[$bank_name]['bank_id'] = $bank_id; $custom = get_bank_custom_fields($bank_id, $new_settings[$bank_name]['custom']); if ($custom['data']) { $new_settings[$bank_name]['custom'] = $custom['data']; } } } foreach ($_POST as $name => $value) {
} if (!$access['Data']['Last_Rebill_Date']['Value']) { unset($access['Data']['Last_Rebill_Date']); } $access['Data']['trans_log']['InputAdditional'] = 'multiple="multiple" onchange=document.location.href="viewTransaction.php?ref="+this.value+"' . $addvar . '"'; $access['Data']['trans_log']['Input'] = 'selectcustom'; $access['Data']['trans_log']['Style'] = 'width:538px;'; $access['Data']['trans_log']['Rows'] = '10'; $access['Data']['trans_log']['DisplayName'] = 'History'; $access['Data']['trans_log']['ExcludeQuery'] = true; $access['Data']['trans_log']['disable'] = false; $access['Data']['trans_log']['Input_Custom'] = "Select reference_number, \t \nCONCAT( \n\tDate_Format(transactionDate,'%W, %b %D, %Y at %k:%i:%s'),\n\t' - (',\n\treference_number,\n\t') ',\n\t\n\tif(td.status!='D',\n\t\tCONCAT(\n\t\t\tif(td.status='P','Pending','Approved'),\n\t\t\tCONCAT(' \$',format(td.amount,2),' - ',td.cardtype)\n\t\t),\n\t\t'Declined'\n\t)\n) as info\nFrom cs_transactiondetails as td where td_ss_ID = '{$ss_ID}' order by transactionDate desc limit 40"; if (!$ss_ID) { unset($access['Data']['trans_log']); } $RF = new rates_fees(); //$r = $RF->update_transaction_profit($transactionId); $profit = $RF->get_profit(array('EffectiveOnly' => false, 'where_trans' => array('td_ss_ID' => $ss_ID)), 2); $row = 2; $access['Data']['Breakdown']['RowDisplay'] = 'Wide'; $access['Data']['Breakdown']['Input'] = ''; $access['Data']['Breakdown']['disable'] = true; $smarty->assign("Profit", $profit); $access['Data']['Breakdown']['AddHtml'] = $smarty->fetch('cp_profitreport.tpl'); if ($_POST['submit_access'] == 'Submit') { $result = processAccessForm(&$access); if ($result) { $msg .= "Company Updated Successfully (" . $result['cnt'] . " Field(s))<BR>"; } else { $msg .= "No Updates Detected<BR>"; }
$transInfo['bankaccountnumber'] = etelDec($transInfo['bankaccountnumber']); } if (!is_numeric($transInfo['bankroutingcode'])) { $transInfo['bankroutingcode'] = etelDec($transInfo['bankroutingcode']); } $serarray = array($transInfo['CCnumber'], $transInfo['bankaccountnumber'], $transInfo['bankroutingcode']); $transInfo['td_process_query'] = str_replace($reparray, $serarray, $transInfo['td_process_query']); $transInfo['td_process_result'] = str_replace($reparray, $serarray, $transInfo['td_process_result']); etelPrint($transInfo); //etelPrint($transInfo['td_process_result']); $sql = "update cs_transactiondetails set \r\n\ttd_process_query = '" . quote_smart($transInfo['td_process_query']) . "',\r\n\ttd_process_result = '" . quote_smart($transInfo['td_process_result']) . "' \r\n\twhere transactionId = '" . intval($transInfo['transactionId']) . "' limit 1"; //mysql_query($sql) or dieLog(mysql_errno().": ".mysql_error()."<BR>$sql"); //echo mysql_affected_rows().'<BR>'; $affected += mysql_affected_rows(); die; $Rates = new rates_fees(); $ratesInfo = $Rates->get_MerchantRates(1328); $output = "<table style='report' border='1' width='100%'>\n"; $disp_array = array('trans' => 'Transaction Fee', 'disct' => 'Discount Rate', 'decln' => 'Decline Fee', 'refnd' => 'Refund Fee', 'chgbk' => 'Chargeback Fee', 'rserv' => 'Reserve Rate', 'cstsv' => 'Customer Service Fee'); $ratesInfo['Default Rates']['trans_type'] = "All other forms of Payment."; foreach ($ratesInfo as $key => $banks) { $output .= "<tr><td colspan='2'><b>Transaction Type: " . $banks['trans_type'] . "</b></td></tr>\n"; foreach ($banks['default']['Processor'] as $transtype => $rate) { if ($disp_array[$transtype]) { $output .= "<tr><td>" . $disp_array[$transtype] . "</td><td>{$rate}</td></tr>\n"; } } } $output .= "</table >\n"; echo $output; print_r($ratesInfo);
$RF = new rates_fees(); //for($i=0;$i<1000000000;$i+=10000) //{ $j = 0; $bank_id = 18; $sql = "SELECT min( pa_trans_id ) AS mintrans\r\nFROM `cs_profit_action`"; $result = sql_query_read($sql) or dieLog($sql); $min = mysql_result($result, 0, 0); if ($min < 1) { $min = 500000000; } $sql = "SELECT transactionId,bank_id FROM `cs_transactiondetails` where \r\n\ttransactionId < {$min} \r\n\torder by transactionId desc LIMIT 200000"; echo "{$sql}<br>"; $result = sql_query_read($sql) or dieLog($sql); while ($transInfo = mysql_fetch_assoc($result)) { $transIDs[] = $transInfo; } foreach ($transIDs as $transInfo) { if (in_array(intval($transInfo['bank_id']), array(18, 31, 32, 33, 34, 35, 37, 38, 39, 40))) { $RF = new rates_fees(); $r = $RF->update_transaction_profit($transInfo['transactionId']); if ($r['status'] != 'success') { print_r($r); } //print($transInfo['transactionId'].'_'.$transInfo['userId'].'_'.$transInfo['reference_number'].'_'.$j); echo $j . " "; } $j++; } echo $j; //echo "<script> setTimeout(\"document.location.href = 'manip.php?".rand(1,1000)."'\",100);</script>";