商圈商户的V3密钥是正确的,解密工具是用的官方提供的。
回调结果:{"id":"2eb20456-0245-5cf7-a661-78de9cad3a32","create_time":"2021-09-03T10:01:19+08:00","resource_type":"encrypt-resource","event_type":"MALL_TRANSACTION.SUCCESS","summary":"支付成功","resource":{"original_type":"mall_transaction","algorithm":"AEAD_AES_256_GCM","ciphertext":"9Hk5bvtXeB3g/RQJm3cW6bBjxs41gd5vIUDD+VHJ/FfMV9wsCDAW8BOY+K4ynt+e+alCTdWeH7BeRMojJiESXWYqg86H87u+d7/soAoQ/nWNNBhBT/uC+v8ZFqvZ1d0COvsbvUd6uCBiL4MRzA+i4x0t9apwJXHJnVgoavk9c9pViOAhjjemnz0/cMnFUPY7iGhIAi4T1TDVPr8FEo0GP25k2RhQvo463CFGc8kVzgwpA54OKkewqqqfZXu4oxDUtvXUfb+Xq6rJcojJLUQKIUcxl1gPruXmpm+KJnE3t7Ut9jBVj3+zrH+RqpT8W7tyaX11XsMKkH4Fa1k1q3tWGDvSa3Uv5TmzJktvqO65HszgcHVVT+TMS7kCYfS+Fgpomt2P94T4Y/voREQfs4U=","associated_data":"mall_transaction","nonce":"sQCkxIGiowJX"}}
一直解密失败,报错如下
javax.crypto.AEADBadTagException: Tag mismatch!
at com.sun.crypto.provider.GaloisCounterMode.decryptFinal(GaloisCounterMode.java:578)
at com.sun.crypto.provider.CipherCore.finalNoPadding(CipherCore.java:1049)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:985)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:847)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
at javax.crypto.Cipher.doFinal(Cipher.java:2164)
at com.smelep.acemade.util.AesUtil.aesgcmDecrypt(AesUtil.java:84)
at com.smelep.acemade.util.AesUtil.main(AesUtil.java:92)
引自官方文档 https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay7_2.shtml 参考
使用Java解密时,抛出异常AEADBadTagException: Tag mismatch!
加密使用的AES-GCM包含了Galois Message Authentication Code (GMAC)的消息认证机制。解密时会对数据的完整性进行校验。出现tag mismatch异常,表示解密时的消息认证失败。通常有三种可能:
开发者可以参考我们的示例代码 。
"associated_data":"mall_transaction"