- 小程序支付回调结果收不到通知参数,需要怎么处理 ?
[图片] 用Apifox测试是通的, 说明回调地址是可访问的。 但支付成功后, 接收不到回调通知的结果参数,报空指针错误,如何处理?以下是代码 @RestController @RequestMapping("/web/notify") public class PayNotifyController { @RequestMapping(path = "/payAccept", method = RequestMethod.POST) @ResponseBody public void payAccept(@RequestBody String inXMl,HttpServletResponse response) throws IOException { log.info("回调inXml1111111111:"+inXMl); response.getWriter().write(WeixinUtil.SUCCESS);; } }
10-09 - 微信小程序支付结果通知收不到参数,需要怎么处理?
/** * 支付通知 * @return * @throws IOException */ @PostMapping("payAccept") public void payAccept() throws IOException { log.info("接收到支付通知1111111111"); Map<String, String> response; try { log.info("接收到支付通知2222222222222222"); String requestStr = HttpsUtil.parseRequst(HttpsUtil.request()); log.debug("回调参数 : " + requestStr); response = HttpsUtil.toMap(requestStr.getBytes(), "UTF-8"); if ("SUCCESS".equals(response.get("return_code"))) { log.debug("***支付成功回调参数:** " + response); // 支付通知内容做签名验证校验,防止被第三方篡改 SortedMap<Object, Object> parameters = new TreeMap<Object, Object>(); parameters.putAll(response); String appid = response.get("appid"); parameters.put("key", PayConfig.key); String signCheck = WeixinUtil.createSign("UTF-8", parameters); // 签名验证不通过 签名验证不通过,非法签名 if (!signCheck.equals(response.get("sign"))) { return; } if ("SUCCESS".equals(response.get("result_code"))) { log.debug("***支付成功回调参数222222:** "); }else { // 支付失败 // 通知微信,收到消息通知,不要在重复发送通知信息 HttpsUtil.response().getWriter().write(WeixinUtil.SUCCESS); } HttpsUtil.response().getWriter().write(WeixinUtil.SUCCESS); return; } } catch (Exception e) { e.printStackTrace(); log.error("发送通知异常:"+e.toString()); } } public static HttpServletRequest request() { HttpServletRequest request = (HttpServletRequest) currentRequest.get(); logger.debug("Request parameters:"); Enumeration<String> parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String paramName = parameterNames.nextElement(); String paramValue = request.getParameter(paramName); logger.debug("请求参数request:"+paramName + ": " + paramValue); } return request; } HttpsUtil.request()没有接收到任何参数,运行到log.info("接收到支付通知2222222222222222");就报空指针了。
09-23