微信支付的回调
时间:2023-05-28 12:37:00
后台接受
InputStream inStream = request.getInputStream(); ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = inStream.read(buffer)) != -1) { outSteam.write(buffer, 0, len); } String resultxml = new String(outSteam.toByteArray(), "utf-8"); Map wxRetMap = PayCommonUtil.doXMLParse(resultxml); outSteam.close(); inStream.close(); // 当返回的return_code为SUCCESS则回调成功 if ("SUCCESS".equalsIgnoreCase(wxRetMap.get("return_code"))) { // 通知微信收到回调 String resXml = " "; BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); out.write(resXml.getBytes()); out.flush(); out.close(); /** * 执行业务代码 * */ try { ///保存流水业务 //附加数据 用户id json {user_id:'1'} String userId = wxRetMap.get("attach");//attach为xml标签名称 } catch (Exception e) { logger.error(e.getMessage()); e.printStackTrace(); } ------------------------------------------------------------------------xml----------------------------------------参数名称------------------------------------- 1