@wendal
大神好!请问nutzwx中有实现微信退款的api吗?我没有找到
6 回复
@wendal @wanjunjun 有退款的接口啊!!
Wx_config config = wxConfigService.fetch(mobiOrder.getWxid());
NutMap payinfo = Json.fromJson(NutMap.class, config.getPayInfo());
WxApi2 wxApi2 = wxConfigService.getWxApi2(config.getId());
File file = new File(Globals.AppRoot + "/WEB-INF/cert/wxpay/" + config.getId() + ".p12");
Map<String, Object> params = new HashMap<>();
params.put("appid", config.getAppid());
params.put("mch_id", payinfo.getString("wxpay_mchid"));
params.put("nonce_str", R.UU32());
params.put("out_trade_no", mobiOrder.getId());
params.put("out_refund_no", mobiOrder.getId());
params.put("total_fee", mobiOrder.getBuyPrice());
params.put("refund_fee", mobiOrder.getBuyPrice());
NutMap resp = wxApi2.postPay("https://api.mch.weixin.qq.com/secapi/pay/refund",
payinfo.getString("wxpay_key"), params,
file,
payinfo.getString("wxpay_mchid"));
log.debug("resp:::" + Json.toJson(resp));
if ("SUCCESS".equals(resp.getString("return_code"))) {
//退款成功更新支付状态
} else {
}
哦,之前没找到。
跟微信交互的api,在返回出来的结果前,加个校验就更方便了。。
帮大家提前规避风险
/**
* 检查微信api返回结果的签名
*/
public boolean checkWxResponseSign(NutMap wxResponseMap){
String wxSign = (String)wxResponseMap.remove("sign");
String sign = WxPaySign.createSign(appKey, wxResponseMap);
if(StringUtils.equalsIgnoreCase(wxSign, sign)){
return true;
}
return false;
}
添加回复
请先登陆