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?

3 Answers 3


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::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.


The answer of philwinkle is fine.

In my case additionally the md5-hash which I had set in authorize.net and Magento was too long. It caused a different hash calculation in


After I changed the md5-hash into a 10 character string it was working.

  • This also fixed the issue for me, on Magento EE 1.14
    – kmdsax
    Commented Feb 27, 2017 at 22:33
  • This resolved my issue as well with Magento CE 2.1.1 Commented Jun 16, 2017 at 21:34

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.

  • Good find - this is what I was alluding to with "You have no trans_md5 defined in the config tree".
    – philwinkle
    Commented May 31, 2013 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
    Commented May 31, 2013 at 16:29
  • How did you generate your MD5 hash? Do you have to use a specific string as the seed?
    – BeaverProj
    Commented Jun 5, 2013 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
    Commented Jun 5, 2013 at 21:55
  • Note: This is what is used to sign the requests... So the security of your transactions is only as strong as this value is hard to guess. I.e. it's a secret, but if I know it I can intercept and then generate my own post queries.
    – davidalger
    Commented Jul 1, 2013 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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