调用微信退款接口https://api.mch.weixin.qq.com/secapi/pay/refund
返回了一个null回来导致报错
代码如下所示:
public static void main(String[] args) {
try {
// 设置API请求参数
SortedMap<String, Object> params = new TreeMap<String, Object>();
params.put("appid", WxPayConfig.appid);
params.put("mch_id", WxPayConfig.mch_id);
params.put("nonce_str", System.currentTimeMillis() + "");
params.put("out_trade_no", 2057);//订单编号
params.put("total_fee", 1);
params.put("refund_fee", 1);
params.put("out_refund_no", 2057);//订单退款编号
params.put("notify_url", WxPayConfig.notify_refund_url+2057);
params.put("trade_type", "JSAPI");
params.put("openid", "openId");
//获取sign
String sign = PayCommonUtil.createSign("UTF-8", params, WxPayConfig.apiKey);//最后这个是自己设置的32位密钥
params.put("sign", sign);
log.error("params:"+params);
//转成XML
String requestXML = PayCommonUtil.getRequestXml(params);
log.error(requestXML);
//得到含有prepay_id的XML
String resXml = HttpUtil.postData(WxPayConfig.refund_url, requestXML);
log.error("resXml:"+resXml);
//解析XML存入Map
Map map = XMLUtil.doXMLParse(resXml);
System.out.println("map:"+map);
} catch (Exception e) {
e.printStackTrace();
}
}
请求没有携带证书?