public bool IsTrustedShopIdValid(ConfigurationModel model)
		{
			if (model.TrustedShopsId.IsNullOrEmpty())
				return false;

			if (model.IsTestMode)
			{
				var tsProtectionServiceSandbox = new TrustedShopsSeal.com.trustedshops.qa.TSProtectionService();
				var certStatus = new TrustedShopsSeal.com.trustedshops.qa.CertificateStatus();
				certStatus = tsProtectionServiceSandbox.checkCertificate(model.TrustedShopsId);

				return (certStatus.stateEnum == "TEST");
			}
			else
			{
				var tsProtectionServiceLive = new TrustedShopsSeal.com.trustedshops.www.TSProtectionService();
				var certStatus = new TrustedShopsSeal.com.trustedshops.www.CertificateStatus();
				certStatus = tsProtectionServiceLive.checkCertificate(model.TrustedShopsId);

				return (certStatus.stateEnum == "PRODUCTION");
			}
		}
        public ActionResult Configure()
        {
			//load settings for a chosen store scope
			var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
			var trustedShopsSealSettings = _settingService.LoadSetting<TrustedShopsSealSettings>(storeScope);

            var model = new ConfigurationModel();
            model.TrustedShopsId = trustedShopsSealSettings.TrustedShopsId;
            model.IsTestMode = trustedShopsSealSettings.IsTestMode;
            model.ShopName = trustedShopsSealSettings.ShopName;
            model.ShopText = trustedShopsSealSettings.ShopText;
            model.WidgetZone = trustedShopsSealSettings.WidgetZone;

            model.AvailableZones.Add(new SelectListItem() { Text = "Before left side column", Value = "left_side_column_before" });
            model.AvailableZones.Add(new SelectListItem() { Text = "After left side column", Value = "left_side_column_after" });
            model.AvailableZones.Add(new SelectListItem() { Text = "Before right side column", Value = "right_side_column_before" });
            model.AvailableZones.Add(new SelectListItem() { Text = "After right side column", Value = "right_side_column_after" });
            model.AvailableZones.Add(new SelectListItem() { Text = "Homepage bottom", Value = "home_page_bottom" });

			var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
			storeDependingSettingHelper.GetOverrideKeys(trustedShopsSealSettings, model, storeScope, _settingService);
            
            return View("SmartStore.Plugin.Widgets.TrustedShopsSeal.Views.TrustedShopsSeal.Configure", model);
        }
		public ActionResult Configure(ConfigurationModel model, FormCollection form)
        {
            if (!ModelState.IsValid)
                return Configure();

			//load settings for a chosen store scope
			var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
			var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
			var trustedShopsSealSettings = _settingService.LoadSetting<TrustedShopsSealSettings>(storeScope);

			bool trustedShopIdOverride = storeDependingSettingHelper.IsOverrideChecked(trustedShopsSealSettings, "TrustedShopsId", form);
			bool isTrustedShopIdValid = true;

			if (trustedShopIdOverride || storeScope == 0)	// do validation
			{
				isTrustedShopIdValid = IsTrustedShopIdValid(model);

				if (isTrustedShopIdValid)
					NotifySuccess(_localizationService.GetResource("Plugins.Widgets.TrustedShopsSeal.CheckIdSuccess"), true);
				else
					NotifyError(_localizationService.GetResource("Plugins.Widgets.TrustedShopsSeal.CheckIdError"), true);
			}

			if (isTrustedShopIdValid)	//save settings
			{
				trustedShopsSealSettings.TrustedShopsId = model.TrustedShopsId;
				trustedShopsSealSettings.IsTestMode = model.IsTestMode;
				trustedShopsSealSettings.WidgetZone = model.WidgetZone;
				trustedShopsSealSettings.ShopName = model.ShopName;
				trustedShopsSealSettings.ShopText = model.ShopText;

				storeDependingSettingHelper.UpdateSettings(trustedShopsSealSettings, form, storeScope, _settingService);
				_settingService.ClearCache();
			}

            return Configure();
        }