在我的自定义付款扩展中:
是否可以在结帐的最后一步显示错误消息?如果我使用 addError 方法,则会在下一页显示消息,例如用户无法更改地址数据...
在所有验证函数中,Mage::throwException 消息都使用 Javascript 显示给用户,但不在授权函数中。那里 Mage::throwException 只阻止要加载的下一页,但不显示任何消息。对用户不利!
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);
}
}