Example #1
0
 public static void ReSet()
 {
     MchId     = PluginUtils.GetPluginSet().OpenMchId;
     AppId     = PluginUtils.GetPluginSet().OpenAppId;
     AppSecret = PluginUtils.GetPluginSet().OpenAppSecret;
     AppKey    = PluginUtils.GetPluginSet().OpenAppKey;
 }
Example #2
0
        static Config()
        {
            //↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

            //合作身份者ID,以2088开头由16位纯数字组成的字符串
            partner = PluginUtils.GetPluginSet().Partner;

            //收款支付宝账号,以2088开头由16位纯数字组成的字符串
            seller_id = PluginUtils.GetPluginSet().Seller;

            //商户的私钥
            private_key = PluginUtils.GetPluginSet().PrivateKey;

            //支付宝的公钥,无需修改该值
            public_key = @"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB";

            //↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑



            //字符编码格式 目前支持 gbk 或 utf-8
            input_charset = "utf-8";

            //签名方式,选择项:RSA、DSA、MD5
            sign_type = "RSA";
        }
Example #3
0
        /// <summary>
        /// 登陆
        /// </summary>
        public ActionResult Login()
        {
            //返回url
            string returnUrl = WebHelper.GetQueryString("returnUrl");

            if (returnUrl.Length == 0)
            {
                returnUrl = "/";
            }

            if (WorkContext.MallConfig.LoginType == "")
            {
                return(PromptView(returnUrl, "商城目前已经关闭登陆功能!"));
            }
            if (WorkContext.Uid > 0)
            {
                return(PromptView(returnUrl, "您已经登录,无须重复登录!"));
            }

            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();
            //生成随机值,防止CSRF攻击
            string salt = Randoms.CreateRandomValue(16);
            //获取Authorization Code地址
            string url = string.Format("{0}/oauth2.0/authorize?client_id={1}&response_type=code&redirect_uri=http://{2}{3}&state={4}",
                                       pluginSetInfo.AuthUrl, pluginSetInfo.AppKey, BMAConfig.MallConfig.SiteUrl, Url.Action("CallBack"), salt);

            Sessions.SetItem(WorkContext.Sid, "qqAuthLoginSalt", salt);
            return(Redirect(url));
        }
Example #4
0
 static PayConfig()
 {
     MchId     = PluginUtils.GetPluginSet().OpenMchId;
     AppId     = PluginUtils.GetPluginSet().OpenAppId;
     AppSecret = PluginUtils.GetPluginSet().OpenAppSecret;
     AppKey    = PluginUtils.GetPluginSet().OpenAppKey;
 }
Example #5
0
        /// <summary>
        /// 返回调用
        /// </summary>
        public ActionResult Return()
        {
            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            // 如果您还没有设置MD5密钥请登陆我们为您提供商户后台,地址:https://merchant3.chinabank.com.cn/
            // 登陆后在上面的导航栏里可能找到“B2C”,在二级导航栏里有“MD5密钥设置”
            // 建议您设置一个16位以上的密钥或更高,密钥最多64位,但设置16位已经足够了
            string key = pluginSetInfo.Key;

            int     v_oid       = WebHelper.GetRequestInt("v_oid");
            string  v_pstatus   = WebHelper.GetRequestString("v_pstatus");
            string  v_pstring   = WebHelper.GetRequestString("v_pstring");
            string  v_pmode     = WebHelper.GetRequestString("v_pmode");
            string  v_md5str    = WebHelper.GetRequestString("v_md5str");
            decimal v_amount    = TypeHelper.StringToDecimal(WebHelper.GetRequestString("v_amount"));
            string  v_moneytype = WebHelper.GetRequestString("v_moneytype");
            string  remark1     = WebHelper.GetRequestString("remark1");
            string  remark2     = WebHelper.GetRequestString("remark2");

            string str = v_oid + v_pstatus + v_amount + v_moneytype + key;

            str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToUpper();

            if (str == v_md5str)
            {
                if (v_pstatus.Equals("20"))
                {
                    //支付成功
                    OrderInfo orderInfo = Orders.GetOrderByOid(v_oid);
                    if (orderInfo != null && orderInfo.PayMode == 1 && orderInfo.PaySN.Length == 0 && orderInfo.SurplusMoney > 0 && orderInfo.SurplusMoney <= v_amount)
                    {
                        Orders.PayOrder(v_oid, OrderState.Confirming, "", DateTime.Now);
                        OrderActions.CreateOrderAction(new OrderActionInfo()
                        {
                            Oid         = v_oid,
                            Uid         = orderInfo.Uid,
                            RealName    = "本人",
                            AdminGid    = 1,
                            AdminGTitle = "非管理员",
                            ActionType  = (int)OrderActionType.Pay,
                            ActionTime  = DateTime.Now,
                            ActionDes   = "你使用网银在线支付订单成功,支付银行为:" + v_pmode
                        });
                    }

                    return(RedirectToAction("payresult", "order", new RouteValueDictionary {
                        { "oid", orderInfo.Oid }
                    }));
                }
                else
                {
                    return(Content("支付失败"));
                }
            }
            else
            {
                return(Content("校验失败,数据可疑"));
            }
        }
