Ejemplo n.º 1
0
 public function saveResponse()
 {
     $dbTrans = PaycardLib::paycard_db();
     $finishQ = sprintf("UPDATE PaycardTransactions\n                            SET responseDatetime='%s',\n                                seconds=%f,\n                                commErr=%d,\n                                httpCode=%d,\n                                validResponse=%d,\n                                xResultCode=%d,\n                                xApprovalNumber='%s',\n                                xResponseCode=%d,\n                                xResultMessage='%s',\n                                xTransactionID='%s',\n                                xBalance='%s',\n                                xToken='%s',\n                                xProcessorRef='%s',\n                                xAcquirerRef='%s'\n                            WHERE paycardTransactionID=%d", $this->now, $this->curlTime, $this->curlErr, $this->curlHttp, $this->normalizedCode, $this->responseCode, $this->approvalNum, $this->resultCode, $this->resultMsg, $this->transactionID, $this->balance, $this->token['record'], $this->token['proc'], $this->token['acq'], $this->request->last_paycard_transaction_id);
     $throw = false;
     if (!$dbTrans->query($finishQ)) {
         $throw = new Exception('Error updating PaycardTransactions with response data');
     }
     if ($dbTrans->table_exists('efsnetRequest')) {
         try {
             if (!empty($this->token['record'])) {
                 $this->legacyToken($dbTrans);
             }
             if ($this->request instanceof PaycardVoidRequest) {
                 $this->legacyVoid($dbTrans);
             } elseif ($this->request instanceof PaycardGiftRequest) {
                 // pass; no legacy table
             } else {
                 $this->legacySave($dbTrans);
             }
         } catch (Exception $ex) {
             if ($throw === false) {
                 $throw = $ex;
             }
         }
     }
     // delay throwing until both saves have been attempted
     if ($throw !== false) {
         throw $throw;
     }
 }
Ejemplo n.º 2
0
 function body_content()
 {
     ?>
     <div class="baseHeight">
     <?php 
     echo PaycardLib::paycard_msgBox(PaycardLib::PAYCARD_TYPE_GIFT, "Check Card Balance?", "If you proceed, you <b>cannot void</b> any previous action on this card!", "[enter] to continue<br>[clear] to cancel");
     CoreLocal::set("msgrepeat", 2);
     ?>
     </div>
     <?php 
 }
