微信公众号开发——现金红包、企业付款

时间:2022-05-01 03:29:23

先说现金红包

微信商户平台配置

微信公众号开发——现金红包、企业付款


微信公众号开发——现金红包、企业付款


微信公众号开发——现金红包、企业付款


微信公众号开发——现金红包、企业付款


微信公众号开发——现金红包、企业付款


微信公众号开发——现金红包、企业付款

设置基本就是如上图


核心代码

普通红包

        /// <summary>
        /// 普通红包 目前支持向指定微信用户的openid发放指定金额红包
        /// 单个红包金额介于[1.00元,200.00元]之间
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            //32位随机数
            string nonce_str = Common.GetRandomStr(32);
            //商户号
            string mch_id = "1389136002";   //需要申请 
            //时间戳
            string timeStamp = Common.GetTimeStamp();
            //商户订单号
            string mch_billno = mch_id + DateTime.Now.ToString("yyyyMMdd") + timeStamp;
            //公众账号appid
            string wxappid = "wx47695e1db631bd37";              //需要设置
            //商户名称
            string send_name = "平安江南";  
            //用户openid
            string re_openid = "oNIwAtD8dekn1LzBpQdsL9pLSj5g";  //程序获取
            //付款金额
            double fee = 1.25;
            int total_amount = int.Parse((fee * 100).ToString());
            //红包发放总人数
            int total_num = 1;
            //红包祝福语
            string wishing = "感谢您对我们工作的支持";
            //调用接口的机器Ip地址
            string client_ip = "61.130.145.142";              //需要设置
            //活动名称
            string act_name = "流动人口登记";
            //备注
            string remark = "祝您天天愉快";

            string KEY = "2Bp913RacktcjajM5grZH8qHn4IKzPKJ";  //需要设置 
            Dictionary<string, string> dic = OrdinaryRedPack.CreateSignatureParamsDic(nonce_str, mch_billno, mch_id, wxappid, send_name, re_openid, total_amount.ToString(), total_num.ToString(), wishing, client_ip, act_name, remark);
            string sign = SafetySpecification.SignatureCompute(dic, KEY);
            string data = OrdinaryRedPack.CreatePostData(nonce_str, sign, mch_billno, mch_id, wxappid, send_name, re_openid, total_amount.ToString(), total_num.ToString(), wishing, client_ip, act_name, remark);

            #region 证书放到服务器固定位置
            string url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack";
            //本地或者服务器的证书位置(证书在微信支付申请成功发来的通知邮件中)
            string cert = @"E:\wwwroot\jngasys.sunmen.cn\web\cert\apiclient_cert.p12";   //本地 @"G:\cert\apiclient_cert.p12"; 需要设置 

            //私钥(在安装证书时设置)
            string password = "1389136002";                     //需要设置 
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            //调用证书
            X509Certificate2 cert1 = new X509Certificate2(cert, password, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet); 
            #endregion

            #region 发起post请求
            HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(url);
            webrequest.ClientCertificates.Add(cert1);
            webrequest.Method = "post";

            byte[] postdatabyte = Encoding.UTF8.GetBytes(data);
            webrequest.ContentLength = postdatabyte.Length;
            Stream stream;
            stream = webrequest.GetRequestStream();
            stream.Write(postdatabyte, 0, postdatabyte.Length);
            stream.Close();

            HttpWebResponse httpWebResponse = (HttpWebResponse)webrequest.GetResponse();
            StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream());
            string responseContent = streamReader.ReadToEnd();
            #endregion

            ViewBag.Sign = sign;
            ViewBag.Res = responseContent;
            return View();
        }

        private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            if (errors == SslPolicyErrors.None)
                return true;
            return false;
        }

