コード例 #1
0
        public ActionResult Configure(ConfigurationModel model)
        {
            if (!ModelState.IsValid)
                return Configure();

            //load settings for a chosen store scope
            var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var payfirmaPaymentSettings = _settingService.LoadSetting<PayfirmaPaymentSettings>(storeScope);

            //save settings
            payfirmaPaymentSettings.APIKey = model.APIKey;
            payfirmaPaymentSettings.MerchantId = model.MerchantId;
            payfirmaPaymentSettings.TransactMode = (TransactMode)model.TransactModeId;
            payfirmaPaymentSettings.IsTest = model.IsTest;

            /* We do not clear cache after each setting update.
             * This behavior can increase performance because cached settings will not be cleared 
             * and loaded from database after each update */
            if (model.APIKey_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(payfirmaPaymentSettings, x => x.APIKey, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(payfirmaPaymentSettings, x => x.APIKey, storeScope);

            if (model.MerchantId_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(payfirmaPaymentSettings, x => x.MerchantId, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(payfirmaPaymentSettings, x => x.MerchantId, storeScope);

            if (model.TransactModeId_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(payfirmaPaymentSettings, x => x.TransactMode, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(payfirmaPaymentSettings, x => x.TransactMode, storeScope);

            if (model.IsTest_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(payfirmaPaymentSettings, x => x.IsTest, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(payfirmaPaymentSettings, x => x.IsTest, storeScope);

            //now clear settings cache
            _settingService.ClearCache();

            SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));

            return Configure();
        }
コード例 #2
0
        public ActionResult Configure()
        {
            //load settings for a chosen store scope
            var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var payfirmaPaymentSettings = _settingService.LoadSetting<PayfirmaPaymentSettings>(storeScope);

            var model = new ConfigurationModel();
            model.APIKey = payfirmaPaymentSettings.APIKey;
            model.MerchantId = payfirmaPaymentSettings.MerchantId;            
            model.TransactModeId = Convert.ToInt32(payfirmaPaymentSettings.TransactMode);                       
            model.TransactModeValues = payfirmaPaymentSettings.TransactMode.ToSelectList();
            model.IsTest = payfirmaPaymentSettings.IsTest;
            model.ActiveStoreScopeConfiguration = storeScope;
            if (storeScope > 0)
            {
                model.APIKey_OverrideForStore = _settingService.SettingExists(payfirmaPaymentSettings, x => x.APIKey, storeScope);
                model.MerchantId_OverrideForStore = _settingService.SettingExists(payfirmaPaymentSettings, x => x.MerchantId, storeScope);                
                model.TransactModeId_OverrideForStore = _settingService.SettingExists(payfirmaPaymentSettings, x => x.TransactMode, storeScope);
                model.IsTest_OverrideForStore = _settingService.SettingExists(payfirmaPaymentSettings, x => x.IsTest, storeScope);

            }

            return View("~/Plugins/Payments.Payfirma/Views/PaymentPayfirma/Configure.cshtml", model);
        }