protected void Page_Load(object sender, EventArgs e) { Boolean isCallback = CommonLogic.QueryStringBool("callback"); pnlActivationForm.Visible = !isCallback; pnlActivationSuccess.Visible = isCallback; if (isCallback) { GlobalConfig ActivationSubmitted = GlobalConfig.getGlobalConfig("BuySafe.ActivationSubmitted"); if (ActivationSubmitted == null) { GlobalConfig.CreateGlobalConfig("BuySafe.ActivationSubmitted", "BUYSAFE", "If true the lead activation form will not be displayed.", "true", "boolean"); } else { ActivationSubmitted.ConfigValue = "true"; ActivationSubmitted.Save(); } GlobalConfig.LoadGlobalConfigs(); } else if (!AppLogic.GlobalConfigBool("BuySafe.ActivationSubmitted")) { List <Store> stores = Store.GetStoreList(true); Store s = BuySafeController.GetDefaultStore(stores); litAccountHash.Text = AppLogic.GlobalConfig("BuySafe.Hash"); litStoreUrl.Text = s.ProductionURI; litCompanyName.Text = s.Name; litReturnURL.Text = Request.Url.AbsoluteUri + "?callback=true"; } else { pnlActivationSuccess.Visible = pnlActivationForm.Visible = false; } }
protected void loadData() { var BadSSL = CommonLogic.QueryStringBool("BadSSL"); if (BadSSL) { ctrlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.wizard.BadSSL", ThisCustomer.LocaleSetting), AlertMessage.AlertType.Error); } BuildPaymentMethodList(AppLogic.AppConfig("PaymentMethods", 0, false)); if (AppLogic.TrustLevel == AspNetHostingPermissionLevel.Unrestricted) { var webconfig = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); var appsettings = (AppSettingsSection)webconfig.GetSection("appSettings"); var connectionStrings = (ConnectionStringsSection)webconfig.GetSection("connectionStrings"); rblEncrypt.Items.FindByValue((appsettings.SectionInformation.IsProtected && connectionStrings.SectionInformation.IsProtected).ToString().ToLowerInvariant()).Selected = true; var mkeysec = (MachineKeySection)webconfig.GetSection("system.web/machineKey"); if (mkeysec.ValidationKey.Equals("autogenerate", StringComparison.InvariantCultureIgnoreCase)) { rblStaticMachineKey.Items.FindByValue("false").Selected = true; ltStaticMachineKey.Text = AppLogic.GetString("admin.wizard.SetStaticMachineKey", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); } else { rblStaticMachineKey.Items.FindByValue("false").Selected = true; ltStaticMachineKey.Text = AppLogic.GetString("admin.wizard.ChangeStaticMachineKey", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); } } switch (BuySafeController.GetBuySafeState()) { case BuySafeState.NotEnabledFreeTrialAvailable: break; case BuySafeState.EnabledFullUserAfterFreeTrial: case BuySafeState.EnabledOnFreeTrial: pnlBuySafeActive.Visible = true; pnlBuySafeInactive.Visible = false; litBuySafeActiveMsg.Text = "buySAFE is enabled"; break; case BuySafeState.EnabledFreeTrialExpired: case BuySafeState.NotEnabledFreeTrialExpired: pnlBuySafeActive.Visible = true; pnlBuySafeInactive.Visible = false; litBuySafeActiveMsg.Text = "<span style='line-height:normal;'>Trial expired. Please contact buySAFE to enable your account.<br />Call 1.888.926.6333 | Email: <a href='mailto:[email protected]'>[email protected]</a></span>"; break; case BuySafeState.Error: pnlBuySafeActive.Visible = true; pnlBuySafeInactive.Visible = false; litBuySafeActiveMsg.Text = "<span style='line-height:normal;'>Please contact buySAFE to enable your account.<br />Call 1.888.926.6333 | Email: <a href='mailto:[email protected]'>[email protected]</a></span>"; break; } }
protected void btnRegisterStore_Click(Object sender, EventArgs e) { Button btn = (Button)sender; int StoreId; if (int.TryParse(btn.CommandArgument, out StoreId)) { BuySafeController.RegisterStore(Store.GetStoreList().FirstOrDefault(s => s.StoreID == StoreId)); SetupStoreLists(); } }
private void SetPageState(BuySafeState pageState) { toppnlEnabledFreeTrialExpired.Visible = toppnlWorking.Visible = pnlFreeTrialStatus.Visible = toppnlError.Visible = toppnlNotEnabledFreeTrialAvailable.Visible = toppnlNotEnabledFreeTrialExpired.Visible = pnlActivationForm.Visible = false; switch (pageState) { case BuySafeState.NotEnabledFreeTrialAvailable: toppnlNotEnabledFreeTrialAvailable.Visible = true; break; case BuySafeState.NotEnabledFreeTrialExpired: toppnlNotEnabledFreeTrialExpired.Visible = true; break; case BuySafeState.EnabledFreeTrialExpired: toppnlEnabledFreeTrialExpired.Visible = true; break; case BuySafeState.EnabledOnFreeTrial: pnlFreeTrialStatus.Visible = true; int daysremaining = BuySafeController.DaysRemainingOnTrial(); litFreeDaysRemaining.Text = string.Format("You have {0} days remaining on your free trial.", daysremaining); toppnlWorking.Visible = true; pnlActivationForm.Visible = !AppLogic.GlobalConfigBool("BuySafe.ActivationSubmitted"); pnlActivated.Visible = AppLogic.GlobalConfigBool("BuySafe.ActivationSubmitted"); SetupStoreLists(); break; case BuySafeState.EnabledFullUserAfterFreeTrial: pnlFreeTrialStatus.Visible = false; toppnlWorking.Visible = true; pnlActivated.Visible = true; SetupStoreLists(); break; case BuySafeState.Error: default: toppnlError.Visible = true; break; } }
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); } }
private void ChooseInitialDisplay() { SetPageState(BuySafeController.GetBuySafeState()); }
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(); }
protected void loadData() { bool BadSSL = CommonLogic.QueryStringBool("BadSSL"); if (BadSSL) { resetError("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!", false); } String PM = AppLogic.AppConfig("PaymentMethods", 0, false).ToUpperInvariant(); BuildPaymentMethodList(PM); if (AppLogic.TrustLevel == AspNetHostingPermissionLevel.Unrestricted) { Configuration webconfig = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); AppSettingsSection appsettings = (AppSettingsSection)webconfig.GetSection("appSettings"); rblEncrypt.Items.FindByValue(appsettings.SectionInformation.IsProtected.ToString().ToLowerInvariant()).Selected = true; MachineKeySection mkeysec = (MachineKeySection)webconfig.GetSection("system.web/machineKey"); if (mkeysec.ValidationKey.Equals("autogenerate", StringComparison.InvariantCultureIgnoreCase)) { rblStaticMachineKey.Items.FindByValue("false").Selected = true; ltStaticMachineKey.Text = AppLogic.GetString("admin.wizard.SetStaticMachineKey", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); } else { rblStaticMachineKey.Items.FindByValue("false").Selected = true; ltStaticMachineKey.Text = AppLogic.GetString("admin.wizard.ChangeStaticMachineKey", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); } } switch (BuySafeController.GetBuySafeState()) { case BuySafeState.NotEnabledFreeTrialAvailible: break; case BuySafeState.EnabledFullUserAfterFreeTrial: case BuySafeState.EnabledOnFreeTrial: pnlBuySafeActive.Visible = true; pnlBuySafeInactive.Visible = false; litBuySafeActiveMsg.Text = "buySAFE is enabled"; break; case BuySafeState.EnabledFreeTrialExpired: case BuySafeState.NotEnabledFreeTrialExpired: pnlBuySafeActive.Visible = true; pnlBuySafeInactive.Visible = false; litBuySafeActiveMsg.Text = "<span style=\"line-height:normal;\">Trial expired. Please contact buySAFE to enable your account.<br />Call 1.888.926.6333 | Email: <a href=\"mailto:[email protected]\">[email protected]</a></span>"; break; case BuySafeState.Error: pnlBuySafeActive.Visible = true; pnlBuySafeInactive.Visible = false; litBuySafeActiveMsg.Text = "<span style=\"line-height:normal;\">Please contact buySAFE to enable your account.<br />Call 1.888.926.6333 | Email: <a href=\"mailto:[email protected]\">[email protected]</a></span>"; break; } }
protected void btnSubmit_Click(object sender, EventArgs e) { Page.Validate(); if (!Page.IsValid) { return; } var BadSSL = false; // save the config settings: AtomStoreZip.Save(); AtomLiveServer.Save(); if (AtomStoreUseSSL.GetValue(AppLogic.StoreID()).ToBool() || AtomStoreUseSSL.GetValue(0).ToBool()) { BadSSL = true; var WorkerWindowInSSL = string.Empty; var 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 (var urlToTry in urlsToTry) { if (BadSSL) { WorkerWindowInSSL = CommonLogic.AspHTTP(urlToTry, 10); if (!string.IsNullOrEmpty(WorkerWindowInSSL) && WorkerWindowInSSL.IndexOf("Worker") != -1) { AtomStoreUseSSL.Save(); BadSSL = false; break; } } } } else { AtomStoreUseSSL.Save(); } AtomLiveServer.Save(); AtomStoreCurrency.Save(); AtomStoreCurrencyNumeric.Save(); AtomStoreName.Save(); AtomStoreLiveTransactions.Save(); var checkedPaymentMethods = GetCheckedPaymentMethods(); AppConfigManager.SetAppConfigValue("PaymentMethods", checkedPaymentMethods); if (AppConfigManager.AppConfigExists("PaymentGateway")) { var newGateway = getSelectedGateway(); if (!string.IsNullOrEmpty(newGateway)) { AppConfigManager.SetAppConfigValue("PaymentGateway", newGateway); } if (newGateway == "PayFlowPro") { var newGatewayProduct = getSelectedGatewayProduct(); AppConfigManager.SetAppConfigValue("PayFlowPro.Product", newGatewayProduct); // If PPA Gateway is selected, then set the PPA Method if (newGatewayProduct == "PayPal Payments Advanced") { if (!checkedPaymentMethods.Contains("PayPalPaymentsAdvanced")) { var currentPaymentMethods = AppConfigManager.GetAppConfigValue("PaymentMethods"); AppConfigManager.SetAppConfigValue("PaymentMethods", string.Format("{0}, PayPalPaymentsAdvanced", currentPaymentMethods)); } } // if any PayFlow gateway is selected, select PayPalExpress if (!checkedPaymentMethods.Contains("PayPalExpress")) { var currentPaymentMethods = AppConfigManager.GetAppConfigValue("PaymentMethods"); AppConfigManager.SetAppConfigValue("PaymentMethods", string.Format("{0}, PayPalExpress", currentPaymentMethods)); cbxPayPalExpress.Checked = true; } } } string BuySafeMessage = string.Empty; if (rblBuySafeEnabled.SelectedIndex == 1) { var bss = BuySafeController.BuySafeOneClickSignup(); if (!bss.Sucessful) { BuySafeMessage = "buySAFE could not be enabled.{0}"; var buysafeResponse = string.IsNullOrEmpty(bss.ErrorMessage) ? "" : " Error message: " + bss.ErrorMessage; ctrlAlertMessage.PushAlertMessage(string.Format(BuySafeMessage, buysafeResponse), AlertMessage.AlertType.Error); } } var errors = new StringBuilder(); var webMgr = new WebConfigManager(); if (AppLogic.TrustLevel == AspNetHostingPermissionLevel.Unrestricted) { 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; } var saveWebConfigExceptions = webMgr.Commit(); var 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 (var ex in saveWebConfigExceptions) { errors.Append(ex.Message + "<br />"); } } } } if (BadSSL) { errors.AppendFormat("{0}<br />", AppLogic.GetString("admin.wizard.BadSSL", ThisCustomer.LocaleSetting)); } if (!webMgr.WebConfigRequiresReload) { Response.Redirect("wizard.aspx"); } var errorMessage = errors.ToString(); if (string.IsNullOrEmpty(errorMessage)) { ctrlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.wizard.success", ThisCustomer.LocaleSetting), AlertMessage.AlertType.Success); } else { ctrlAlertMessage.PushAlertMessage(errorMessage, AlertMessage.AlertType.Error); } loadData(); }