Reputation: 492
At my custom payment extension:
Is it possible to display an error message at the last step of the checkout? If I use addError Method the message is displayed the next page, where the user can not change address data for example...
In all validate functions Mage::throwException messages are displayed with Javascript to the user, but not at the authorize function. There Mage::throwException only blocks the next page to be loaded, but no message is displayed. Bad for the user!
public function authorize(Varien_Object $payment, $amount)
{
$error = $this->api_call($payment, $amount);
//no error, proceed to success page
if(strlen($error) == 0)
{
return $this;
}
//error
else
{
//this adds an error message
//which is displayed the next page
$session = Mage::getSingleton("checkout/session");
$session->addError($return);
session_write_close();
//throw exception, which is not displayed anywhere
//if i don't do this, i get success page with addError message,
//but user has to do checkout again
Mage::throwException($return);
}
}
Upvotes: 0
Views: 3362
Reputation: 2125
Have you tried doing this;
throw new Mage_Payment_Model_Info_Exception(Mage::helper('checkout')->__('An error occured and this is the message'));
Not tested but looking at OnePageController and saveOrder function this type of exception is handled differently and it looks as though it may jump you back to the payment section and display the error message.
Upvotes: 1