コード例 #1
0
        /// <summary>
        /// 微信支付
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string BrandWcPayRequest(HttpContext context)
        {
            if (!bllPay.IsWeiXinBrowser)
            {
                resp.errcode = 1;
                resp.errmsg  = "请用微信客户端访问";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            string orderId   = context.Request["order_id"];
            var    orderInfo = bll.Get <CrowdFundRecord>(string.Format(" RecordID={0}", orderId));

            if (orderInfo == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单号不存在";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (orderInfo.UserID != currentUserInfo.UserID)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单号无效";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (orderInfo.Status == 1)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单已经支付,不需重复支付";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            string    appId     = "";                                              //appid
            string    mchId     = "";                                              //mch_id
            string    key       = "";                                              //key
            string    openId    = "";                                              //openid
            string    ip        = "";                                              //ip
            string    notifyUrl = baseUrl + "/WxPayNotify/NotifyCrowdFundV2.aspx"; //支付通知地址
            string    body      = "";                                              //订单内容
            PayConfig payConfig = bllPay.GetPayConfig();

            appId  = payConfig.WXAppId;
            mchId  = payConfig.WXMCH_ID;
            key    = payConfig.WXPartnerKey;
            openId = currentUserInfo.WXOpenId;
            ip     = context.Request.UserHostAddress;
            string   payReqStr   = bllPay.GetBrandWcPayRequest(orderInfo.RecordID.ToString(), orderInfo.Amount, appId, mchId, key, openId, ip, notifyUrl, body);
            WXPayReq payReqModel = ZentCloud.Common.JSONHelper.JsonToModel <WXPayReq>(payReqStr);

            if (!string.IsNullOrEmpty(payReqModel.paySign))
            {
                return(ZentCloud.Common.JSONHelper.ObjectToJson(new
                {
                    errcode = 0,
                    pay_req = payReqModel
                }));
            }
            resp.errcode = 1;
            resp.errmsg  = "fail";
            return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }
コード例 #2
0
 public PayClient(PayConfig config)
 {
     this.config = new ConfigInfo()
     {
         PID       = config.Data["pid"],
         SCode     = config.Data["appsecret"],
         NotifyUrl = config.Data["notifyurl"]
     };
 }
コード例 #3
0
        public static string SendRequest(string bill_date, string bill_type, PayConfig config)
        {
            WxPayData wxPayData = new WxPayData();

            wxPayData.SetValue("bill_date", bill_date);
            wxPayData.SetValue("bill_type", bill_type);
            WxPayData wxPayData2 = WxPayApi.DownloadBill(wxPayData, config, 6);

            return(wxPayData2.ToPrintStr());
        }
コード例 #4
0
ファイル: HttpService.cs プロジェクト: xslonglianxia/XKD
        public static string Post(string xml, string url, bool isUseCert, PayConfig config, int timeout)
        {
            GC.Collect();
            string          text            = "";
            HttpWebRequest  httpWebRequest  = null;
            HttpWebResponse httpWebResponse = null;
            string          result;

            try
            {
                ServicePointManager.DefaultConnectionLimit = 200;
                if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
                {
                    ServicePointManager.ServerCertificateValidationCallback = ((object s, X509Certificate ce, X509Chain ch, SslPolicyErrors e) => true);
                }
                httpWebRequest             = (HttpWebRequest)WebRequest.Create(url);
                httpWebRequest.Method      = "POST";
                httpWebRequest.Timeout     = timeout * 1000;
                httpWebRequest.ContentType = "text/xml";
                byte[] bytes = Encoding.UTF8.GetBytes(xml);
                httpWebRequest.ContentLength = (long)bytes.Length;
                if (isUseCert)
                {
                    X509Certificate2 value = new X509Certificate2(config.SSLCERT_PATH, config.SSLCERT_PASSWORD);
                    httpWebRequest.ClientCertificates.Add(value);
                }
                Stream requestStream = httpWebRequest.GetRequestStream();
                requestStream.Write(bytes, 0, bytes.Length);
                requestStream.Close();
                httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.UTF8);
                text = streamReader.ReadToEnd().Trim();
                streamReader.Close();
            }
            catch (Exception ex)
            {
                HttpService.WxDebuglog(ex.Message, "_wxpay.txt");
                result = "POSTERROR:" + ex.Message;
                return(result);
            }
            finally
            {
                if (httpWebResponse != null)
                {
                    httpWebResponse.Close();
                }
                if (httpWebRequest != null)
                {
                    httpWebRequest.Abort();
                }
            }
            result = text;
            return(result);
        }
コード例 #5
0
        public void BuildOrder(HttpContext context, int payType, UserInfo user)
        {
            decimal amount = Convert.ToDecimal(context.Request["amount"]);

            if (amount <= 0)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "金额必须大于0";
                bll.ContextResponse(context, apiResp);
                return;
            }
            string    websiteOwner = bll.WebsiteOwner;
            PayConfig payConfig    = bllPay.GetPayConfig();

            if (payType == 1 && !bllPay.IsAliPay(payConfig))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该商户支付宝支付还没有配置";
                bll.ContextResponse(context, apiResp);
                return;
            }
            else if (payType == 2 && !bllPay.IsJDPay(payConfig))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该商户京东支付还没有配置";
                bll.ContextResponse(context, apiResp);
                return;
            }
            OrderPay orderPay = new OrderPay();

            orderPay.OrderId      = bll.GetGUID(TransacType.PayRegisterOrder);
            orderPay.InsertDate   = DateTime.Now;
            orderPay.Subject      = "支付充值";
            orderPay.Total_Fee    = amount;
            orderPay.Type         = "4";
            orderPay.WebsiteOwner = websiteOwner;
            orderPay.UserId       = user.UserID;
            orderPay.PayType      = payType;
            if (!bll.Add(orderPay))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "生成支付订单失败";
                bll.ContextResponse(context, apiResp);
                return;
            }

            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            apiResp.result = new
            {
                pay_order_id = orderPay.OrderId
            };
            bllUser.ContextResponse(context, apiResp);
        }