Example #6
0
        public ActionResult Config()
        {
            ConfigModel model = new ConfigModel();

            model.PayFee    = PluginUtils.GetPluginSet().PayFee;
            model.FreeMoney = PluginUtils.GetPluginSet().FreeMoney;
            return(View("~/plugins/OWZX.PayPlugin.EMSRemit/views/adminemsremit/config.cshtml", model));
        }
Example #7
0
        public ActionResult Config()
        {
            ConfigModel model = new ConfigModel();

            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            model.PayFee    = pluginSetInfo.PayFee;
            model.FreeMoney = pluginSetInfo.FreeMoney;

            return(View("~/plugins/BrnMall.PayPlugin.COD/views/admincod/config.cshtml", model));
        }
Example #8
0
        public ActionResult Config()
        {
            ConfigModel model = new ConfigModel();

            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            model.BargainorId = pluginSetInfo.BargainorId;
            model.TenpayKey   = pluginSetInfo.TenpayKey;
            model.PayFee      = pluginSetInfo.PayFee;
            model.FreeMoney   = pluginSetInfo.FreeMoney;

            return(View("~/plugins/NStore.PayPlugin.Tenpay/views/admintenpay/config.cshtml", model));
        }
Example #9
0
        public ActionResult Config()
        {
            ConfigModel model = new ConfigModel();

            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            model.Mid       = pluginSetInfo.Mid;
            model.Key       = pluginSetInfo.Key;
            model.PayFee    = pluginSetInfo.PayFee;
            model.FreeMoney = pluginSetInfo.FreeMoney;

            return(View("~/plugins/NStore.PayPlugin.ChinaBank/views/adminchinabank/config.cshtml", model));
        }
        public ActionResult Config()
        {
            ConfigModel model = new ConfigModel();

            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            model.Partner    = pluginSetInfo.Partner;
            model.Key        = pluginSetInfo.Key;
            model.PrivateKey = pluginSetInfo.PrivateKey;
            model.Seller     = pluginSetInfo.Seller;

            return(View("~/plugins/BrnShop.PayPlugin.Alipay/views/adminalipay/config.cshtml", model));
        }
Example #11
0
        public ActionResult Config()
        {
            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            ConfigModel model = new ConfigModel();

            model.AuthUrl     = pluginSetInfo.AuthUrl;
            model.AppKey      = pluginSetInfo.AppKey;
            model.AppSecret   = pluginSetInfo.AppSecret;
            model.Server      = pluginSetInfo.Server;
            model.UNamePrefix = pluginSetInfo.UNamePrefix;

            return(View("~/plugins/NStore.OAuthPlugin.QQ/views/adminqqoauth/config.cshtml", model));
        }
Example #12
0
        public ActionResult Config()
        {
            ConfigModel model = new ConfigModel();

            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            model.Partner   = pluginSetInfo.Partner;
            model.Key       = pluginSetInfo.Key;
            model.Seller    = pluginSetInfo.Seller;
            model.PayFee    = pluginSetInfo.PayFee;
            model.FreeMoney = pluginSetInfo.FreeMoney;

            return(View("~/plugins/NStore.PayPlugin.Alipay/views/adminalipay/config.cshtml", model));
        }
