Hi Chris, I faced the same problem (although I could not see the order in the Admin screen - only in the db using phpMyAdmin).
I made the following changes to the function before_process() in the file authorizenet.php which is under catalog/includes/modules/payment. I have put comments preceded by XXX:
---------------------------------------------------
function before_process() {
global $response;
// Change made by using ADC Direct Connection
$response_vars = explode(',', $response[0]);
$x_response_code = $response_vars[0];
$x_response_subcode = $response_vars[1];
$x_response_reason_code = $response_vars[2];
$x_response_reason_text = $response_vars[3];
// XXX added variable to hold order id
$x_response_order_id = $response_vars[7]; // order id is stored as the invoice number
if ($x_response_code != '1') {
// XXX insert_id is not defined at this point - so it doesnot delete
//tep_db_query("delete from " . TABLE_ORDERS . " where orders_id = '" . (int)$insert_id . "'"); //Remove order
// XXX I get the order id from the response from Authorize.net. Now it deletes the order if transaction fails
tep_db_query("delete from " . TABLE_ORDERS . " where orders_id = '" . (int)$x_response_order_id . "'");
if($x_response_code == '') {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode('The server cannot connect to Authorize.net. Please check your cURL and server settings.'), 'SSL', true, false));
}
else if($x_response_code == '2') {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode('Your credit card was declined ') . urlencode('(') . urlencode("$x_response_reason_code") . urlencode('): ') . urlencode("$x_response_reason_text"), 'SSL', true, false));
}
else if($x_response_code == '3') {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode('There was an error processing your credit card ') . urlencode('(') . urlencode("$x_response_reason_code") . urlencode('): ') . urlencode("$x_response_reason_text"), 'SSL', true, false));
}
else {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode('There was an unspecified error processing your credit card.'), 'SSL', true, false));
}
}
}
---------------------------------------------------
Hope this helps.
regards,
sandip