Ejemplo n.º 3
0
 protected function varied_message($ref, $reprint = false, $sigSlip = false)
 {
     if (CoreLocal::get('autoReprint') == 1) {
         $sigSlip = true;
     }
     $date = ReceiptLib::build_time(time());
     list($emp, $reg, $trans) = explode('-', $ref);
     $slip = '';
     // query database for gc receipt info
     $db = Database::tDataConnect();
     if ($reprint) {
         $db = Database::mDataConnect();
     }
     $order = $sigSlip ? 'DESC' : 'ASC';
     $trans_type = $db->concat('p.cardType', "' '", 'p.transType', '');
     $sql = "SELECT {$trans_type} AS tranType,\n                    CASE WHEN p.transType = 'Return' THEN -1*p.amount ELSE p.amount END as amount,\n                    p.registerNo as terminalID,\n                    p.PAN,\n                    CASE WHEN p.manual=1 THEN 'Manual' ELSE 'Swiped' END as entryMethod,\n                    CASE WHEN transType='VOID' THEN '' ELSE p.xApprovalNumber END AS xAuthorizationCode,\n                    p.xBalance,\n                    CASE WHEN transType='VOID' THEN p.xApprovalNumber ELSE '' END AS xVoidCode,\n                    p.transID,\n                    p.requestDatetime AS datetime\n                FROM PaycardTransactions AS p\n                WHERE dateID=" . date('Ymd') . "\n                    AND empNo=" . $emp . "\n                    AND registerNo=" . $reg . "\n                    AND transNo=" . $trans . "\n                    AND p.validResponse=1\n                    AND p.xResultMessage LIKE '%Appro%'\n                    AND p.cardType = 'Gift'\n                ORDER BY p.requestDatetime " . $order;
     $result = $db->query($sql);
     $num = $db->num_rows($result);
     while ($row = $db->fetch_row($result)) {
         $slip .= ReceiptLib::centerString("................................................") . "\n";
         // store header
         for ($i = 1; $i <= CoreLocal::get('chargeSlipCount'); $i++) {
             $slip .= ReceiptLib::centerString(CoreLocal::get("chargeSlip" . $i)) . "\n";
         }
         $slip .= "\n";
         $col1 = array();
         $col2 = array();
         $col1[] = $row['tranType'];
         $col2[] = "Date: " . date('m/d/y h:i a', strtotime($row['datetime']));
         $col1[] = "Terminal ID: " . $row['terminalID'];
         $col2[] = "Reference: " . $ref . "-" . $row['transID'];
         $col1[] = "Card: " . $row['PAN'];
         $col2[] = "Entry Method: " . $row['entryMethod'];
         if ((int) $row['xVoidCode'] > 0) {
             $col1[] = "Void Auth: " . $row['xVoidCode'];
             $col2[] = "Orig Auth: " . $row['xAuthorizationCode'];
         } else {
             $col1[] = "Authorization: " . $row['xAuthorizationCode'];
             $col2[] = "";
         }
         $col1[] = ReceiptLib::boldFont() . "Amount: " . PaycardLib::paycard_moneyFormat($row['amount']) . ReceiptLib::normalFont();
         // bold ttls apbw 11/3/07
         $col2[] = "New Balance: " . PaycardLib::paycard_moneyFormat($row['xBalance']);
         $slip .= ReceiptLib::twoColumns($col1, $col2);
         // name/phone on activation only
         if (($row['tranType'] == 'Gift Card Activation' || $row['tranType'] == 'Gift Card Issue') && $sigSlip) {
             $slip .= "\n" . ReceiptLib::centerString("Name:  ___________________________________") . "\n" . "\n" . ReceiptLib::centerString("Phone: ___________________________________") . "\n";
         }
         $slip .= ReceiptLib::centerString("................................................") . "\n";
     }
     return $slip;
 }
