From f484542fca3e374589db12b47a550e4ac481b972 Mon Sep 17 00:00:00 2001 From: czc Date: Thu, 13 Jul 2023 17:33:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E5=9C=B0=E5=9D=80=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/cyl/h5/controller/PayNotifyController.java | 4 ++-- ruoyi-mall/src/main/java/com/cyl/wechat/WechatPayUtil.java | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) 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);