Easy Pay Pending Payment Plan Report "Alabama", "AK" => "Alaska", "AZ" => "Arizona", "AR" => "Arkansas", "CA" => "California", "CO" => "Colorado", "CT" => "Connecticut", "DE" => "Delaware", "DC" => "District of Columbia", "FL" => "Florida", "GA" => "Georgia", "HI" => "Hawaii", "ID" => "Idaho", "IL" => "Illinois", "IN" => "Indiana", "IA" => "Iowa", "KS" => "Kansas", "KY" => "Kentucky", "LA" => "Louisiana", "ME" => "Maine", "MD" => "Maryland", "MA" => "Massachusetts", "MI" => "Michigan", "MN" => "Minnesota", "MS" => "Mississippi", "MO" => "Missouri", "MT" => "Montana", "NE" => "Nebraska", "NV" => "Nevada", "NH" => "New Hampshire", "NJ" => "New Jersey", "NM" => "New Mexico", "NY" => "New York", "NC" => "North Carolina", "ND" => "North Dakota", "OH" => "Ohio", "OK" => "Oklahoma", "OR" => "Oregon", "PA" => "Pennsylvania", "RI" => "Rhode Island", "SC" => "South Carolina", "SD" => "South Dakota", "TN" => "Tennessee", "TX" => "Texas", "UT" => "Utah", "VT" => "Vermont", "VA" => "Virginia", "WA" => "Washington", "WV" => "West Virginia", "WI" => "Wisconsin", "WY" => "Wyoming" ); // validate a date string of format MM/DD/YY , MM/DD/YYYY , or MMDDYYYY , return -1 on fail, else format YYYY-MM-DD function read_date($date) { if(ctype_digit($date)) { // the entire string is numbers, assume format of MMDDYYYY if(strlen($date) != 8) return -1; $m = substr($date, 0, 2); $d = substr($date, 2, 2); $y = substr($date, 4, 4); } else if( preg_match("/[-\/]/", substr($date, 2, 1)) && preg_match("/[-\/]/", substr($date, 5, 1)) ) { // assume formate of MM/DD/YYYY or MM/DD/YY $m = substr($date, 0, 2); $d = substr($date, 3, 2); if(strlen($date) == 8) { // 2 digit year received $y = substr($date, 6, 2); // compare the 2 digit submitted year to 20 years from now (eg, '27' if now is 2007) if((int)$y < (int)date("y") + 20) { // the 2 digit submitted year is less than the 2 digit year 20 years from now // eg. if it's 2007, the year submitted is less than 27. // treat it as 21st century $y = 2000 + (int)$y; } else { // the 2 digit submitted year is greater than the 2 digit year 20 years from now // treat is as 20th century $y = 1900 + (int)$y; } } else $y = substr($date, 6, 4); // 4 digit year } else return -1; // date string in unrecognized format if(!ctype_digit($m)) return -1; if(!ctype_digit($d)) return -1; if(!ctype_digit($y)) return -1; if(($m < 1) || ($m > 12)) return -1; if(($d < 1) || ($d > 31)) return -1; if(($y < 1800) || ($y > 2350)) return -1; $formated = $y . '-' . $m . '-' . $d; return $formated; } // validate a date string of either MM/YYYY or MM/DD/YYYY, return -1 on fail, else format YYYY-MM-DD function read_exp_date($date) { if(strlen($date) == 10) return read_date($date); if(strlen($date) != 7) return -1; $m = substr($date, 0, 2); $y = substr($date, 3, 4); if(!ctype_digit($m)) return -1; if(!ctype_digit($y)) return -1; if(($m < 1) || ($m > 12)) return -1; if(($y < 1800) || ($y > 2350)) return -1; if(!preg_match("/[-\/]/", substr($date, 2, 1))) return -1; $days = array( '01' => '31', '02' => '28', '03' => '31', '04' => '30', '05' => '31', '06' => '30', '07' => '31', '08' => '31', '09' => '30', '10' => '31', '11' => '30', '12' => '31'); $d = $days[$m]; $formated = $y . '-' . $m . '-' . $d; return $formated; } // validate a money string function is_money($money) { return preg_match("/^([0-9]{1,9})(\.([0-9]{0,2}))?$/", $money); } function invalid($error) { return "

  • $error
    "; } function is_card($card) { return preg_match("/^([0-9]{1,9})(\.([0-9]{0,2}))?$/", $card); } if(isset($_POST['submit'])) { // Form has been submitted, so process it $auth_net_login_id = "6p9JUXdyu5U"; $auth_net_tran_key = "2tAN78a4ytEMr64L"; $authnet_values = array ( "x_login" => $auth_net_login_id, "x_version" => "3.1", "x_delim_char" => "|", "x_delim_data" => "TRUE", "x_url" => "FALSE", "x_type" => "AUTH_CAPTURE", "x_method" => "CC", "x_tran_key" => $auth_net_tran_key, "x_relay_response" => "FALSE", "x_description" => "Lakes Region General Hospital", # information collected through the form: "x_card_num" => "4242424242424242", "x_exp_date" => "1209", "x_card_code" => "", "x_amount" => "12.23", "x_first_name" => "Charles D.", "x_last_name" => "Gaulle", "x_address" => "342 N. Main Street #150", "x_city" => "Ft. Worth", "x_state" => "TX", "x_zip" => "12345", ); // Validate information $department=$_REQUEST['department']; $cardpresent=$_REQUEST['cardpresent']; $error = ''; if(isset($_POST['voucher']) && ($_POST['voucher'] != '')) $voucher = $_POST['voucher']; else $error .= invalid("Invalid Acct/Voucher Number"); if(isset($_POST['card_num']) && ($_POST['card_num'] != '')) $authnet_values['x_card_num'] = $_POST['card_num']; else $error .= invalid("credit card number - must have a value"); if (($_POST['exp_month'] != '') && ($_POST['exp_year'] != '') && ($_POST['exp_month'] != '00') && ($_POST['exp_year'] != '00')&& read_exp_date($_POST['exp_month'].'/'.$_POST['exp_year'])) { $authnet_values['x_exp_date'] = read_exp_date($_POST['exp_month'].'/20'.$_POST['exp_year']); $todaycomp = $_POST['exp_year'].$_POST['exp_month']; if ( $today > $todaycomp ) $error .= invalid("expiration date must be greater than today"); } else $error .= invalid("expiration date"); if(isset($_POST['amount']) && is_money($_POST['amount'])) $authnet_values['x_amount'] = $_POST['amount']; else $error .= invalid("amount"); if(isset($_POST['first_name']) && ($_POST['first_name'] != '')) $authnet_values['x_first_name'] = $_POST['first_name']; else $error .= invalid("Credit Card first name"); $paytype = ""; if ( substr($_POST['card_num'], 0, 2) == "34" ){ $paytype = "OA"; } if ( substr($_POST['card_num'], 0, 2) == "37" ){ $paytype = "OA"; } if ( substr($_POST['card_num'], 0, 1) == "5" ){ $paytype = "OM"; } if ( substr($_POST['card_num'], 0, 4) == "6011" ){ $paytype = "OD"; } if ( substr($_POST['card_num'], 0, 1) == "4" ){ $paytype = "OV"; } $regexPattern = "/^4[0-9]{12}(?:[0-9]{3})?$/"; if($paytype == "OV") { $regexPattern = "/^4[0-9]{12}(?:[0-9]{3})?$/"; } else if($paytype == "OD") { $regexPattern = "/^6(?:011|5[0-9]{2})[0-9]{12}$/"; } else if($paytype == "OA") { $regexPattern = "/^3[47][0-9]{13}$/"; } else if($paytype == "OM") { $regexPattern = "/^5[1-5][0-9]{14}$/"; } else if($paytype == "diners") { $regexPattern = "/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/"; } else if($paytype == "jcb") { $regexPattern = "/^(?:2131|1800|35\d{3})\d{11}$/"; } else { $error .= invalid("Invalid Card Type"); } if(preg_match($regexPattern, $_POST['card_num'])) $authnet_values['x_card_num'] = $_POST['card_num']; else $error .= invalid("credit card number format"); // Now check the modulus 10 check digit - if required $cardNo = $_POST['card_num']; $checksum = 0; // running checksum total $mychar = ""; // next char to process $j = 1; // takes value of 1 or 2 // Process each digit one by one starting at the right for ($i = strlen($cardNo) - 1; $i >= 0; $i--) { // Extract the next digit and multiply by 1 or 2 on alternative digits. $calc = $cardNo{$i} * $j; // If the result is in two digits add 1 to the checksum total if ($calc > 9) { $checksum = $checksum + 1; $calc = $calc - 10; } // Add the units element to the checksum total $checksum = $checksum + $calc; // Switch the value of j if ($j ==1) {$j = 2;} else {$j = 1;}; } // All done - if checksum is divisible by 10, it is a valid modulus 10. // If not, report an error. if ($checksum % 10 != 0) { $error .= invalid("credit card check digits are incorrect"); } if(isset($_POST['last_name']) && ($_POST['last_name'] != '')) $authnet_values['x_last_name'] = $_POST['last_name']; else $error .= invalid("Credit Card last name"); $authnet_values['x_address'] = "NA"; $authnet_values['x_city'] = "NA"; $authnet_values['x_state'] = "NA"; if(isset($_POST['zip']) && (($_POST['zip'] != '') && (strlen($_POST['zip']) == 5))) $authnet_values['x_zip'] = $_POST['zip']; else $error .= invalid("zip code - must be 5 digits"); $begnumber = 0; $begnumber2 = 0; $stringsize = 0; $xauthnet_values['x_actnumber'] = $voucher; $begnumber = substr($xauthnet_values['x_actnumber'], 0, 2); $begnumber2 = substr($xauthnet_values['x_actnumber'], 0, 3); if ( $begnumber2 == "993" || $begnumber2 == "995" ) { $begnumber = "12"; } $stringsize = strlen($xauthnet_values['x_actnumber']); if ( $begnumber == "12" ) { // echo "begnumber is ".$begnumber; // echo "department is ".$department; if ((substr($department, 0, 4) != "CLR ") && (substr($department, 0, 4) != "CFR ")) { // echo "invalid location for this number string".$begnumber; // echo "string size is ".$stringsize; $error .= invalid("Invalid Department - If the Voucher number begins with 12 or 993 or 995 then the Department must be CLR or CFR"); } } if ( $begnumber != "12" ) { if ((substr($department, 0, 4) == "CLR ") || (substr($department, 0, 4) == "CFR ")) { $error .= invalid("If the Voucher number does not begin with 12 or 993 or 995 then the Department cannot be CLR or CFR"); } } if ( $begnumber == "12" ) { if ( ($stringsize != 10) && ($stringsize != 12) && ($stringsize != 13) ) { $error .= invalid("Invalid Account Number"); } } if($error == '') { // form submission successfully validated, submit request to authorize.net and exit $fields = ""; foreach( $authnet_values as $key => $value ) $fields .= "$key=" . urlencode( $value ) . "&"; // * * * * * #$auth_net_url = "https://certification.authorize.net/gateway/transact.dll"; # Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts #$auth_net_url = "https://secure.authorize.net/gateway/transact.dll"; # October 1, 2007 # Current API Login ID: # Current Transaction Key: // * * * * * echo "Processing your request, please wait for confirmation...

    "; $resp = ""; $text = $resp; echo "
    "; /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // STATISTICAL USE ONLY: // /////////////////////////////////////////////////////////// $howMany = substr_count($resp, "|"); /////////////////////////////////////////////////////////// $text = $resp; $h = substr_count($text, "|"); $h++; for($j=1; $j <= $h; $j++){ $p = strpos($text, "|"); if ($p === false) { // note: three equal signs // x_delim_char is obviously not found in the last go-around if($j>=69){ } else { } }else{ $p++; // We found the x_delim_char and accounted for it . . . now do something with it // get one portion of the response at a time $pstr = substr($text, 0, $p); // this prepares the text and returns one value of the submitted // and processed name/value pairs at a time // for AIM-specific interpretations of the responses // please consult the AIM Guide and look up // the section called Gateway Response API $pstr_trimmed = substr($pstr, 0, -1); // removes "|" at the end if($pstr_trimmed==""){ $pstr_trimmed="NO VALUE RETURNED"; } switch($j){ case 1: $fval=""; if($pstr_trimmed=="1"){ $fval="Approved"; }elseif($pstr_trimmed=="2"){ $fval="Declined"; }elseif($pstr_trimmed=="3"){ $fval="Error"; } break; case 2: $resp_subcode=$pstr_trimmed; break; case 3: $resp_reasoncode=$pstr_trimmed; break; case 4: $resp_text=$pstr_trimmed; break; case 5: break; case 6: break; case 7: break; case 10: $this_amount=$pstr_trimmed; break; case 14: $first_name=$pstr_trimmed; break; case 15: $last_name=$pstr_trimmed; break; case 17: //echo "Billing Address : "; //echo $pstr_trimmed; break; case 18: //echo "City : "; //echo $pstr_trimmed; break; case 19: //echo "State : "; //echo $pstr_trimmed; break; case 20: //echo "ZIP : "; //echo $pstr_trimmed; break; case 21: //echo "Country : "; //echo $pstr_trimmed; break; case 22: //echo "Phone : "; break; default: break; } // remove the part that we identified and work with the rest of the string $text = substr($text, $p); } } $this_amount=$_POST['amount']; $cardnumber=$_POST['card_num']; $shortcard = substr($cardnumber, -4, 4); $expm=$_POST['exp_month']; $expy=$_POST['exp_year']; $ccv=$_POST['card_code']; $holdfirst=$_POST['first_name']; $holdlast=$_POST['last_name']; $smth=$_POST['serv_month']; $sday=$_POST['serv_day']; $syr=$_POST['serv_year']; $voucher=$_POST['voucher']; //$balance1=$row_RecSetPeople['balance']; $ptname=$_POST['ptname']; $ptname = strtoupper($ptname); $gname=$_POST['gname']; $gname = strtoupper($gname); $t=time(); $thedate = date("D F d Y h:i:s A",$t); $vcomp=$_POST['voucher']; $copayamt="0";; # include ("/srv/include/db.inc.php"); # $holdinitials = $user; $track1 = "track1 not in use at this time"; $track2 = "track2 not used"; $holdclient = "CPS"; if (substr($department, 0, 4) == "LRGH") { $holdclient = "LAKES"; } if (substr($department, 0, 4) == "LCHA") { $holdclient = "LAKES"; } if (substr($department, 0, 4) == "LCPT") { $holdclient = "LAKES"; } if (substr($department, 0, 4) == "ENT ") { $holdclient = "ENT"; } if (substr($department, 0, 4) == "LRA ") { $holdclient = "LRA"; } if (substr($department, 0, 4) == "FRH ") { $holdclient = "FRANKL"; } if (substr($department, 0, 4) == "EMS ") { $holdclient = "EMS"; } if (substr($department, 0, 4) == "CLR ") { $holdclient = "CLR"; } if (substr($department, 0, 4) == "CFR ") { $holdclient = "CFR"; } if (substr($department, 0, 4) == "INS ") { $holdclient = "INS"; } echo "Department is ".$department; $space="HEAD"; include ("/srv/include/machine.php"); $port = 4451; $account="123456789 "; $Clientno="03016000"; $holdcity = ""; $holdstate = ""; $holdaddr = ""; $holdzip = ""; $Chunks = explode("|", $result); if ( $Chunks[19] == "VOIDED" || $Chunks[21] == "VOIDED" || $Chunks[22] == "VOIDED"){ echo "Credit Card Preauthorization Form has been VOIDED!"; }else { echo "Credit Card Preauthorization Form successfully submitted!"; } echo "
    "; echo "
    "; echo "

    "; $elink="PHPPREAUTHBILL.PHP?filler= "."&gname=".$gname."&ptname=".$ptname."&voucher=".$voucher."&serv=".$smth."/".$sday."/".$syr."&amount=".$this_amount."&authname=".$holdfirst." ".$holdlast."&expire=".$expm."/".$expy."&shortcard=".$shortcard."&client=".$holdclient."&department=".$department; ?>
    PRINT AUTHORIZATION



    "; echo "
    $error

    "; echo "« go back"; exit; } } // Form has not been submitted, so display it ?>
    Required Information
    Account / Voucher to Pay:
    Visit Authorized Amount:
    Patient Name:
    Guarantor Name:
    Service Date
    Credit Card Information
    Credit Card Present: Yes No
    Card Number
    Expiration Date /
    CCV
    Holder First Name
    Holder Last Name
    Zip