这个签名现在还在困扰我
微信支付V3 JSAPI 支付签名验证失败?后台加密算法: /** * 获取签名 * * @param appId 小程序ID * @param timeStamp 时间戳 * @param nonceStr 随机字符串 * @param prepayId 订单详情扩展字符串 * @param privateKeyPath 私钥路径 * @return String */ public static String generatePaySign(String appId, String timeStamp, String nonceStr, String prepayId, String privateKeyPath) { try { // wx4*********36\n1698200889\nI861W82KHVUTZWRUIEV286NNBR1X3LRS\nprepay_id=wx2510280927566122c3d35b6b2273710000\n String originStr = """ %s\\n%s\\n%s\\n%s\\n """.formatted(appId, timeStamp, nonceStr, prepayId).trim(); PrivateKey privateKey = PemUtil.loadPrivateKeyFromPath(privateKeyPath); Signature signature = Signature.getInstance("SHA256withRSA"); signature.initSign(privateKey); signature.update(originStr.getBytes(StandardCharsets.UTF_8)); return Base64.getEncoder().encodeToString(signature.sign()); } catch (NoSuchAlgorithmException e) { log.error("[创建订单]获取签名失败", e); throw new RuntimeException(e.getMessage()); } catch (Exception e) { log.error(e.getMessage(), e); throw new RuntimeException(e.getMessage()); } } 使用官方工具验证通过 [图片] 小程序无法拉起支付(参数对应没问题) [图片] [图片]
05-24