By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,520 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

interfacing to Authorize.net using AIM method and cURL

P: n/a
I have a small PHP ecommerce site set up using Authorize.net's SIM (simple)
interface. Working fine, but... I'd like to implement their AIM interface
(so visitor's will never see the gateway's URL).

I found a script that does this but requires cURL... and my hosting provider
doesn't support it.

Here is the snippet of the code that uses cURL functions ($data values are
set before this from the purchase form):
$curl_handle = curl_init ();
curl_setopt ($curl_handle, CURLOPT_URL,
"https://secure.authorize.net/gateway/transact.dll");
curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data);
$response = curl_exec ($curl_handle) or die ("There has been an error
connecting to Authorize.net.");
curl_close ($curl_handle);
It appears that data is being posted to the gateway and information returned
(credit card accepted/declined) and then processed without actual web pages
being displayed.

What is cURL actually doing and can it be done some other way?

Is there any way I can accomplish the same thing without curl libraries...
maybe write my own lower level code? I can certainly post data to the
gateway... and, if I knew how to accept the returned data, can perform the
necessary steps from there. My big blank spot seems to be how to receive
that data response.

Thanks.

Rick
Jul 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: 1
Check out this function

# $host includes host and path and filename
# ex: "myserver.com/this/is/path/to/file.php"
# $query is the POST query data
# ex: "a=thisstring&number=46&string=thatstring
# $others is any extra headers you want to send
# ex: "Accept-Encoding: compress, gzip\r\n"
function post($host,$query,$others=''){
$path=explode('/',$host);
$host=$path[0];
unset($path[0]);
$path='/'.(implode('/',$path));
$post="POST $path HTTP/1.1\r\nHost: $host\r\nContent-type: application/x-www-form-urlencoded\r\n${others}User-Agent: Mozilla 4.0\r\nContent-length: ".strlen($query)."\r\nConnection: close\r\n\r\n$query";
$h=fsockopen($host,80);
fwrite($h,$post);
for($a=0,$r='';!$a;){
$b=fread($h,8192);
$r.=$b;
$a=(($b=='')?1:0);
}
fclose($h);
return $r;
}

Posted on http://uk.php.net/fsockopen

I'm sure this will help you out.
Aug 30 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.