コード例 #1
0
        public static WxPayData RefundQuery(WxPayData inputObj, PayConfig config, int timeOut = 6)
        {
            string url = "https://api.mch.weixin.qq.com/pay/refundquery";

            inputObj.SetValue("appid", config.AppId);
            inputObj.SetValue("mch_id", config.MchID);
            inputObj.SetValue("nonce_str", WxPayApi.GenerateNonceStr());
            inputObj.SetValue("sign", inputObj.MakeSign(config.Key));
            string    xml       = inputObj.ToXml();
            DateTime  now       = DateTime.Now;
            string    xml2      = HttpService.Post(xml, url, false, config, timeOut);
            DateTime  now2      = DateTime.Now;
            int       num       = (int)(now2 - now).TotalMilliseconds;
            WxPayData wxPayData = new WxPayData();

            wxPayData.FromXml(xml2, config.Key);
            return(wxPayData);
        }
コード例 #2
0
ファイル: WxPayApi.cs プロジェクト: spiltservice/cloudshop
		public static WxPayData Reverse(WxPayData inputObj, PayConfig config, int timeOut = 6)
		{
			string text = "https://api.mch.weixin.qq.com/secapi/pay/reverse";
			if (!inputObj.IsSet("out_trade_no") && !inputObj.IsSet("transaction_id"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "撤销订单API接口中缺少必填参数out_trade_no 或者 transaction_id", LogType.CloseOrder);
			}
			inputObj.SetValue("appid", config.AppId);
			inputObj.SetValue("mch_id", config.MchID);
			inputObj.SetValue("nonce_str", WxPayApi.GenerateNonceStr());
			inputObj.SetValue("sign", inputObj.MakeSign(config.Key));
			string xml = inputObj.ToXml();
			DateTime now = DateTime.Now;
			string xml2 = HttpService.Post(xml, text, true, config, timeOut);
			DateTime now2 = DateTime.Now;
			int timeCost = (int)(now2 - now).TotalMilliseconds;
			WxPayData wxPayData = new WxPayData();
			wxPayData.FromXml(xml2, config.Key);
			WxPayApi.ReportCostTime(text, timeCost, wxPayData, config);
			return wxPayData;
		}
コード例 #3
0
ファイル: WxPayApi.cs プロジェクト: spiltservice/cloudshop
		public static WxPayData ShortUrl(WxPayData inputObj, PayConfig config, int timeOut = 6)
		{
			string text = "https://api.mch.weixin.qq.com/tools/shorturl";
			if (!inputObj.IsSet("long_url"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "需要转换的URL,签名用原串,传输需URL encode!", LogType.ShortUrl);
			}
			inputObj.SetValue("appid", config.AppId);
			inputObj.SetValue("mch_id", config.MchID);
			inputObj.SetValue("nonce_str", WxPayApi.GenerateNonceStr());
			inputObj.SetValue("sign", inputObj.MakeSign(config.Key));
			string xml = inputObj.ToXml();
			DateTime now = DateTime.Now;
			string xml2 = HttpService.Post(xml, text, false, config, timeOut);
			DateTime now2 = DateTime.Now;
			int timeCost = (int)(now2 - now).TotalMilliseconds;
			WxPayData wxPayData = new WxPayData();
			wxPayData.FromXml(xml2, config.Key);
			WxPayApi.ReportCostTime(text, timeCost, wxPayData, config);
			return wxPayData;
		}
コード例 #4
0
ファイル: JsApiPay.cs プロジェクト: spiltservice/cloudshop
        public static string GetEditAddressParameters(string appId, string access_token, bool appendLog = false)
        {
            string text = "";

            try
            {
                string    host      = JsApiPay.page.Request.Url.Host;
                string    path      = JsApiPay.page.Request.Path;
                string    query     = JsApiPay.page.Request.Url.Query;
                string    value     = "http://" + host + path + query;
                WxPayData wxPayData = new WxPayData();
                wxPayData.SetValue("appid", appId);
                wxPayData.SetValue("url", value);
                wxPayData.SetValue("timestamp", WxPayApi.GenerateTimeStamp());
                wxPayData.SetValue("noncestr", WxPayApi.GenerateNonceStr());
                wxPayData.SetValue("accesstoken", access_token);
                string    password   = wxPayData.ToUrl();
                string    text2      = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1");
                WxPayData wxPayData2 = new WxPayData();
                wxPayData2.SetValue("appId", appId);
                wxPayData2.SetValue("scope", "jsapi_address");
                wxPayData2.SetValue("signType", "sha1");
                wxPayData2.SetValue("addrSign", text2);
                wxPayData2.SetValue("timeStamp", wxPayData.GetValue("timestamp"));
                wxPayData2.SetValue("nonceStr", wxPayData.GetValue("noncestr"));
                text = wxPayData2.ToJson();
                JsApiPay.paramDict.Add("paramJson", text);
                if (appendLog)
                {
                    WxPayLog.AppendLog(JsApiPay.paramDict, text2, JsApiPay.page.Request.Url.ToString(), "获取收货地址js函数入口参数", LogType.GetOrEditAddress);
                }
            }
            catch (Exception ex)
            {
                WxPayLog.AppendLog(JsApiPay.paramDict, "", JsApiPay.page.Request.Url.ToString(), "获取收货地址js函数入口参数:" + ex.Message, LogType.GetOrEditAddress);
                throw new WxPayException(ex.ToString());
            }
            return(text);
        }
