Exemple #1
0
 public static function voidableCheck($pan4, $trans)
 {
     $dbTrans = PaycardLib::paycard_db();
     $today = date('Ymd');
     $sql = 'SELECT transID
             FROM PaycardTransactions
             WHERE dateID=' . $today . '
                 AND empNo=' . $trans[0] . '
                 AND registerNo=' . $trans[1] . '
                 AND transNo=' . $trans[2] . '
                 AND PAN LIKE \'%' . $pan4 . '\'';
     if (!$dbTrans->table_exists('PaycardTransactions')) {
         $sql = "SELECT transID,cashierNo,laneNo,transNo FROM efsnetRequest WHERE " . $dbTrans->identifier_escape('date') . "='" . $today . "' AND (PAN LIKE '%" . $pan4 . "')";
     }
     $search = PaycardLib::paycard_db_query($sql, $dbTrans);
     $num = PaycardLib::paycard_db_num_rows($search);
     if ($num < 1) {
         PaycardLib::paycard_reset();
         return array(false, PaycardLib::paycard_msgBox(PaycardLib::PAYCARD_TYPE_CREDIT, "Card Not Used", "That card number was not used in this transaction", "[clear] to cancel"));
     } else {
         if ($num > 1) {
             PaycardLib::paycard_reset();
             return array(false, PaycardLib::paycard_msgBox(PaycardLib::PAYCARD_TYPE_CREDIT, "Multiple Uses", "That card number was used more than once in this transaction; select the payment and press VOID", "[clear] to cancel"));
         }
     }
     $payment = PaycardLib::paycard_db_fetch_row($search);
     return array(true, $payment['transID']);
 }
 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 
 }
Exemple #3
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 
 }
Exemple #4
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 
 }
Exemple #5
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 
 }
Exemple #6
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 
 }
Exemple #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");
     $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 
 }
 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;
 }
Exemple #9
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");
     }
 }
Exemple #10
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;
 }
Exemple #11
0
 /**
   Updated for E2E
   Status: done
 */
 public function entered($validate, $json)
 {
     $enabled = PaycardDialogs::enabledCheck();
     if ($enabled !== true) {
         $json['output'] = $enabled;
         return $json;
     }
     // error checks based on processing mode
     switch (CoreLocal::get("paycard_mode")) {
         case PaycardLib::PAYCARD_MODE_VOID:
             // use the card number to find the trans_id
             $pan4 = substr($this->trans_pan['pan'], -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, $trans[1], $trans[2], $json);
             } else {
                 $json['output'] = $result;
                 return $json;
             }
             break;
         case PaycardLib::PAYCARD_MODE_AUTH:
             // set initial variables
             //Database::getsubtotals();
             $e2e = EncBlock::parseEncBlock(CoreLocal::get('paycard_PAN'));
             if (empty($e2e['Block']) || empty($e2e['Key'])) {
                 PaycardLib::paycard_reset();
                 $json['output'] = PaycardLib::paycard_msgBox(PaycardLib::PAYCARD_TYPE_CREDIT, "Swipe Error", "Error reading card. Swipe again.", "[clear] to cancel");
                 UdpComm::udpSend('termReset');
                 return $json;
             }
             return PaycardLib::setupAuthJson($json);
             break;
     }
     // switch mode
     // if we're still here, it's an error
     PaycardLib::paycard_reset();
     $json['output'] = PaycardDialogs::invalidMode();
     return $json;
 }