Exemple #1
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;
 }
 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 #3
0
 function preprocess()
 {
     $this->tendertype = "";
     if (isset($_REQUEST["selectlist"])) {
         $choice = $_REQUEST["selectlist"];
         if ($choice == "EF") {
             $chk = PrehLib::fsEligible();
             if ($chk !== true) {
                 $this->change_page($chk);
                 return false;
             }
             // 13Feb13 Andy
             // Disable option to enter tender here by returning immediately
             // to pos2.php. Should be conigurable or have secondary
             // functionality removed entirely
             $this->tendertype = 'EF';
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return false;
         } else {
             if ($choice == "EC") {
                 $chk = PrehLib::ttl();
                 if ($chk !== true) {
                     $this->change_page($chk);
                     return false;
                 }
                 // 13Feb13 Andy
                 // Disabled option; see above
                 $this->tendertype = 'EC';
                 $this->change_page($this->page_url . "gui-modules/pos2.php");
                 return false;
             } else {
                 if ($choice == '') {
                     $this->change_page($this->page_url . "gui-modules/pos2.php");
                     return false;
                 }
             }
         }
     } else {
         if (isset($_REQUEST['tendertype'])) {
             $this->tendertype = $_REQUEST['tendertype'];
             $valid_input = false;
             $in = $_REQUEST['tenderamt'];
             if (empty($in)) {
                 if ($this->tendertype == 'EF') {
                     CoreLocal::set("strRemembered", 100 * CoreLocal::get("fsEligible") . "EF");
                 } else {
                     CoreLocal::set("strRemembered", 100 * CoreLocal::get("runningTotal") . "EC");
                 }
                 CoreLocal::set("msgrepeat", 1);
                 $valid_input = true;
             } else {
                 if (is_numeric($in)) {
                     if ($this->tendertype == 'EF' && $in > 100 * CoreLocal::get("fsEligible")) {
                         $valid_input = false;
                     } else {
                         CoreLocal::set("strRemembered", $in . $this->tendertype);
                         CoreLocal::set("msgrepeat", 1);
                         $valid_input = true;
                     }
                 } else {
                     if (strtoupper($in) == "CL") {
                         CoreLocal::set("strRemembered", "");
                         CoreLocal::set("msgrepeat", 0);
                         $valid_input = true;
                     }
                 }
             }
             if ($valid_input) {
                 $this->change_page($this->page_url . "gui-modules/pos2.php");
                 return false;
             }
         }
     }
     return true;
 }