In my experience this is a classic error that happens when first setting up an Authorize.net account for use with the Authorize.net AIM Module. The problem occurs because of what is really a two-fold cause.
Incorrect Authorize.net Direct Response configuration
and/or
Incomplete Authorize.net (AIM) payment module
You either need to login to Authorize.net and make some changes to your Direct Response settings, or you need to modify your Authorize.net (AIM) payment module code. I have found that the best is to modify the payment module, as it is technically missing some lines of code that it should have when processing Authorize.net transactions.
in /includes/modules/payment/authorizenet_aim.php around line 320:
you'll find:
Code:
'x_relay_response' => 'FALSE', // AIM uses direct response, not relay response
'x_delim_data' => 'TRUE', // The default delimiter is a comma
'x_version' => '3.1', // 3.1 is required to use CVV codes
change it to:
Code:
'x_relay_response' => 'FALSE', // AIM uses direct response, not relay response
'x_delim_data' => 'TRUE', // The default delimiter is a comma
'x_delim_char' => ',', // Force the delimiter to a comma
'x_encap_char' => '', // Force the encapsulation character to nothing
'x_version' => '3.1', // 3.1 is required to use CVV codes
If you're only using Authorize.net with your ZenCart shop, I would also recommend you login to your Authorize.Net interface and do the following:
- Login
- Click on Account (top border)
- Click on Settings (Left Border)
- Click on "Direct Response" in the Transaction Format Settings group
- Change Delimited Response to Yes
- Change Default Field Separator to ",(comma)"
- Change Field Encapsulation Character to blank/nothing (first in list)
- Press the "Submit" button to save changes
- You're all done!
This has to be by far the most common error my clients end up having when trying to switch to AIM on their own.
For the PHP-wise people, the error is happening because the default response that a new Authorize.Net account is returning is Quote Encapsulated, Comma Delimited
Code:
"1","1","1","This transaction has been approved.",...blahblahblah
but the Authorize.net AIM payment module is splitting it like so on line 411:
Code:
$response = split('\,', $authorize);
So on line 413 when we get the response code:
Code:
$response_code = explode(',', $response[0]);
$response_code doesn't contain just the number one, but rather 1 surrounded by the double quote encapsulation characters like so "1". So when we check for an approval on line ~427:
Code:
// DEBUG LOGGING
if ($x_response_code != '1' ||
We naturally get what looks like a decline, because "1" isn't equal to 1.
For the ZC crew, It seems like it would be best to incorporate the x_delim_char and x_encaps_char as a core change, since we don't want to rely on the default setup that Authorize.net implements.
For anyone having problems that the above info doesn't fix, well, post the debug information (obviously, with all sensitive data removed) and maybe we can figure out what's up.
HTH