同样的问题,我头都大了
微信支付回调解析失败apiV3版本微信支付回调解析失败,之前都好好的,现在开始报错:ValidationException: Processing WechatPay notification,signature verification failed。 报文主体:{ "id": "0977fbe8-521a-5ef9-ba03-1faeb678c84d", "create_time": "2023-12-05T11:47:37+08:00", "resource_type": "encrypt-resource", "event_type": "TRANSACTION.SUCCESS", "summary": "支付成功", "resource": { "original_type": "transaction", "algorithm": "AEAD_AES_256_GCM", "ciphertext": "UtFOqggq56Wkvcwm56nNMcNuwECxk/IMpQnX0BhigBMoFGK+//vMmdACyaSimOAi/goti/xys3NLOpD0qR2AJQICLq5xCv64ScUZS0XSV/e74QSl7FtpaeG4hVZd/VD9gDTj5wAPfpezozXpS0EQFTV+iiYeGAd5BB9MOjbpHF/sGHLolCCE+ftGTSM5DWbz8phsl/j8AspATxnxBtS02EufNjZ5pRC5CA5uE2k9VPGxwGxYGXKSlHpuSbUIFxF1BjStEDJ6GLz7eQhxaLxhHizgryyn2SbOlVqNIY4pZXCtj7v68SInlpXB1Q2fkx61U62XDQLtFAaxPFQ1q8JXh9gVXySMzUH8SIcrNHFi/aRjeuVU6lhTDTnDlv00LbvY3dRHG/bkdceaatEG79pI4RJcSLeQMT+3EW7K7jhf2TbDZ6YyhdZH6QGyZ3Rb3p003bYGathcLph0AlSUGO0dsRTk+edAsY3zgUenQ21GTge0SSSviyk6Vz0vT/IXEJcz+WF8MFTNjD3jXS/eEtY/UbW+7G38rwlV2HAFzCHbC1kb8gQJkXa9/0una/vgRoR+tcakg27HG6B3j6XXlsUF", "associated_data": "transaction", "nonce": "pKbMMsyVxAxo" } }
01-31同样的问题,大佬怎么解决的,教一下啊
收到小程序支付成功通知回调,但一直报错,求助啊?支付后,成功收到回调通知,使用官方工具包进行处理报错,报错和打印的数据如下: com.wechat.pay.java.core.exception.ValidationException: Processing WechatPay notification,signature verification failed,signType[WECHATPAY2-SHA256-RSA2048] serial[28A6ECAC59FBAC47784205BB1AB25B744ADF55CF] message[1691820382 Ftx0RrGc4hp8nHm05xQwNGKhlG2VLRX5 {"id":"15b6e163-c913-5b31-9655-b24c60419b3a","create_time":"2023-08-12T14:06:22 08:00","resource_type":"encrypt-resource","event_type":"TRANSACTION.SUCCESS","summary":"支付成功","resource":{"original_type":"transaction","algorithm":"AEAD_AES_256_GCM","ciphertext":"2SytYk8XbdJbJYjo3Nh ljTLaS3tiUuJqXWsZQB0WuNUmHIqZwEjL130JSSCJlJZj PwPNf ACPVCeGFBrwawGyOzC5PmAaG9Uk5mqulTpT/Jgo2R9qLk7J2lkTwXLvfxxZGYemkHzwv7fMmoOheoLThv2yIXmgXd7y7wkMMkiBEWMym 15 8jyPxuosZtxoGetVXN15hPQX/VvY41iBEJ4DQxwp0zZtg1urAMDrXIqmlkycEjDNvDEY8s2YHG23c4tuGLS64rT 9mhMdkXVR3V2CC7ZYMlMin7RvVwsV9Fk/JQD0F1r3cQV0p9NP9AsqxZ8f7iqJ7btCL65wHSmWnPgmqbokD6125yFQ8TRVa9giax7NP3 6aV8A Hm2QvKP4uvWeRHTS9pAEe3NP96mWqM7Qs21vlR2QorWNTGxyj6vY217nG85Q2E34nD0UxhDx19FAFpQVLbsgcWQZEeRYvleXZGMGNPfxEOQQoj3IiQewzBuH1KTmfqpR6jkivx0g0vbej1vIpCYfQ aM88LP/vnaVgJfFWKU7PS Y 4 zxRoDEWJG2VQ2FoGNh4q8Kx3V9v2cHC2SNnBmnghN","associated_data":"transaction","nonce":"liX2WiKzV6vZ"}} ] sign[XBQmbyuwd9gczoTplkw6GgYab0CYzAV8Fw+ASswgshsi0qw8rQeLzvpvacSIzSJR3YQqK71bpnhJGo9hoONC3FGnBuGoWLibY3f8fzwERlmRKnaBILYohnwbjHlbMVvKd02asAuW2jx+ISGPpCDxnj9OURc6nAriOtzg5Sdcj+x059DtkXFrteFN1DK6S8XGFFHyRJkRIOoD6h+52V4aP7eSKqkGHrK2v5jnUqTithcmEMqTakNbIuI95dN3WmeYeq21cZS2z8sLzXQ9FSQidVYknFyXFUHdNslY/U66z2J34Jlf2rZKmI0Jefgpuinmaz365cApkpZXETmBhrrR1A==] at com.wechat.pay.java.core.notification.NotificationParser.validateRequest(NotificationParser.java:93) at com.wechat.pay.java.core.notification.NotificationParser.parse(NotificationParser.java:49) 我的代码: // 所有配置参数都是发起支付时候的,能成功发起说明这些配置参数肯定没问题 NotificationConfig config = new RSAAutoCertificateConfig.Builder() .merchantId(merchantId) .privateKeyFromPath(privateKeyPath) .merchantSerialNumber(merchantSerialNumber) .apiV3Key(apiV3Key) .build(); // 初始化 NotificationParser NotificationParser parser = new NotificationParser(config); // 构造 RequestParam RequestParam requestParam = new RequestParam.Builder() .serialNumber(wechatPaySerial) .nonce(wechatpayNonce) .signature(wechatSignature.replace(" ","+")) .timestamp(wechatTimestamp) .body(body) // 这个body是StreamUtils.copyToString(req.getInputStream(), StandardCharsets.UTF_8);从req获取的 .build(); logger.log("==requestParam=="+ JsonUtil.toJson(requestParam)); Transaction transaction; try { // 这里失败的 // 以支付通知回调为例,验签、解密并转换成 Transaction transaction = parser.parse(requestParam, Transaction.class); } catch (ValidationException e) { // 签名验证失败,返回 401 UNAUTHORIZED 状态码 logger.log("sign verification failed", e); return ResponseEntity.status(HttpStatus.UNAUTHORIZED); } 官方工具包版本: <dependency> <groupId>com.github.wechatpay-apiv3</groupId> <artifactId>wechatpay-java</artifactId> <version>0.2.11</version> </dependency>
01-31