Exemple #1
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 
 }
Exemple #2
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;
     }
 }
Exemple #3
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;
 }