public ActionResult AddReceiver()
{
WeixinTrace.Log("rnrn----------------------------添加分账接收方-----------------------------------------------rnrn");
Logger logger = LogManager.GetLogger("SimpleDemo");
string receiver = "
{
"type":"PERSONAL_WECHATID","account":"zuoann2012","name":"小李飞刀","relation_type":"PARTNER"
}
";
string mch_id = Globals.Configuration["AppSettings:TenPayV3_MchId"].ToString();
string appid = Globals.Configuration["AppSettings:WxOpenAppId"].ToString();
string TenPayV3_Key = Globals.Configuration["AppSettings:TenPayV3_Key"].ToString();
string nonce_str = TenPayV3Util.GetNoncestr();
string stringA = "appid=" + appid + "&mch_id=" + mch_id + "&nonce_str=" + nonce_str+ "&receiver="+ receiver;
string stringSignTemp = stringA + "&key=" + TenPayV3_Key; //注:key为商户平台设置的密钥key
string sign = EncryptHelper.GetHmacSha256(stringSignTemp, TenPayV3_Key).ToUpper();
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("mch_id", mch_id);
dic.Add("appid", appid);
dic.Add("nonce_str", nonce_str);
dic.Add("sign", sign);
dic.Add("receiver", receiver);
StringBuilder sb = new StringBuilder();
sb.Append("<xml>");
foreach (string k in dic.Keys)
{
string v = (string)dic[k];
sb.Append("<" + k + ">" + v + "</" + k + ">");
}
sb.Append("</xml>");
string post_xml = sb.ToString();
logger.Info("rnrn********************************post_xml************************************rnrn");
logger.Info(post_xml);
string result = HttpPost("https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver", post_xml);
logger.Info("rnrn*********************************返回值************************************rnrn");
logger.Info(result);
return Content(result);
}
您好,您的项目做好了吗?我也是用.net开发的,但是我一直提示签名验证错误。https://developers.weixin.qq.com/community/pay/doc/0002e21bfdcc98b5e91a1ba1d56400麻烦给看看。