5/4/2006
ZenCart Authorize.net AIM Module Broken When Using cURL Binary
The ZenCart default Authorize.net AIM (authorizenet_aim.php) module has a problem when using the binary version of cURL.
exec() returns the executed function output as an array. To properly use this array return, we need to pop off the first array element and explode() it at the commas.
Original
//exec("/usr/bin/curl -d "$data" https://secure.authorize.net/gateway/transact.dll", $response);
$url = 'https://secure.authorize.net/gateway/transact.dll'; dv($url); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$authorize = curl_exec($ch);
curl_close ($ch);
$response = split('\,', $authorize);
Updated
exec("/usr/bin/curl -d "$data" https://secure.authorize.net/gateway/transact.dll", $response);
//add this line
$response = explode(",", urldecode($response[0]));
/* comment out PHP cURL module usage
$url = 'https://secure.authorize.net/gateway/transact.dll'; dv($url); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$authorize = curl_exec($ch);
curl_close ($ch);
$response = split('\,', $authorize);
*/
Popularity: 15%


