收藏
回答

商家转账支付回调 验证签名&解密数据 失败?

获取解密数据出现错误 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();
}


最后一次编辑于  2025-08-27
回答关注问题邀请回答
收藏

1 个回答

  • Memory (私信不回复)
    Memory (私信不回复)
    2025-08-27

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

    2025-08-27
    有用
    回复 3
    • Jemmi
      Jemmi
      2025-08-27
      我看是的报错的请求的签名是 WECHATPAY/SIGNTEST/,对于这种探针流量需要怎么处理?
      2025-08-27
      回复
    • Memory (私信不回复)
      Memory (私信不回复)
      2025-08-27回复Jemmi
      忽略,返回应答非 200 即可,例如响应 500
      2025-08-27
      回复
    • Jemmi
      Jemmi
      2025-08-27回复Memory (私信不回复)
      好的,谢谢
      2025-08-27
      回复
登录 后发表内容