<?php
include ('celebrityData.php'); // authoize.net user/trankey and pw
include ('SQLcon.php');// my connctio nsettings
$ID_KEY = $_POST['x_cust_id'];
$EQuerry =
mysql_query("SELECT Event_ID, Workshop_Date FROM EventCalanderMembers WHERE EveID = ' $ID_KEY'") or
die(mysql_error());
$EventKey = $EQnews['Event_ID'];
$EventWorkshopKey = $EQnews['Workshop_Date'];
$days =
explode (',',
$news['Event_Dates']);
for ($i=0; $i< $numDays; $i++){
$studentMax[$i] =
explode (':',
$days[$i]);
}//end for
$numDaysMax =
count($studentMax);
for ($i=0; $i < $numDaysMax; $i++){
if ($EventWorkshopKey == $studentMax[$i][0]){
$CurDateStu = $EventWorkshopKey;
$CurStuQuery =
mysql_query("SELECT Workshop_Date FROM EventCalanderMembers WHERE Workshop_Date = '$CurDateStu'") or
die(mysql_error());
$dates_avail = $studentMax[$i][1]-$Dates_used_here;
if ($dates_avail > 0){
//the processing form
$auth_net_login_id = $loginid;
$auth_net_tran_key = $txnkey;
$relay_url = "https://www.celebrity-institute.com/WorkshopCPS/response.php";
// $auth_net_url = "https://certification.authorize.net/gateway/transact.dll";
// Uncomment the line ABOVE for shopping cart test accounts or BELOW for live merchant accounts
$auth_net_url = "https://secure.authorize.net/gateway/transact.dll";
$sql1 =
mysql_query("SELECT * FROM EventsStudents WHERE User_Name='$user'");
(
"x_login" => $auth_net_login_id,
"x_version" => "3.1",
"x_email_customer" => "TRUE",
"x_merchant_email" => "info@celebrity-insititute.com",
"x_delim_char" => "|",
"x_delim_data" => "TRUE",
// "x_relay_url" => $relay_url,
"x_relay_url" => "FALSE",
"x_password" => $password,
"x_type" => "AUTH_CAPTURE",
"x_method" => "CC",
"x_tran_key" => $auth_net_tran_key,
"x_relay_response" => "FALSE",
"x_card_num" => $_POST["x_card_num"],
"x_exp_date" => $_POST["x_exp_date"],
"x_card_code" => $_POST["x_card_code"],
"x_description" => $_POST["x_description"],
"x_amount" => $_POST["x_amount"],
"x_test_request" => $_POST['x_test_request'],
"x_cust_id" => $_POST['x_cust_id'],
"x_first_name" => $foo['First_Name'],
"x_last_name" => $foo['Last_Name'],
"x_email" => $foo['email'],
"x_city" => $foo['city'],
"x_state" => $foo['state'],
"x_zip" => $foo['zip'],
// "x_Country" => $foo['country'],
"x_address" => $foo['address'],
);
$fields = "";
foreach( $authnet_values as $key => $value ) {
$fields .=
"$key=" .
urlencode( $value ) .
"&";
}
///////////////////////////////////////////////////////////
$ch = curl_init($auth_net_url); // URL of gateway for cURL to post to
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);
//echo "<b>04: Parse the results string into individual, meaningful segments:</b><br>";
echo "<table cellpadding="5
" cellspacing="0
" border="0
">";
$text = $resp;
$h++;
// for($j=1; $j <= $h; $j++){
for($j=1; $j <= 1; $j++){
if ($p === false) { // note: three equal signs
/*
echo "<tr>";
echo "<td class="e">";
// x_delim_char is obviously not found in the last go-around
if($j>=69){
echo "Merchant-defined (".$j."): ";
echo ": ";
echo "</td>";
echo "<td class="v">";
echo $text;
echo "<br>";
} else {
echo $j;
echo ": ";
echo "</td>";
echo "<td class="v">";
echo $text;
echo "<br>";
}
echo "</td>";
echo "</tr>";
*/
}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
// 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:
// echo "Response Code";
$fval="";
if($pstr_trimmed=="1"){
$fval="Your transaction was approved!";
$update =
mysql_query("UPDATE EventCalanderMembers SET Student_Status_For_Event = '3' WHERE EveID = '$ID_KEY'") or
die(mysql_error());
}elseif($pstr_trimmed=="2"){
$fval="Your transaction was declined!";
}elseif($pstr_trimmed=="3"){
$fval="Error! Please submit your information again.";
$update =
mysql_query("UPDATE EventCalanderMembers SET Student_Status_For_Event = '1' WHERE EveID = '$ID_KEY'") or
die(mysql_error());
}
break;
/*
case 2:
echo "Response Subcode: ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 3:
echo "Response Reason Code: ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 4:
echo "Response Reason Text: ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 5:
echo "Approval Code: ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 6:
echo "AVS Result Code: ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 7:
echo "Transaction ID: ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 8:
echo "Invoice Number (x_invoice_num): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 9:
echo "Description (x_description): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 10:
echo "Amount (x_amount): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 11:
echo "Method (x_method): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 12:
echo "Transaction Type (x_type): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 13:
echo "Customer ID (x_cust_id): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 14:
echo "Cardholder First Name (x_first_name): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 15:
echo "Cardholder Last Name (x_last_name): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 16:
echo "Company (x_company): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 17:
echo "Billing Address (x_address): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 18:
echo "City (x_city): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 19:
echo "State (x_state): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 20:
echo "ZIP (x_zip): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 21:
echo "Country (x_country): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 22:
echo "Phone (x_phone): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 23:
echo "Fax (x_fax): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 24:
echo "E-Mail Address (x_email): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 25:
echo "Ship to First Name (x_ship_to_first_name): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 26:
echo "Ship to Last Name (x_ship_to_last_name): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 27:
echo "Ship to Company (x_ship_to_company): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 28:
echo "Ship to Address (x_ship_to_address): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 29:
echo "Ship to City (x_ship_to_city): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 30:
echo "Ship to State (x_ship_to_state): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 31:
echo "Ship to ZIP (x_ship_to_zip): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 32:
echo "Ship to Country (x_ship_to_country): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 33:
echo "Tax Amount (x_tax): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 34:
echo "Duty Amount (x_duty): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 35:
echo "Freight Amount (x_freight): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 36:
echo "Tax Exempt Flag (x_tax_exempt): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 37:
echo "PO Number (x_po_num): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 38:
echo "MD5 Hash: ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
case 39:
echo "Card Code Response: ";
echo "</td>";
echo "<td class="v">";
$fval="";
if($pstr_trimmed=="M"){
$fval="M = Match";
}elseif($pstr_trimmed=="N"){
$fval="N = No Match";
}elseif($pstr_trimmed=="P"){
$fval="P = Not Processed";
}elseif($pstr_trimmed=="S"){
$fval="S = Should have been present";
}elseif($pstr_trimmed=="U"){
$fval="U = Issuer unable to process request";
}else{
$fval="NO VALUE RETURNED";
}
echo $fval;
echo "<br>";
break;
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 55:
case 56:
case 57:
case 58:
case 59:
case 60:
case 61:
case 62:
case 63:
case 64:
case 65:
case 66:
case 67:
case 68:
echo "Reserved (".$j."): ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
break;
default:
if($j>=69){
echo "Merchant-defined (".$j."): ";
echo ": ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
} else {
echo $j;
echo ": ";
echo "</td>";
echo "<td class="v">";
echo $pstr_trimmed;
echo "<br>";
}
break;
*/
}//end switch
// remove the part that we identified and work with the rest of the string
// $text = substr($text, $p);
}
}
}else {//else if dates avail greater then 0
echo 'Sorry the requested day has filled up<BR>';
}
}//end if
} //end for max day num