获取解密数据出现错误 java.lang.IllegalArgumentException: Last unit does not have enough valid bits,后续该笔支付微信重试回调直接成功了,想问下这个错误的具体产生原因是什么,如何避免这个错误?
验证签名&解密数据 的方法如下:
com.wechat.pay.contrib.apache.httpclient.notification.NotificationHandler#parse
public String verify(String wechatPaySerial, String nonce, String timestamp, String signature, String body) {
NotificationRequest request = new NotificationRequest.Builder()
.withSerialNumber(wechatPaySerial)
.withNonce(nonce)
.withTimestamp(timestamp)
.withSignature(signature)
.withBody(body)
.build();
// 验签和解析请求体
Notification notification = null;
try {
notification = handler.parse(request);
} catch (ValidationException e) {
log.error("微信验证签名失败", e);
} catch (ParseException e) {
log.error("解析微信结果失败", e);
}
return notification == null ? null : notification.getDecryptData();
}

打印一下日志看看是不是拨测通知,可以通过查看签名值中的 WECHATPAY/SIGNTEST/ 前缀快速判断是否为探测流量。