Example #13
0
        public ActionResult Config()
        {
            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            ConfigModel model = new ConfigModel();

            model.AuthUrl     = pluginSetInfo.AuthUrl;
            model.AppID       = pluginSetInfo.AppID;
            model.AppSecret   = pluginSetInfo.AppSecret;
            model.Server      = pluginSetInfo.Server;
            model.UNamePrefix = pluginSetInfo.UNamePrefix;

            return(View("~/plugins/OWZX.OAuthPlugin.WeChat/views/adminwechatoauth/config.cshtml", model));
        }
Example #14
0
        /// <summary>
        /// 支付
        /// </summary>
        public ActionResult Pay()
        {
            //订单id
            int oid = WebHelper.GetQueryInt("oid");

            //订单信息
            OrderInfo orderInfo = Orders.GetOrderByOid(oid);

            if (orderInfo == null || orderInfo.Uid != WorkContext.Uid || orderInfo.OrderState != (int)OrderState.WaitPaying || orderInfo.PayMode != 1)
            {
                return(Redirect("/"));
            }

            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();
            string        v_mid         = pluginSetInfo.Mid; //商户号
            string        key           = pluginSetInfo.Key;

            string v_url   = string.Format("http://{0}/ChinaBank/Notify", BSPConfig.ShopConfig.SiteUrl);        //返回接收支付结果的页面
            string remark2 = string.Format("[url:=http://{0}/ChinaBank/Notify]", BSPConfig.ShopConfig.SiteUrl); //服务器异步通知的接收地址

            string v_oid    = oid.ToString();
            string v_amount = orderInfo.SurplusMoney.ToString();

            string v_moneytype = "CNY";

            string text = v_amount + v_moneytype + v_oid + v_mid + v_url + key; // 拼凑加密串

            string v_md5info = FormsAuthentication.HashPasswordForStoringInConfigFile(text, "md5").ToUpper();

            StringBuilder sbHtml = new StringBuilder();

            sbHtml.Append("<form action=\"https://pay3.chinabank.com.cn/PayGate?encoding=UTF-8\"  method=\"post\" name=\"E_FORM\">");
            sbHtml.AppendFormat("<input type=\"hidden\" name=\"v_md5info\" value=\"{0}\" size=\"100\" />", v_md5info);
            sbHtml.AppendFormat("<input type=\"hidden\" name=\"v_mid\" value=\"{0}\" />", v_mid);
            sbHtml.AppendFormat("<input type=\"hidden\" name=\"v_oid\" value=\"{0}\" />", v_oid);
            sbHtml.AppendFormat("<input type=\"hidden\" name=\"v_amount\" value=\"{0}\" />", v_amount);
            sbHtml.AppendFormat("<input type=\"hidden\" name=\"v_moneytype\" value=\"{0}\" />", v_moneytype);
            sbHtml.AppendFormat("<input type=\"hidden\" name=\"v_url\" value=\"{0}\" />", v_url);

            //<!--以下几项项为网上支付完成后,随支付反馈信息一同传给信息接收页-->
            sbHtml.Append("<input type=\"hidden\"  name=\"remark1\" value=\"\" />");
            sbHtml.AppendFormat("<input type=\"hidden\"  name=\"remark2\" value=\"{0}\" />", remark2);
            sbHtml.Append("<input type=\"submit\" value=\"网银在线支付\"/>");
            sbHtml.Append("</form>");
            sbHtml.Append("<script>document.forms['E_FORM'].submit();</script>");
            return(Content(sbHtml.ToString()));
        }
