コード例 #1
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            string       weixinAppId    = masterSettings.WeixinAppId;

            masterSettings.WeixinAppId         = this.txtAppId.Text;
            masterSettings.WeixinAppSecret     = this.txtAppSecret.Text;
            masterSettings.IsValidationService = this.ooIsValidationService.SelectedValue;
            masterSettings.WeixinNumber        = this.txtWeixinNumber.Text;
            masterSettings.WeixinLoginUrl      = this.txtWeixinLoginUrl.Text;
            masterSettings.OpenManyService     = this.ooManyService.SelectedValue;
            masterSettings.EnableVshopReferral = this.ooShowReferral.SelectedValue;
            masterSettings.IsForceAttention    = this.ooIsForceAttention.SelectedValue;
            if (masterSettings.IsForceAttention)
            {
                masterSettings.WeixinGuideAttention = masterSettings.IsForceAttention;
            }
            else
            {
                masterSettings.WeixinGuideAttention = this.ooWeixinGuideAttention.SelectedValue;
            }
            if (string.IsNullOrEmpty(masterSettings.WeixinAppId) || string.IsNullOrEmpty(masterSettings.WeixinAppSecret))
            {
                masterSettings.WeixinGuideAttention = false;
                masterSettings.IsForceAttention     = false;
            }
            if (weixinAppId != masterSettings.WeixinAppId)
            {
                WXFansHelper.ClearFansData();
                masterSettings.IsInitWXFansInteractData = false;
                masterSettings.IsInitWXFansData         = false;
            }
            if (string.IsNullOrEmpty(masterSettings.WeixinAppId) || string.IsNullOrEmpty(masterSettings.WeixinAppSecret))
            {
                this.ooWeixinGuideAttention.Visible      = false;
                this.hspanWeixinGuideAttention.Visible   = true;
                this.hspanWeixinGuideAttention.InnerHtml = "您尚未填写您的AppId和AppSecret";
                this.ooIsForceAttention.Visible          = false;
                this.hspanWeixinGuideAttention.Visible   = true;
                this.hspanWeixinGuideAttention.InnerHtml = "您尚未填写您的AppId和AppSecret";
            }
            else
            {
                this.ooWeixinGuideAttention.SelectedValue = masterSettings.WeixinGuideAttention;
                this.ooIsForceAttention.SelectedValue     = masterSettings.IsForceAttention;
                this.ooIsForceAttention.Visible           = true;
                this.hspanIsForceAttention.Visible        = false;
                this.ooWeixinGuideAttention.Visible       = true;
                this.hspanWeixinGuideAttention.Visible    = false;
            }
            SettingsManager.Save(masterSettings);
            this.ShowMsg("修改成功", true);
        }