Ejemplo n.º 4
0
 /**
   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();
 }
Ejemplo n.º 5
0
 public function findOriginal()
 {
     $dbTrans = PaycardLib::paycard_db();
     $sql = 'SELECT refNum,
                 xTransactionID,
                 amount,
                 xToken as token,
                 xProcessorRef as processData,
                 xAcquirerRef AS acqRefData,
                 xApprovalNumber,
                 transType AS mode
             FROM PaycardTransactions
             WHERE dateID=' . $this->today . '
                 AND empNo=' . $this->cashierNo . '
                 AND registerNo=' . $this->original[1] . '
                 AND transNo=' . $this->original[2] . '
                 AND transID=' . $this->transID;
     $res = $dbTrans->query($sql);
     if ($res === false || $dbTrans->numRows($res) != 1) {
         throw new Exception('Could not locate original transaction');
     }
     return $dbTrans->fetchRow($res);
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 function body_content()
 {
     ?>
     <div class="baseHeight">
     <?php 
     // generate message to print
     $type = CoreLocal::get("paycard_type");
     $mode = CoreLocal::get("paycard_mode");
     $amt = CoreLocal::get("paycard_amount");
     if ($amt == 0) {
         if ($mode == PaycardLib::PAYCARD_MODE_ACTIVATE) {
             echo PaycardLib::paycard_msgBox($type, "Enter Activation Amount", "Enter the amount to put on the card", "[clear] to cancel");
         } else {
             if ($mode == PaycardLib::PAYCARD_MODE_ADDVALUE) {
                 echo PaycardLib::paycard_msgBox($type, "Enter Add-Value Amount", "Enter the amount to put on the card", "[clear] to cancel");
             }
         }
     } else {
         if (!is_numeric($amt) || $amt < 0.005) {
             echo PaycardLib::paycard_msgBox($type, "Invalid Amount", "Enter a positive amount to put on the card", "[clear] to cancel");
         } else {
             if ($mode == PaycardLib::PAYCARD_MODE_ACTIVATE) {
                 echo PaycardLib::paycard_msgBox($type, "Activate " . PaycardLib::paycard_moneyFormat($amt) . "?", "", "[enter] to continue if correct<br>Enter a different amount if incorrect<br>[clear] to cancel");
             } else {
                 if ($mode == PaycardLib::PAYCARD_MODE_ADDVALUE) {
                     echo PaycardLib::paycard_msgBox($type, "Add Value " . PaycardLib::paycard_moneyFormat($amt) . "?", "", "[enter] to continue if correct<br>Enter a different amount if incorrect<br>[clear] to cancel");
                 }
             }
         }
     }
     CoreLocal::set("msgrepeat", 2);
     ?>
     </div>
     <?php 
 }
Ejemplo n.º 8
0
 function body_content()
 {
     ?>
     <div class="baseHeight">
     <?php 
     // generate message to print
     $type = CoreLocal::get("paycard_type");
     $mode = CoreLocal::get("paycard_mode");
     $amt = CoreLocal::get("paycard_amount");
     $due = CoreLocal::get("amtdue");
     $cb = CoreLocal::get('CacheCardCashBack');
     $balance_limit = CoreLocal::get('PaycardRetryBalanceLimit');
     if ($type == 'EBTFOOD') {
         $due = CoreLocal::get('fsEligible');
     }
     if ($cb > 0) {
         $amt -= $cb;
     }
     if (!is_numeric($amt) || abs($amt) < 0.005) {
         echo PaycardLib::paycard_msgBox($type, "Invalid Amount: {$amt}", "Enter a different amount", "[clear] to cancel");
     } else {
         if ($amt > 0 && $due < 0) {
             echo PaycardLib::paycard_msgBox($type, "Invalid Amount", "Enter a negative amount", "[clear] to cancel");
         } else {
             if ($amt < 0 && $due > 0) {
                 echo PaycardLib::paycard_msgBox($type, "Invalid Amount", "Enter a positive amount", "[clear] to cancel");
             } else {
                 if ($amt - $due > 0.005 && $type != 'DEBIT' && $type != 'EBTCASH') {
                     echo PaycardLib::paycard_msgBox($type, "Invalid Amount", "Cannot exceed amount due", "[clear] to cancel");
                 } else {
                     if ($amt - $due - 0.005 > $cb && ($type == 'DEBIT' || $type == 'EBTCASH')) {
                         echo PaycardLib::paycard_msgBox($type, "Invalid Amount", "Cannot exceed amount due plus cashback", "[clear] to cancel");
                     } else {
                         if ($balance_limit > 0 && $amt - $balance_limit > 0.005) {
                             echo PaycardLib::paycard_msgBox($type, "Exceeds Balance", "Cannot exceed card balance", "[clear] to cancel");
                         } else {
                             if ($balance_limit > 0) {
                                 $msg = "Tender " . PaycardLib::paycard_moneyFormat($amt);
                                 if (CoreLocal::get("CacheCardType") != "") {
                                     $msg .= " as " . CoreLocal::get("CacheCardType");
                                 } elseif (CoreLocal::get('paycard_type') == PaycardLib::PAYCARD_TYPE_GIFT) {
                                     $msg .= ' as GIFT';
                                 }
                                 echo PaycardLib::paycard_msgBox($type, $msg . "?", "", "Card balance is {$balance_limit}<br>\n                    [enter] to continue if correct<br>Enter a different amount if incorrect<br>\n                    [clear] to cancel");
                             } elseif ($amt > 0) {
                                 $msg = "Tender " . PaycardLib::paycard_moneyFormat($amt);
                                 if (CoreLocal::get("CacheCardType") != "") {
                                     $msg .= " as " . CoreLocal::get("CacheCardType");
                                 } elseif (CoreLocal::get('paycard_type') == PaycardLib::PAYCARD_TYPE_GIFT) {
                                     $msg .= ' as GIFT';
                                 }
                                 if ($cb > 0) {
                                     $msg .= ' (CB:' . PaycardLib::paycard_moneyFormat($cb) . ')';
                                 }
                                 $msg .= '?';
                                 if (CoreLocal::get('CacheCardType') == 'EBTFOOD' && abs(CoreLocal::get('subtotal') - CoreLocal::get('fsEligible')) > 0.005) {
                                     $msg .= '<br />' . _('Not all items eligible');
                                 }
                                 echo PaycardLib::paycard_msgBox($type, $msg, "", "[enter] to continue if correct<br>Enter a different amount if incorrect<br>[clear] to cancel");
                             } elseif ($amt < 0) {
                                 echo PaycardLib::paycard_msgBox($type, "Refund " . PaycardLib::paycard_moneyFormat($amt) . "?", "", "[enter] to continue if correct<br>Enter a different amount if incorrect<br>[clear] to cancel");
                             } else {
                                 echo PaycardLib::paycard_errBox($type, "Invalid Entry", "Enter a different amount", "[clear] to cancel");
                             }
                         }
                     }
                 }
             }
         }
     }
     CoreLocal::set("msgrepeat", 2);
     ?>
     </div>
     <?php 
 }
Ejemplo n.º 9
0
 function body_content()
 {
     ?>
     <div class="baseHeight">
     <?php 
     // generate message to print
     $type = CoreLocal::get("paycard_type");
     $mode = CoreLocal::get("paycard_mode");
     $amt = CoreLocal::get("paycard_amount");
     if ($mode == PaycardLib::PAYCARD_MODE_VOIDITEM) {
         echo PaycardLib::paycard_msgBox($type, "Void " . PaycardLib::paycard_moneyFormat($amt) . " Gift Card?", "", "[enter] to continue voiding<br>[clear] to cancel the void");
     } else {
         if ($amt > 0) {
             echo PaycardLib::paycard_msgBox($type, "Void " . PaycardLib::paycard_moneyFormat($amt) . " Payment?", "Please enter password then", "[enter] to continue voiding or<br>[clear] to cancel the void");
         } else {
             echo PaycardLib::paycard_msgBox($type, "Void " . PaycardLib::paycard_moneyFormat($amt) . " Refund?", "Please enter password then", "[enter] to continue voiding or<br>[clear] to cancel the void");
         }
     }
     CoreLocal::set("msgrepeat", 2);
     ?>
     </div>
     <?php 
 }
Ejemplo n.º 10
0
 public function parse($str)
 {
     $ret = $this->default_json();
     $plugin_info = new Paycards();
     $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvPage.php';
     Database::getsubtotals();
     switch ($str) {
         case 'DATACAP':
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvMenu.php';
             break;
         case 'DATACAPEMV':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             CoreLocal::set('CacheCardType', 'EMV');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPCC':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             CoreLocal::set('CacheCardType', 'CREDIT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPDC':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             if (CoreLocal::get('CacheCardCashBack')) {
                 CoreLocal::set('paycard_amount', CoreLocal::get('amtdue') + CoreLocal::get('CacheCardCashBack'));
             }
             CoreLocal::set('CacheCardType', 'DEBIT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPEF':
             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");
                     $ret['main_frame'] = false;
                     return $ret;
                 }
             }
             CoreLocal::set('paycard_amount', CoreLocal::get('fsEligible'));
             CoreLocal::set('CacheCardType', 'EBTFOOD');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPEC':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             if (CoreLocal::get('CacheCardCashBack')) {
                 CoreLocal::set('paycard_amount', CoreLocal::get('amtdue') + CoreLocal::get('CacheCardCashBack'));
             }
             CoreLocal::set('CacheCardType', 'EBTCASH');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPGD':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             CoreLocal::set('CacheCardType', 'GIFT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT);
             break;
         case 'PVDATACAPGD':
             CoreLocal::set('CacheCardType', 'GIFT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_BALANCE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvBalance.php';
             break;
         case 'PVDATACAPEF':
             CoreLocal::set('CacheCardType', 'EBTFOOD');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_BALANCE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvBalance.php';
             break;
         case 'PVDATACAPEC':
             CoreLocal::set('CacheCardType', 'EBTCASH');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_BALANCE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvBalance.php';
             break;
         case 'ACDATACAPGD':
             CoreLocal::set('CacheCardType', 'GIFT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_ACTIVATE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvGift.php?mode=' . CoreLocal::get('paycard_mode');
             break;
         case 'AVDATACAPGD':
             CoreLocal::set('CacheCardType', 'GITFT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_ADDVALUE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvGift.php?mode=' . CoreLocal::get('paycard_mode');
             break;
     }
     CoreLocal::set('paycard_id', CoreLocal::get('LastID') + 1);
     return $ret;
 }
Ejemplo n.º 11
0
 public static function paycard_db()
 {
     if (self::$paycardDB === null) {
         self::$paycardDB = new \COREPOS\pos\lib\SQLManager('127.0.0.1', CoreLocal::get('DBMS'), CoreLocal::get('tDatabase'), CoreLocal::get('localUser'), CoreLocal::get('localPass'));
     }
     return self::$paycardDB;
 }
Ejemplo n.º 12
0
 /** 
  @param $errorCode error code contstant from paycardLib.php
 
  Set CoreLocal::["boxMsg"] appropriately for
  the given error code. I find this easier
  than manually setting an appropriate message
  every time I return a common error like
  PaycardLib::PAYCARD_ERR_NOSEND. I think everything but
  PaycardLib::PAYCARD_ERR_PROC can have one default message
  assigned here
 */
 public function setErrorMsg($errorCode)
 {
     switch ($errorCode) {
         case PaycardLib::PAYCARD_ERR_NOSEND:
             CoreLocal::set("boxMsg", PaycardLib::paycard_errorText("Internal Error", $errorCode, "", 1, 1, 0, 0, 1, CoreLocal::get("paycard_type")));
             break;
         case PaycardLib::PAYCARD_ERR_COMM:
             CoreLocal::set("boxMsg", PaycardLib::paycard_errorText("Communication Error", $errorCode, "", 1, 1, 0, 0, 0, CoreLocal::get("paycard_type")));
             break;
         case PaycardLib::PAYCARD_ERR_TIMEOUT:
             CoreLocal::set("boxMsg", PaycardLib::paycard_errorText("Timeout Error", $errorCode, "", 0, 0, 0, 1, 0, CoreLocal::get("paycard_type")));
             break;
         case PaycardLib::PAYCARD_ERR_DATA:
             CoreLocal::set("boxMsg", PaycardLib::paycard_errorText("System Error", $errorCode, "", 0, 0, 0, 1, 1, CoreLocal::get("paycard_type")));
             break;
         default:
             CoreLocal::set("boxMsg", PaycardLib::paycard_errorText("Internal Error", $errorCode, "", 1, 1, 0, 0, 1, CoreLocal::get("paycard_type")));
             break;
     }
     return $errorCode;
 }
