评论

.net 添加分账接收方【普通直连分账】

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);

        }


点赞 0
收藏
评论

1 个评论

登录 后发表内容