微信支付---解析微信返回值

public void wechat_notify(HttpServletRequest request,HttpServletResponse response)  throws Exception{
// 读取参数
InputStream inputStream;
StringBuffer sb = new StringBuffer();
inputStream = request.getInputStream();
String s;
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
while ((s = in.readLine()) != null) {
sb.append(s);
}
in.close();
inputStream.close();


// 解析xml成map
Map m = new HashMap();
m = XMLUtil.doXMLParse(sb.toString());


// 过滤空 设置 TreeMap
SortedMap packageParams = new TreeMap();
Iterator it = m.keySet().iterator();
while (it.hasNext()) {
String parameter = (String) it.next();
String parameterValue = m.get(parameter);


String v = "";
if (null != parameterValue) {
v = parameterValue.trim();
}
packageParams.put(parameter, v);
}


// 账号信息
String key = PropertiesHandler.getConfigValue("API_KEY").toString(); // key


logger.info(packageParams);


//判读返回码 return_code是否:“success”

是则成功 否则失败

注意:

微信返回默认返回7次

你可能感兴趣的:(微信支付---解析微信返回值)