Processing Harrington Healthcare Recurring Credit Cards....
DO NOT TOUCH OR HIT ANY KEY UNTIL YOU SEE FINISHED AT THE BOTTOM OF THE SCREEN!!!!
$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" => "Harrington Healthcare -Recurring Payment",
# 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",
"x_duplicate_window" => "0",
);
// Validate information
$error = '';
$authnet_values['x_card_num'] = $card;
$authnet_values['x_exp_date'] = $expire;
$authnet_values['x_amount'] = $dollar;
$authnet_values['x_first_name'] = $fname;
$authnet_values['x_last_name'] = $lname;
$authnet_values['x_address'] = $street;
$authnet_values['x_city'] = $city;
$authnet_values['x_state'] = $state;
$authnet_values['x_zip'] = $zip;
$authnet_values['x_card_code'] = $code;
$authnet_values['x_duplicate_window'] = 0;
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:
$auth_net_login_id = "8563ffFG4tk9";
$auth_net_tran_key = "57v778L5EXLdA6jZ";
$ch = curl_init("https://secure.authorize.net/gateway/transact.dll");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ###
$resp = curl_exec($ch); //execute post and get results
curl_close ($ch);
// * * * * *
$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";
}
$resp_code=$fval;
break;
case 2:
$resp_subcode=$pstr_trimmed;
break;
case 3:
$resp_reasoncode=$pstr_trimmed;
break;
case 4:
$resp_text=$pstr_trimmed;
break;
case 5:
$approval_code=$pstr_trimmed;
break;
case 6:
break;
case 7:
$trans_id=$pstr_trimmed;
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);
}
}
$acct_num1=$account;
$auth_code=$approval_code;
$amount=$this_amount;
//$balance1=$row_RecSetPeople['balance'];
$resp_code1=$resp_code;
$trans_id1=$trans_id;
date_default_timezone_set('America/New_York');
$t=time();
$thedate = date("D F d Y h:i:s A",$t);
#
include ("/srv/include/db.inc.php");
$mytable = "smallpaygate";
$paytype = "R-U";
if ( substr($card, 0, 2) == "34" ){
$paytype = "R-A";
}
if ( substr($card, 0, 2) == "37" ){
$paytype = "R-A";
}
if ( substr($card, 0, 1) == "5" ){
$paytype = "R-M";
}
if ( substr($card, 0, 4) == "6011" ){
$paytype = "R-D";
}
if ( substr($card, 0, 1) == "4" ){
$paytype = "R-V";
}
$shortcard = substr($card, 10, 28);
$db = mysql_connect($hostname_dbConn, $username_dbConn, $password_dbConn);
mysql_select_db($database_dbConn,$db);
$authnet_values['x_last_name'] = mysql_real_escape_string($authnet_values['x_last_name']);
$lname = mysql_real_escape_string($lname);
$fname = mysql_real_escape_string($fname);
$patient = mysql_real_escape_string($patient);
$acct_num1 = mysql_real_escape_string($acct_num1);
$shortcard = mysql_real_escape_string($shortcard);
$cardholdname = $fname." ".$lname;
$query = "INSERT INTO $mytable (acct_num,auth_code,paid,resp_code,trans_id,date_time,transtype,cardholdername,cardnumber,patientname,client_number) VALUES ('$acct_num1', '$auth_code', '$amount', '$resp_code1', '$trans_id1', '$thedate', '$paytype', '$cardholdname', '$shortcard', '$patient', '500001' )";
mysql_query($query,$db);
mysql_close ($db);
#
#
if ( $resp_code == "Approved" ){
?>