裂变红包

        /// <summary>
        /// 裂变红包
        /// </summary>
        /// <returns></returns>
        public ActionResult Index2() 
        {

            //32位随机数
            string nonce_str = Common.GetRandomStr(32);
            //商户号
            string mch_id = "1389136002";   //需要申请 
            //时间戳
            string timeStamp = Common.GetTimeStamp();
            //商户订单号
            string mch_billno = mch_id + DateTime.Now.ToString("yyyyMMdd") + timeStamp;
            //公众账号appid
            string wxappid = "wx47695e1db631bd37";              //需要设置
            //商户名称
            string send_name = "平安江南";
            //用户openid
            string re_openid = "oNIwAtDti5FSBpn45qReOVphvqeg";  //程序获取
            //付款金额
            double fee = 10;
            int total_amount = int.Parse((fee * 100).ToString());
            //红包发放总人数
            int total_num = 10;

            string amt_type = "ALL_RAND";
            //红包祝福语
            string wishing = "感谢您对我们工作的支持";
            //调用接口的机器Ip地址
            //string client_ip = "61.130.145.142"; //需要设置
            //活动名称
            string act_name = "流动人口登记";
            //备注
            string remark = "祝您天天愉快";

            string KEY = "2Bp913RacktcjajM5grZH8qHn4IKzPKJ";  //需要设置 


            Dictionary<string, string> dic = FissionRedPack.CreateSignatureParamsDic(nonce_str, mch_billno, mch_id, wxappid, send_name, re_openid, total_amount.ToString(), total_num.ToString(),amt_type, wishing, act_name, remark);


            string sign = SafetySpecification.SignatureCompute(dic, KEY);

            string data = FissionRedPack.CreatePostData(sign,mch_billno,mch_id,wxappid,send_name,re_openid,total_amount.ToString(),amt_type,total_num.ToString(),wishing,act_name,remark,nonce_str);

            string url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendgroupredpack";
            //本地或者服务器的证书位置(证书在微信支付申请成功发来的通知邮件中)
            string cert = @"E:\wwwroot\jngasys.sunmen.cn\web\cert\apiclient_cert.p12";  //@"F:\apiclient_cert.p12";
            //私钥(在安装证书时设置)
            string password = "1389136002";
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            //调用证书
            X509Certificate2 cer = new X509Certificate2(cert, password, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);

            #region 发起post请求
            HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(url);
            webrequest.ClientCertificates.Add(cer);
            webrequest.Method = "post";

            byte[] postdatabyte = Encoding.UTF8.GetBytes(data);
            webrequest.ContentLength = postdatabyte.Length;
            Stream stream;
            stream = webrequest.GetRequestStream();
            stream.Write(postdatabyte, 0, postdatabyte.Length);
            stream.Close();

            HttpWebResponse httpWebResponse = (HttpWebResponse)webrequest.GetResponse();
            StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream());
            string responseContent = streamReader.ReadToEnd();
            #endregion


            ViewBag.Sign = sign;
            ViewBag.Res = responseContent;

            return View();
        }

企业付款,微信商户平台配置也差不多

核心代码

 /// <summary>
        /// 企业支付
        /// </summary>
        /// <returns></returns>
        public ActionResult Index3() 
        {
            //公众账号appid
            string mch_appid = "wx47695e1db631bd37";              //需要设置
            //商户号
            string mchid = "1389136002";   //需要申请 

            //32位随机数
            string nonce_str = Common.GetRandomStr(32);

            //时间戳
            string timeStamp = Common.GetTimeStamp();
            //商户订单号 10000098201411111234567890

            string partner_trade_no = mchid + DateTime.Now.ToString("yyyyMMdd") + timeStamp;

            //用户openid
            string openid = "oNIwAtD8dekn1LzBpQdsL9pLSj5g";  //程序获取


            //校验用户姓名选项
            string check_name = "OPTION_CHECK";

            //收款用户姓名
            string re_user_name = "徐建兵";

            //金额
            double fee = 1;
            int amount = int.Parse((fee * 100).ToString());

            //企业付款描述信息
            string desc = "理赔";
            //调用接口的机器Ip地址
            string spbill_create_ip = "61.130.145.142";              //需要设置


            string KEY = "2Bp913RacktcjajM5grZH8qHn4IKzPKJ";  //需要设置 


            Dictionary<string, string> dic = EnterprisePlay.CreateSignatureParamsDic(mch_appid, mchid, nonce_str, partner_trade_no, openid, check_name, re_user_name, amount.ToString(), desc, spbill_create_ip);

            string sign = SafetySpecification.SignatureCompute(dic, KEY);


            string data = EnterprisePlay.CreatePostData(mch_appid, mchid, nonce_str, partner_trade_no, openid, check_name, re_user_name, amount.ToString(), desc, spbill_create_ip, sign);

            string url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers";
            //本地或者服务器的证书位置(证书在微信支付申请成功发来的通知邮件中)
            string cert = @"E:\wwwroot\jngasys.sunmen.cn\web\cert\apiclient_cert.p12";  //@"F:\apiclient_cert.p12";
            //私钥(在安装证书时设置)
            string password = "1389136002";
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            //调用证书
            X509Certificate2 cer = new X509Certificate2(cert, password, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);

            #region 发起post请求
            HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(url);
            webrequest.ClientCertificates.Add(cer);
            webrequest.Method = "post";

            byte[] postdatabyte = Encoding.UTF8.GetBytes(data);
            webrequest.ContentLength = postdatabyte.Length;
            Stream stream;
            stream = webrequest.GetRequestStream();
            stream.Write(postdatabyte, 0, postdatabyte.Length);
            stream.Close();

            HttpWebResponse httpWebResponse = (HttpWebResponse)webrequest.GetResponse();
            StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream());
            string responseContent = streamReader.ReadToEnd();
            #endregion



            ViewBag.Sign = sign;
            ViewBag.Res = responseContent;

            return View();
        }

