コード例 #1
0
ファイル: WxPayApi.cs プロジェクト: spiltservice/cloudshop
		public static WxPayData Micropay(WxPayData inputObj, PayConfig config, int timeOut = 10)
		{
			string text = "https://api.mch.weixin.qq.com/pay/micropay";
			if (!inputObj.IsSet("body"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "缺少必填参数body", LogType.MicroPay);
			}
			else if (!inputObj.IsSet("out_trade_no"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "缺少必填参数out_trade_no", LogType.MicroPay);
			}
			else if (!inputObj.IsSet("total_fee"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "缺少必填参数total_fee", LogType.MicroPay);
			}
			else if (!inputObj.IsSet("auth_code"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "缺少必填参数auth_code", LogType.MicroPay);
			}
			inputObj.SetValue("spbill_create_ip", config.IPAddress);
			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, 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;
		}
コード例 #2
0
ファイル: WxPayApi.cs プロジェクト: spiltservice/cloudshop
		public static WxPayData UnifiedOrder(WxPayData inputObj, PayConfig config, int timeOut = 6)
		{
			string text = "https://api.mch.weixin.qq.com/pay/unifiedorder";
			if (!inputObj.IsSet("out_trade_no"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "缺少统一支付接口必填参数out_trade_no!", LogType.UnifiedOrder);
			}
			else if (!inputObj.IsSet("body"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "缺少统一支付接口必填参数body!", LogType.UnifiedOrder);
			}
			else if (!inputObj.IsSet("total_fee"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "缺少统一支付接口必填参数total_fee!", LogType.UnifiedOrder);
			}
			else if (!inputObj.IsSet("trade_type"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "缺少统一支付接口必填参数trade_type!", LogType.UnifiedOrder);
			}
			if (inputObj.GetValue("trade_type").ToString() == "JSAPI" && !inputObj.IsSet("openid"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!", LogType.UnifiedOrder);
			}
			if (inputObj.GetValue("trade_type").ToString() == "NATIVE" && !inputObj.IsSet("product_id"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "统一支付接口中,缺少必填参数product_id!trade_type为JSAPI时,product_id为必填参数!", LogType.UnifiedOrder);
			}
			if (!inputObj.IsSet("NOTIFY_URL"))
			{
				WxPayLog.AppendLog(inputObj.GetParam(), "", HttpContext.Current.Request.Url.ToString(), "统一支付接口中,缺少必填参数NOTIFY_URL!", LogType.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, 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;
		}
コード例 #3
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;
		}
コード例 #4
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;
		}
コード例 #5
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;
		}