public static void UpdateSettingsDictionary(int storeId, short paymentProviderId, Dictionary <string, string> settings)
        {
            using (esTransactionScope transaction = new esTransactionScope())
            {
                // DELETE all existing settings for this store/provider
                StorePaymentProviderSettingQuery qDelete = new StorePaymentProviderSettingQuery();
                qDelete.Where(qDelete.StoreId == storeId, qDelete.PaymentProviderId == paymentProviderId);
                StorePaymentProviderSettingCollection oldSettings = new StorePaymentProviderSettingCollection();
                oldSettings.Load(qDelete);
                oldSettings.MarkAllAsDeleted();
                oldSettings.Save();

                // INSERT new settings for this store/provider
                if (settings.Keys.Count > 0)
                {
                    StorePaymentProviderSettingCollection newSettings = new StorePaymentProviderSettingCollection();
                    foreach (KeyValuePair <string, string> setting in settings)
                    {
                        StorePaymentProviderSetting newSetting = newSettings.AddNew();
                        newSetting.StoreId           = storeId;
                        newSetting.PaymentProviderId = paymentProviderId;
                        newSetting.Name  = setting.Key;
                        newSetting.Value = setting.Value;
                    }
                    newSettings.Save();
                }

                transaction.Complete();
            }
        }
Пример #2
0
        public void UpdatePaymentProviderConfig(ProviderConfig config)
        {
            int storeId = this.Id.Value;

            PaymentProvider provider = PaymentProvider.Get(config.ProviderId.GetValueOrDefault(-1));

            StorePaymentProvider storePaymentProvider = StorePaymentProvider.GetOrCreate(storeId, provider.Id.Value);

            //storePaymentProvider.IsEnabled = config.IsEnabled;
            storePaymentProvider.Save();

            StorePaymentProviderSettingCollection.UpdateSettingsDictionary(storeId, provider.Id.Value, config.Settings);
        }
Пример #3
0
        public List <ProviderConfig> GetPaymentProviderConfigs()
        {
            List <ProviderConfig> paymentConfigs = new List <ProviderConfig>();

            foreach (StorePaymentProvider spp in this.StorePaymentProviderCollectionByStoreId)
            {
                ProviderConfig config = new ProviderConfig();
                config.ProviderId = spp.UpToPaymentProviderByPaymentProviderId.Id;
                //config.IsEnabled = spp.IsEnabled.GetValueOrDefault();
                config.Settings = StorePaymentProviderSettingCollection.GetSettingsDictionary(spp.StoreId.Value, spp.PaymentProviderId.Value);

                paymentConfigs.Add(config);
            }

            return(paymentConfigs);
        }