以下是上面代码中用到的类库

微信公众号开发——现金红包、企业付款


SafetySpecification 安全规范类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;


namespace WeiXinBusiness.common
{
    /// <summary>
    /// 安全规范
    /// </summary>
    public class SafetySpecification
    {
        /// <summary>
        /// 签名计算
        /// </summary>
        /// <param name="dic"></param>
        /// <param name="Key">微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置</param>
        /// <returns></returns>
        public static string SignatureCompute(Dictionary<string, string> dic, string Key)
        {
            #region 3-1.签名参数 按照字段名的ASCII 码从小到大排序(字典序)后

            string[] arrkey = new string[dic.Keys.Count];

            int i = 0;
            foreach (string key in dic.Keys)
            {
                arrkey[i] = key;
                i++;
            }

            arrkey = arrkey.OrderBy(n => n).ToArray();
            #endregion

            #region 3-2.使用URL键值对的格式(即key1=value1&key2=value2…)拼接成字符串string1
            string stringA = "";
            foreach (string key in arrkey)
            {
                stringA += key + "=" + dic[key] + "&";
            }
            stringA = stringA.Substring(0, stringA.Length - 1);
            #endregion

            //Key 2Bp913RacktcjajM5grZH8qHn4IKzPKJ
            string stringSignTemp = stringA + "&key=" + Key;

            string sign = MD5(stringSignTemp).ToUpper();

            return sign;
        }

        /// <summary>
        /// 把字符串进行MD5计算
        /// </summary>
        /// <param name="stringSignTemp"></param>
        /// <returns></returns>
        private static string MD5(string stringSignTemp)
        {
            string cl = stringSignTemp;
            string pwd = "";
            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
            // 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择 
            byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(cl));
            // 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
            for (int i = 0; i < s.Length; i++)
            {
                // 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符 
                pwd = pwd + s[i].ToString("x2");
            }
            return pwd;
        }       
    }
}

