Magento - There was an error processing your order. Please contact us or try again later错误处理办法


RP 1.4.1.1使用在Magento1.4.0.1 在checkout/onepage/页面走到最后一步点ORDER PLACE报错:There was an error processing your order. Please contact us or try again later

经过代码跟踪,发现在app/code/core/Mage/Checkout/controllers/OnepageController.php这个位置saveOrderAction方法里的$this->getOnepage()->saveOrder();这个调用里出错了

继续跟中,可以把错误异常锁定在app/code/core/Mage/Checkout/Model/Type\Onepage.php里的saveOrder这个方法里。

把异常报告打开发现原来是在saveOrder这个方法里执行RP包的Payment.php这个文件中出错了,

if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]) {$ip = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]; } 
elseif ($HTTP_SERVER_VARS["HTTP_CLIENT_IP"]){ $ip = $HTTP_SERVER_VARS["HTTP_CLIENT_IP"]; }
elseif ($HTTP_SERVER_VARS["REMOTE_ADDR"]) {$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"]; } 
elseif (getenv("HTTP_X_FORWARDED_FOR")){ $ip = getenv("HTTP_X_FORWARDED_FOR"); 	} 
elseif (getenv("HTTP_CLIENT_IP")) { $ip = getenv("HTTP_CLIENT_IP");	} 
elseif (getenv("REMOTE_ADDR")){$ip = getenv("REMOTE_ADDR"); 	}

这段获取内容获取IP,在本地的测试环境出现Notice级别的错误:Notice: Undefined variable:HTTP_SERVER_VARS

最后将整段换成自己代码库的方法:

if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
   $ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
   $ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
   $ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] 
        && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
   $ip = $_SERVER['REMOTE_ADDR'];
else
   $ip = "unknown";

重新测试一遍,使用RP接口正常走完订单流程,没再报There was an error processing your order. Please contact us or try again later

标签: Error, magento, 环境, RP