Example #15
0
        public ActionResult Config()
        {
            ConfigModel model = new ConfigModel();

            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            model.WPMchId       = pluginSetInfo.WPMchId;
            model.WPAppId       = pluginSetInfo.WPAppId;
            model.WPAppSecret   = pluginSetInfo.WPAppSecret;
            model.WPAppKey      = pluginSetInfo.WPAppKey;
            model.OpenMchId     = pluginSetInfo.OpenMchId;
            model.OpenAppId     = pluginSetInfo.OpenAppId;
            model.OpenAppSecret = pluginSetInfo.OpenAppSecret;
            model.OpenAppKey    = pluginSetInfo.OpenAppKey;

            return(View("~/plugins/BrnShop.PayPlugin.WeChat/views/adminwechat/config.cshtml", model));
        }
Example #16
0
 /// <summary>
 /// 重置支付宝配置
 /// </summary>
 public static void ReSet()
 {
     seller_id   = PluginUtils.GetPluginSet().Seller;
     partner     = PluginUtils.GetPluginSet().Partner;
     private_key = PluginUtils.GetPluginSet().PrivateKey;
 }
Example #17
0
        /// <summary>
        /// 回调
        /// </summary>
        public ActionResult CallBack()
        {
            //返回url
            string returnUrl = WebHelper.GetQueryString("returnUrl");

            if (returnUrl.Length == 0)
            {
                returnUrl = "/";
            }

            if (WorkContext.MallConfig.LoginType == "")
            {
                return(PromptView(returnUrl, "商城目前已经关闭登陆功能!"));
            }
            if (WorkContext.Uid > 0)
            {
                return(PromptView(returnUrl, "您已经登录,无须重复登录!"));
            }

            //返回的随机值
            string backSalt = WebHelper.GetQueryString("state");
            //Authorization Code
            string code = WebHelper.GetQueryString("code");
            //保存在session中随机值
            string salt = Sessions.GetValueString(WorkContext.Sid, "qqAuthLoginSalt");

            if (backSalt.Length > 0 && code.Length > 0 && salt.Length > 0 && backSalt == salt)
            {
                //清空session中随机值
                Sessions.SetItem(WorkContext.Sid, "qqAuthLoginSalt", null);

                PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

                //构建获取Access Token的参数
                string postData = string.Format("grant_type=authorization_code&code={0}&client_id={1}&client_secret={2}&redirect_uri=http://{3}{4}",
                                                code, pluginSetInfo.AppKey, pluginSetInfo.AppSecret, BMAConfig.MallConfig.SiteUrl, Url.Action("CallBack"));
                //发送获得Access Token的请求
                string result = WebHelper.GetRequestData(pluginSetInfo.AuthUrl + "/oauth2.0/token", postData);
                //将返回结果解析成参数列表
                NameValueCollection parmList = WebHelper.GetParmList(result);
                //Access Token值
                string access_token = parmList["access_token"];

                //通过上一步获取的Access Token,构建获得对应用户身份的OpenID的url
                string url = string.Format("{0}/oauth2.0/me?access_token={1}", pluginSetInfo.AuthUrl, access_token);
                //发送获得OpenID的请求
                result = WebHelper.GetRequestData(url, "get", null);
                //移除返回结果开头的“callback(”和结尾的“);”字符串
                string json = StringHelper.TrimEnd(StringHelper.TrimStart(result, "callback("), ");");
                //OpenID值
                string openId = JSON.ToObject <PartOAuthUser>(json).OpenId;


                //判断此用户是否已经存在
                int uid = OAuths.GetUidByOpenIdAndServer(openId, pluginSetInfo.Server);
                if (uid > 0)//存在时
                {
                    PartUserInfo partUserInfo = Users.GetPartUserById(uid);
                    //更新用户最后访问
                    Users.UpdateUserLastVisit(partUserInfo.Uid, DateTime.Now, WorkContext.IP, WorkContext.RegionId);
                    //更新购物车中用户id
                    Carts.UpdateCartUidBySid(partUserInfo.Uid, WorkContext.Sid);
                    MallUtils.SetUserCookie(partUserInfo, -1);

                    return(Redirect("/"));
                }
                else
                {
                    //获取用户信息的url
                    url = string.Format("{0}/user/get_user_info?access_token={1}&oauth_consumer_key={2}&openid={3}",
                                        pluginSetInfo.AuthUrl, access_token, pluginSetInfo.AppKey, openId);
                    //发送获取用户信息的请求
                    result = WebHelper.GetRequestData(url, "get", null);
                    //将返回结果序列化为对象
                    OAuthUser oAuthUser = JSON.ToObject <OAuthUser>(result);
                    if (oAuthUser.Ret == 0)//当没有错误时
                    {
                        UserInfo userInfo = OAuths.CreateOAuthUser(oAuthUser.Nickname, pluginSetInfo.UNamePrefix, openId, pluginSetInfo.Server, WorkContext.RegionId);
                        if (userInfo != null)
                        {
                            //发放注册积分
                            Credits.SendRegisterCredits(ref userInfo, DateTime.Now);
                            //更新购物车中用户id
                            Carts.UpdateCartUidBySid(userInfo.Uid, WorkContext.Sid);
                            MallUtils.SetUserCookie(userInfo, -1);
                            return(Redirect("/"));
                        }
                        else
                        {
                            return(PartialView("用户创建失败"));
                        }
                    }
                    else
                    {
                        return(PartialView("QQ授权登陆失败"));
                    }
                }
            }
            else
            {
                return(Redirect("/"));
            }
        }
