Пример #1
0
        protected void btnBuySafeSignUp_Click(Object sender, EventArgs e)
        {
            BuySafeRegistrationStatus s = BuySafeController.BuySafeOneClickSignup();

            if (s.Sucessful)
            {
                pnlBuySafeSignUp.Visible = false;
                SetPageState(BuySafeState.EnabledOnFreeTrial);
                SetError("You have successfully registered with BuySafe.", false);
            }
            else if (!string.IsNullOrEmpty(s.ErrorMessage))
            {
                SetError(s.ErrorMessage, true);
            }
            else
            {
                SetPageState(BuySafeState.Error);
            }
        }
Пример #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            bool BadSSL = false;

            // save the config settings:
            AtomStoreZip.Save();
            AtomLiveServer.Save();

            StringBuilder errors = new StringBuilder();

            if (AppLogic.TrustLevel == AspNetHostingPermissionLevel.Unrestricted)
            {
                WebConfigManager webMgr = new WebConfigManager();
                if (webMgr.ProtectWebConfig != rblEncrypt.SelectedValue.Equals("true", StringComparison.InvariantCultureIgnoreCase) || rblStaticMachineKey.SelectedValue.Equals("true", StringComparison.InvariantCultureIgnoreCase))
                {
                    webMgr.ProtectWebConfig = rblEncrypt.SelectedValue.Equals("true", StringComparison.InvariantCultureIgnoreCase);

                    if (rblStaticMachineKey.SelectedValue.Equals("true", StringComparison.InvariantCultureIgnoreCase))
                    {
                        webMgr.SetMachineKey          = true;
                        webMgr.ValidationKeyGenMethod = WebConfigManager.KeyGenerationMethod.Auto;
                        webMgr.DecryptKeyGenMethod    = WebConfigManager.KeyGenerationMethod.Auto;
                    }

                    List <Exception> saveWebConfigExceptions = webMgr.Commit();

                    WebConfigManager webMgrNew = new WebConfigManager();

                    if (saveWebConfigExceptions.Count > 0 && (webMgr.ProtectWebConfig != webMgrNew.ProtectWebConfig || rblStaticMachineKey.SelectedValue.EqualsIgnoreCase("true")))
                    {
                        if (webMgr.ProtectWebConfig != webMgrNew.ProtectWebConfig)
                        {
                            errors.Append("Your web config encryption could not be changed due to the following error(s): <br />");
                        }
                        if (rblStaticMachineKey.SelectedValue.EqualsIgnoreCase("true"))
                        {
                            errors.Append("Could not set static machine key due to the following error(s): <br />");
                        }
                        foreach (Exception ex in saveWebConfigExceptions)
                        {
                            errors.Append(ex.Message + "<br />");
                        }
                    }
                }
            }

            if (AtomStoreUseSSL.GetValue(AppLogic.StoreID()).ToBool() || AtomStoreUseSSL.GetValue(0).ToBool())
            {
                BadSSL = true;
                String        WorkerWindowInSSL = String.Empty;
                List <string> urlsToTry         = new List <string>();
                urlsToTry.Add(AppLogic.GetStoreHTTPLocation(false).Replace("http://", "https://") + "empty.htm");
                urlsToTry.Add(AppLogic.GetStoreHTTPLocation(false).Replace("http://", "https://").Replace("https://", "https://www.") + "empty.htm");

                foreach (String urlToTry in urlsToTry)
                {
                    if (BadSSL)
                    {
                        try
                        {
                            WorkerWindowInSSL = CommonLogic.AspHTTP(AppLogic.GetStoreHTTPLocation(false).Replace("http://", "https://") + "empty.htm", 10);
                        }
                        catch { }

                        if (WorkerWindowInSSL.IndexOf("Worker") != -1)
                        {
                            AtomStoreUseSSL.Save();
                            BadSSL = false;
                            break;
                        }
                    }
                }
            }
            else
            {
                AtomStoreUseSSL.Save();
            }

            AtomLiveServer.Save();
            AtomStoreCurrency.Save();
            AtomStoreCurrencyNumeric.Save();
            AtomStoreName.Save();
            AtomStoreLiveTransactions.Save();

            string temp = GetCheckedPaymentMethods();

            AppConfig config = AppLogic.GetAppConfig(0, "UseSSL");

            config = AppLogic.GetAppConfig(0, "PaymentMethods");
            if (config != null)
            {
                if (temp.Length > 0)
                {
                    config.ConfigValue = temp;
                }
                else
                {
                    config.ConfigValue = string.Empty;
                }
            }

            config = AppLogic.GetAppConfig(0, "Micropay.Enabled");
            if (config != null)
            {
                if (temp.IndexOf(AppLogic.ro_PMMicropay, StringComparison.InvariantCultureIgnoreCase) != -1)
                {
                    config.ConfigValue = "true"; // preserve setting of obsolete appconfig
                }
                else
                {
                    config.ConfigValue = "false"; // preserve setting of obsolete appconfig
                }
            }

            config = AppLogic.GetAppConfig(0, "PaymentGateway");
            if (config != null)
            {
                string newGateway        = getSelectedGateway();
                string newGatewayProduct = getSelectedGatewayProduct();

                if (!String.IsNullOrEmpty(newGateway))
                {
                    config.ConfigValue = newGateway;
                }

                if (newGateway == "PayFlowPro")
                {
                    var payFlowProProduct = AppLogic.GetAppConfig(0, "PayFlowPro.Product");
                    payFlowProProduct.ConfigValue = newGatewayProduct;

                    // If PPA Gateway is selected, then set the PPA Method
                    if (newGatewayProduct == "PayPal Payments Advanced")
                    {
                        if (!temp.Contains("PayPalEmbeddedCheckout"))
                        {
                            var ppaConfig = AppLogic.GetAppConfig(0, "PaymentMethods");
                            ppaConfig.ConfigValue += ", PayPalEmbeddedCheckout";
                        }
                    }

                    // if any PayFlow gateway is selected, select PayPalExpress
                    if (!temp.Contains("PayPalExpress"))
                    {
                        var ppeConfig = AppLogic.GetAppConfig(0, "PaymentMethods");
                        ppeConfig.ConfigValue   += ", PayPalExpress";
                        cbxPayPalExpress.Checked = true;
                    }
                }
            }

            if ("WIZARD".Equals(AppLogic.AppConfig("OrderShowCCPwd", 0, false), StringComparison.InvariantCultureIgnoreCase))
            {
                config = AppLogic.GetAppConfig(0, "OrderShowCCPwd");
                if (config != null)
                {
                    config.ConfigValue = CommonLogic.GetRandomNumber(1000, 1000000).ToString() + CommonLogic.GetRandomNumber(1000, 1000000).ToString() + CommonLogic.GetRandomNumber(1000, 1000000).ToString();
                }
            }

            string BuySafeMessage = string.Empty;

            if (rblBuySafeEnabled.SelectedIndex == 1)
            {
                BuySafeRegistrationStatus bss = BuySafeController.BuySafeOneClickSignup();
                if (!bss.Sucessful)
                {
                    BuySafeMessage = "<br/><b style=\"color:red;\">buySAFE could not be enabled.{0}";
                    errors.Append(string.Format(BuySafeMessage, (string.IsNullOrEmpty(bss.ErrorMessage) ? "" : " Error message: " + bss.ErrorMessage)));
                }
            }

            if (BadSSL)
            {
                errors.Append("No SSL certificate was found on your site. Please check with your hosting company! You must be able to invoke your store site using https:// before turning SSL on in this admin site!<br />");
            }

            if (errors.ToString().Length > 0)
            {
                resetError(errors.ToString(), true);
            }
            else
            {
                resetError("Configuration Wizard completed successfully.", false);
            }

            loadData();
        }