|
@@ -1,5 +1,6 @@
|
|
|
package com.llisoft.pay.controller;
|
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -9,11 +10,13 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.util.StreamUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
+import com.llisoft.common.util.XmlUtil;
|
|
|
import com.llisoft.pay.service.WxPayService;
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -41,8 +44,11 @@ public class WxPayController {
|
|
|
@ApiOperation(value="异步通知")
|
|
|
@PostMapping(value="/notify")
|
|
|
public @ResponseBody String notify(HttpServletRequest request) throws Exception {
|
|
|
- Map<String, String> resultMap = this.getParamMap(request);
|
|
|
- logger.info("收到微信异步通知: {}", resultMap);
|
|
|
+ // https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7&index=8
|
|
|
+ String xml = StreamUtils.copyToString(request.getInputStream(), StandardCharsets.UTF_8);
|
|
|
+ logger.info("收到微信异步通知: {}", xml);
|
|
|
+ Map<String, String> resultMap = XmlUtil.toObject(xml, Map.class, String.class, String.class);
|
|
|
+ logger.info("解析异步通知内容: {}", resultMap);
|
|
|
return wxPayService.dispose(resultMap) ? "success" : "";
|
|
|
}
|
|
|
|