当前位置:   article > 正文

java 微信支付回调_JAVA微信支付多次回调方法解决方案

微信支付回调 java

@WebServlet("/ActionServlet")

public class PayWxOrderingReqCBS extends HttpServlet {

public PayWxOrderingReqCBS() {

super();

}

/**

* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse

*      response)

*/

protected void doGet(HttpServletRequest request,

HttpServletResponse response) throws ServletException, IOException {

doPost(request, response);

}

/**

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse

*      response)

*/

protected void doPost(HttpServletRequest request,

HttpServletResponse response) throws ServletException, IOException {

String msg = "success";

response.setContentType("text/xml");

System.out.print("微信支付回调数据开始");

String inputLine;

String notityXml = "";

String resXml = "";

try {

while ((inputLine = request.getReader().readLine()) != null) {

notityXml += inputLine;

}

request.getReader().close();

} catch (Exception e) {

e.printStackTrace();

}

System.out.println("接收到的报文:" + notityXml);

System.out.println("微信支付回调数据结束");

System.out.println("告知服务端订单情况");

String b = Xml2JsonUtil.xml2JSON(notityXml);

System.out.println("=======================>"+b);

try {

JSONObject c = new JSONObject(b);

String d = c.get("xml").toString();

JSONObject e = new JSONObject(d);

String f = e.get("return_code").toString();

if (f.contains("SUCCESS")) {

/** 告知订单状态,修改订单状态 */

具体业务

}

} catch (JSONException e) {

e.printStackTrace();

} catch (SwordBaseCheckedException e) {

e.printStackTrace();

}

resXml = "" + ""

+ "" + " ";

BufferedOutputStream out = new BufferedOutputStream(

response.getOutputStream());

out.write(resXml.getBytes());

out.flush();

out.close();

response.getWriter().println(msg);

}

原文:http://www.cnblogs.com/chinaDream2014/p/5916063.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/132218
推荐阅读
相关标签
  

闽ICP备14008679号