コード例 #6
0
ファイル: WxPay.aspx.cs プロジェクト: uvbs/mmp
        protected void Page_Load(object sender, EventArgs e)
        {
            string   orderId  = this.Request["OrderId"];
            OrderPay orderPay = bllOrder.GetOrderPay(orderId);

            if (orderPay != null && orderPay.Status == 0)
            {
                PayConfig payConfig = bllPay.GetPayConfig();
                PayString = bllPay.GetBrandWcPayRequest(orderId, orderPay.Total_Fee, payConfig.WXAppId, payConfig.WXMCH_ID, payConfig.WXPartnerKey, bllOrder.GetCurrentUserInfo().WXOpenId, this.Request.UserHostAddress, string.Format("http://{0}/Admin/DoPay/DoPayWxNotify.aspx", this.Request.Url.Host), "易劳积分充值" + orderPay.Total_Fee + "元");
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            open_id = PayRequest.GetQueryString("open_id");


            PayConfig payConfig = new PayConfig();

            notify_url = payConfig.notify_url;
            return_url = payConfig.return_url;
            cancel_url = payConfig.cancel_url;
        }
コード例 #8
0
        public void Add(Users Users, int[] PId, double[] Cost)
        {
            Users baseUsers = Entity.Users.FirstOrDefault(n => n.Id == Users.Id && n.Agent == BasicAgent.Id);
            bool  Check     = true;

            if (baseUsers != null)
            {
                Users.Cash0 = Users.Cash0 / 1000;
                if (Users.Cash0 >= BasicSet.AgentCash0 && Users.ECash0 >= BasicSet.AgentECash0 && Users.Cash1 >= BasicSet.AgentCash1 && Users.ECash1 >= BasicSet.AgentECash1)
                {
                    baseUsers.Cash0  = Users.Cash0;
                    baseUsers.ECash0 = Users.ECash0;
                    baseUsers.Cash1  = Users.Cash1;
                    baseUsers.ECash1 = Users.ECash1;
                    baseUsers.State  = 1;
                }
                else
                {
                    Check = false;
                }
                for (int i = 0; i < PId.Length; i++)
                {
                    int       pid  = PId[i];
                    double    cost = Cost[i] / 1000;
                    PayConfig PC   = Entity.PayConfig.FirstOrDefault(n => n.Id == pid);
                    if (PC == null)
                    {
                        Check = false;
                    }
                    if (cost >= PC.CostAgent)
                    {
                        UserPay UserPay = new UserPay();
                        UserPay.UId  = baseUsers.Id;
                        UserPay.PId  = pid;
                        UserPay.Cost = cost;
                        Entity.UserPay.AddObject(UserPay);
                    }
                    else
                    {
                        Check = false;
                    }
                }
            }
            //Entity.UserPayChange.AddObject(UserPayChange);
            if (Check)
            {
                Entity.SaveChanges();
                BaseRedirect();
            }
            else
            {
                Response.Redirect("/Agent/home/error.html?IsAjax=" + Request["IsAjax"] + "&msg=费率设置有误~");
            }
        }
コード例 #9
0
        public void ChangeStatus(PayConfig PayConfig, string InfoList, string Clomn, string Value)
        {
            if (string.IsNullOrEmpty(InfoList))
            {
                InfoList = PayConfig.Id.ToString();
            }
            int Ret = Entity.ChangeEntity <PayConfig>(InfoList, Clomn, Value);

            Entity.SaveChanges();
            Response.Write(Ret);
        }
コード例 #10
0
        /// <summary>
        /// 支付宝支付
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string BuildAlipayRequest(HttpContext context)
        {
            string orderId = context.Request["order_id"];

            if (bllPay.IsWeiXinBrowser)
            {
                resp.errcode = 1;
                resp.errmsg  = "请不要在微信客户端中访问";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (!bllPay.IsMobile)
            {
                resp.errcode = 1;
                resp.errmsg  = "请用手机浏览器访问";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            var orderInfo = bll.Get <CrowdFundRecord>(string.Format(" RecordID={0}", orderId));

            if (orderInfo == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单号不存在";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (orderInfo.UserID != currentUserInfo.UserID)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单号无效";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (orderInfo.Status == 1)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单已经支付,不需重复支付";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            PayConfig payConfig = bllPay.GetPayConfig();
            string    notifyUrl = baseUrl + "/Alipay/NotifyCrowdFundV2.aspx";
            var       payForm   = bllPay.GetAliPayRequestMobile(orderInfo.RecordID.ToString(), (double)orderInfo.Amount, payConfig.Seller_Account_Name, payConfig.Partner, payConfig.PartnerKey, notifyUrl);


            if (!string.IsNullOrEmpty(payForm))
            {
                return(ZentCloud.Common.JSONHelper.ObjectToJson(new
                {
                    errcode = 0,
                    pay_req = payForm
                }));
            }
            resp.errcode = 1;
            resp.errmsg  = "fail";
            return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }
コード例 #11
0
ファイル: JsApiPay.cs プロジェクト: spiltservice/cloudshop
        public static string GetJsApiParameters(PayConfig config)
        {
            WxPayData wxPayData = new WxPayData();

            wxPayData.SetValue("appId", JsApiPay.unifiedOrderResult.GetValue("appid"));
            wxPayData.SetValue("timeStamp", WxPayApi.GenerateTimeStamp());
            wxPayData.SetValue("nonceStr", WxPayApi.GenerateNonceStr());
            wxPayData.SetValue("package", "prepay_id=" + JsApiPay.unifiedOrderResult.GetValue("prepay_id"));
            wxPayData.SetValue("signType", "MD5");
            wxPayData.SetValue("paySign", wxPayData.MakeSign(config.Key));
            return(wxPayData.ToJson());
        }
コード例 #12
0
        public void Save(PayConfig PayConfig, string[] queryArray, int?AnsyCash, int?AnsyAgent)
        {
            PayConfig.Cost      = PayConfig.Cost / 1000;
            PayConfig.CostAgent = PayConfig.CostAgent / 1000;
            PayConfig.CostUser  = PayConfig.CostUser / 1000;
            if (PayConfig.Cost < 0 || PayConfig.CostUser < 0 || PayConfig.CostUser > 1 || PayConfig.Cost > 1 || PayConfig.Cost > PayConfig.CostUser)
            {
                Response.Redirect("/Manage/Home/Error.html?IsAjax=1&msg=费率设置有误");
                return;
            }
            PayConfig basePayConfig = Entity.PayConfig.FirstOrDefault(n => n.Id == PayConfig.Id);

            //如果是微信支付配置的子商户号没有填写的话,去掉这个元素
            if (basePayConfig.DllName == "WeiXin")
            {
                if (queryArray[4].IsNullOrEmpty())
                {
                    var temp = new ArrayList(queryArray);
                    temp.RemoveAt(4);
                    queryArray = (string[])temp.ToArray(typeof(string));
                }
            }
            if (queryArray != null)
            {
                basePayConfig.QueryArray = string.Join(",", queryArray);
            }
            basePayConfig = Request.ConvertRequestToModel <PayConfig>(basePayConfig, PayConfig);
            Entity.SaveChanges();
            if (AnsyCash == 1)
            {
                //使用删除全部后根据用户表生成,有效解决了因接口关闭或新增加接口,老用户没有配置问题
                string SQL = "Delete UserPay Where PId=" + basePayConfig.Id;
                Entity.ExecuteStoreCommand(SQL);
                SQL = "INSERT INTO UserPay(UId,PId,Cost,IsDel) Select ID," + basePayConfig.Id + " As PId," + basePayConfig.CostUser + " As Cost, 0 As IsDel From Users";
                Entity.ExecuteStoreCommand(SQL);
            }
            if (AnsyAgent == 1)
            {
                //使用删除全部后根据用户表生成,有效解决了因接口关闭或新增加接口,老用户没有配置问题
                string SQL = "Delete UserPayAgent Where PId=" + basePayConfig.Id;
                Entity.ExecuteStoreCommand(SQL);
                SQL = "INSERT INTO UserPayAgent(AId,PId,Cost,IsDel) Select ID," + basePayConfig.Id + " As PId," + basePayConfig.CostUser + " As Cost, 0 As IsDel From SysAgent";
                Entity.ExecuteStoreCommand(SQL);
            }

            if (AnsyAgent == 1 || AnsyCash == 1)
            {
                APIExtensions.ClearCacheAll();
            }

            BaseRedirect();
        }
コード例 #13
0
ファイル: HttpService.cs プロジェクト: 123456-cq/xkq34_src
        public static string Post(string xml, string url, bool isUseCert, PayConfig config, int timeout)
        {
            GC.Collect();
            string          str           = "";
            HttpWebRequest  request       = null;
            HttpWebResponse response      = null;
            Stream          requestStream = null;

            try
            {
                ServicePointManager.DefaultConnectionLimit = 200;
                if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
                {
                    ServicePointManager.ServerCertificateValidationCallback = (s, ce, ch, e) => true;
                }
                request             = (HttpWebRequest)WebRequest.Create(url);
                request.Method      = "POST";
                request.Timeout     = timeout * 0x3e8;
                request.ContentType = "text/xml";
                byte[] bytes = Encoding.UTF8.GetBytes(xml);
                request.ContentLength = bytes.Length;
                if (isUseCert)
                {
                    X509Certificate2 certificate = new X509Certificate2(config.SSLCERT_PATH, config.SSLCERT_PASSWORD);
                    request.ClientCertificates.Add(certificate);
                }
                requestStream = request.GetRequestStream();
                requestStream.Write(bytes, 0, bytes.Length);
                requestStream.Close();
                response = (HttpWebResponse)request.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                str = reader.ReadToEnd().Trim();
                reader.Close();
            }
            catch (Exception exception)
            {
                WxDebuglog(exception.Message, "_wxpay.txt");
                return("POSTERROR:" + exception.Message);
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
                if (request != null)
                {
                    request.Abort();
                }
            }
            return(str);
        }
コード例 #14
0
ファイル: PayMethod.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            PayConfig payConfig = bllPay.GetPayConfig();

            apiResp.result = new
            {
                is_wx_pay  = bllPay.IsWeixinPay(payConfig),
                is_ali_pay = bllPay.IsAliPay(payConfig),
                is_jd_pay  = bllPay.IsJDPay(payConfig)
            };
            apiResp.status = true;
            bllPay.ContextResponse(context, apiResp);
        }
コード例 #15
0
 public PayClient(PayConfig config)
 {
     this.config = new ConfigInfo()
     {
         AppID     = config.Data["appid"],
         AppSecret = config.Data["appsecret"],
         MCH_ID    = config.Data["mch_id"],
         MCH_KEY   = config.Data["mch_key"],
         NotifyUrl = config.Data["notifyurl"],
         ServerIP  = config.Data["serverip"],
         WapUrl    = config.Data["wapurl"]
     };
 }
コード例 #16
0
ファイル: paypc.aspx.cs プロジェクト: HeavenJoe/xorpay_net
        protected void Page_Load(object sender, EventArgs e)
        {
            pay_type = PayRequest.GetQueryString("pay_type");
            if (pay_type == "alipay")
            {
                pay_text = "支付宝";
            }
            else if (pay_type == "native")
            {
                pay_text = "微信";
            }

            notify_url = new PayConfig().notify_url;
        }
コード例 #17
0
ファイル: NativePay.cs プロジェクト: spiltservice/cloudshop
        public string GetPrePayUrl(string productId, PayConfig config)
        {
            WxPayData wxPayData = new WxPayData();

            wxPayData.SetValue("appid", config.AppId);
            wxPayData.SetValue("mch_id", config.MchID);
            wxPayData.SetValue("time_stamp", WxPayApi.GenerateTimeStamp());
            wxPayData.SetValue("nonce_str", WxPayApi.GenerateNonceStr());
            wxPayData.SetValue("product_id", productId);
            wxPayData.SetValue("sign", wxPayData.MakeSign(config.Key));
            string str = this.ToUrlParams(wxPayData.GetValues());

            return("weixin://wxpay/bizpayurl?" + str);
        }
コード例 #18
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;
		}
コード例 #19
0
        public static string SendRequest(RefundInfo info, PayConfig config, out string WxRefundNum)
        {
            WxPayData wxPayData = new WxPayData();

            if (!string.IsNullOrEmpty(info.transaction_id))
            {
                wxPayData.SetValue("transaction_id", info.transaction_id);
            }
            else
            {
                wxPayData.SetValue("out_trade_no", info.out_trade_no);
            }
            wxPayData.SetValue("total_fee", (int)info.TotalFee.Value);
            wxPayData.SetValue("refund_fee", (int)info.RefundFee.Value);
            wxPayData.SetValue("out_refund_no", info.out_refund_no);
            wxPayData.SetValue("op_user_id", config.MchID);
            if (!string.IsNullOrEmpty(config.sub_appid))
            {
                wxPayData.SetValue("sub_appid", config.sub_appid);
                wxPayData.SetValue("sub_mch_id", config.sub_mch_id);
            }
            WxPayData wxPayData2 = WxPayApi.Refund(wxPayData, config, 60);
            SortedDictionary <string, object> values = wxPayData2.GetValues();
            string result;

            if (values.ContainsKey("return_code") && values["return_code"].ToString() == "SUCCESS" && values.ContainsKey("result_code") && values["result_code"].ToString() == "SUCCESS")
            {
                WxRefundNum = "";
                result      = "SUCCESS";
            }
            else
            {
                HttpService.WxDebuglog(JsonConvert.SerializeObject(values), "_wxpay.txt");
                string str = "";
                if (values.ContainsKey("err_code_des"))
                {
                    str = values["err_code_des"].ToString();
                }
                if (values.ContainsKey("refund_id"))
                {
                    WxRefundNum = values["refund_id"].ToString();
                }
                else
                {
                    WxRefundNum = "";
                }
                result = str + values["return_msg"].ToString();
            }
            return(result);
        }
コード例 #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string text = base.Request.QueryString.Get("orderId");

            if (!string.IsNullOrEmpty(text))
            {
                InpourRequestInfo inpourBlance = MemberProcessor.GetInpourBlance(text);
                if (inpourBlance != null)
                {
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                    PackageInfo  packageInfo    = new PackageInfo();
                    packageInfo.Body       = inpourBlance.InpourId;
                    packageInfo.NotifyUrl  = Globals.GetProtocal(HttpContext.Current) + "://" + $"{base.Request.Url.Host}/pay/WeiXinInpourNotify";
                    packageInfo.OutTradeNo = inpourBlance.InpourId;
                    packageInfo.TotalFee   = (int)(inpourBlance.InpourBlance * 100m);
                    if (packageInfo.TotalFee < decimal.One)
                    {
                        packageInfo.TotalFee = decimal.One;
                    }
                    string text2 = "";
                    if (string.IsNullOrEmpty(text2))
                    {
                        PayConfig payConfig = new PayConfig();
                        payConfig.AppId     = masterSettings.WeixinAppId;
                        payConfig.Key       = masterSettings.WeixinPartnerKey;
                        payConfig.MchID     = masterSettings.WeixinPartnerID;
                        payConfig.AppSecret = masterSettings.WeixinAppSecret;
                        JsApiPay            jsApiPay             = new JsApiPay();
                        NameValueCollection openidAndAccessToken = JsApiPay.GetOpenidAndAccessToken(this.Page, payConfig.AppId, payConfig.AppSecret, false);
                        if (openidAndAccessToken.HasKeys())
                        {
                            text2 = openidAndAccessToken["openId"];
                        }
                    }
                    if (!string.IsNullOrEmpty(masterSettings.Main_AppId) && !string.IsNullOrEmpty(masterSettings.Main_Mch_ID))
                    {
                        packageInfo.sub_openid = text2;
                    }
                    else
                    {
                        packageInfo.OpenId = text2;
                    }
                    packageInfo.sub_mch_id = masterSettings.WeixinPartnerID;
                    PayClient payClient = null;
                    payClient = ((string.IsNullOrEmpty(masterSettings.Main_AppId) || string.IsNullOrEmpty(masterSettings.Main_Mch_ID)) ? new PayClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, "", "", "") : new PayClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, masterSettings.WeixinPartnerID, masterSettings.WeixinAppId, ""));
                    PayRequestInfo req = payClient.BuildPayRequest(packageInfo);
                    this.pay_json = this.ConvertPayJson(req);
                }
            }
        }
