<?php

$txtAuthorizeLoginId=urlencode('5rWJhq38ShG');
$txtAuthorizePassword='Cooters1';
$txtAuthorizeTransKey=urlencode('5JqprS48438GQKJL');
$chkAuthorizeMode='YES';

$x_customdata="Custom";
$x_Login= urlencode($txtAuthorizeLoginId); // Replace LOGIN with your login
$x_Password= urlencode($txtAuthorizePassword); // Replace PASS with your password
$x_tran_key = urlencode($txtAuthorizeTransKey); // Tran Key
$x_Delim_Data= urlencode("TRUE");
$x_Delim_Char= urlencode(",");
$x_Encap_Char= urlencode("");
$x_Type= urlencode("AUTH_CAPTURE");

$x_ADC_Relay_Response = urlencode("FALSE");

if($chkAuthorizeMode != "NO"){
        $x_Test_Request= urlencode("TRUE");
}
#
# Customer Information
#


$x_Method= urlencode("CC");
$x_Amount= urlencode('110');
$x_First_Name= urlencode('test');
$x_Last_Name= urlencode('test');
$x_Card_Num= urlencode('4005550000000019');
$ExpDate = ('12' . '2009');
$x_Exp_Date= urlencode($ExpDate);
$x_card_code =urlencode('123');

$x_Address= urlencode('test');
$x_City= urlencode('test');
$x_State= urlencode('test');
$x_Zip= urlencode('333');
$x_country=urlencode('test');

$x_saleid = urlencode($saleid);
$x_userid = urlencode($userid);
$x_dDate = urlencode(date('Y-m-d'));

$x_Email= urlencode('simi@armia.com');
$x_Email_Customer= urlencode("TRUE");
$x_Merchant_Email= urlencode('chris@gigamediagroup.com');
$x_description = urlencode("::Product Purchase" );

$x_cust_ip='192.168.0.12';
$x_invid="15";
$x_company='dollar rate';
$x_phone=urlencode('ss');
$x_cust_id=$Cust_id;
$x_invoice_num=$var_inv_no;
$x_invno=$var_inv_no;

#
# Build fields string to post
#
$fields = "x_Version=3.1&x_Login=$x_Login&x_tran_key=$x_tran_key&x_Delim_Data=$x_Delim_Data&x_Delim_Char=$x_Delim_Char&x_Encap_Char=$x_Encap_Char";
$fields .= "&x_Type=$x_Type&x_Test_Request=$x_Test_Request&x_Method=$x_Method&x_Amount=$x_Amount&x_First_Name=$x_First_Name";
$fields .= "&x_Last_Name=$x_Last_Name&x_Card_Num=$x_Card_Num&x_Exp_Date=$x_Exp_Date&x_card_code=$x_card_code&x_Address=$x_Address&x_City=$x_City&x_State=$x_State&x_Zip=$x_Zip&x_country=$x_country&x_Email=$x_Email&x_Email_Customer=$x_Email_Customer&x_Merchant_Email=$x_Merchant_Email&x_ADC_Relay_Response=$x_ADC_Relay_Response&x_invid=$x_invid&x_cust_ip=$x_cust_ip&x_company=$x_company&x_phone=$x_phone&x_cust_id=$x_cust_id&x_invoice_num=$x_invno&x_description=$x_description";
if ($x_Password != '') {
        $fields .= "&x_Password=$x_Password";
}

#
# Start CURL session
#
//$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
$ref ="https://192.168.0.11/Cybermatch/buy_now.php"; // Replace this URL with the URL of this script
//$authurl="https://test.authorize.net/gateway/transact.dll";
$authurl="https://secure.authorize.net/gateway/transact.dll";
$ch=curl_init("https://secure.authorize.net/gateway/transact.dll");
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_VERBOSE, 1);
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");


$buffer = curl_exec($ch);
//echo "bufferrrr=".$buffer;
curl_close($ch);


$return = preg_split("/[,]+/", "$buffer");
$details = $return[0];


switch ($details)
{
    case "1":
                 $cc_flag=true;
				 echo 'case 1';
           echo  $cc_tran=$return[6];

              break;

        case "2":
                        $cc_flag = false;
                        $cc_err="The card has been declined";
                          echo $cc_err .="<br>" . $return[3];
                break;
        case "4":
                        $cc_flag = false;
                        $cc_err="The card has been held for review";
                                                echo  $cc_err .="<br>" . $return[3];
                break;
    default:
                     $cc_flag = false;
                        $cc_err="Error Got ";
                         echo  $cc_err .="<br>" . $return[3];
        break;
}

?>