官方文档地址
https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_4_5.shtml
签名生成
https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_0.shtml
支付回调数据
{
"id":"EV-2018022511223320873",
"create_time":"2015-05-20T13:29:35+08:00",
"resource_type":"encrypt-resource",
"event_type":"TRANSACTION.SUCCESS",
"resource":{
"algorithm":"AEAD_AES_256_GCM",
"ciphertext":"...",
"nonce":"...",
"original_type":"transaction",
"associated_data":""
},
"summary":"支付成功"
}猛地一看啥也看不懂 不过文档有介绍
参数解密
下面详细描述对通知数据进行解密的流程:
1、用商户平台上设置的APIv3密钥【微信商户平台—>账户设置—>API安全—>设置APIv3密钥】,记为key;
2、针对resource.algorithm中描述的算法(目前为AEAD_AES_256_GCM),取得对应的参数nonce和associated_data;
3、使用key、nonce和associated_data,对数据密文resource.ciphertext进行解密,得到JSON形式的资源对象;
注: AEAD_AES_256_GCM算法的接口细节,请参考rfc5116。微信支付使用的密钥key长度为32个字节,随机串nonce长度12个字节,associated_data长度小于16个字节并可能为空。
这个参考上一篇文章
SHA256签名AEAD_AES_256_GCM解密
解密过程需要返回的 resource数组中的 ciphertext,associated_data,nonce 三个数据
最终的解密结果 能看懂了,直接用
array(12) {
["mchid"]=>
string(10) "***"
["appid"]=>
string(18) ""***""
["out_trade_no"]=>
string(20) ""***""
["transaction_id"]=>
string(28) ""***""
["trade_type"]=>
string(6) "NATIVE"
["trade_state"]=>
string(7) "SUCCESS"
["trade_state_desc"]=>
string(12) "支付成功"
["bank_type"]=>
string(6) "OTHERS"
["attach"]=>
string(28) "order_id=708,method=wxNative"
["success_time"]=>
string(25) "2021-05-30T16:46:02+08:00"
["payer"]=>
array(1) {
["openid"]=>
string(28) '***'
}
["amount"]=>
array(4) {
["total"]=>
int(1)
["payer_total"]=>
int(1)
["currency"]=>
string(3) "CNY"
["payer_currency"]=>
string(3) "CNY"
}
}
评论 (0)