yca 2014-03-18
支付宝提供的网页支付接口,notify_url调用时签名要使用非排序方式,原demo有bug,致使多次调用计算签名都失败,最终找出了问题,AlipayCore类中createLinkStringNoSort()方法不能使用HashMap,代之以LinkedHashMap,以此做记录。
public static String createLinkStringNoSort(Map<String, String> params) { Map<String, String> sParaSort = new LinkedHashMap<String,String>(); sParaSort.put("service", params.get("service")); sParaSort.put("v", params.get("v")); sParaSort.put("sec_id", params.get("sec_id")); sParaSort.put("notify_data", params.get("notify_data")); String prestr = ""; for (String key : sParaSort.keySet()) { prestr = prestr + key + "=" + sParaSort.get(key) + "&"; } prestr = prestr.substring(0, prestr.length() - 1); return prestr; }