コード例 #2
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            if (masterSettings.IsDemoSite)
            {
                this.ShowMsg("演示站不允许修改支付配置信息", false);
            }
            else
            {
                if (this.radEnableWxPay.SelectedValue || this.radEnableWxH5Pay.SelectedValue)
                {
                    if (string.IsNullOrEmpty(this.txtAppId.Text))
                    {
                        this.ShowMsg("微信支付AppId不能为空!", false);
                        return;
                    }
                    if (string.IsNullOrEmpty(this.txtAppSecret.Text))
                    {
                        this.ShowMsg("微信支付AppSecret不能为空!", false);
                        return;
                    }
                    if (string.IsNullOrEmpty(this.txtPartnerID.Text))
                    {
                        this.ShowMsg("微信支付mch_id不能为空!", false);
                        return;
                    }
                    if (string.IsNullOrEmpty(this.txtPartnerKey.Text))
                    {
                        this.ShowMsg("微信支付Key不能为空!", false);
                        return;
                    }
                }
                string weixinCertPath = this.txtCerFileName.Text;
                if (this.file_UploadCert.HasFile)
                {
                    if (!Globals.ValidateCertFile(this.file_UploadCert.PostedFile.FileName))
                    {
                        this.ShowMsg("非法的证书文件", false);
                        return;
                    }
                    string newFileName = this.GetNewFileName(this.file_UploadCert.PostedFile.FileName);
                    this.file_UploadCert.PostedFile.SaveAs(base.Server.MapPath("~/pay/cert/") + newFileName);
                    weixinCertPath = "/pay/cert/" + newFileName;
                }
                string weixinAppId = this.setting.WeixinAppId;
                this.setting.WeixinAppId     = this.txtAppId.Text;
                this.setting.WeixinAppSecret = this.txtAppSecret.Text;
                this.setting.WeixinPartnerID = this.txtPartnerID.Text;
                if (this.txtPartnerKey.Text.Replace("*", "").Length != 6)
                {
                    this.setting.WeixinPartnerKey = this.txtPartnerKey.Text;
                }
                this.setting.WeixinPaySignKey    = this.txtPaySignKey.Text;
                this.setting.EnableWeiXinRequest = this.radEnableWxPay.SelectedValue;
                this.setting.EnableWapWeiXinPay  = this.radEnableWxH5Pay.SelectedValue;
                this.setting.OpenAppWxPay        = this.radEnableAppWxPay.SelectedValue;
                this.setting.WeixinCertPath      = weixinCertPath;
                if (this.OnOffServiceMode.SelectedValue)
                {
                    string text  = Globals.StripAllTags(this.txtMainAppID.Text);
                    string text2 = Globals.StripAllTags(this.txtMainMchID.Text);
                    if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2))
                    {
                        this.ShowMsg("开启了服务商模式,请输入服务商商户ID和服务商AppID", false);
                        return;
                    }
                    this.setting.Main_AppId  = text;
                    this.setting.Main_Mch_ID = text2;
                }
                else
                {
                    this.setting.Main_AppId  = "";
                    this.setting.Main_Mch_ID = "";
                }
                if (string.IsNullOrEmpty(this.setting.Main_Mch_ID))
                {
                    this.setting.WeixinCertPassword = this.txtPartnerID.Text;
                }
                else
                {
                    this.setting.WeixinCertPassword = this.setting.Main_Mch_ID;
                }
                if (weixinAppId != this.setting.WeixinAppId)
                {
                    WXFansHelper.ClearFansData();
                    this.setting.IsInitWXFansInteractData = false;
                    this.setting.IsInitWXFansData         = false;
                }
                if (this.radEnableWxQrcodePay.SelectedValue)
                {
                    string text3 = "";
                    text3 = ((string.IsNullOrEmpty(this.setting.Main_AppId) || string.IsNullOrEmpty(this.setting.Main_Mch_ID)) ? $"<xml><AppId>{this.setting.WeixinAppId}</AppId><MCHID>{this.setting.WeixinPartnerID}</MCHID><AppSecret>{this.setting.WeixinPartnerKey}</AppSecret><CertPath>{this.setting.WeixinCertPath}</CertPath></xml>" : $"<xml><AppId>{this.setting.Main_AppId}</AppId><MCHID>{this.setting.Main_Mch_ID}</MCHID><AppSecret>{this.setting.WeixinPartnerKey}</AppSecret><Sub_AppId>{this.setting.WeixinAppId}</Sub_AppId><Sub_mch_Id>{this.setting.WeixinPartnerID}</Sub_mch_Id><CertPath>{this.setting.WeixinCertPath}</CertPath></xml>");
                    if (this.wxQrCodePay == null)
                    {
                        PaymentModeInfo paymentMode = new PaymentModeInfo
                        {
                            Name            = "微信扫码支付",
                            Gateway         = "hishop.plugins.payment.wxqrcode.wxqrcoderequest",
                            Description     = string.Empty,
                            IsUseInpour     = this.OnOffPcInpour.SelectedValue,
                            ApplicationType = PayApplicationType.payOnPC,
                            Settings        = HiCryptographer.Encrypt(text3)
                        };
                        SalesHelper.CreatePaymentMode(paymentMode);
                    }
                    else
                    {
                        PaymentModeInfo paymentModeInfo = this.wxQrCodePay;
                        paymentModeInfo.Settings        = HiCryptographer.Encrypt(text3);
                        paymentModeInfo.ApplicationType = PayApplicationType.payOnPC;
                        paymentModeInfo.IsUseInpour     = this.OnOffPcInpour.SelectedValue;
                        SalesHelper.UpdatePaymentMode(paymentModeInfo);
                    }
                }
                else if (this.wxQrCodePay != null)
                {
                    SalesHelper.DeletePaymentMode(this.wxQrCodePay.ModeId);
                }
                SettingsManager.Save(this.setting);
                this.ShowMsg("保存支付设置成功", true, "");
            }
        }