@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 = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>"
+ "<return_msg><![CDATA[OK]]></return_msg>" + "</xml> ";
BufferedOutputStream out = new BufferedOutputStream(
response.getOutputStream());
out.write(resXml.getBytes());
out.flush();
out.close();
response.getWriter().println(msg);
}
相关文章
- 11-11java微信支付异步回调接收参数
- 11-11微信扫码支付模式二【无法回调】解决方案(转)
- 11-11【java】java反射机制,动态获取对象的属性和对应的参数值,并属性按照字典序排序,Field.setAccessible()方法的说明【可用于微信支付 签名生成】
- 11-11Java+微信支付(下预购单+回调+退款+查询账单)
- 11-11JAVA微信支付多次回调方法解决方案
- 11-11JAVA微信扫码支付模式二功能实现以及回调
- 11-11JAVA微信扫码支付模式二功能实现以及回调
- 11-11JAVA微信扫码支付模式二功能实现以及回调
- 11-11java配合uniapp的微信支付、商户转账等解决方案
- 11-11重学 Java 设计模式:实战桥接模式(多支付渠道「微信、支付宝」与多支付模式「刷脸、指纹」场景)