コード例 #21
0
ファイル: index.aspx.cs プロジェクト: HeavenJoe/xorpay_net
        protected void Page_Load(object sender, EventArgs e)
        {
            PayConfig payConfig = new PayConfig();

            openid_callback = $"https://xorpay.com/api/openid/{PayConfig.aid}?callback={HttpUtility.UrlEncode(payConfig.protocol + "/page/openid.aspx?pay=xorpay")}";

            jsapi_callback = $"https://xorpay.com/api/openid/{PayConfig.aid}?callback={HttpUtility.UrlEncode(payConfig.protocol + "/index.aspx?pay=xorpay")}";

            unionurl = $"{payConfig.protocol}/unionurl.aspx";

            check_config = string.IsNullOrWhiteSpace(PayConfig.aid) || string.IsNullOrWhiteSpace(PayConfig.app_secret) ? 0 : 1;

            open_id = PayRequest.GetQueryString("openid");
        }
コード例 #22
0
        public void Post()
        {
            string Tag = "NFC";//HFNFC

            if (ConfigurationManager.AppSettings["NFCPayWay"] != null)
            {
                Tag = ConfigurationManager.AppSettings["NFCPayWay"].ToString();
            }
            PayConfig PayConfig = Entity.PayConfig.FirstOrNew(n => n.DllName == Tag && n.State == 1);

            DataObj.Data = PayConfig.OutJson();
            DataObj.Code = "0000";
            DataObj.OutString();
        }