Ejemplo n.º 13
0
 private static function ingenicoBlock($str, $ret)
 {
     $data = substr($str, 4);
     $tracks = explode('@@', $data);
     $track1 = false;
     $track2 = false;
     $track3 = $tracks[count($tracks) - 1];
     if ($tracks[0][0] == '%') {
         $track1 = $tracks[0];
     } elseif ($tracks[0][0] == ';') {
         $track2 = $tracks[0];
     }
     if ($track2 === false && $tracks[1][0] == ';') {
         $track2 = $tracks[1];
     }
     if ($track1 !== false) {
         $pieces = explode('^', $track1);
         $masked = ltrim($pieces[0], '%');
         $ret['Issuer'] = PaycardLib::paycard_issuer($masked);
         $ret['Last4'] = substr($masked, -4);
         if (count($pieces) >= 3) {
             $ret['Name'] = $pieces[1];
         }
     } elseif ($track2 !== false) {
         list($start, $end) = explode('=', $track2, 2);
         $masked = ltrim($start, ';');
         $ret['Issuer'] = PaycardLib::paycard_issuer($masked);
         $ret['Last4'] = substr($masked, -4);
     }
     if (strstr($track3, ';')) {
         list($e2e, $actual_track3) = explode(';', $track3, 2);
         $track3 = $e2e;
     }
     $pieces = explode(':', $track3);
     if (count($pieces) == 4) {
         $ret['Block'] = $pieces[2];
         $ret['Key'] = $pieces[3];
     } elseif (count($pieces) == 2 && $track1 === false) {
         $ret['Block'] = $pieces[0];
         $ret['Key'] = $pieces[1];
     }
     return $ret;
 }
