收藏
回答

php native支付 回调解密一直返回false

//数据包
{"id":"6b46b3e4-1e7c-59d5-84c3-93499c7b708d","create_time":"2022-01-05T15:51:10+08:00","resource_type":"encrypt-resource","event_type":"TRANSACTION.SUCCESS","summary":"支付成功","resource":{"original_type":"transaction","algorithm":"AEAD_AES_256_GCM","ciphertext":"MQN18lzceDWCj8tWzu1XH+ATWpfJQ8SPWs+PQEIyn6Nikk1F9L2kLxTYJ7LP/KMaG1HICkJKLwelVV90VXB16FdGLybUJrXkRQmGCdAutpB5JKiqz9aXPxleeqdMwcGP29y0ABYGwNp/k8pRtZSidtgofQb3zOJXlsMqM2FlTRKug3FsYfq4V780xSygMbzOGm5/mxOHvagCGByuU7mIcJCXiqELjidBPiLFE/KjN4P4VaxI9VGQTZRyUhAcl7dm2WVs060VU6aLF1dXN2WBV0iPtt6JsYRAPYH3aHS12GputZBobHked4yuxNZN6PIKwlmlMc4gd5imh/LrVvbJjfDH4TqmpSo9+wOC/gV/dhzMBBT88sSonSLoKWop5EfdNVDcDA2xbwrYHWHRhljmkLhBgtaLyogFb/ASVsfJRujabKJkPT+3vT5Bn9gfs7gnLDzW8I2HeJTfYCEoBjEkw6H0QW69x5r8xuEk50SJLDN9hNY2hSrxSWxTQaJ5jSgWvOmdMyJpOxRO/z4GhXNE0kmFWKkF+s46Pp+bYu8BR3Dyh85IZ9t46zInVHRbfJ5BmySsBn/fJMFvqTztl4D/mg==","associated_data":"transaction","nonce":"BUxpqQepKKZ9"}}
//apiv3key
1518DB9E0CE59070DA92F7F319DF6A97

php版本7.3.4

解密一直返回false ciphertext base64_decode 也是一直乱码

请问这样的情况 是否是我apiv3key不正确

回答关注问题邀请回答
收藏

1 个回答

  • 北望沣渭
    北望沣渭
    2022-01-05
    require_once 'vendor/autoload.php';
    use WeChatPay\Crypto\AesGcm;
    $json = json_decode('{...}');
    $res = AesGcm::decrypt($json->resource->ciphertext, $apiv3Key, $json->resource->nonce, $json->resource->associated_data);
    
    print_r($res);
    
    2022-01-05
    有用 2
    回复 2
    • Non-zero Sum Game
      Non-zero Sum Game
      2022-01-06
      好的 我试试 感谢
      2022-01-06
      回复
    • Non-zero Sum Game
      Non-zero Sum Game
      2022-01-06
      多谢 使用了您提供的方法 已经好使了 感觉问题出在 数据包过期 不过我重置了apiv3秘钥 用之前的数据包 也是false
      2022-01-06
      回复
登录 后发表内容