OrdinaryRedPack 普通红包类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeiXinBusiness.redpack
{
    /// <summary>
    /// 普通红包
    /// </summary>
    public class OrdinaryRedPack
    {

        /// <summary>
        /// 创建 签名参数字典
        /// </summary>
        /// <param name="nonce_str">随机字符串</param>
        /// <param name="mch_billno">商户订单号(详见开发文档)</param>
        /// <param name="mch_id">商户号</param>
        /// <param name="wxappid">公众账号appid</param>
        /// <param name="send_name">商户名称</param>
        /// <param name="re_openid">用户openid</param>
        /// <param name="total_amount">付款金额(单位分)</param>
        /// <param name="total_num">红包发放总人数</param>
        /// <param name="wishing">红包祝福语</param>
        /// <param name="client_ip">Ip地址</param>
        /// <param name="act_name">活动名称</param>
        /// <param name="remark">备注</param>
        /// <param name="scene_id">场景id(详见开发文档)</param>
        /// <param name="risk_info">活动信息(详见开发文档)</param>
        /// <param name="consume_mch_id">资金授权商户号(服务商替特约商户发放时使用)</param>
        /// <returns></returns>
        public static Dictionary<string, string> CreateSignatureParamsDic(string nonce_str, string mch_billno, string mch_id, string wxappid, string send_name, string re_openid, string total_amount, string total_num, string wishing, string client_ip, string act_name, string remark, string scene_id = "", string risk_info = "", string consume_mch_id = "")
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();


            dic.Add("nonce_str", nonce_str);
            dic.Add("mch_billno", mch_billno);
            dic.Add("mch_id", mch_id);
            dic.Add("wxappid", wxappid);
            dic.Add("send_name", send_name);
            dic.Add("re_openid", re_openid);
            dic.Add("total_amount", total_amount);
            dic.Add("total_num", total_num);
            dic.Add("wishing", wishing);
            dic.Add("client_ip", client_ip);
            dic.Add("act_name", act_name);
            dic.Add("remark", remark);

            if (!string.IsNullOrEmpty(scene_id))
            {
                dic.Add("scene_id", scene_id);
            }

            if (!string.IsNullOrEmpty(risk_info))
            {
                dic.Add("risk_info", risk_info);
            }

            if (!string.IsNullOrEmpty(consume_mch_id))
            {
                dic.Add("consume_mch_id", consume_mch_id);
            }

            return dic;
        }

        /// <summary>
        /// 创建post数据
        /// </summary>
        /// <param name="nonce_str"></param>
        /// <param name="sign"></param>
        /// <param name="mch_billno"></param>
        /// <param name="mch_id"></param>
        /// <param name="wxappid"></param>
        /// <param name="send_name"></param>
        /// <param name="re_openid"></param>
        /// <param name="total_amount"></param>
        /// <param name="total_num"></param>
        /// <param name="wishing"></param>
        /// <param name="client_ip"></param>
        /// <param name="act_name"></param>
        /// <param name="remark"></param>
        /// <param name="scene_id"></param>
        /// <param name="risk_info"></param>
        /// <param name="consume_mch_id"></param>
        /// <returns></returns>
        public static string CreatePostData(string nonce_str, string sign, string mch_billno, string mch_id, string wxappid, string send_name, string re_openid, string total_amount, string total_num, string wishing, string client_ip, string act_name, string remark, string scene_id = "", string risk_info = "", string consume_mch_id = "")
        {
            string str = "";
            str += "<xml>";
            str += "<sign><![CDATA[" + sign + "]]></sign>";
            str += "<mch_billno><![CDATA[" + mch_billno + "]]></mch_billno>";
            str += "<mch_id><![CDATA[" + mch_id + "]]></mch_id>";
            str += "<wxappid><![CDATA[" + wxappid + "]]></wxappid>";
            str += "<send_name><![CDATA[" + send_name + "]]></send_name>";
            str += "<re_openid><![CDATA[" + re_openid + "]]></re_openid>";
            str += "<total_amount><![CDATA[" + total_amount + "]]></total_amount>";
            str += "<total_num><![CDATA[" + total_num + "]]></total_num>";
            str += "<wishing><![CDATA[" + wishing + "]]></wishing>";
            str += "<client_ip><![CDATA[" + client_ip + "]]></client_ip>";
            str += "<act_name><![CDATA[" + act_name + "]]></act_name>";
            str += "<remark><![CDATA[" + remark + "]]></remark>";

            if (!string.IsNullOrEmpty(scene_id))
            {
                str += "<scene_id><![CDATA[" + scene_id + "]]></scene_id>";
            }

            if (!string.IsNullOrEmpty(consume_mch_id))
            {
                str += "<consume_mch_id><![CDATA[" + consume_mch_id + "]]></consume_mch_id>";
            }

            str += "<nonce_str><![CDATA[" + nonce_str + "]]></nonce_str>";

            if (!string.IsNullOrEmpty(risk_info))
            {
                str += "<risk_info>" + risk_info + "</risk_info>";
            }

            str += "</xml>";

            return str;
        }
    }
}

