//print_r($_POST["id"]); session_start(); include("db.php"); include("function.php"); include('authorizenet.inc.php'); if($_SESSION["userid"]==""){ $dt1=date("His"); $dt2=gen_key(10); $userid=substr(str_replace(".","","$dt1$REMOTE_ADDR$dt2"),0,20); $_SESSION["userid"]=$userid; } if($_POST["act"]=="checkout"){ $idvar=$_POST["id"]; $item_nos=implode(",",$idvar); while (list($key, $pid) = each($_POST["id"])){ $temparray[count($temparray)]=getarticlename($pid); } //print_r($temparray); $item_name1=implode(",",$temparray); $totoamt=$_POST["ototal"]; } if($_POST["act"]=="order"){ //----------------------- Add query for order table --------------------------------------------- $flag=$_POST["cardtype"]; $id_nos=$_POST["idvar"]; $qry="Insert into orders values (null, '".$id_nos."', now(), '', '".$_POST["item_name1"]."', 'no', 'cc', 'in progress', 'no', '".addslashes($_POST["totoamt"])."', '', '', '".addslashes($_POST["x_First_Name"])."', '".addslashes($_POST["x_Last_Name"])."', '".addslashes($_POST["x_Address"])."', '".addslashes($_POST["x_City"])."', '".addslashes($_POST["x_State"])."', '".addslashes($_POST["x_Zip"])."', '".addslashes($_POST["x_Phone"])."', '".addslashes($_POST["x_Country"])."', '".addslashes($_POST["x_Email"])."', '".$flag."', '".addslashes($_POST["x_Card_Num"])."', '".addslashes($_POST["x_Exp_Date"])."', '".addslashes($_POST["x_Card_Code"])."', '', '', '', '', '".$_SERVER['REMOTE_ADDR']."')"; mysql_query($qry); echo mysql_error(); $orderid=mysql_insert_id(); $_SESSION["orderid"]=$orderid; $ordervar="G1-".$orderid; $qryalter="UPDATE orders set order_id='".$ordervar."' where id='".$orderid."'"; mysql_query($qryalter); echo mysql_error(); $payment_data['x_amount']=number_format($_POST['totoamt'],2); $payment_data['x_invoice_num']=$orderid; $payment_data['x_Description']="test"; $payment_data['x_card_num']=$_POST["x_Card_Num"]; $payment_data['x_exp_date']=$_POST["x_Exp_Date"]; $payment_data['x_card_code']=$_POST["x_Card_Code"]; $payment_data["x_cust_id"]="1"; $payment_data["x_first_name"]=$_POST["x_First_Name"]; $payment_data["x_last_name"]=$_POST["x_Last_Name"]; $payment_data["x_address"]=$_POST["x_Address"]; $payment_data["x_city"]=$_POST["x_City"]; $payment_data["x_state"]=$_POST["x_State"]; $payment_data["x_zip"]=$_POST["x_Zip"]; $payment_data["x_country"]=$_POST["x_Country"]; $payment_data["x_phone"]=$_POST["x_Phone"]; $payment_data["x_email"]=$_POST["x_Email"]; //-------------- $payment_gateway = new authorizenet(); $pay = $payment_gateway->pay($payment_data); $this->response_text=$pay['x_response_reason_text']; if($pay["x_response_code"]==1) { //echo "sucess";//return true; mysql_query("UPDATE orders SET payment = 'Yes' WHERE id='".$pay['x_invoice_num']."'") ; //print_r($pay); //include("contact_email.php"); header("location:thankyoucc.php"); } else { //echo "fail"; //mysql_query("UPDATE orders SET payment = 'in progress' WHERE id='".$pay['x_invoice_num']."'"); $errmessage=$pay["x_response_reason_text"]; //return false; } } //-------------------------------- End of query ------------------------------------------- ?>