Tell me more ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

I have Authorize.net Direct Post enabled on Magento 1.13 with the following settings:

Payment Action: Authorize Only Test Mode: No Gateway URL: https://test.authorize.net/gateway/transact.dll

During checkout, after entering test credit card information and clicking "Place Order"

I get a pop up alert saying:

"Response hash validation failed. Transaction declined."

What is causing this and how do I fix it?

share|improve this question

2 Answers

As defined in app/code/core/Mage/Authorizenet/Model/Directpost.php, this exception is thrown if any portion of the below evaluates as false:

if (!$this->getConfigData('trans_md5') || !$this->getConfigData('login') ||
    !$response->isValidHash($this->getConfigData('trans_md5'), $this->getConfigData('login'))
) {
    Mage::throwException(
        Mage::helper('authorizenet')->__('Response hash validation failed. Transaction declined.')
    );
}

So, it's one of three things:

  • You have no trans_md5 defined in the config tree payment/authorizenet_directpost/trans_md5

  • There is no login defined in payment/authorizenet_directpost/login

  • The method isValidHash is returning false

The method isValidHash returns false because there is an issue with either the generated hash (e.g. your API Login/Key are wrong, generate a new one and re-enter) or the amount of the transaction somehow differs between Authorize and your system.

The latter is less likely, but because generateHash in Mage_Authorizenet_Model_Directpost_Response uses the transaction amount as part of the hash, it's a potential factor here.

share|improve this answer

The problem was that payment/authorizenet_directpost/trans_md5 configuration was NULL.

To fix this set an MD5-Hash in the Authorize.net merchant admin under Settings > Security Settings > General Security Settings > MD5-Hash.

Then enter that same value in the Magento Admin under System > Configuration > Payment Methods > Authorize.net Direct Post > Merchant MD5.

share|improve this answer
Good find - this is what I was alluding to with "You have no trans_md5 defined in the config tree". – philwinkle May 31 at 15:27
1  
Thanks. Your answer led me to the the solution, but it took me a minute to figure out exactly where and how to set the MD5 in auth.net and magento, so I wanted to try to make it a little clearer for anyone else having this problem. – Howie Ross May 31 at 16:29
How did you generate your MD5 hash? Do you have to use a specific string as the seed? – BeaverProj Jun 5 at 18:08
@BeaverProj you don't need to generate the MD5. auth.net and magento will generate it for you from the the sting you enter. Just make sure that what you enter int auth.net and magento matches. – Howie Ross Jun 5 at 21:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.