0
votes

I installed a realex extension a couple of days ago on my Magento-based website and I've been having trouble getting it to work. We have been getting an error when trying to complete orders - it would come back with the generic popup:

There was a problem processing your order

After contacting Realex themselves they told us that the could see we were trying to connect and that it wasn't a problem at their end.

I checked the website's error log and found this:

2013-05-02T08:47:50+00:00 ERR (3): 
exception 'Ampersand_Realex_Model_Exception_Hash' with message 'Hash does not match.' in /home/excellen/public_html/app/code/community/Ampersand/Realex/Model/Adapter/Remote/Abstract.php:41
Stack trace:
#0 /home/excellen/public_html/app/code/community/Ampersand/Realex/Model/Adapter/Remote/AuthCaptureAbstract.php(299): Ampersand_Realex_Model_Adapter_Remote_Abstract->_validateResponseHash()
#1 /home/excellen/public_html/app/code/core/Ampersand/PaymentGateway/Model/Service/Abstract.php(585): Ampersand_Realex_Model_Adapter_Remote_AuthCaptureAbstract->callbackForFinalAuth()
#2 /home/excellen/public_html/app/code/core/Ampersand/PaymentGateway/Model/Service/Abstract.php(249): Ampersand_PaymentGateway_Model_Service_Abstract->_processServiceMessages()
#3 /home/excellen/public_html/app/code/core/Ampersand/PaymentGateway/Model/Service/Abstract.php(220): Ampersand_PaymentGateway_Model_Service_Abstract->_authorizeAndCapture(Object(Mage_Sales_Model_Order_Payment), '40')
#4 /home/excellen/public_html/app/code/core/Ampersand/PaymentGateway/Model/Method/DirectAbstract.php(203): Ampersand_PaymentGateway_Model_Service_Abstract->capture(Object(Mage_Sales_Model_Order_Payment), '40')
#5 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Order/Payment.php(408): Ampersand_PaymentGateway_Model_Method_DirectAbstract->capture(Object(Mage_Sales_Model_Order_Payment), '40')
#6 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Order/Invoice.php(385): Mage_Sales_Model_Order_Payment->capture(Object(Mage_Sales_Model_Order_Invoice))
#7 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Order/Payment.php(569): Mage_Sales_Model_Order_Invoice->capture()
#8 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Order/Payment.php(375): Mage_Sales_Model_Order_Payment->_invoice()
#9 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Order/Payment.php(317): Mage_Sales_Model_Order_Payment->capture(NULL)
#10 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Order.php(877): Mage_Sales_Model_Order_Payment->place()
#11 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Order.php(1095): Mage_Sales_Model_Order->_placePayment()
#12 /home/excellen/public_html/app/code/core/Mage/Core/Model/Resource/Transaction.php(105): Mage_Sales_Model_Order->place()
#13 /home/excellen/public_html/app/code/core/Mage/Core/Model/Resource/Transaction.php(159): Mage_Core_Model_Resource_Transaction->_runCallbacks(Array)
#14 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Service/Quote.php(189): Mage_Core_Model_Resource_Transaction->save()
#15 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Service/Quote.php(249): Mage_Sales_Model_Service_Quote->submitOrder()
#16 /home/excellen/public_html/app/code/core/Mage/Checkout/Model/Type/Onepage.php(774): Mage_Sales_Model_Service_Quote->submitAll()
#17 /home/excellen/public_html/app/code/core/Mage/Checkout/controllers/OnepageController.php(511): Mage_Checkout_Model_Type_Onepage->saveOrder()
#18 /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_OnepageController->saveOrderAction()
#19 /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch()
#20 /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match('saveOrder')
#21 /home/excellen/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch(Object(Mage_Core_Controller_Request_Http))
#22 /home/excellen/public_html/app/Mage.php(683): Mage_Core_Model_App->run()
#23 /home/excellen/public_html/index.php(87): Mage::run(Array)
#24 {main}

And this is the section from the file that it is telling me there is a problem in:

/**
 * Validate the response hash from Realex.
 */
