diff --git a/ruoyi-mall/src/main/java/com/cyl/h5/controller/PayNotifyController.java b/ruoyi-mall/src/main/java/com/cyl/h5/controller/PayNotifyController.java index 20e7ea4..b714f6c 100644 --- a/ruoyi-mall/src/main/java/com/cyl/h5/controller/PayNotifyController.java +++ b/ruoyi-mall/src/main/java/com/cyl/h5/controller/PayNotifyController.java @@ -38,7 +38,7 @@ import java.util.Map; */ @Api(description ="微信回调接口列表") @RestController -@RequestMapping("/wechat/pay/callback") +@RequestMapping("/no-auth/wechat") public class PayNotifyController { private static final Logger log = LoggerFactory.getLogger(PayNotifyController.class); @@ -52,7 +52,7 @@ public class PayNotifyController { * @param request * @throws IOException */ - @PostMapping("/weChatPayNotify") + @PostMapping("/notify") public void weChatPayNotify(HttpServletRequest request) throws Exception { log.info("收到了微信支付回调"); // 从请求头中获取信息 diff --git a/ruoyi-mall/src/main/java/com/cyl/wechat/WechatPayUtil.java b/ruoyi-mall/src/main/java/com/cyl/wechat/WechatPayUtil.java index 7468277..ab019c9 100644 --- a/ruoyi-mall/src/main/java/com/cyl/wechat/WechatPayUtil.java +++ b/ruoyi-mall/src/main/java/com/cyl/wechat/WechatPayUtil.java @@ -29,8 +29,7 @@ public class WechatPayUtil { public static String getSign(String signatureStr,String privateKey) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IOException, URISyntaxException { //replace 根据实际情况,不一定都需要 String replace = privateKey.replace("\\n", "\n"); - ClassPathResource classPathResource = new ClassPathResource(privateKey); - InputStream certStream = classPathResource.getInputStream(); + InputStream certStream = Files.newInputStream(Paths.get(privateKey)); PrivateKey merchantPrivateKey = PemUtil.readPemPrivateKey(certStream); Signature sign = Signature.getInstance("SHA256withRSA"); sign.initSign(merchantPrivateKey);