/// <summary> /// 创建 验证支付通知的 Model /// </summary> /// <param name="isApp">是否App应用</param> /// <returns></returns> public static WxPayModel Create() { WxPayModel wxPayModel = new WxPayModel(); //先设置基本信息 wxPayModel.SetAppId(WeiXinConst.AppId); wxPayModel.SetAppKey(WeiXinConst.PaySignKey); wxPayModel.SetPartnerKey(WeiXinConst.PartnerKey); wxPayModel.SetSignType("sha1"); return(wxPayModel); }
/// <summary> /// 创建 订单查询Model /// </summary> /// <param name="tradeNo">订单号</param> /// <param name="isApp">是否为App支付创建的,默认为是</param> /// <returns></returns> public static WxPayModel Create(string tradeNo) { WxPayModel wxPayModel = new WxPayModel(); //先设置基本信息 wxPayModel.SetAppId(WeiXinConst.AppId); wxPayModel.SetAppKey(WeiXinConst.PaySignKey); wxPayModel.SetPartnerKey(WeiXinConst.PartnerKey); wxPayModel.SetSignType("sha1"); //设置请求package信息 wxPayModel.SetParameter("partner", WeiXinConst.PartnerId); //注册时分配的财付通商户号 partnerId wxPayModel.SetParameter("out_trade_no", tradeNo); //商户系统内部的订单号,32 个字符内、可包含字母,确保在商户系统唯一; return(wxPayModel); }
/// <summary> /// 根据传入的dic 设置参数 /// </summary> /// <param name="dic"></param> /// <param name="isApp"></param> /// <returns></returns> public static WxPayModel Create(Dictionary <string, string> dic) { WxPayModel wxPayModel = new WxPayModel(); //先设置基本信息 wxPayModel.SetAppId(WeiXinConst.AppId); wxPayModel.SetAppKey(WeiXinConst.PaySignKey); wxPayModel.SetPartnerKey(WeiXinConst.PartnerKey); wxPayModel.SetSignType("sha1"); foreach (var key in dic.Keys) { wxPayModel.SetParameter(key, dic[key]); } return(wxPayModel); }
/// <summary> /// 创建 支付Model /// </summary> /// <param name="description">商品描述</param> /// <param name="tradeNo">订单号</param> /// <param name="totalFee">订单金额(分为单位)</param> /// <param name="notifyUrl">支付完成后,接收微信通知支付结果的Url</param> /// <param name="createIp">用户浏览器端Ip</param> /// <returns></returns> public static WxPayModel Create(string description, string tradeNo, string totalFee, string notifyUrl, string createIp) { WxPayModel wxPayModel = new WxPayModel(); //先设置基本信息 wxPayModel.SetAppId(WeiXinConst.AppId); wxPayModel.SetAppKey(WeiXinConst.PaySignKey); wxPayModel.SetPartnerKey(WeiXinConst.PartnerKey); wxPayModel.SetSignType("sha1"); //设置请求package信息 wxPayModel.SetParameter("bank_type", "WX"); //固定 wxPayModel.SetParameter("fee_type", "1"); //取值:1(人民币) ,暂只支持 1; wxPayModel.SetParameter("input_charset", "UTF-8"); // wxPayModel.SetParameter("partner", WeiXinConst.PartnerId); //注册时分配的财付通商户号 partnerId wxPayModel.SetParameter("body", description); //商品描述 wxPayModel.SetParameter("out_trade_no", tradeNo); //商户系统内部的订单号,32 个字符内、可包含字母,确保在商户系统唯一; //todo:暂时写死为 1分 wxPayModel.SetParameter("total_fee", totalFee); //订单总金额,单位为分; wxPayModel.SetParameter("notify_url", notifyUrl); //在支付完成后,接收微信通知支付结果的URL,需给绝对路径,255字符内,格式如:http://wap.tenpay.com/tenpay.asp; wxPayModel.SetParameter("spbill_create_ip", createIp); //指用户浏览器端 IP,不是商户服务器 IP,格式为IPV4; return(wxPayModel); }