コード例 #23
0
ファイル: PaySmsRecharge.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string orderId = context.Request["order_id"];

            if (string.IsNullOrEmpty(orderId))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "order_id必传";
                bll.ContextResponse(context, apiResp);
                return;
            }
            OrderPay  orderPay  = bllOrder.GetOrderPay(orderId);
            PayConfig payConfig = bllPay.GetPayConfig();

            if (payConfig == null || string.IsNullOrEmpty(payConfig.WXAppId) || string.IsNullOrEmpty(payConfig.WXMCH_ID) || string.IsNullOrEmpty(payConfig.WXPartnerKey))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该商户微信支付还没有配置";
                bll.ContextResponse(context, apiResp);
                return;
            }

            string appId     = payConfig.WXAppId;                                                                             //微信AppId
            string mchId     = payConfig.WXMCH_ID;                                                                            //商户号
            string key       = payConfig.WXPartnerKey;                                                                        //api密钥
            string openId    = CurrentUserInfo.WXOpenId;                                                                      //openid
            string ip        = context.Request.UserHostAddress;                                                               //ip
            string notifyUrl = string.Format("http://{0}/WxPayNotify/SmsRechargeNotify.aspx", context.Request.Url.Authority); //支付充值通知地址
            string body      = "";                                                                                            //订单内容

            string payReqStr = bllPay.GetBrandWcPayRequest(orderPay.OrderId, orderPay.Total_Fee, appId, mchId, key, openId, ip, notifyUrl, body);

            BllPay.WXPayReq payReqModel = ZentCloud.Common.JSONHelper.JsonToModel <BllPay.WXPayReq>(payReqStr);
            if (string.IsNullOrEmpty(payReqModel.paySign))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "构造支付信息失败";
                bll.ContextResponse(context, apiResp);
                return;
            }

            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            apiResp.result = new
            {
                pay_req = payReqModel
            };
            bll.ContextResponse(context, apiResp);
        }
