package com.llisoft.pay.controller; import java.nio.charset.StandardCharsets; import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.util.StreamUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import com.llisoft.pay.service.PayWxV3Service; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Api(tags="微信支付回调") @Controller @RequestMapping("/callback/wxpay") public class CallbackWxPayController { private Logger logger = LoggerFactory.getLogger(CallbackWxPayController.class); @Autowired private PayWxV3Service payWxV3Service; @ApiOperation(value="异步通知") @PostMapping(value="/notify") public ResponseEntity.BodyBuilder notify(HttpServletRequest request) throws Exception { String xml = StreamUtils.copyToString(request.getInputStream(), StandardCharsets.UTF_8); logger.debug("收到微信异步通知: {}", xml); return ResponseEntity.badRequest(); } }