FissionRedPack 裂变红包类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeiXinBusiness.redpack
{
    /// <summary>
    /// 裂变红包
    /// </summary>
    public class FissionRedPack
    {
        /// <summary>
        /// 创建 签名参数字典
        /// </summary>
        /// <param name="nonce_str">随机字符串</param>
        /// <param name="mch_billno">商户订单号(详见开发文档)</param>
        /// <param name="mch_id">商户号</param>
        /// <param name="wxappid">公众账号appid</param>
        /// <param name="send_name">商户名称</param>
        /// <param name="re_openid">用户openid</param>
        /// <param name="total_amount">付款金额(单位分)</param>
        /// <param name="total_num">红包发放总人数</param>
        /// <param name="amt_type">红包金额设置方式</param>
        /// <param name="wishing">红包祝福语</param>
        /// <param name="act_name">活动名称</param>
        /// <param name="remark">备注</param>
        /// <param name="scene_id">场景id(详见开发文档)</param>
        /// <param name="risk_info">活动信息(详见开发文档)</param>
        /// <param name="consume_mch_id">资金授权商户号(服务商替特约商户发放时使用)</param>
        /// <returns></returns>
        public static Dictionary<string, string> CreateSignatureParamsDic(string nonce_str, string mch_billno, string mch_id, string wxappid, string send_name, string re_openid, string total_amount, string total_num,string amt_type, string wishing,  string act_name, string remark, string scene_id = "", string risk_info = "", string consume_mch_id = "")
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("nonce_str", nonce_str);
            dic.Add("mch_billno", mch_billno);
            dic.Add("mch_id", mch_id);
            dic.Add("wxappid", wxappid);
            dic.Add("send_name", send_name);
            dic.Add("re_openid", re_openid);
            dic.Add("total_amount", total_amount);
            dic.Add("total_num", total_num);
            dic.Add("amt_type", amt_type);
            dic.Add("wishing", wishing);
            dic.Add("act_name", act_name);
            dic.Add("remark", remark);

            if (!string.IsNullOrEmpty(scene_id))
            {
                dic.Add("scene_id", scene_id);
            }

            if (!string.IsNullOrEmpty(risk_info))
            {
                dic.Add("risk_info", risk_info);
            }

            if (!string.IsNullOrEmpty(consume_mch_id))
            {
                dic.Add("consume_mch_id", consume_mch_id);
            }

            return dic;
        }



        /// <summary>
        /// 创建post数据
        /// </summary>
        /// <param name="nonce_str"></param>
        /// <param name="sign"></param>
        /// <param name="mch_billno"></param>
        /// <param name="mch_id"></param>
        /// <param name="wxappid"></param>
        /// <param name="send_name"></param>
        /// <param name="re_openid"></param>
        /// <param name="total_amount"></param>
        /// <param name="total_num"></param>
        /// <param name="wishing"></param>
        /// <param name="client_ip"></param>
        /// <param name="act_name"></param>
        /// <param name="remark"></param>
        /// <param name="scene_id"></param>
        /// <param name="risk_info"></param>
        /// <param name="consume_mch_id"></param>
        /// <returns></returns>
        public static string CreatePostData(string sign, string mch_billno, string mch_id, string wxappid, string send_name, string re_openid, string total_amount, string amt_type, string total_num, string wishing, string act_name, string remark, string nonce_str,  string scene_id = "", string risk_info = "", string consume_mch_id = "")
        {
            string str = "";
            str += "<xml>";
            str += "<sign><![CDATA[" + sign + "]]></sign>";
            str += "<mch_billno><![CDATA[" + mch_billno + "]]></mch_billno>";
            str += "<mch_id><![CDATA[" + mch_id + "]]></mch_id>";
            str += "<wxappid><![CDATA[" + wxappid + "]]></wxappid>";
            str += "<send_name><![CDATA[" + send_name + "]]></send_name>";
            str += "<re_openid><![CDATA[" + re_openid + "]]></re_openid>";
            str += "<total_amount><![CDATA[" + total_amount + "]]></total_amount>";
            str += "<amt_type><![CDATA[" + amt_type + "]]></amt_type> ";
            str += "<total_num><![CDATA[" + total_num + "]]></total_num>";
            str += "<wishing><![CDATA[" + wishing + "]]></wishing>";
            str += "<act_name><![CDATA[" + act_name + "]]></act_name>";
            str += "<remark><![CDATA[" + remark + "]]></remark>";

            if (!string.IsNullOrEmpty(scene_id))
            {
                str += "<scene_id><![CDATA[" + scene_id + "]]></scene_id>";
            }

            if (!string.IsNullOrEmpty(consume_mch_id))
            {
                str += "<consume_mch_id><![CDATA[" + consume_mch_id + "]]></consume_mch_id>";
            }

            str += "<nonce_str><![CDATA[" + nonce_str + "]]></nonce_str>";

            if (!string.IsNullOrEmpty(risk_info))
            {
                str += "<risk_info>" + risk_info + "</risk_info>";
            }

            str += "</xml>";

            return str;
        }
    }
}