コード例 #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string order_no = PayRequest.GetQueryString("order_no");

            if (!string.IsNullOrWhiteSpace(order_no))
            {
                var jsapiInfo = Orders.GetJsApiInfo(order_no);
                wxJsApiParam = string.IsNullOrWhiteSpace(jsapiInfo) ? "{}" : jsapiInfo;
            }

            PayConfig payConfig = new PayConfig();

            return_url = payConfig.return_url;
            cancel_url = payConfig.cancel_url;
        }
コード例 #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PayConfig    payConfig      = new PayConfig();
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            payConfig.AppId            = masterSettings.WeixinAppId;
            payConfig.AppSecret        = masterSettings.WeixinAppSecret;
            payConfig.Key              = masterSettings.WeixinPartnerKey;
            payConfig.MchID            = masterSettings.WeixinPartnerID;
            payConfig.SSLCERT_PATH     = masterSettings.WeixinCertPath;
            payConfig.SSLCERT_PASSWORD = masterSettings.WeixinCertPassword;
            ResultNotify resultNotify = new ResultNotify(this.Page, payConfig);

            resultNotify.ProcessNotify();
        }
コード例 #26
0
ファイル: QueryClient.cs プロジェクト: spiltservice/cloudshop
        public static string SendRequest(string transaction_id, string out_trade_no, PayConfig config)
        {
            WxPayData wxPayData = new WxPayData();

            if (!string.IsNullOrEmpty(transaction_id))
            {
                wxPayData.SetValue("transaction_id", transaction_id);
            }
            else
            {
                wxPayData.SetValue("out_trade_no", out_trade_no);
            }
            WxPayData wxPayData2 = WxPayApi.OrderQuery(wxPayData, config, 6);

            return(wxPayData2.ToPrintStr());
        }