Ejemplo n.º 14
0
 public static function validateVoid($request, $response, $lineitem, $id)
 {
     // make sure the payment is applicable to void
     $err_header = _('Unable to Void');
     $buttons = _('[clear] to cancel');
     $error = self::voidReqResp($request, $response);
     if ($error === false) {
         $error = self::voidLineItem($lineitem, $id);
     }
     if ($error !== false) {
         return PaycardLib::paycard_errBox(PaycardLib::PAYCARD_TYPE_CREDIT, $err_header, $error, $buttons);
     } else {
         return true;
     }
 }
Ejemplo n.º 15
0
 function body_content()
 {
     ?>
     <div class="baseHeight">
     <?php 
     // generate message to print
     echo PaycardLib::paycard_msgBox(PaycardLib::PAYCARD_TYPE_GIFT, "Check Card Balance?", "", "[enter] to continue<br>[clear] to cancel");
     ?>
     </div>
     <?php 
 }
Ejemplo n.º 16
0
 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;
 }
Ejemplo n.º 17
0
 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;
 }
Ejemplo n.º 18
0
 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>&nbsp;\n                <p>[enter] to continue\n                <br>[void] " . _('to reverse the charge') . "\n                </font>");
     }
     return True;
 }
Ejemplo n.º 19
0
 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);
 }
