session_start(); $x_card_num = $_SESSION['x_card_num']; include 'db167.php'; include 'widget.php'; $cartno = $_COOKIE['cartno']; function hmac ($key, $data) { // RFC 2104 HMAC implementation for php. // Creates an md5 HMAC. // Eliminates the need to install mhash to compute a HMAC // Hacked by Lance Rushing $b = 64; // byte length for md5 if (strlen($key) > $b) { $key = pack("H*",md5($key)); } $key = str_pad($key, $b, chr(0x00)); $ipad = str_pad('', $b, chr(0x36)); $opad = str_pad('', $b, chr(0x5c)); $k_ipad = $key ^ $ipad ; $k_opad = $key ^ $opad; return md5($k_opad . pack("H*",md5($k_ipad . $data))); } //get payment information //set up to talk to authnet $x_login = "6cP3rJ2j"; $x_version = "3.1"; $currency = ""; $tstamp = time(); //go get transact key $query = "SELECT * FROM pp_content WHERE page = 'txn' LIMIT 1"; $all = mysql_query($query) or die ('no query '.mysql_error()); $row = mysql_fetch_row($all); $txnkey = $row[1]; //get sequence $query = "SELECT * FROM pp_content WHERE page = 'sequence' LIMIT 1"; $all = mysql_query($query) or die ('no query '.mysql_error()); $row = mysql_fetch_row($all); $sequence = $row[1]; //add 1 to sequence $query = "UPDATE pp_content SET data = data + 1 WHERE page = 'sequence' LIMIT 1"; mysql_query($query) or die ('no sequence update '.mysql_error()); /////////////////////added because of the double charging thing? What's going on??? if($ship_info){ $pieces = explode("|",$ship_info); $ship_type = $pieces[0]; $ship_cost = $pieces[1]; $before = $x_amount; $x_amount += $ship_cost; } $fs = strpos($name," "); $fname = substr($txt,0,$fs); $lname = substr($txt,$fs); $data['x_amount'] = $x_amount; $data['x_login'] = $x_login; //$data['x_trans_key'] = $txnkey; $data['x_version'] = $x_version; $data['x_test_request'] = "FALSE"; $data['x_first_name'] = $fname; $data['x_last_name'] = $lname; $data['x_address'] = $bill_address; $data['x_city'] = $bill_city; $data['x_zip'] = $bill_zip; $data['x_country'] = $bill_country; $data['x_phone'] = $phone1; $data['x_email'] = $email; $data['x_email_customer'] = "FALSE"; $data['x_merchant_email'] = "freddy@freddythunder.com"; $data['x_invoice_num'] = $sequence; $data['x_description'] = "Horizon Motorsports LLC. - PitBike PitStop"; $data['x_method'] = "CC"; $data['x_type'] = "AUTH_CAPTURE"; $data['x_card_num'] = preg_replace("/[^0-9]/","",$x_card_num); $cc_exp = $month."/".$year; $data['x_exp_date'] = $cc_exp; $data['x_card_code'] = $x_ccv; ////insertFP $data['x_fp_sequence'] = $sequence; $tstamp = time(); $loginid = $x_login; $currency = ""; $data['x_fp_timestamp'] = $tstamp; $data['x_fp_hash'] = hmac($txnkey,$loginid."^".$sequence."^".$tstamp."^".$x_amount."^".$currency); $senddata = ""; reset($data); while(list($key,$val) = each($data)){ $senddata .= $key."=".urlencode($val)."&"; } //strips last & $senddata = preg_replace("/&$/","",$senddata); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://secure.authorize.net/gateway/transact.dll"); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt($ch, CURLOPT_PROXY, "proxy.shr.secureserver.net:3128"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $senddata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); //curl_setopt($ch, CURLOPT_TIMEOUT, 120); $response = curl_exec($ch) or die ("there is no curl!! error: ".curl_error($ch)." ".curl_errno($ch)); curl_close($ch); $response = explode(",",$response); ?>