osCommerce AuthorizeNet Module Debug Code http://www.oscommerce.co.nz/contributions/authorizenet_debug_code.txt by Geoff Ford - Attitude Group Ltd - 11 December 2003 http://www.oscommerce.co.nz/ Contact Details available on website Overview -------- Quick but useful modification to the standard AuthorizeNet SIM module to email information AuthorizeNet returns to the shop owner on an error. Please consult the AuthorizeNet SIM Implementation guide for an explanation of errors (http://www.authorizenet.com/support/guides.php). Disclaimer ---------- This code has been tested with osCommerce 2.2 MS2. BACKUP YOUR FILES BEFORE INSTALLING. Use this code at your own risk. No warranty offered. Let us know if you find any bugs. Installation Instructions ------------------------- Scroll down to the before_process method (line 250 in my version). Replace: function before_process() { global $HTTP_POST_VARS; if ($HTTP_POST_VARS['x_response_code'] == '1') return; if ($HTTP_POST_VARS['x_response_code'] == '2') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_AUTHORIZENET_TEXT_DECLINED_MESSAGE), 'SSL', true, false)); } // Code 3 is an error - but anything else is an error too (IMHO) tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_AUTHORIZENET_TEXT_ERROR_MESSAGE), 'SSL', true, false)); } with ... function before_process() { global $HTTP_POST_VARS, $HTTP_SESSION_VARS; if ($HTTP_POST_VARS['x_response_code'] == '1') return; //debug code for failed responses $authorizenet_warning_body = "Message sent at ".date("D M j G:i:s T Y")." Customer ID: ".tep_db_prepare_input($HTTP_SESSION_VARS['customer_id'])." x_response_code:" . tep_db_prepare_input($HTTP_POST_VARS['x_response_code']) . " x_response_reason_code:" . tep_db_prepare_input($HTTP_POST_VARS['x_response_reason_code']) . " x_response_reason_text:" . tep_db_prepare_input($HTTP_POST_VARS['x_response_reason_text']) . " x_avs_code:" . tep_db_prepare_input($HTTP_POST_VARS['x_avs_code']); tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, "ALERT: AuthorizeNet Error Message Returned", $authorizenet_warning_body, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); if ($HTTP_POST_VARS['x_response_code'] == '2') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_AUTHORIZENET_TEXT_DECLINED_MESSAGE), 'SSL', true, false)); } // Code 3 is an error - but anything else is an error too (IMHO) tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_AUTHORIZENET_TEXT_ERROR_MESSAGE), 'SSL', true, false)); }