function preprocess() { // check for posts before drawing anything, so we can redirect if (isset($_REQUEST['reginput'])) { $input = strtoupper(trim($_REQUEST['reginput'])); // CL always exits if ($input == "CL") { PaycardLib::paycard_reset(); CoreLocal::set("msgrepeat", 1); CoreLocal::set("strRemembered", 'TO'); CoreLocal::set("toggletax", 0); CoreLocal::set("togglefoodstamp", 0); $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } $continue = false; // when voiding tenders, the input must be an FEC's passcode if (CoreLocal::get("paycard_mode") == PaycardLib::PAYCARD_MODE_VOID && $input != "" && substr($input, -2) != "CL") { $db = Database::pDataConnect(); if (Authenticate::checkPermission($input, 11)) { CoreLocal::set("adminP", $input); $continue = true; } } // when voiding items, no code is necessary, only confirmation if (CoreLocal::get("paycard_mode") != PaycardLib::PAYCARD_MODE_VOID && $input == "") { $continue = true; } // go? if ($continue) { // send the request, then disable the form $this->add_onload_command('paycard_submitWrapper();'); $this->action = "onsubmit=\"return false;\""; } // if we're still here, display prompt again } else { if (CoreLocal::get("paycard_mode") == PaycardLib::PAYCARD_MODE_AUTH) { // call paycard_void on first load to set up // transaction and check for problems $id = CoreLocal::get("paycard_id"); foreach (CoreLocal::get("RegisteredPaycardClasses") as $rpc) { $myObj = new $rpc(); if ($myObj->handlesType(CoreLocal::get("paycard_type"))) { $ret = $myObj->paycard_void($id); if (isset($ret['output']) && !empty($ret['output'])) { CoreLocal::set("boxMsg", $ret['output']); $this->change_page($this->page_url . "gui-modules/boxMsg2.php"); return False; } break; } } } } return True; }
/** Populates session with default values. Short-hand for calling every other function in this file. Normally called once on startup. */ public static function initiate_session() { self::systemInit(); self::memberReset(); self::transReset(); self::printReset(); PaycardLib::paycard_reset(); Database::getsubtotals(); Database::loadglobalvalues(); self::loadData(); self::customReceipt(); self::loadParams(); }
function preprocess() { // check for posts before drawing anything, so we can redirect if (isset($_REQUEST['reginput'])) { $input = strtoupper(trim($_REQUEST['reginput'])); // CL always exits if ($input == "CL") { PaycardLib::paycard_reset(); $this->change_page($this->page_url . "gui-modules/pos2.php"); return false; } elseif ($input == "" || $input == 'MANUAL') { $this->action = "onsubmit=\"return false;\""; $this->add_onload_command("emvSubmit();"); if ($input == 'MANUAL') { $this->prompt = true; } $this->run_transaction = true; } // if we're still here, we haven't accepted a valid amount yet; display prompt again } elseif (isset($_REQUEST['xml-resp'])) { $xml = $_REQUEST['xml-resp']; $e2e = new MercuryE2E(); $json = array(); $plugin_info = new Paycards(); $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvSuccess.php'; $json['receipt'] = false; $success = $e2e->handleResponseDataCapBalance($xml); if ($success === PaycardLib::PAYCARD_ERR_OK) { $json = $e2e->cleanup($json); CoreLocal::set("strEntered", ""); CoreLocal::set("strRemembered", ""); CoreLocal::set("msgrepeat", 0); if ($json['receipt']) { $json['main_frame'] .= '?receipt=' . $json['receipt']; } } else { CoreLocal::set("msgrepeat", 0); $json['main_frame'] = MiscLib::base_url() . 'gui-modules/boxMsg2.php'; } header('Location: ' . $json['main_frame']); return false; } return true; }
function preprocess() { // check for posts before drawing anything, so we can redirect if (isset($_REQUEST['reginput'])) { $input = strtoupper(trim($_REQUEST['reginput'])); // CL always exits if ($input == "CL") { CoreLocal::set("msgrepeat", 0); CoreLocal::set("toggletax", 0); CoreLocal::set("togglefoodstamp", 0); PaycardLib::paycard_reset(); CoreLocal::set("CachePanEncBlock", ""); CoreLocal::set("CachePinEncBlock", ""); CoreLocal::set("CacheCardType", ""); CoreLocal::set("CacheCardCashBack", 0); CoreLocal::set('ccTermState', 'swipe'); UdpComm::udpSend("termReset"); $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } else { if ($input == "") { if ($this->validate_amount()) { $this->action = "onsubmit=\"return false;\""; $this->add_onload_command("paycard_submitWrapper();"); } } else { if ($input != "" && substr($input, -2) != "CL") { // any other input is an alternate amount CoreLocal::set("paycard_amount", "invalid"); if (is_numeric($input)) { CoreLocal::set("paycard_amount", $input / 100); if (CoreLocal::get('CacheCardCashBack') > 0 && CoreLocal::get('CacheCardCashBack') <= 40) { CoreLocal::set('paycard_amount', $input / 100 + CoreLocal::get('CacheCardCashBack')); } } } } } // if we're still here, we haven't accepted a valid amount yet; display prompt again } // post? return True; }
function preprocess() { // check for posts before drawing anything, so we can redirect if (isset($_REQUEST['reginput'])) { $input = strtoupper(trim($_REQUEST['reginput'])); // CL always exits if ($input == "CL") { CoreLocal::set("msgrepeat", 0); CoreLocal::set("toggletax", 0); CoreLocal::set("togglefoodstamp", 0); PaycardLib::paycard_reset(); $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } // when (de)activating/adding-value, double check that the current amount is acceptable // before checking input (similar logic is later when generating the message) $amtValid = false; $amt = CoreLocal::get("paycard_amount"); if (!is_numeric($amt) || $amt < 0.005) { } else { // all errors are caught above; here, the amount is okay $amtValid = true; } // no input is confirmation to proceed if ($input == "" && $amtValid) { $this->add_onload_command("paycard_submitWrapper();"); $this->action = "onsubmit=\"return false;\""; } else { if ($input != "" && substr($input, -2) != "CL") { // any other input is an alternate amount CoreLocal::set("paycard_amount", "invalid"); if (is_numeric($input)) { CoreLocal::set("paycard_amount", $input / 100); } } } // if we're still here, we haven't accepted a valid amount yet; display prompt again } // post? return True; }
function preprocess() { // check for posts before drawing anything, so we can redirect if (isset($_REQUEST['reginput'])) { $input = strtoupper(trim($_REQUEST['reginput'])); // CL always exits if ($input == "CL") { CoreLocal::set("msgrepeat", 0); CoreLocal::set("toggletax", 0); CoreLocal::set("togglefoodstamp", 0); PaycardLib::paycard_reset(); $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } // when checking balance, no input is confirmation to proceed if ($input == "") { $this->add_onload_command("paycard_submitWrapper();"); $this->action = "onsubmit=\"return false;\""; } // any other input is unrecognized, display prompt again } // post? return True; }
public static function notVoided($trans, $id) { $dbTrans = PaycardLib::paycard_db(); $today = date('Ymd'); $sql = "SELECT transID \n FROM PaycardTransactions \n WHERE dateID=" . $today . "\n AND empNo=" . $trans[0] . "\n AND registerNo=" . $trans[1] . "\n AND transNo=" . $trans[2] . "\n AND transID=" . $id . "\n AND transType='VOID'\n AND xResultCode=1"; // @deprecated table 5May14 if (!$dbTrans->table_exists('PaycardTransactions')) { $sql = "SELECT transID FROM efsnetRequestMod WHERE " . $dbTrans->identifier_escape('date') . "=" . $today . " AND cashierNo=" . $trans[0] . " AND laneNo=" . $trans[1] . " AND transNo=" . $trans[2] . " AND transID=" . $id . " AND mode='void' AND xResponseCode=0"; } $search = PaycardLib::paycard_db_query($sql, $dbTrans); $voided = PaycardLib::paycard_db_num_rows($search); if ($voided > 0) { PaycardLib::paycard_reset(); return PaycardLib::paycard_errBox(PaycardLib::PAYCARD_TYPE_CREDIT, "Unable to Void", "Card transaction already voided", "[clear] to cancel"); } else { return true; } }
public function lookupTransaction($ref, $local, $mode) { $merchantID = GOEMERCH_ID; $password = GOEMERCH_PASSWD; $gatewayID = GOEMERCH_GATEWAY_ID; if (substr($ref, 13, 4) == "9999") { $merchantID = "1264"; $password = "******"; $gatewayID = "a91c38c3-7d7f-4d29-acc7-927b4dca0dbe"; } $dateStr = date('mdy'); $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; $xml .= "<TRANSACTION>"; $xml .= "<FIELDS>"; $xml .= "<FIELD KEY=\"merchant\">{$merchantID}</FIELD>"; if ($password != "") { $xml .= "<FIELD KEY=\"password\">{$password}</FIELD>"; } $xml .= "<FIELD KEY=\"gateway_id\">{$gatewayID}</FIELD>"; $xml .= "<FIELD KEY=\"operation_type\">query</FIELD>"; $xml .= "<FIELD KEY=\"trans_type\">SALE</FIELD>"; $xml .= "<FIELD KEY=\"begin_date\">{$dateStr}</FIELD>"; $xml .= "<FIELD KEY=\"begin_time\">0001AM</FIELD>"; $xml .= "<FIELD KEY=\"end_date\">{$dateStr}</FIELD>"; $xml .= "<FIELD KEY=\"end_time\">1159PM</FIELD>"; $xml .= "<FIELD KEY=\"order_id\">{$ref}</FIELD>"; $xml .= "</FIELDS>"; $xml .= "</TRANSACTION>"; $this->GATEWAY = "https://secure.goemerchant.com/secure/gateway/xmlgateway.aspx"; $curl_result = $this->curlSend($xml, 'POST', true, array(), false); if ($curl_result['curlErr'] != CURLE_OK || $curl_result['curlHTTP'] != 200) { return array('output' => DisplayLib::boxMsg('No response from processor', '', true), 'confirm_dest' => MiscLib::base_url() . 'gui-modules/pos2.php', 'cancel_dest' => MiscLib::base_url() . 'gui-modules/pos2.php'); } $directions = 'Press [enter] or [clear] to continue'; $resp = array('confirm_dest' => MiscLib::base_url() . 'gui-modules/pos2.php', 'cancel_dest' => MiscLib::base_url() . 'gui-modules/pos2.php'); $info = new Paycards(); $url_stem = $info->pluginUrl(); $xml_resp = new xmlData($curl_result['response']); $status = 'UNKNOWN'; if ($xml_resp->get_first('RECORDS_FOUND') == 0) { $status = 'NOTFOUND'; $directions = 'Press [enter] to try again, [clear] to stop'; $query_string = 'id=' . ($local ? '_l' : '') . $ref . '&mode=' . $mode; $resp['confirm_dest'] = $url_stem . '/gui/PaycardTransLookupPage.php?' . $query_string; } else { $responseCode = $xml_resp->get_first('TRANS_STATUS1'); $resultCode = $responseCode; $normalized = $resultCode; $xTransID = $xml_resp->get_first('REFERENCE_NUMBER1'); $rMsg = ''; if ($responseCode == 1) { $status = 'APPROVED'; $rMsg = 'APPROVED'; $normalized = 1; } else { if ($responseCode == 2) { $status == 'DECLINED'; $rMsg = 'DECLINED'; $normalized = 2; } else { if ($responseCode == 0) { $status == 'ERROR'; $eMsg = $xml_resp->get_first('ERROR1'); $normalized = 3; if ($eMsg) { $rMsg = substr($eMsg, 0, 100); } else { $rMsg = 'ERROR'; } } else { $responseCode = -3; $normalized = 0; $status = 'UNKNOWN'; } } } $apprNumber = ''; // not returned by query op if ($local == 1 && $mode == 'verify') { // Update efsnetResponse record to contain // actual processor result and finish // the transaction correctly $db = Database::tDataConnect(); $upP = $db->prepare("\n UPDATE PaycardTransactions \n SET xResponseCode=?,\n xResultCode=?,\n xResultMessage=?,\n xTransactionID=?,\n xApprovalNumber=?,\n commErr=0,\n httpCode=200,\n validResponse=?\n WHERE refNum=?\n AND transID=?"); $args = array($responseCode, $resultCode, $rMsg, $xTransID, $apprNumber, $normalized, $ref, CoreLocal::get('paycard_id')); $upR = $db->execute($upP, $args); $upP = $db->prepare("\n UPDATE efsnetResponse SET\n xResponseCode=?,\n xResultCode=?, \n xResultMessage=?,\n xTransactionID=?,\n xApprovalNumber=?,\n commErr=0,\n httpCode=200\n WHERE refNum=?\n AND transID=?"); $args = array($responseCode, $resultCode, $rMsg, $xTransID, $apprNumber, $ref, CoreLocal::get('paycard_id')); if ($db->table_exists('efsnetResponse')) { $upR = $db->execute($upP, $args); } if ($status == 'APPROVED') { PaycardLib::paycard_wipe_pan(); $this->cleanup(array()); $resp['confirm_dest'] = $url_stem . '/gui/paycardSuccess.php'; $resp['cancel_dest'] = $url_stem . '/gui/paycardSuccess.php'; $directions = 'Press [enter] to continue'; } else { PaycardLib::paycard_reset(); } } // end verification record update } // end found result switch (strtoupper($status)) { case 'APPROVED': $line1 = $status; $line2 = 'Amount: ' . sprintf('%.2f', $xml_resp->get_first('AMOUNT1')); $line3 = 'Type: CREDIT'; $voided = $xml_resp->get_first('CREDIT_VOID1'); $line4 = 'Voided: ' . (strtoupper($voided) == 'VOID' ? 'Yes' : 'No'); $resp['output'] = DisplayLib::boxMsg($line1 . '<br />' . $line2 . '<br />' . $line3 . '<br />' . $line4 . '<br />' . $directions, '', true); break; case 'DECLINED': $resp['output'] = DisplayLib::boxMsg('The original transaction was declined <br />' . $directions, '', true); break; case 'ERROR': $resp['output'] = DisplayLib::boxMsg('The original transaction resulted in an error <br />' . $directions, '', true); break; case 'NOTFOUND': $resp['output'] = DisplayLib::boxMsg('Processor has no record of the transaction <br />' . $directions, '', true); break; case 'UNKNOWN': $resp['output'] = DisplayLib::boxMsg('Processor responded but made no sense <br />' . $directions, '', true); break; } return $resp; }
function preprocess() { // check for posts before drawing anything, so we can redirect if (isset($_REQUEST['reginput'])) { $input = strtoupper(trim($_REQUEST['reginput'])); // CL always exits if ($input == "CL") { CoreLocal::set("msgrepeat", 0); CoreLocal::set("toggletax", 0); CoreLocal::set("togglefoodstamp", 0); PaycardLib::paycard_reset(); CoreLocal::set("CachePanEncBlock", ""); CoreLocal::set("CachePinEncBlock", ""); CoreLocal::set("CacheCardType", ""); CoreLocal::set("CacheCardCashBack", 0); CoreLocal::set('ccTermState', 'swipe'); UdpComm::udpSend("termReset"); $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } elseif ($input == "" || $input == 'MANUAL') { if ($this->validate_amount()) { $this->action = "onsubmit=\"return false;\""; $this->add_onload_command("emvSubmit();"); if ($input == 'MANUAL') { $this->prompt = true; } $this->run_transaction = true; } } elseif ($input != "" && substr($input, -2) != "CL") { // any other input is an alternate amount CoreLocal::set("paycard_amount", "invalid"); if (is_numeric($input)) { CoreLocal::set("paycard_amount", $input / 100); if (CoreLocal::get('CacheCardCashBack') > 0 && CoreLocal::get('CacheCardCashBack') <= 40) { CoreLocal::set('paycard_amount', $input / 100 + CoreLocal::get('CacheCardCashBack')); } } } // if we're still here, we haven't accepted a valid amount yet; display prompt again } elseif (isset($_REQUEST['xml-resp'])) { $xml = $_REQUEST['xml-resp']; $e2e = new MercuryE2E(); $json = array(); $plugin_info = new Paycards(); $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvSuccess.php'; $json['receipt'] = false; $success = $e2e->handleResponseDataCap($xml); if ($success === PaycardLib::PAYCARD_ERR_OK) { $json = $e2e->cleanup($json); CoreLocal::set("strRemembered", ""); CoreLocal::set("msgrepeat", 0); if ($json['receipt']) { $json['main_frame'] .= '?receipt=' . $json['receipt']; } } else { CoreLocal::set("msgrepeat", 0); $json['main_frame'] = MiscLib::base_url() . 'gui-modules/boxMsg2.php'; } header('Location: ' . $json['main_frame']); return false; } // post? return true; }
$json['receipt'] = false; foreach (CoreLocal::get("RegisteredPaycardClasses") as $rpc) { $myObj = new $rpc(); if ($myObj->handlesType(CoreLocal::get("paycard_type"))) { break; } } $result = $myObj->doSend(CoreLocal::get("paycard_mode")); if ($result === PaycardLib::PAYCARD_ERR_OK) { PaycardLib::paycard_wipe_pan(); $json = $myObj->cleanup($json); CoreLocal::set("strRemembered", ""); CoreLocal::set("msgrepeat", 0); } else { if ($result === PaycardLib::PAYCARD_ERR_NSF_RETRY) { // card shows balance < requested amount // try again with lesser amount $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/paycardboxMsgAuth.php'; } else { if ($result === PaycardLib::PAYCARD_ERR_TRY_VERIFY) { // communication error. query processor about // transaction status. $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardTransLookupPage.php?mode=verify&id=_l' . $myObj->last_ref_num; } else { PaycardLib::paycard_reset(); CoreLocal::set("msgrepeat", 0); $json['main_frame'] = MiscLib::base_url() . 'gui-modules/boxMsg2.php'; } } } echo JsonLib::array_to_json($json);
public function lookupTransaction($ref, $local, $mode) { $ws_params = array('merchant' => CoreLocal::get('MercuryE2ETerminalID'), 'pw' => CoreLocal::get('MercuryE2EPassword'), 'invoice' => $ref); // emp_no 9999 => test transaction if (substr($ref, 4, 4) == "9999") { $ws_params['merchant'] = '395347308=E2ETKN'; $ws_params['pw'] = '123E2ETKN'; } $this->SOAPACTION = 'http://www.mercurypay.com/CTranDetail'; $soaptext = $this->soapify('CTranDetail', $ws_params, 'http://www.mercurypay.com'); $this->GATEWAY = 'https://' . self::PRIMARY_URL . '/ws/ws.asmx'; $curl_result = $this->curlSend($soaptext, 'SOAP', false, array(), false); if ($curl_result['curlErr'] != CURLE_OK || $curl_result['curlHTTP'] != 200) { $this->GATEWAY = 'https://' . self::BACKUP_URL . '/ws/ws.asmx'; $curl_result = $this->curlSend($soaptext, 'SOAP', false, array(), false); if ($curl_result['curlErr'] != CURLE_OK || $curl_result['curlHTTP'] != 200) { return array('output' => DisplayLib::boxMsg('No response from processor', '', true), 'confirm_dest' => MiscLib::base_url() . 'gui-modules/pos2.php', 'cancel_dest' => MiscLib::base_url() . 'gui-modules/pos2.php'); } } $directions = 'Press [enter] or [clear] to continue'; $resp = array('confirm_dest' => MiscLib::base_url() . 'gui-modules/pos2.php', 'cancel_dest' => MiscLib::base_url() . 'gui-modules/pos2.php'); $info = new Paycards(); $url_stem = $info->pluginUrl(); $xml_resp = $this->desoapify('CTranDetailResponse', $curl_result['response']); $xml = new xmlData($xml_resp); $status = trim($xml->get_first('STATUS')); if ($status === '') { $status = 'NOTFOUND'; $directions = 'Press [enter] to try again, [clear] to stop'; $query_string = 'id=' . ($local ? '_l' : '') . $ref . '&mode=' . $mode; $resp['confirm_dest'] = $url_stem . '/gui/PaycardTransLookupPage.php?' . $query_string; } else { if ($local == 1 && $mode == 'verify') { // Update efsnetResponse record to contain // actual processor result and finish // the transaction correctly $responseCode = -3; $resultCode = 0; $normalized = 0; if ($status == 'Approved') { $responseCode = 1; $normalized = 1; PaycardLib::paycard_wipe_pan(); $this->cleanup(array()); $resp['confirm_dest'] = $url_stem . '/gui/paycardSuccess.php'; $resp['cancel_dest'] = $url_stem . '/gui/paycardSuccess.php'; $directions = 'Press [enter] to continue'; } else { if ($status == 'Declined') { PaycardLib::paycard_reset(); $responseCode = 2; $normalized = 2; } else { if ($status == 'Error') { PaycardLib::paycard_reset(); $responseCode = 0; $resultCode = -1; // CTranDetail does not provide this value $normalized = 3; } else { // Unknown status; clear any data PaycardLib::paycard_reset(); } } } $apprNumber = $xml->get_first('authcode'); $xTransID = $xml->get_first('reference'); $rMsg = $status; if ($apprNumber) { $rMsg .= ' ' . $apprNumber; } if (strlen($rMsg) > 100) { $rMsg = substr($rMsg, 0, 100); } $db = Database::tDataConnect(); $upP = $db->prepare("\n UPDATE PaycardTransactions \n SET xResponseCode=?,\n xResultCode=?,\n xResultMessage=?,\n xTransactionID=?,\n xApprovalNumber=?,\n commErr=0,\n httpCode=200,\n validResponse=?\n WHERE refNum=?\n AND transID=?"); $args = array($responseCode, $resultCode, $rMsg, $xTransID, $apprNumber, $normalized, $ref, CoreLocal::get('paycard_id')); $upR = $db->execute($upP, $args); $upP = $db->prepare("\n UPDATE efsnetResponse SET\n xResponseCode=?,\n xResultCode=?, \n xResultMessage=?,\n xTransactionID=?,\n xApprovalNumber=?,\n commErr=0,\n httpCode=200\n WHERE refNum=?\n AND transID=?"); $args = array($responseCode, $resultCode, $rMsg, $xTransID, $apprNumber, $ref, CoreLocal::get('paycard_id')); if ($db->table_exists('efsnetResponse')) { $upR = $db->execute($upP, $args); } } } switch (strtoupper($status)) { case 'APPROVED': $line1 = $status . ' ' . $xml->get_first('authcode'); $line2 = 'Amount: ' . sprintf('%.2f', $xml->get_first('total')); $trans_type = $xml->get_first('trantype'); $line3 = 'Type: ' . $trans_type; $voided = $xml->get_first('voided'); $line4 = 'Voided: ' . ($voided == 'true' ? 'Yes' : 'No'); $resp['output'] = DisplayLib::boxMsg($line1 . '<br />' . $line2 . '<br />' . $line3 . '<br />' . $line4 . '<br />' . $directions, '', true); break; case 'DECLINED': $resp['output'] = DisplayLib::boxMsg('The original transaction was declined <br />' . $directions, '', true); break; case 'ERROR': $resp['output'] = DisplayLib::boxMsg('The original transaction resulted in an error <br />' . $directions, '', true); break; case 'NOTFOUND': $resp['output'] = DisplayLib::boxMsg('Processor has no record of the transaction <br />' . $directions, '', true); break; } return $resp; }
public function entered($validate, $json) { $enabled = PaycardDialogs::enabledCheck(); if ($enabled !== true) { $json['output'] = $enabled; return $json; } // error checks based on processing mode if (CoreLocal::get("paycard_mode") == PaycardLib::PAYCARD_MODE_VOID) { $pan4 = substr($this->getPAN(), -4); $trans = array(CoreLocal::get('CashierNo'), CoreLocal::get('laneno'), CoreLocal::get('transno')); list($success, $result) = PaycardDialogs::voidableCheck($pan4, $trans); if ($success === true) { return $this->paycard_void($result, -1, -1, $json); } else { $json['output'] = $result; return $json; } } // check card data for anything else if ($validate) { $valid = PaycardDialogs::validateCard(CoreLocal::get('paycard_PAN'), false); if ($valid !== true) { $json['output'] = $valid; return $json; } } // other modes switch (CoreLocal::get("paycard_mode")) { case PaycardLib::PAYCARD_MODE_AUTH: return PaycardLib::setupAuthJson($json); case PaycardLib::PAYCARD_MODE_ACTIVATE: case PaycardLib::PAYCARD_MODE_ADDVALUE: CoreLocal::set("paycard_amount", 0); CoreLocal::set("paycard_id", CoreLocal::get("LastID") + 1); // kind of a hack to anticipate it this way.. $plugin_info = new Paycards(); $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/paycardboxMsgGift.php'; return $json; case PaycardLib::PAYCARD_MODE_BALANCE: $plugin_info = new Paycards(); $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/paycardboxMsgBalance.php'; return $json; } // switch mode // if we're still here, it's an error PaycardLib::paycard_reset(); $json['output'] = PaycardDialogs::invalidMode(); return $json; }
function preprocess() { $this->bmp_path = $this->page_url . 'scale-drivers/drivers/NewMagellan/ss-output/tmp/'; // check for input if (isset($_REQUEST["reginput"])) { $input = strtoupper(trim($_POST["reginput"])); // capture file if present; otherwise re-request // signature via terminal if (isset($_REQUEST['doCapture']) && $_REQUEST['doCapture'] == 1 && $input == '') { if (isset($_REQUEST['bmpfile']) && !empty($_REQUEST['bmpfile']) && file_exists($_REQUEST['bmpfile'])) { $bmp = file_get_contents($_REQUEST['bmpfile']); $format = 'BMP'; $img_content = $bmp; $dbc = Database::tDataConnect(); $capQ = 'INSERT INTO CapturedSignature (tdate, emp_no, register_no, trans_no, trans_id, filetype, filecontents) VALUES (?, ?, ?, ?, ?, ?, ?)'; $capP = $dbc->prepare_statement($capQ); $args = array(date('Y-m-d H:i:s'), CoreLocal::get('CashierNo'), CoreLocal::get('laneno'), CoreLocal::get('transno'), CoreLocal::get('paycard_id'), $format, $img_content); $capR = $dbc->exec_statement($capP, $args); unlink($_REQUEST['bmpfile']); // continue to below. finishing transaction is the same // as with paper signature slip } else { UdpComm::udpSend('termSig'); return true; } } $mode = CoreLocal::get("paycard_mode"); $type = CoreLocal::get("paycard_type"); $tender_id = CoreLocal::get("paycard_id"); if ($input == "") { // [enter] exits this screen // remember the mode, type and transid before we reset them CoreLocal::set("boxMsg", ""); /** paycard_mode is sometimes cleared pre-emptively perhaps by a double keypress on enter so tender out if the last record in the transaction is a tender record */ $peek = PrehLib::peekItem(true); if ($mode == PaycardLib::PAYCARD_MODE_AUTH || $peek !== false && isset($peek['trans_type']) && $peek['trans_type'] == 'T') { CoreLocal::set("strRemembered", "TO"); CoreLocal::set("msgrepeat", 1); CoreLocal::set('paycardTendered', true); } else { TransRecord::debugLog('Not Tendering Out (mode): ' . print_r($mode, true)); } // only reset terminal if the terminal was used for the transaction // activating a gift card should not reset terminal if (CoreLocal::get("paycard_type") == PaycardLib::PAYCARD_TYPE_ENCRYPTED) { UdpComm::udpSend('termReset'); CoreLocal::set('ccTermState', 'swipe'); CoreLocal::set("CacheCardType", ""); } PaycardLib::paycard_reset(); $this->change_page($this->page_url . "gui-modules/pos2.php"); return false; } elseif ($mode == PaycardLib::PAYCARD_MODE_AUTH && $input == "VD" && (CoreLocal::get('CacheCardType') == 'CREDIT' || CoreLocal::get('CacheCardType') == 'EMV' || CoreLocal::get('CacheCardType') == 'GIFT' || CoreLocal::get('CacheCardType') == '')) { $plugin_info = new Paycards(); $this->change_page($plugin_info->pluginUrl() . "/gui/PaycardEmvVoid.php"); return false; } } /* shouldn't happen unless session glitches but getting here implies the transaction succeeded */ $var = CoreLocal::get("boxMsg"); if (empty($var)) { CoreLocal::set("boxMsg", "<b>Approved</b><font size=-1>\n <p> \n <p>[enter] to continue\n <br>[void] " . _('to reverse the charge') . "\n </font>"); } return True; }
function send_void() { // initialize $dbTrans = PaycardLib::paycard_db(); if (!$dbTrans) { PaycardLib::paycard_reset(); return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND); } $request = new PaycardVoidRequest($this->refnum(CoreLocal::get('paycard_id'))); $request->setProcessor('AuthDotNot'); $mode = 'void'; $cardPAN = $this->trans_pan['pan']; $request->setPAN($cardPAN); $request->setIssuer(CoreLocal::get("paycard_issuer")); $cardExM = substr(CoreLocal::get("paycard_exp"), 0, 2); $cardExY = substr(CoreLocal::get("paycard_exp"), 2, 2); $cardTr1 = $this->trans_pan['tr1']; $cardTr2 = $this->trans_pan['tr2']; $request->setCardholder(CoreLocal::get("paycard_name")); // x_login and x_tran_key need to // be filled in to work $postValues = array("x_login" => AUTHDOTNET_LOGIN, "x_tran_key" => AUTHDOTNET_TRANS_KEY, "x_market_type" => "2", "x_device_type" => "5", "cp_version" => "1.0", "x_text_request" => "1", "x_amount" => $request->formattedAmount(), "x_user_ref" => $request->refNum, "x_type" => "VOID", "x_card_num" => $cardPAN, "x_exp_date" => $cardExM . $cardExY); try { $res = $request->findOriginal(); $request->saveRequest(); } catch (Exception $ex) { return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND); } $TransactionID = $res['xTransactionID']; $postValues["x_ref_trans_id"] = $TransactionID; $this->last_request = $request; $postData = $this->array2post($postValues); $this->GATEWAY = "https://test.authorize.net/gateway/transact.dll"; return $this->curlSend($postData, 'POST', False); }
function send_auth() { $dbTrans = PaycardLib::paycard_db(); if (!$dbTrans) { PaycardLib::paycard_reset(); return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND); // database error, nothing sent (ok to retry) } $request = new PaycardRequest($this->refnum(CoreLocal::get('paycard_id'))); $request->setProcessor('FirstData'); $mode = 'sale'; $this->trans_pan['pan'] = CoreLocal::get("paycard_PAN"); $cardPAN = $this->trans_pan['pan']; $cardExM = substr(CoreLocal::get("paycard_exp"), 0, 2); $cardExY = substr(CoreLocal::get("paycard_exp"), 2, 2); $cardTr1 = CoreLocal::get("paycard_tr1"); $cardTr2 = CoreLocal::get("paycard_tr2"); $cardTr3 = CoreLocal::get("paycard_tr3"); $request->setCardholder(CoreLocal::get("paycard_name")); $cvv2 = CoreLocal::get("paycard_cvv2"); if (CoreLocal::get("training") == 1) { $cardPAN = "4111111111111111"; $cardPANmasked = "xxxxxxxxxxxxTEST"; $cardIssuer = "Visa"; $cardTr1 = False; $cardTr2 = False; $request->setCardholder("Just Testing"); $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1); $cardExM = date("m", $nextyear); $cardExY = date("y", $nextyear); } $request->setPAN($cardPAN); $request->setIssuer(CoreLocal::get("paycard_issuer")); $sendPAN = 0; $sendExp = 0; $sendTr1 = 0; $sendTr2 = 0; $magstripe = ""; if (!$cardTr1 && !$cardTr2) { $sendPAN = 1; $sendExp = 1; } if ($cardTr1) { $sendTr1 = 1; $magstripe .= "%" . $cardTr1 . "?"; } if ($cardTr2) { $sendTr2 = 1; $magstripe .= ";" . $cardTr2 . "?"; } if ($cardTr2 && $cardTr3) { $sendPAN = 1; $magstripe .= ";" . $cardTr3 . "?"; } $request->setSent($sendPAN, $sendExp, $sendTr1, $sendTr2); try { $request->saveRequest(); } catch (Exception $ex) { PaycardLib::paycard_reset(); return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_NOSEND); // internal error, nothing sent (ok to retry) } $this->last_request = $request; $xml = '<fdggwsapi:FDGGWSApiOrderRequest xmlns:v1="http://secure.linkpt.net/fdggwsapi/schemas_us/v1" xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi"> <v1:Transaction>'; $xml .= "<v1:CreditCardTxType> \n <v1:Type>{$mode}</v1:Type> \n </v1:CreditCardTxType>"; $xml .= "<v1:CreditCardData> \n <v1:CardNumber>{$pan}</v1:CardNumber> \n <v1:ExpMonth>{$cardExM}</v1:ExpMonth> \n <v1:ExpYear>{$cardExY}</v1:ExpYear> \n <v1:CardCodeValue>{$cvv2}</v1:CardCodeValue>\n </v1:CreditCardData>"; $xml .= "<v1:Payment>\n <v1:ChargeTotal>" . $request->formattedAmount() . "</v1:ChargeTotal> \n </v1:Payment>"; $xml .= "<v1:TransactionDetails>\n <v1:OrderId>" . $request->refNum . "</v1:OrderId>\n <v1:Ip>" . filter_input(INPUT_SERVER, 'REMOTE_ADDR') . "</v1:Ip>\n </v1:TransactionDetails>"; $xml .= '</v1:Transaction> </fdggwsapi:FDGGWSApiOrderRequest>'; $this->GATEWAY = "https://ws.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl"; if ($live == 0) { $this->GATEWAY = "https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl"; } $extraCurlSetup = array(CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => "WS" . FD_STORE_ID . "._.1:" . FD_PASSWD, CURLOPT_SSLCERT => FD_CERT_PATH . "/WS" . FD_STORE_ID . "._.1.pem", CURLOPT_SSLKEY => FD_CERT_PATH . "/WS" . FD_STORE_ID . "._.1.key", CURLOPT_SSLKEYPASSWD => FD_KEY_PASSWD); $soaptext = $this->soapify('', array('xml' => $xml), '', False); return $this->curlSend($soaptext, 'SOAP', True, $extraCurlSetup); }
function preprocess() { $this->hide_input(true); $dbc = Database::tDataConnect(); $q = ' SELECT MAX(paycardTransactionID) FROM PaycardTransactions WHERE transID=' . (int) CoreLocal::get('paycard_id'); $r = $dbc->query($q); if ($r && $dbc->numRows($r)) { $w = $dbc->fetchRow($r); $this->id = $w[0]; } if (!$this->id) { CoreLocal::set('boxMsg', 'Cannot locate transaction to void'); $this->change_page(MiscLib::baseURL() . 'gui-modules/boxMsg2.php'); return false; } CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_VOID); // check for posts before drawing anything, so we can redirect if (isset($_REQUEST['reginput'])) { $input = strtoupper(trim($_REQUEST['reginput'])); // CL always exits if ($input == "CL") { PaycardLib::paycard_reset(); CoreLocal::set("msgrepeat", 1); CoreLocal::set("strRemembered", 'TO'); CoreLocal::set("toggletax", 0); CoreLocal::set("togglefoodstamp", 0); $this->change_page($this->page_url . "gui-modules/pos2.php"); return false; } elseif (Authenticate::checkPassword($input)) { $this->action = "onsubmit=\"return false;\""; $this->add_onload_command("emvSubmit();"); $this->run_transaction = true; } // if we're still here, we haven't accepted a valid amount yet; display prompt again } elseif (isset($_REQUEST['xml-resp'])) { $xml = $_REQUEST['xml-resp']; $e2e = new MercuryE2E(); $json = array(); $plugin_info = new Paycards(); $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvSuccess.php'; $json['receipt'] = false; $success = $e2e->handleResponseDataCap($xml); if ($success === PaycardLib::PAYCARD_ERR_OK) { $json = $e2e->cleanup($json); CoreLocal::set("strEntered", ""); CoreLocal::set("strRemembered", ""); CoreLocal::set("msgrepeat", 0); if ($json['receipt']) { $json['main_frame'] .= '?receipt=' . $json['receipt']; } } else { CoreLocal::set("msgrepeat", 0); $json['main_frame'] = MiscLib::base_url() . 'gui-modules/boxMsg2.php'; } header('Location: ' . $json['main_frame']); return false; } return true; }
function paycard_entered($mode, $card, $manual, $type) { $ret = $this->default_json(); // initialize $validate = true; // run Luhn's on PAN, check expiration date PaycardLib::paycard_reset(); CoreLocal::set("paycard_mode", $mode); CoreLocal::set("paycard_manual", $manual ? 1 : 0); // error checks based on transaction if ($mode == PaycardLib::PAYCARD_MODE_AUTH) { if (CoreLocal::get("ttlflag") != 1) { // must subtotal before running card $ret['output'] = PaycardLib::paycard_msgBox($type, "No Total", "Transaction must be totaled before tendering or refunding", "[clear] to cancel"); return $ret; } else { if (abs(CoreLocal::get("amtdue")) < 0.005) { // can't tender for more than due $ret['output'] = PaycardLib::paycard_msgBox($type, "No Total", "Nothing to tender or refund", "[clear] to cancel"); return $ret; } } } // check for pre-validation override if (strtoupper(substr($card, 0, 1)) == 'O') { $validate = false; $card = substr($card, 1); } // parse card data if (CoreLocal::get("paycard_manual")) { // make sure it's numeric if (!ctype_digit($card) || strlen($card) < 18) { // shortest known card # is 14 digits, plus MMYY $ret['output'] = PaycardLib::paycard_msgBox($type, "Manual Entry Unknown", "Please enter card data like:<br>CCCCCCCCCCCCCCCCMMYY", "[clear] to cancel"); return $ret; } // split up input (and check for the Concord test card) if ($type == PaycardLib::PAYCARD_TYPE_UNKNOWN) { $type = PaycardLib::paycard_type($card); } if ($type == PaycardLib::PAYCARD_TYPE_GIFT) { CoreLocal::set("paycard_PAN", $card); // our gift cards have no expiration date or conf code } else { CoreLocal::set("paycard_PAN", substr($card, 0, -4)); CoreLocal::set("paycard_exp", substr($card, -4, 4)); } } else { if ($type == PaycardLib::PAYCARD_TYPE_ENCRYPTED) { // add leading zero back to fix hex encoding, if needed if (substr($card, 0, 7) == "2E60080") { $card = "0" . $card; } CoreLocal::set("paycard_PAN", $card); } else { // swiped magstripe (reference to ISO format at end of this file) $stripe = PaycardLib::paycard_magstripe($card); if (!is_array($stripe)) { $ret['output'] = PaycardLib::paycard_errBox($type, CoreLocal::get("paycard_manual") . "Card Data Invalid", "Please swipe again or type in manually", "[clear] to cancel"); return $ret; } CoreLocal::set("paycard_PAN", $stripe["pan"]); CoreLocal::set("paycard_exp", $stripe["exp"]); CoreLocal::set("paycard_name", $stripe["name"]); CoreLocal::set("paycard_tr1", $stripe["tr1"]); CoreLocal::set("paycard_tr2", $stripe["tr2"]); CoreLocal::set("paycard_tr3", $stripe["tr3"]); } } // manual/swiped // determine card issuer and type CoreLocal::set("paycard_type", PaycardLib::paycard_type(CoreLocal::get("paycard_PAN"))); CoreLocal::set("paycard_issuer", PaycardLib::paycard_issuer(CoreLocal::get("paycard_PAN"))); /* check card type. Credit is default. */ $type = CoreLocal::get("CacheCardType"); if ($type == '') { $type = 'CREDIT'; CoreLocal::set("CacheCardType", "CREDIT"); } /* assign amount due. EBT food should use eligible amount */ CoreLocal::set("paycard_amount", CoreLocal::get("amtdue")); if ($type == 'EBTFOOD') { if (CoreLocal::get('fntlflag') == 0) { /* try to automatically do fs total */ $try = PrehLib::fsEligible(); if ($try !== True) { $ret['output'] = PaycardLib::paycard_msgBox($type, "Type Mismatch", "Foodstamp eligible amount inapplicable", "[clear] to cancel"); return $ret; } } /** Always validate amount as non-zero */ if (CoreLocal::get('fsEligible') <= 0.005 && CoreLocal::get('fsEligible') >= -0.005) { $ret['output'] = PaycardLib::paycard_msgBox($type, _('Zero Total'), "Foodstamp eligible amount is zero", "[clear] to cancel"); UdpComm::udpSend('termReset'); return $ret; } CoreLocal::set("paycard_amount", CoreLocal::get("fsEligible")); } if (($type == 'EBTCASH' || $type == 'DEBIT') && CoreLocal::get('CacheCardCashBack') > 0) { CoreLocal::set('paycard_amount', CoreLocal::get('amtdue') + CoreLocal::get('CacheCardCashBack')); } // if we knew the type coming in, make sure it agrees if ($type != PaycardLib::PAYCARD_TYPE_UNKNOWN && $type != CoreLocal::get("paycard_type")) { $ret['output'] = PaycardLib::paycard_msgBox($type, "Type Mismatch", "Card number does not match card type", "[clear] to cancel"); return $ret; } foreach (CoreLocal::get("RegisteredPaycardClasses") as $rpc) { if (!class_exists($rpc)) { continue; } $myObj = new $rpc(); if ($myObj->handlesType(CoreLocal::get("paycard_type"))) { return $myObj->entered($validate, $ret); } } $ret['output'] = PaycardLib::paycard_errBox(PaycardLib::PAYCARD_TYPE_UNKNOWN, "Unknown Card Type " . CoreLocal::get("paycard_type"), "", "[clear] to cancel"); return $ret; }