Ejemplo n.º 20
0
 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);
 }
Ejemplo n.º 21
0
 public function updateCardInfo($pan, $name, $issuer)
 {
     $this->setPAN($pan);
     $this->cardholder = $name;
     $this->issuer = $issuer;
     $dbTrans = PaycardLib::paycard_db();
     $upP = $dbTrans->prepare('
         UPDATE PaycardTransactions
         SET PAN=?,
             issuer=?,
             name=?
         WHERE paycardTransactionID=?
     ');
     $dbTrans->execute($upP, array($this->pan, $this->issuer, $this->cardholder, $this->last_paycard_transaction_id));
 }
Ejemplo n.º 22
0
 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;
 }
Ejemplo n.º 23
0
 private function handleResponseAuth($authResult)
 {
     $xml = new xmlData($authResult["response"]);
     $request = $this->last_request;
     $this->last_paycard_transaction_id = $request->last_paycard_transaction_id;
     $response = new PaycardResponse($request, $authResult);
     // initialize
     $dbTrans = Database::tDataConnect();
     $program = 'Gift';
     $validResponse = $xml->isValid() ? 1 : 0;
     $errorMsg = $xml->get_first("ERRORMSG");
     $balance = $xml->get("BALANCE");
     if ($validResponse) {
         /*
                     tendering more than the available balance returns an "NSF" error message, 
                     but no Balance field however, the available balance is buried in the 
                     RawOutput field, so we can dig it out and fill in the missing Balance field
                     -- as of 1/22/08, valutec appears to now be returning the Balance field normally 
                     (in its own XML field, not in RawOutput), but we still need to append it to 
                     the Message so the cashier can see it
         */
         if ($errorMsg && substr($errorMsg, 0, 3) == "NSF") {
             if (!$balance || $balance === "") {
                 $rawOutput = $xml->get("RAWOUTPUT");
                 $begin = strpos($rawOutput, "%1cBAL%3a");
                 if ($begin !== false) {
                     $end = strpos($rawOutput, "%1c", $begin + 1);
                     if ($end !== false && $end > $begin) {
                         $balance = trim(urldecode(substr($rawOutput, $begin + 9, $end - $begin - 9)));
                     }
                 }
             } else {
                 if ($balance && $balance !== "") {
                     $errorMsg = "NSF, BAL: " . PaycardLib::paycard_moneyFormat($balance);
                 }
             }
         }
         // verify that echo'd fields match our request
         if ($xml->get('TRANSACTIONTYPE') && $xml->get('TRANSACTIONTYPE') == $program && $xml->get('IDENTIFIER') && $xml->get('IDENTIFIER') == $identifier && $xml->get('AUTHORIZED')) {
             $validResponse = 1;
             // response was parsed normally, echo'd fields match, and other required fields are present
         } else {
             $validResponse = 4;
             // response was parsed as XML but fields didn't match
         }
     }
     $response->setBalance($balance);
     $resultCode = 0;
     $apprNumber = $xml->get('AUTHORIZATIONCODE');
     $response->setApprovalNum($apprNumber);
     $rMsg = '';
     if ($apprNumber != '' && $xml->get('AUTHORIZED') == 'true') {
         $validResponse = 1;
         $resultCode = 1;
         $rMsg = 'Approved';
     } else {
         $rMsg = substr($xml->get_first('ERRORMSG'), 0, 100);
     }
     $response->setResultMsg($rMsg);
     $response->setResultCode($resultCode);
     $response->setResponseCode($resultCode);
     $response->setNormalizedCode($resultCode);
     $response->setValid($validResponse);
     try {
         $response->saveResponse();
     } catch (Exception $ex) {
     }
     // check for communication errors (any cURL error or any HTTP code besides 200)
     if ($authResult['curlErr'] != CURLE_OK || $authResult['curlHTTP'] != 200) {
         if ($authResult['curlHTTP'] == '0') {
             CoreLocal::set("boxMsg", "No response from processor<br />\n                                The transaction did not go through");
             return PaycardLib::PAYCARD_ERR_PROC;
         }
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_COMM);
     }
     // check for data errors (any failure to parse response XML or echo'd field mismatch
     if ($validResponse != 1) {
         // invalid server response, we don't know if the transaction was processed (use carbon)
         return $this->setErrorMsg(PaycardLib::PAYCARD_ERR_DATA);
     }
     $amtUsed = $xml->get('CARDAMOUNTUSED');
     if ($amtUsed) {
         $request->changeAmount($amtUsed);
     }
     // put the parsed response into session so the caller, receipt printer, etc can get the data they need
     CoreLocal::set("paycard_response", array());
     CoreLocal::set("paycard_response", $xml->array_dump());
     $temp = CoreLocal::get("paycard_response");
     $temp["Balance"] = $temp["BALANCE"];
     CoreLocal::set("paycard_response", $temp);
     // comm successful, check the Authorized, AuthorizationCode and ErrorMsg fields
     if ($xml->get('AUTHORIZED') == 'true' && $xml->get('AUTHORIZATIONCODE') != '' && $xml->get_first('ERRORMSG') == '') {
         return PaycardLib::PAYCARD_ERR_OK;
         // authorization approved, no error
     }
     // the authorizor gave us some failure code
     // authorization failed, response fields in $_SESSION["paycard_response"]
     CoreLocal::set("boxMsg", "Processor error: " . $errorMsg);
     return PaycardLib::PAYCARD_ERR_PROC;
 }