protected function _validateResponseHash()
{
    $hash = $this->_getHelper()->generateSha1Hash(
        $this->_getConfig()->getSharedSecret(),
        $this->getResponse()->getTimestamp(),
        $this->getResponse()->getMerchantId(),
        $this->getResponse()->getUniqueOrderId(),
        $this->getResponse()->getResult(),
        $this->getResponse()->getMessage(),
        $this->getResponse()->getPasref(),
        $this->getResponse()->getAuthCode()
    );

    if ($hash != $this->getResponse()->getSha1Hash()) {
        throw new Ampersand_Realex_Model_Exception_Hash(
            $this->_getHelper()->__('Hash does not match.')
        );
    }

    return $this;
}

At this point though I've really reached the limit of my knowledge! I can understand that the two hashes aren't matching but what would be causing this and how could I go about fixing it?

I'm going to try and recreate the problem on a vanilla version of Magento, but if anyone can spot what is causing the problem or has had a similar problem then I'd really appreciate any help!


UPDATE:

I tried installing two further extensions that would handle credit card payments - the first was an alternative REALEX extension (developed by SF9) and the second was a SAGEPAY extension - both have returned errors. The following is the error log from the SagePay plugin:

    2013-05-02T10:15:57+00:00 ERR (3): 
exception 'Mage_Core_Exception' with message 'Payment has failed, please reload checkout page and try again. Your card has not been charged.' in /home/excellen/public_html/app/Mage.php:594
Stack trace:
#0 /home/excellen/public_html/app/code/local/Ebizmarts/SagePaySuite/Model/Observer/Sales.php(127): Mage::throwException('Payment has fai...')
#1 /home/excellen/public_html/app/code/core/Mage/Core/Model/App.php(1338): Ebizmarts_SagePaySuite_Model_Observer_Sales->saveAfter(Object(Varien_Event_Observer))
#2 /home/excellen/public_html/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Ebizmarts_SagePaySuite_Model_Observer_Sales), 'saveAfter', Object(Varien_Event_Observer))
#3 /home/excellen/public_html/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent('sales_order_sav...', Array)
#4 /home/excellen/public_html/app/code/core/Mage/Core/Model/Abstract.php(466): Mage::dispatchEvent('sales_order_sav...', Array)
#5 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Abstract.php(53): Mage_Core_Model_Abstract->_afterSave()
#6 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Order.php(2155): Mage_Sales_Model_Abstract->_afterSave()
#7 /home/excellen/public_html/app/code/core/Mage/Core/Model/Abstract.php(319): Mage_Sales_Model_Order->_afterSave()
#8 /home/excellen/public_html/app/code/core/Mage/Core/Model/Resource/Transaction.php(151): Mage_Core_Model_Abstract->save()
#9 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Service/Quote.php(189): Mage_Core_Model_Resource_Transaction->save()
#10 /home/excellen/public_html/app/code/core/Mage/Sales/Model/Service/Quote.php(249): Mage_Sales_Model_Service_Quote->submitOrder()
#11 /home/excellen/public_html/app/code/core/Mage/Checkout/Model/Type/Onepage.php(774): Mage_Sales_Model_Service_Quote->submitAll()
#12 /home/excellen/public_html/app/code/core/Mage/Checkout/controllers/OnepageController.php(511): Mage_Checkout_Model_Type_Onepage->saveOrder()
#13 /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_OnepageController->saveOrderAction()
#14 /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('saveOrder')
#15 /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#16 /home/excellen/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#17 /home/excellen/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#18 /home/excellen/public_html/index.php(87): Mage::run('', 'store')
#19 {main}
2013-05-02T10:15:58+00:00 ERR (3): 
exception 'Zend_Mail_Transport_Exception' with message 'Unable to send mail. mail() has been disabled for security reasons' in /home/excellen/public_html/lib/Zend/Mail/Transport/Sendmail.php:137
Stack trace:
#0 /home/excellen/public_html/lib/Zend/Mail/Transport/Abstract.php(348): Zend_Mail_Transport_Sendmail->_sendMail()
#1 /home/excellen/public_html/lib/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#2 /home/excellen/public_html/app/code/core/Mage/Core/Model/Email/Template.php(454): Zend_Mail->send()
#3 /home/excellen/public_html/app/code/core/Mage/Core/Model/Email/Template.php(506): Mage_Core_Model_Email_Template->send('david@excellent...', 'Excellent Sciss...', Array)
#4 /home/excellen/public_html/app/code/core/Mage/Checkout/Helper/Data.php(221): Mage_Core_Model_Email_Template->sendTransactional('checkout_paymen...', 'general', 'david@excellent...', 'Excellent Sciss...', Array)
#5 /home/excellen/public_html/app/code/core/Mage/Checkout/controllers/OnepageController.php(528): Mage_Checkout_Helper_Data->sendPaymentFailedEmail(Object(Mage_Sales_Model_Quote), 'Payment has fai...')
#6 /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_OnepageController->saveOrderAction()
#7 /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('saveOrder')
#8 /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#9 /home/excellen/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#10 /home/excellen/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#11 /home/excellen/public_html/index.php(87): Mage::run('', 'store')
#12 {main}