EnterprisePlay 企业支付类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeiXinBusiness.enterprise_play
{
    public class EnterprisePlay
    {
        /// <summary>
        /// 创建 签名参数字典
        /// </summary>
        /// <param name="mch_appid">公众账号appid</param>
        /// <param name="mchid">商户号</param>
        /// <param name="nonce_str">32位随机数</param>
        /// <param name="partner_trade_no">商户订单号</param>
        /// <param name="openid">用户openid</param>
        /// <param name="check_name">校验用户姓名选项</param>
        /// <param name="re_user_name">收款用户姓名</param>
        /// <param name="amount">金额</param>
        /// <param name="desc">企业付款描述信息</param>
        /// <param name="spbill_create_ip">调用接口的机器Ip地址</param>
        /// <returns></returns>
        public static Dictionary<string, string> CreateSignatureParamsDic(string mch_appid, string mchid, string nonce_str, string partner_trade_no, string openid, string check_name, string re_user_name, string amount, string desc, string spbill_create_ip)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("mch_appid", mch_appid);
            dic.Add("mchid", mchid);
            dic.Add("nonce_str", nonce_str);
            dic.Add("partner_trade_no", partner_trade_no);
            dic.Add("openid", openid);
            dic.Add("check_name", check_name);
            dic.Add("re_user_name", re_user_name);
            dic.Add("amount", amount);
            dic.Add("desc", desc);
            dic.Add("spbill_create_ip", spbill_create_ip);
            return dic;
        }



        /// <summary>
        /// 创建post数据
        /// </summary>
        /// <param name="mch_appid">公众账号appid</param>
        /// <param name="mchid">商户号</param>
        /// <param name="nonce_str">32位随机数</param>
        /// <param name="partner_trade_no">商户订单号</param>
        /// <param name="openid">用户openid</param>
        /// <param name="check_name">校验用户姓名选项</param>
        /// <param name="re_user_name">收款用户姓名</param>
        /// <param name="amount">金额</param>
        /// <param name="desc">企业付款描述信息</param>
        /// <param name="spbill_create_ip">调用接口的机器Ip地址</param>
        /// <param name="sign">签名</param>
        /// <returns></returns>
        public static string CreatePostData(string mch_appid, string mchid, string nonce_str, string partner_trade_no, string openid, string check_name, string re_user_name, string amount, string desc, string spbill_create_ip, string sign)
        {
            string str = "";
            str += "<xml>";
            str += "<mch_appid>" + mch_appid + "</mch_appid>";
            str += "<mchid>" + mchid + "</mchid>";
            str += "<nonce_str>" + nonce_str + "</nonce_str>";
            str += "<partner_trade_no>" + partner_trade_no + "</partner_trade_no>";
            str += "<openid>" + openid + "</openid>";
            str += "<check_name>" + check_name + "</check_name>";
            str += "<re_user_name>" + re_user_name + "</re_user_name>";
            str += "<amount>" + amount + "</amount>";
            str += "<desc>" + desc + "</desc>";
            str += "<spbill_create_ip>" + spbill_create_ip + "</spbill_create_ip>";
            str += "<sign>" + sign + "</sign>";
            str += "</xml>";

            return str;
        }
    }
}