Ejemplo n.º 24
0
$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);
Ejemplo n.º 25
0
 function body_content()
 {
     ?>
     <div class="baseHeight">
     <?php 
     // generate message to print
     $amt = CoreLocal::get("paycard_amount");
     if ($amt > 0) {
         echo PaycardLib::paycard_msgBox($type, "Void " . PaycardLib::paycard_moneyFormat($amt) . " Payment?", "Please enter password then", "[enter] to continue voiding or<br>[clear] to cancel the void");
     } else {
         echo PaycardLib::paycard_msgBox($type, "\n                Void " . PaycardLib::paycard_moneyFormat($amt) . " Refund?", "Please enter password then", "[enter] to continue voiding or<br>[clear] to cancel the void");
     }
     ?>
     </div>
     <?php 
 }
Ejemplo n.º 26
0
 function body_content()
 {
     ?>
     <div class="baseHeight">
     <?php 
     $title = $this->mode == PaycardLib::PAYCARD_MODE_ACTIVATE ? 'Activate Gift Card' : 'Add Value to Gift Card';
     $msg = '';
     if (!$this->amount) {
         $msg .= 'Enter amount<br />
             [clear] to cancel';
     } else {
         $msg .= 'Value: $' . sprintf('%.2f', $this->amount) . '
                 [enter] to continue if correct<br>Enter a different amount if incorrect<br>
                 [clear] to cancel';
     }
     // generate message to print
     echo PaycardLib::paycard_msgBox(PaycardLib::PAYCARD_TYPE_GIFT, $title, '', $msg);
     ?>
     </div>
     <?php 
     $this->add_onload_command("\$('#formlocal').append(\$('<input type=\"hidden\" name=\"mode\" />').val({$this->mode}));\n");
     if ($this->amount) {
         $this->add_onload_command("\$('#formlocal').append(\$('<input type=\"hidden\" name=\"amount\" />').val({$this->amount}));\n");
     }
 }