Here's an example of the code. I should post this somewhere. I keep getting requests for it, though it's a modified version of what I got elsewhere.
Remember you need to install cURL first. That's fairly OS dependant (even the *nix flavors are sometimes different). Do some web searches to gather, or post at phpbuilder, I don't remember where I got my instructions for the cURL install.)
// Begin CC processing
// initial variables to define or pass from your shopping cart
$curl = "pathtocURL";
$my_authnet_userid = "xxxxxx";
$total = "$grandtotal";
$cc_number = "$Card_Number";
$cc_exp = "$Exp_Date";
$invoiceno = "$id";
$billing_address = "$Billing_Address";
$billing_zip = "$Billing_Zip";
exec("curl -d 'x_Login=$my_authnet_userid&x_Amount=$total&x_Card_Num=$cc_number&x_Exp_Date=$cc_exp&x_ADC_URL=FALSE&x_ADC_Delim_Data=TRUE&x_Invoice_Num=$invoiceno&x_Version=3.0&x_Address=$billing_address&x_Zip=$billing_zip' https://secure.authorize.net/gateway/transact.dll", $authorize, $ret);
$auth_return = split("|", $authorize[0]);
// for debugging you can print the variables returned:
// comment out lines after testing.
// for ($idx = 0; $idx < 39; ++$idx) {
// $pos = $idx+1;
// echo "Code".$pos.": ".$auth_return[$idx]."<BR>";
// }
if($auth_return[0] == 1){
// this section passes these three variables to your processing form
// for order tracking purposes
$auth_code = $auth_return[4];
$avs_code = $auth_return[5];
$trans_id = $auth_return[6];
} elseif($auth_return[0] == 2){
echo "<b>Your order cannot be processed at this time, as your credit card was not accepted.</b><br>";
} elseif($auth_return[0] == 3){
echo "<b>Your credit card can not be processed at this time.</b><br><br>";
echo "The reason for this error: $auth_return[3]<br><br>\n";
echo "Please click back on your browser and verify your information.<br>\n";
}
else {
echo "Auth_Return is not 1, 2 or 3\n";
}
// End CC Processing
There's a whole lot of code for database interaction, product calculations, and other stuff, but this is the part that handles the authorize.net transaction.