Example #18
0
        /// <summary>
        /// 通知调用
        /// </summary>
        public ActionResult Notify()
        {
            PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();

            // 如果您还没有设置MD5密钥请登陆我们为您提供商户后台,地址:https://merchant3.chinabank.com.cn/
            // 登陆后在上面的导航栏里可能找到“B2C”,在二级导航栏里有“MD5密钥设置”
            // 建议您设置一个16位以上的密钥或更高,密钥最多64位,但设置16位已经足够了
            string key = pluginSetInfo.Key;

            string  v_oid       = WebHelper.GetRequestString("v_oid");
            string  v_pstatus   = WebHelper.GetRequestString("v_pstatus");
            string  v_pstring   = WebHelper.GetRequestString("v_pstring");
            string  v_pmode     = WebHelper.GetRequestString("v_pmode");
            string  v_md5str    = WebHelper.GetRequestString("v_md5str");
            decimal v_amount    = TypeHelper.StringToDecimal(WebHelper.GetRequestString("v_amount"));
            string  v_moneytype = WebHelper.GetRequestString("v_moneytype");
            string  remark1     = WebHelper.GetRequestString("remark1");
            string  remark2     = WebHelper.GetRequestString("remark2");

            string str = v_oid + v_pstatus + v_amount + v_moneytype + key;

            str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToUpper();

            if (str == v_md5str)
            {
                if (v_pstatus.Equals("20"))
                {
                    List <OrderInfo> orderList = new List <OrderInfo>();
                    foreach (string oid in StringHelper.SplitString(v_oid))
                    {
                        OrderInfo orderInfo = Orders.GetOrderByOid(TypeHelper.StringToInt(oid));
                        orderList.Add(orderInfo);
                    }
                    decimal allSurplusMoney = 0M;
                    foreach (OrderInfo orderInfo in orderList)
                    {
                        allSurplusMoney += orderInfo.SurplusMoney;
                    }

                    //支付成功
                    if (orderList.Count > 0 && allSurplusMoney <= v_amount)
                    {
                        foreach (OrderInfo orderInfo in orderList)
                        {
                            if (orderInfo.SurplusMoney > 0 && orderInfo.OrderState == (int)OrderState.WaitPaying)
                            {
                                Orders.PayOrder(orderInfo.Oid, OrderState.Confirming, "", DateTime.Now);
                                OrderActions.CreateOrderAction(new OrderActionInfo()
                                {
                                    Oid        = orderInfo.Oid,
                                    Uid        = orderInfo.Uid,
                                    RealName   = "本人",
                                    ActionType = (int)OrderActionType.Pay,
                                    ActionTime = DateTime.Now,
                                    ActionDes  = "你使用网银在线支付订单成功,支付银行为:" + v_pmode
                                });
                            }
                        }
                    }
                }
                return(Content("ok"));
            }
            else
            {
                return(Content("error"));
            }
        }