/**
* 支付通知相应处理
* @param request
* @param response
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
@ResponseBody
@RequestMapping(value = "/paynotify", method = RequestMethod.POST)
public String paynotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
String resXml = "fail";
response.setCharacterEncoding("UTF-8");
response.setContentType("text/xml");
ServletInputStream in = request.getInputStream();
String xmlMsg = Tools.inputStream2String(in);
logger.info(xmlMsg);
if (!TextUtils.isEmpty(xmlMsg)) {
Map<String, String> map = WXPayUtil.xmlToMap(xmlMsg);
String return_code = map.get("return_code");
String return_msg = map.get("return_msg");
if (return_code.equals("SUCCESS") && TextUtils.isEmpty(return_msg)) {
return_msg = "OK";
}
map = new HashMap<String, String>();
map.put("return_code", return_code);
map.put("return_msg", return_msg);
// 响应xml
resXml = WXPayUtil.mapToXml(map);
logger.info("resXml:" + resXml);
}
return resXml;
}
微信支付通知方法-附上部分代码
最新推荐文章于 2024-08-17 11:27:47 发布