Ejemplo n.º 1
0
        /// <summary>
        /// Install plugin
        /// </summary>
        public override void Install()
        {
            // Initialize database
            System.Data.Entity.Database.SetInitializer(new StripeDatabaseInitializer());

            // initialize and create database
            using (var context = new Plugin.Payment.Stripe.Data.StripeContext())
            {
                context.Database.Initialize(true);
                context.SaveChanges();
            }

            // Add settings
            _settingDictionaryService.Insert(new BeYourMarket.Model.Models.SettingDictionary()
            {
                Name = SettingStripeApiKey,
                Value = "sk_test_kUNQFEh3YLbEFEa38tbeMJLV",
                Created = DateTime.Now,
                LastUpdated = DateTime.Now,
                ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added,
                SettingID = CacheHelper.Settings.ID
            });

            _settingDictionaryService.Insert(new BeYourMarket.Model.Models.SettingDictionary()
            {
                Name = SettingStripePublishableKey,
                Value = "pk_test_EfbP8SfcALEJ8Jk2JxtSxmqe",
                Created = DateTime.Now,
                LastUpdated = DateTime.Now,
                ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added,
                SettingID = CacheHelper.Settings.ID
            });

            _settingDictionaryService.Insert(new BeYourMarket.Model.Models.SettingDictionary()
            {
                Name = SettingStripeClientID,
                Value = "ca_6Rh18px61rjCEZIav5ItunZ1mKD8YjvU",
                Created = DateTime.Now,
                LastUpdated = DateTime.Now,
                ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added,
                SettingID = CacheHelper.Settings.ID
            });

            _unitOfWorkAsync.SaveChanges();

            base.Install();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Uninstall plugin
        /// </summary>
        public override void Uninstall()
        {
            // Remove settings
            var settings = _settingDictionaryService.Query(
                x => x.Name == SettingStripeApiKey ||
                     x.Name == SettingStripePublishableKey ||
                     x.Name == SettingStripeClientID).Select();

            foreach (var setting in settings)
            {
                _settingDictionaryService.Delete(setting);
            }

            _unitOfWorkAsync.SaveChanges();

            var context = new Plugin.Payment.Stripe.Data.StripeContext();
            context.DeletePluginData<Plugin.Payment.Stripe.Data.StripeContext>();

            base.Uninstall();
        }