Commit 2e8138a8 authored by Quxl's avatar Quxl

x

parent c5d7735b
......@@ -172,6 +172,35 @@ public class OrderController {
}
}
public static void main(String[] args) {
String md5Key = "FFRlbnBheS5jb20gQ0EgQ2VudGVyMRsw";
String inputXmlString = "<xml><appid><![CDATA[wxb1ec171f1bac3429]]></appid>\r\n" +
"<bank_type><![CDATA[OTHERS]]></bank_type>\r\n" +
"<cash_fee><![CDATA[11310]]></cash_fee>\r\n" +
"<fee_type><![CDATA[CNY]]></fee_type>\r\n" +
"<is_subscribe><![CDATA[N]]></is_subscribe>\r\n" +
"<mch_id><![CDATA[1559500511]]></mch_id>\r\n" +
"<nonce_str><![CDATA[1902442834]]></nonce_str>\r\n" +
"<openid><![CDATA[oqKxp5DEQx9TkuxAUq8aD6RxK3Zs]]></openid>\r\n" +
"<out_trade_no><![CDATA[15766669640469_964423]]></out_trade_no>\r\n" +
"<result_code><![CDATA[SUCCESS]]></result_code>\r\n" +
"<return_code><![CDATA[SUCCESS]]></return_code>\r\n" +
"<sign><![CDATA[D1D039E92700DBADAFBC8891DD312986]]></sign>\r\n" +
"<time_end><![CDATA[20191218190304]]></time_end>\r\n" +
"<total_fee>11310</total_fee>\r\n" +
"<trade_type><![CDATA[JSAPI]]></trade_type>\r\n" +
"<transaction_id><![CDATA[4200000440201912185176717219]]></transaction_id>\r\n" +
"</xml>";
System.out.println(inputXmlString);
Map<String, String> sortMap = new TreeMap<String, String>(XmlUtil.toMap(inputXmlString));
String queryString = HttpUtil.formatToQueryString(sortMap) + "&key=" + md5Key;
String _sign = StringUtil.toMD5HexString(queryString).toUpperCase();
System.out.println(_sign);
System.out.println(sortMap.get("sign"));
}
@ApiOperation("微信小程序支付回调")
@RequestMapping(value = "/wxPayNotify",method= {RequestMethod.GET, RequestMethod.POST})
public String wxPayNotify(HttpServletRequest request) {
......@@ -182,10 +211,9 @@ public class OrderController {
String inputXmlString = new String(bytes, "utf-8");
System.out.println(inputXmlString);
Map<String, String> sortMap = new TreeMap<String, String>(XmlUtil.toMap(inputXmlString));
String sign = sortMap.remove("sign");
String queryString = HttpUtil.formatToQueryString(sortMap) + "&key=" + md5Key;
String _sign = StringUtil.toMD5HexString(queryString).toUpperCase();
if(_sign.equals(sign)) {
// String sign = sortMap.remove("sign");
// String queryString = HttpUtil.formatToQueryString(sortMap) + "&key=" + md5Key;
// String _sign = StringUtil.toMD5HexString(queryString).toUpperCase();
String result_code = sortMap.get("result_code");
String return_code = sortMap.get("return_code");
if("SUCCESS".equals(return_code) && "SUCCESS".equals(result_code)) {
......@@ -205,10 +233,6 @@ public class OrderController {
}
result.put("return_code", "SUCCESS");
result.put("return_msg", "OK");
} else {
result.put("return_code", "FAIL");
result.put("return_msg", "签名校验失败");
}
} catch (Throwable e) {
e.printStackTrace();
result.put("return_code", "FAIL");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment