Example #1
0
        /// <summary>
        /// 关闭订单 请求参数
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="mchId"></param>
        /// <param name="outTradeNo"></param>
        /// <param name="key"></param>
        /// <param name="nonceStr"></param>
        /// <param name="signType"></param>
        public TenPayV3CloseOrderRequestData(string appId, string mchId, string outTradeNo, string key, string nonceStr,
                                             string signType = "MD5")
        {
            AppId      = appId;
            MchId      = mchId;
            NonceStr   = nonceStr;
            OutTradeNo = outTradeNo;
            SignType   = signType;
            Key        = key;

            #region 设置RequestHandler

            //创建支付应答对象
            PackageRequestHandler = new RequestHandler(null);
            //初始化
            PackageRequestHandler.Init();

            //设置package订单参数
            PackageRequestHandler.SetParameter("appid", this.AppId);             //公众账号ID
            PackageRequestHandler.SetParameter("mch_id", this.MchId);            //商户号
            PackageRequestHandler.SetParameter("out_trade_no", this.OutTradeNo); //填入商家订单号
            PackageRequestHandler.SetParameter("nonce_str", this.NonceStr);      //随机字符串
            Sign = PackageRequestHandler.CreateMd5Sign("key", this.Key);
            PackageRequestHandler.SetParameter("sign", Sign);                    //签名

            #endregion
        }
Example #2
0
        /// <summary>
        /// 企业付款
        /// </summary>
        /// <param name="appId">微信分配的公众账号ID(企业号corpid即为此appId)</param>
        /// <param name="mchId">商户号</param>
        /// <param name="nonceStr">随机字符串</param>
        /// <param name="deviceInfo">微信支付分配的终端设备号</param>
        /// <param name="partnerTradeNo">商户订单号</param>
        /// <param name="openId">用户openid</param>
        /// <param name="key"></param>
        /// <param name="checkName">校验用户姓名选项(NO_CHECK:不校验真实姓名 FORCE_CHECK:强校验真实姓名) </param>
        /// <param name="reUserName">收款用户姓名</param>
        /// <param name="amount">金额(单位:元,小数点后不要超过2位,否则会被四舍五入到分)</param>
        /// <param name="desc">企业付款描述信息</param>
        /// <param name="spbillCreateIP">Ip地址</param>
        /// <param name="wwMsgType">付款消息类型(NORMAL_MSG:普通付款消息 APPROVAL _MSG:审批付款消息)</param>
        /// <param name="approvalNumber">审批单号</param>
        /// <param name="approvalType">审批类型</param>
        /// <param name="actName">项目名称,最长50个utf8字符</param>
        /// <param name="agentId"></param>
        public TenPayV3PayToWorkerRequestData(string appId, string mchId, string secret, string nonceStr, string partnerTradeNo,
                                              string openId, string key, string checkName, string reUserName, decimal amount, string desc, string spbillCreateIP,
                                              string deviceInfo, string actName, string wwMsgType = null, string approvalNumber = null, string approvalType = null, uint?agentId = null)
        {
            AppId          = appId;
            MchId          = mchId;
            Secret         = secret;
            NonceStr       = nonceStr;
            PartnerTradeNo = partnerTradeNo;
            OpenId         = openId;
            CheckName      = checkName;
            ReUserName     = reUserName;
            Amount         = amount;
            Desc           = desc;
            SpbillCreateIP = spbillCreateIP;
            DeviceInfo     = deviceInfo;
            ActName        = actName;
            WwMsgType      = wwMsgType;
            ApprovalNumber = approvalNumber;
            ApprovalType   = approvalType;
            AgentId        = agentId;
            Key            = key;

            #region 设置RequestHandler

            //创建支付应答对象
            PackageRequestHandler = new RequestHandler(null);
            //初始化
            PackageRequestHandler.Init();

            //设置package订单参数
            PackageRequestHandler.SetParameter("appid", this.AppId);                                                          //微信分配的公众账号ID(企业微信corpid即为此appid)
                                                                                                                              //https://work.weixin.qq.com/api/doc#90000/90135/90278
            PackageRequestHandler.SetParameter("mch_id", this.MchId);                                                         //商户号
            PackageRequestHandler.SetParameter("nonce_str", this.NonceStr);                                                   //随机字符串
            PackageRequestHandler.SetParameterWhenNotNull("device_info", this.DeviceInfo);                                    //微信支付分配的终端设备号
            PackageRequestHandler.SetParameter("partner_trade_no", this.PartnerTradeNo);                                      //商户订单号
            PackageRequestHandler.SetParameter("openid", this.OpenId);                                                        //用户openid
            PackageRequestHandler.SetParameter("check_name", this.CheckName);                                                 //校验用户姓名选项
            PackageRequestHandler.SetParameter("re_user_name", this.ReUserName);                                              //收款用户姓名
            PackageRequestHandler.SetParameter("amount", ((int)(this.Amount * 100 + 0.5m)).ToString());                       //金额
            PackageRequestHandler.SetParameter("desc", this.Desc);                                                            //企业付款描述信息
            PackageRequestHandler.SetParameter("spbill_create_ip", this.SpbillCreateIP);                                      //Ip地址
            PackageRequestHandler.SetParameterWhenNotNull("ww_msg_type", this.WwMsgType);                                     //付款消息类型
            PackageRequestHandler.SetParameterWhenNotNull("approval_number", this.ApprovalNumber);                            //审批单号
            PackageRequestHandler.SetParameterWhenNotNull("approval_type", this.ApprovalType);                                //审批类型
            PackageRequestHandler.SetParameter("act_name", this.ActName);                                                     //项目名称
            PackageRequestHandler.SetParameterWhenNotNull("agentid", this.AgentId.HasValue ? this.AgentId.ToString() : null); //项目名称

            //企业微信签名:https://work.weixin.qq.com/api/doc#90000/90135/90281

            var workWxSign = PackageRequestHandler.CreateMd5Sign("secret", this.Secret, WorkPaySignType.WorkPayApi);
            PackageRequestHandler.SetParameter("workwx_sign", workWxSign); //企业微信签名

            Sign = PackageRequestHandler.CreateMd5Sign("key", this.Key);
            PackageRequestHandler.SetParameter("sign", Sign); //签名

            #endregion
        }
Example #3
0
        /// <summary>
        /// 企业付款
        /// </summary>
        /// <param name="mchAppid">公众账号appid</param>
        /// <param name="mchId">商户号</param>
        /// <param name="deviceInfo">设备号</param>
        /// <param name="nonceStr">随机字符串</param>
        /// <param name="outTradeNo">商户订单号</param>
        /// <param name="openId">用户openid</param>
        /// <param name="key"></param>
        /// <param name="checkName">校验用户姓名选项</param>
        /// <param name="reUserName">收款用户姓名</param>
        /// <param name="amount">金额(单位:元,小数点后不要超过2位,否则会被四舍五入到分)</param>
        /// <param name="desc">企业付款描述信息</param>
        /// <param name="spbillCreateIP">Ip地址</param>
        public TenPayV3TransfersRequestData(string mchAppid, string mchId, string deviceInfo, string nonceStr, string outTradeNo, string openId, string key, string checkName, string reUserName, decimal amount, string desc, string spbillCreateIP)
        {
            MchAppId       = mchAppid;
            MchId          = mchId;
            DeviceInfo     = deviceInfo;
            NonceStr       = nonceStr;
            OutTradeNo     = outTradeNo;
            OpenId         = openId;
            CheckName      = checkName;
            ReUserName     = reUserName;
            Amount         = amount;
            Desc           = desc;
            SpbillCreateIP = spbillCreateIP;
            Key            = key;

            #region 设置RequestHandler

            //创建支付应答对象
            PackageRequestHandler = new RequestHandler(null);
            //初始化
            PackageRequestHandler.Init();

            //设置package订单参数
            PackageRequestHandler.SetParameter("mch_appid", this.MchAppId);                             //公众账号appid
            PackageRequestHandler.SetParameter("mchid", this.MchId);                                    //商户号
            //https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
            PackageRequestHandler.SetParameter("device_info", this.DeviceInfo);                         //终端设备号
            PackageRequestHandler.SetParameter("nonce_str", this.NonceStr);                             //随机字符串
            PackageRequestHandler.SetParameter("partner_trade_no", this.OutTradeNo);                    //商户订单号
            PackageRequestHandler.SetParameter("openid", this.OpenId);                                  //用户openid
            PackageRequestHandler.SetParameter("check_name", this.CheckName);                           //校验用户姓名选项
            PackageRequestHandler.SetParameter("re_user_name", this.ReUserName);                        //收款用户姓名
            PackageRequestHandler.SetParameter("amount", ((int)(this.Amount * 100 + 0.5m)).ToString()); //金额
            PackageRequestHandler.SetParameter("desc", this.Desc);                                      //企业付款描述信息
            PackageRequestHandler.SetParameter("spbill_create_ip", this.SpbillCreateIP);                //Ip地址
            Sign = PackageRequestHandler.CreateMd5Sign("key", this.Key);
            PackageRequestHandler.SetParameter("sign", Sign);                                           //签名

            #endregion
        }
Example #4
0
        /// <summary>
        /// 关闭订单 请求参数
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="mchId"></param>
        /// <param name="outTradeNo"></param>
        /// <param name="key"></param>
        /// <param name="nonceStr"></param>
        /// <param name="signType"></param>
        public TenPayV3GetSignKeyRequestData(string mchId, string nonceStr, string key, string signType = "MD5")
        {
            MchId    = mchId;
            NonceStr = nonceStr;
            SignType = signType;
            Key      = key;

            #region 设置RequestHandler

            //创建支付应答对象
            PackageRequestHandler = new RequestHandler(null);
            //初始化
            PackageRequestHandler.Init();

            //设置package订单参数
            PackageRequestHandler.SetParameter("mch_id", this.MchId);       //商户号
            PackageRequestHandler.SetParameter("nonce_str", this.NonceStr); //随机字符串
            Sign = PackageRequestHandler.CreateMd5Sign("key", this.Key);
            PackageRequestHandler.SetParameter("sign", Sign);               //签名

            #endregion
        }
        /// <summary>
        /// 服务商
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="mchId"></param>
        /// <param name="subappid">子商户公众账号ID</param>
        /// <param name="submchid">子商户号</param>
        /// <param name="body"></param>
        /// <param name="outTradeNo"></param>
        /// <param name="totalFee">单位:分</param>
        /// <param name="spbillCreateIp"></param>
        /// <param name="notifyUrl"></param>
        /// <param name="tradeType"></param>
        /// <param name="openid">trade_type=NATIVE时,OpenId应该为null</param>
        /// <param name="subOpenid">用户子标识,不需要则填写null</param>
        /// <param name="key"></param>
        /// <param name="nonceStr"></param>
        /// <param name="deviceInfo">自定义参数,可以为终端设备号(门店号或收银设备ID),PC网页或公众号内支付可以传"WEB",String(32)如:013467007045764</param>
        /// <param name="timeStart">订单生成时间,如果为空,则默认为当前服务器时间</param>
        /// <param name="timeExpire">订单失效时间,留空则不设置失效时间</param>
        /// <param name="detail">商品详细列表</param>
        /// <param name="attach">附加数据</param>
        /// <param name="feeType">符合ISO 4217标准的三位字母代码,默认人民币:CNY</param>
        /// <param name="goodsTag">商品标记,使用代金券或立减优惠功能时需要的参数,说明详见代金券或立减优惠。String(32),如:WXG</param>
        /// <param name="productId">trade_type=NATIVE时(即扫码支付),此参数必传。此参数为二维码中包含的商品ID,商户自行定义。String(32),如:12235413214070356458058</param>
        /// <param name="limitPay">是否限制用户不能使用信用卡支付</param>
        /// <param name="sceneInfo">场景信息。该字段用于上报场景信息,目前支持上报实际门店信息。</param>
        public TenPayV3UnifiedorderRequestData(
            string appId, string mchId, string subappid, string submchid, string body, string outTradeNo, int totalFee, string spbillCreateIp,
            string notifyUrl, TenPayV3Type tradeType, string openid, string subOpenid, string key, string nonceStr,
            string deviceInfo = null, DateTimeOffset?timeStart = null, DateTime?timeExpire = null,
            string detail     = null, string attach = null, string feeType = "CNY", string goodsTag = null,
            string productId  = null, bool limitPay = false,
            TenPayV3UnifiedorderRequestData_SceneInfo sceneInfo = null
            )
        {
            AppId          = appId;
            MchId          = mchId;
            DeviceInfo     = deviceInfo;
            NonceStr       = nonceStr;
            SignType       = "MD5";
            Body           = body ?? "Senparc TenpayV3";
            Detail         = detail;
            Attach         = attach;
            OutTradeNo     = outTradeNo;
            FeeType        = feeType;
            TotalFee       = totalFee;
            SpbillCreateIP = spbillCreateIp;
            TimeStart      = (timeStart ?? SystemTime.Now).ToString("yyyyMMddHHmmss");
            TimeExpire     = timeExpire.HasValue ? timeExpire.Value.ToString("yyyyMMddHHmmss") : null;
            GoodsTag       = goodsTag;
            NotifyUrl      = notifyUrl;
            TradeType      = tradeType;
            ProductId      = productId;
            LimitPay       = limitPay ? "no_credit" : null;
            OpenId         = openid;
            Key            = key;
            SubAppId       = subappid;
            SubMchId       = submchid;
            SubOpenid      = subOpenid;
            SceneInfo      = sceneInfo;


            #region 设置RequestHandler

            //创建支付应答对象
            PackageRequestHandler = new RequestHandler(null);
            //初始化
            PackageRequestHandler.Init();

            //设置package订单参数
            //以下设置顺序按照官方文档排序,方便维护:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1
            PackageRequestHandler.SetParameter("appid", this.AppId);                       //公众账号ID
            PackageRequestHandler.SetParameter("mch_id", this.MchId);                      //商户号
            PackageRequestHandler.SetParameterWhenNotNull("sub_appid", this.SubAppId);     //子商户公众账号ID
            PackageRequestHandler.SetParameterWhenNotNull("sub_mch_id", this.SubMchId);    //子商户号
            PackageRequestHandler.SetParameterWhenNotNull("device_info", this.DeviceInfo); //自定义参数
            PackageRequestHandler.SetParameter("nonce_str", this.NonceStr);                //随机字符串
            PackageRequestHandler.SetParameterWhenNotNull("sign_type", this.SignType);     //签名类型,默认为MD5
            PackageRequestHandler.SetParameter("body", this.Body);                         //商品信息
            PackageRequestHandler.SetParameterWhenNotNull("detail", this.Detail);          //商品详细列表
            PackageRequestHandler.SetParameterWhenNotNull("attach", this.Attach);          //附加数据
            PackageRequestHandler.SetParameter("out_trade_no", this.OutTradeNo);           //商家订单号
            PackageRequestHandler.SetParameterWhenNotNull("fee_type", this.FeeType);       //符合ISO 4217标准的三位字母代码,默认人民币:CNY
            PackageRequestHandler.SetParameter("total_fee", this.TotalFee.ToString());     //商品金额,以分为单位(money * 100).ToString()
            PackageRequestHandler.SetParameter("spbill_create_ip", this.SpbillCreateIP);   //用户的公网ip,不是商户服务器IP
            PackageRequestHandler.SetParameterWhenNotNull("time_start", this.TimeStart);   //订单生成时间
            PackageRequestHandler.SetParameterWhenNotNull("time_expire", this.TimeExpire); //订单失效时间
            PackageRequestHandler.SetParameterWhenNotNull("goods_tag", this.GoodsTag);     //商品标记
            PackageRequestHandler.SetParameter("notify_url", this.NotifyUrl);              //接收财付通通知的URL
            PackageRequestHandler.SetParameter("trade_type", this.TradeType.ToString());   //交易类型
            PackageRequestHandler.SetParameterWhenNotNull("product_id", this.ProductId);   //trade_type=NATIVE时(即扫码支付),此参数必传。
            PackageRequestHandler.SetParameterWhenNotNull("limit_pay", this.LimitPay);     //上传此参数no_credit--可限制用户不能使用信用卡支付
            PackageRequestHandler.SetParameterWhenNotNull("openid", this.OpenId);          //用户的openId,trade_type=JSAPI时(即公众号支付),此参数必传
            PackageRequestHandler.SetParameterWhenNotNull("sub_openid", this.SubOpenid);   //用户子标识
            if (SceneInfo != null)
            {
                PackageRequestHandler.SetParameter("scene_info", SceneInfo.ToString());   //场景信息
            }

            Sign = PackageRequestHandler.CreateMd5Sign("key", this.Key);

            PackageRequestHandler.SetParameter("sign", Sign);                              //签名
            #endregion
        }