Dear all,
Researched this matter quite thoroughly, been trying to setup payment gateway where our php script talks with /gateway/transact.dll.
Unless you have CURL or maybe OpenSSL installed on your server, you cannot connect with /gateway/transact.dll.
This is because fsockopen can only do HTTP and not HTTPS.
Here is the code that works for Port:80 (HTTP):-
$query1 = "x_ADC_Delim_Data=TRUE&";
$query1 .="x_ADC_URL=FALSE&";
$query1 .="x_Amount=10.00&";
$query1 .="x_Card_Num=4222222222222222&";
$query1 .="x_Exp_Date=06/01&";
$query1 .="x_Test_Request=TRUE&";
$query1 .="x_Login=$x_login&";
$query1 .="x_Password=$x_password&";
$query1 .="x_Version=3.0";
$query2 = "POST /gateway/transact.dll HTTP/1.0\r\n";
$query2 .= "Content-type: application/x-www-form-urlencoded\r\n";
$query2 .= "Content-length: " . strlen($query1) . "\r\n\r\n";
$fp = fsockopen("secure.authorize.net",80,&$errno,&$errstr);
if ($fp) {
fputs($fp,$query2.$query1);
$response = "";
while (!feof($fp))
{
$response .= fgets ($fp,6000);
}
}
$contents = explode ("Content:", $response);
$a = $contents[1];
$results = explode (",", $a);
$num_elements =count($results);
for ($i = 0; $i < $num_elements; $i++)
{
echo ("$i $results[$i] <br>\n");
}
If anyone could this to work without CURL or openSSL, I am all ears. Please email me at jason@hodfords.com
Thanks.
Jason.