0

在我的自定义付款扩展中:

是否可以在结帐的最后一步显示错误消息?如果我使用 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);
    }
}
4

1 回答 1

1

你试过这样做吗?

throw new Mage_Payment_Model_Info_Exception(Mage::helper('checkout')->__('An error occured and this is the message'));

未经测试,但查看 OnePageController 和 saveOrder 函数,这种类型的异常处理方式不同,看起来它可能会将您跳回支付部分并显示错误消息。

于 2013-09-18T20:42:19.953 回答