$result = 0; // 0 is never returned, so we use it to make sure it changes $myObj = 0; $json = array(); $plugin_info = new Paycards(); $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/paycardSuccess.php'; $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();
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; }
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; }