コード例 #5
0
        public static WxPayData DownloadBill(WxPayData inputObj, PayConfig config, int timeOut = 6)
        {
            string url = "https://api.mch.weixin.qq.com/pay/downloadbill";

            inputObj.SetValue("appid", config.AppId);
            inputObj.SetValue("mch_id", config.MchID);
            inputObj.SetValue("nonce_str", WxPayApi.GenerateNonceStr());
            inputObj.SetValue("sign", inputObj.MakeSign(config.Key));
            string    xml       = inputObj.ToXml();
            string    text      = HttpService.Post(xml, url, false, config, timeOut);
            WxPayData wxPayData = new WxPayData();

            if (text.Substring(0, 5) == "<xml>")
            {
                wxPayData.FromXml(text, config.Key);
            }
            else
            {
                wxPayData.SetValue("result", text);
            }
            return(wxPayData);
        }
コード例 #6
0
        public static WxPayData UnifiedOrder(WxPayData inputObj, PayConfig config, int timeOut = 6)
        {
            string url = "https://api.mch.weixin.qq.com/pay/unifiedorder";

            if (!inputObj.IsSet("NOTIFY_URL"))
            {
                inputObj.SetValue("NOTIFY_URL", config.NOTIFY_URL);
            }
            inputObj.SetValue("appid", config.AppId);
            inputObj.SetValue("mch_id", config.MchID);
            inputObj.SetValue("spbill_create_ip", config.IPAddress);
            inputObj.SetValue("nonce_str", WxPayApi.GenerateNonceStr());
            inputObj.SetValue("sign", inputObj.MakeSign(config.Key));
            string    xml       = inputObj.ToXml();
            DateTime  now       = DateTime.Now;
            string    xml2      = HttpService.Post(xml, url, false, config, timeOut);
            DateTime  now2      = DateTime.Now;
            int       num       = (int)(now2 - now).TotalMilliseconds;
            WxPayData wxPayData = new WxPayData();

            wxPayData.FromXml(xml2, config.Key);
            return(wxPayData);
        }
コード例 #7
0
ファイル: WxPayApi.cs プロジェクト: spiltservice/cloudshop
		public static WxPayData Refund(WxPayData inputObj, PayConfig config, int timeOut = 60)
		{
			string text = "https://api.mch.weixin.qq.com/secapi/pay/refund";
			if (!inputObj.IsSet("out_trade_no") && !inputObj.IsSet("transaction_id"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "退款订单API接口中缺少必填参数out_trade_no 或者 transaction_id", LogType.Refund);
			}
			else if (!inputObj.IsSet("out_refund_no"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "退款订单API接口中缺少必填参数out_refund_no", LogType.Refund);
			}
			else if (!inputObj.IsSet("total_fee"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "退款订单API接口中缺少必填参数total_fee", LogType.Refund);
			}
			else if (!inputObj.IsSet("refund_fee"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "退款订单API接口中缺少必填参数refund_fee", LogType.Refund);
			}
			else if (!inputObj.IsSet("op_user_id"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "退款订单API接口中缺少必填参数op_user_id", LogType.Refund);
			}
			inputObj.SetValue("appid", config.AppId);
			inputObj.SetValue("mch_id", config.MchID);
			inputObj.SetValue("nonce_str", Guid.NewGuid().ToString().Replace("-", ""));
			inputObj.SetValue("sign", inputObj.MakeSign(config.Key));
			string xml = inputObj.ToXml();
			DateTime now = DateTime.Now;
			string xml2 = HttpService.Post(xml, text, true, config, timeOut);
			DateTime now2 = DateTime.Now;
			int timeCost = (int)(now2 - now).TotalMilliseconds;
			WxPayData wxPayData = new WxPayData();
			wxPayData.FromXml(xml2, config.Key);
			WxPayApi.ReportCostTime(text, timeCost, wxPayData, config);
			return wxPayData;
		}
コード例 #8
0
ファイル: WxPayApi.cs プロジェクト: spiltservice/cloudshop
		public static WxPayData DownloadBill(WxPayData inputObj, PayConfig config, int timeOut = 6)
		{
			string url = "https://api.mch.weixin.qq.com/pay/downloadbill";
			if (!inputObj.IsSet("bill_date"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "对账单接口中,缺少必填参数bill_date", LogType.DownLoadBill);
			}
			inputObj.SetValue("appid", config.AppId);
			inputObj.SetValue("mch_id", config.MchID);
			inputObj.SetValue("nonce_str", WxPayApi.GenerateNonceStr());
			inputObj.SetValue("sign", inputObj.MakeSign(config.Key));
			string xml = inputObj.ToXml();
			string text = HttpService.Post(xml, url, false, config, timeOut);
			WxPayData wxPayData = new WxPayData();
			if (text.Substring(0, 5) == "<xml>")
			{
				wxPayData.FromXml(text, config.Key);
			}
			else
			{
				wxPayData.SetValue("result", text);
			}
			return wxPayData;
		}