微信支付回调地址修改

pull/1/head
czc 2 years ago
parent 7472a8d85a
commit f484542fca

@ -38,7 +38,7 @@ import java.util.Map;
*/ */
@Api(description ="微信回调接口列表") @Api(description ="微信回调接口列表")
@RestController @RestController
@RequestMapping("/wechat/pay/callback") @RequestMapping("/no-auth/wechat")
public class PayNotifyController { public class PayNotifyController {
private static final Logger log = LoggerFactory.getLogger(PayNotifyController.class); private static final Logger log = LoggerFactory.getLogger(PayNotifyController.class);
@ -52,7 +52,7 @@ public class PayNotifyController {
* @param request * @param request
* @throws IOException * @throws IOException
*/ */
@PostMapping("/weChatPayNotify") @PostMapping("/notify")
public void weChatPayNotify(HttpServletRequest request) throws Exception { public void weChatPayNotify(HttpServletRequest request) throws Exception {
log.info("收到了微信支付回调"); log.info("收到了微信支付回调");
// 从请求头中获取信息 // 从请求头中获取信息

@ -29,8 +29,7 @@ public class WechatPayUtil {
public static String getSign(String signatureStr,String privateKey) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IOException, URISyntaxException { public static String getSign(String signatureStr,String privateKey) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IOException, URISyntaxException {
//replace 根据实际情况,不一定都需要 //replace 根据实际情况,不一定都需要
String replace = privateKey.replace("\\n", "\n"); String replace = privateKey.replace("\\n", "\n");
ClassPathResource classPathResource = new ClassPathResource(privateKey); InputStream certStream = Files.newInputStream(Paths.get(privateKey));
InputStream certStream = classPathResource.getInputStream();
PrivateKey merchantPrivateKey = PemUtil.readPemPrivateKey(certStream); PrivateKey merchantPrivateKey = PemUtil.readPemPrivateKey(certStream);
Signature sign = Signature.getInstance("SHA256withRSA"); Signature sign = Signature.getInstance("SHA256withRSA");
sign.initSign(merchantPrivateKey); sign.initSign(merchantPrivateKey);

Loading…
Cancel
Save