コード例 #27
0
ファイル: NativePay.cs プロジェクト: spiltservice/cloudshop
        public string GetPayUrl(PayInfo pay, PayConfig config)
        {
            WxPayData wxPayData = new WxPayData();

            wxPayData.SetValue("body", pay.OutTradeNo);
            wxPayData.SetValue("attach", pay.Attach);
            wxPayData.SetValue("out_trade_no", pay.OutTradeNo);
            wxPayData.SetValue("total_fee", pay.TotalFee);
            wxPayData.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
            wxPayData.SetValue("time_expire", pay.TimeEnd);
            wxPayData.SetValue("goods_tag", pay.GoodsTag);
            wxPayData.SetValue("trade_type", "NATIVE");
            wxPayData.SetValue("product_id", pay.ProductId);
            WxPayData wxPayData2 = WxPayApi.UnifiedOrder(wxPayData, config, 6);

            return(wxPayData2.GetValue("code_url").ToString());
        }
コード例 #28
0
        private string PayConfig(HttpContext context)
        {
            PayConfig payConfig = bllPay.GetPayConfig();

            payConfig = bllPay.ConvertRequestToModel <PayConfig>(payConfig);
            if (bllPay.Update(payConfig))
            {
                resp.Status = 1;
                resp.Msg    = "提交成功";
            }
            else
            {
                resp.Status = -1;
                resp.Msg    = "提交失败";
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
コード例 #29
0
ファイル: Alipay.aspx.cs プロジェクト: uvbs/mmp
        protected void Page_Load(object sender, EventArgs e)
        {
            string cur_order_id = this.Request["order_id"];

            if (!bllPay.IsMobile)
            {
                errorMsg = "请用手机浏览器访问";
                return;
            }
            if (string.IsNullOrWhiteSpace(cur_order_id))
            {
                errorMsg = "订单号未找到";
                return;
            }
            orderPay = bllOrder.GetOrderPay(cur_order_id, websiteOwner: bllOrder.WebsiteOwner, payType: 1);
            if (orderPay == null)
            {
                errorMsg = "订单未找到";
                return;
            }
            if (orderPay.Status == 1)
            {
                errorMsg = "订单已经付款";
                //formString = "<div style=\"height:100%;color:red;font-size:24px;text-algin:center;\">订单已经付款</div>";
                return;
            }
            if (bllPay.IsWeiXinBrowser)
            {
                return;
            }

            try
            {
                PayConfig payConfig  = bllPay.GetPayConfig();
                string    baseUrl    = string.Format("http://{0}", this.Request.Url.Authority);
                string    notifyUrl  = baseUrl + "/Alipay/ShMemberNotifyUrl.aspx";
                string    formString = bllPay.GetAliPayRequestMobile(orderPay.OrderId, (double)orderPay.Total_Fee,
                                                                     payConfig.Seller_Account_Name, payConfig.Partner, payConfig.PartnerKey, notifyUrl);
                Response.Write(formString);
            }
            catch (Exception ex)
            {
                errorMsg = "支付页生成失败";
            }
        }
コード例 #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            pay_type = PayRequest.GetQueryString("pay_type");
            if (pay_type == "alipay")
            {
                pay_text = "支付宝(在手机浏览器中打开)";
            }
            else if (pay_type == "jsapi")
            {
                pay_text = "微信(在微信客户端打开)";
            }

            PayConfig payConfig = new PayConfig();

            notify_url = payConfig.notify_url;
            return_url = payConfig.return_url;
            cancel_url = payConfig.cancel_url;
        }