CallbackWxPayController.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.llisoft.pay.controller;
  2. import java.nio.charset.StandardCharsets;
  3. import javax.servlet.http.HttpServletRequest;
  4. import org.slf4j.Logger;
  5. import org.slf4j.LoggerFactory;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.http.ResponseEntity;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.util.StreamUtils;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import com.llisoft.pay.service.PayWxV3Service;
  13. import io.swagger.annotations.Api;
  14. import io.swagger.annotations.ApiOperation;
  15. @Api(tags="微信支付回调")
  16. @Controller
  17. @RequestMapping("/callback/wxpay")
  18. public class CallbackWxPayController {
  19. private Logger logger = LoggerFactory.getLogger(CallbackWxPayController.class);
  20. @Autowired
  21. private PayWxV3Service payWxV3Service;
  22. @ApiOperation(value="异步通知")
  23. @PostMapping(value="/notify")
  24. public ResponseEntity.BodyBuilder notify(HttpServletRequest request) throws Exception {
  25. String xml = StreamUtils.copyToString(request.getInputStream(), StandardCharsets.UTF_8);
  26. logger.debug("收到微信异步通知: {}", xml);
  27. return ResponseEntity.badRequest();
  28. }
  29. }