问题已解决,公钥和平台证书序列号 都要在 https://api.mch.weixin.qq.com/v3/certificates API中获取,证书序列号 在 .NET 中并不需要转为16进制
.net 商户转帐到零钱 出错在使用商户转帐到零钱时 发起商户转帐 低于2000 不使用 “收款用户姓名 user_name” 可以正常转帐成功,使用 敏感信息加密后出错 400, 用户姓名加密程序如下: 公钥用的是 证书文件中的 apiclient_cert.pem byte[] publicKey = Encoding.UTF8.GetBytes(证书文件); public static string RSAEncrypt(string text, byte[] publicKey) { using (var x509 = new X509Certificate2(publicKey)) { using (var rsa = (RSACryptoServiceProvider)x509.PublicKey.Key) { var buff = rsa.Encrypt(Encoding.UTF8.GetBytes(text), true); return Convert.ToBase64String(buff); } } } API接口请求程序如下: public static string send(string authorization, string str, string UserAgent) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.mch.weixin.qq.com/v3/transfer/batches"); request.UserAgent = UserAgent; request.Method = "POST"; request.Accept = "application/json"; request.ContentType = "application/json"; request.Headers.Add("Authorization", authorization); request.Headers.Add("Wechatpay-Serial", WxPayConfig.CERTIFICATE); Stream requestStream = request.GetRequestStream(); StreamWriter streamWriter = new StreamWriter(requestStream); streamWriter.Write(str); streamWriter.Flush(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(responseStream); str = streamReader.ReadToEnd(); streamWriter.Close(); streamReader.Close(); } catch (Exception e) { Log.Info("出错信息:", e.ToString()); } return str; } 具体不知道什么原因,把姓名加入后就不能成功转帐 POST 请求 JSON数据如下: { "appid": "wx4c00359c0c0ca000", "out_batch_no": "DP202209170022066342", "batch_name": "测试转帐", "batch_remark": "测试商户转帐到零钱", "total_amount": 100, "total_num": 1, "transfer_detail_list": [ { "out_detail_no": "UD202209170022066343", "transfer_amount": 100, "transfer_remark": "测试转帐", "openid": "oA_LG610T2AOBSJbOC414141xt_8F4", "user_name": "jAkxHab9eU2SvrD7udOX//s3l+uXzsfEAaMJwKXDhQyMVzLwth2uj/4mILmSTsonqusfvYEagwUU9zYXHZCTETnH0SudYyaVjKA6/hUCkkuS7uxGm3HpwOwpv6sdIXyLk6aBr4A6XZblSTzUhNZG1WweJHL4F7ztuBx43V2E+ksg3D+TFHSqSNN1CSkVJ23jFHxjvKw4NrIKKywkILbODtpIPa6uW6oenyJCIruHr+3sR5Wrb6nZFxBoplrkwe1mUliikPRu8XIq6Qj0/Y0Yggdam/oh1gyPs3jHItJ2hAXGInct/GTCZamyGbyka/7kCrTEYGI92ADMOwoNM/be3w==" } ] }
2022-09-19请问有完整 的DEMO吗,我是在post请求中 使用 request.Headers.Add("Wechatpay-Serial", 平台证书序列号; 一直是400的错误不知道什么原因 user_name 这个也用RSA公钥加密了
商户上送敏感信息时使用微信支付平台公钥加密,要在http头携带微信支付平台证书序列号,如何理解?https://pay.weixin.qq.com/wiki/doc/apiv3_partner/wechatpay/wechatpay4_3.shtml文档中: 商户上送敏感信息时使用微信支付平台公钥加密,证书序列号包含在请求HTTP头部的[代码]Wechatpay-Serial[代码]是直接在http头中增加“Wechatpay-Serial”属性,带上微信支付平台证书即可? 不是在“Authorization”里面增加子属性吧?
2022-09-16