It was running in test mode so it was not an issue related to the details that I have entered in the admin section - something seems to be wrong with the credit card payment methods (as I can successfully complete orders by choosing PayPal or other methods)

Really stuck on this one, hope someone can help! :(


UPDATE: The system.log output:

2013-05-03T08:44:20+00:00 ERR (3): Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'Mage/Realex/Model/Remote.php' for inclusion (include_path='/home/excellen/public_html/app/code/local:/home/excellen/public_html/app/code/community:/home/excellen/public_html/app/code/core:/home/excellen/public_html/lib:.:/usr/lib/php:/usr/local/lib/php')  in /home/excellen/public_html/lib/Varien/Autoload.php on line 93
2013-05-03T08:45:10+00:00 ERR (3): Warning: include(Mage/Realex/Model/Remote.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory  in /home/excellen/public_html/lib/Varien/Autoload.php on line 93
2013-05-03T08:45:10+00:00 ERR (3): Warning: include(Mage/Realex/Model/Remote.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory  in /home/excellen/public_html/lib/Varien/Autoload.php on line 93
2013-05-03T08:45:10+00:00 ERR (3): Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'Mage/Realex/Model/Remote.php' for inclusion (include_path='/home/excellen/public_html/app/code/local:/home/excellen/public_html/app/code/community:/home/excellen/public_html/app/code/core:/home/excellen/public_html/lib:.:/usr/lib/php:/usr/local/lib/php')  in /home/excellen/public_html/lib/Varien/Autoload.php on line 93
2013-05-03T08:45:19+00:00 DEBUG (7): HEADERS ALREADY SENT: <pre>[0] /home/excellen/public_html/app/code/core/Mage/Core/Controller/Response/Http.php:52
[1] /home/excellen/public_html/lib/Zend/Controller/Response/Abstract.php:766
[2] /home/excellen/public_html/app/code/core/Mage/Core/Controller/Response/Http.php:83
[3] /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php:188
[4] /home/excellen/public_html/app/code/core/Mage/Core/Model/App.php:354
[5] /home/excellen/public_html/app/Mage.php:683
[6] /home/excellen/public_html/index.php:87
</pre>
2013-05-03T08:45:38+00:00 DEBUG (7): HEADERS ALREADY SENT: <pre>[0] /home/excellen/public_html/app/code/core/Mage/Core/Controller/Response/Http.php:52
[1] /home/excellen/public_html/lib/Zend/Controller/Response/Abstract.php:766
[2] /home/excellen/public_html/app/code/core/Mage/Core/Controller/Response/Http.php:83
[3] /home/excellen/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php:188
[4] /home/excellen/public_html/app/code/core/Mage/Core/Model/App.php:354
[5] /home/excellen/public_html/app/Mage.php:683
[6] /home/excellen/public_html/index.php:87
</pre>
1

1 Answers

0
votes

Are you able to edit that code to get some logging? If so, can you print out the data and post the results here?

Add the following lines just before the if () statement in the code. I'm not sure if there's a convenient logging helper you can use, so I'm just printing them to STDOUT...

print "Data to hash: " . $this->getResponse()->getTimestamp() . "." .
  $this->getResponse()->getMerchantId() . "." .
  $this->getResponse()->getUniqueOrderId() . "." .
  $this->getResponse()->getResult() . "." .
  $this->getResponse()->getMessage() . "." .
  $this->getResponse()->getPasref() . "." .
  $this->getResponse()->getAuthCode() . "\n";

print "Local hash: " . $hash . "\n";
print "Hash from XML: " . $this->getResponse()->getSha1Hash() . "\n";

(Don't print out your shared secret and definitely don't post it here!)

Owen