public ActionResult TestSms(SmsVerizonModel model)
        {
            try
            {
                if (String.IsNullOrEmpty(model.TestMessage))
                {
                    model.TestSmsResult = "Enter test message";
                }
                else
                {
                    var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("Mobile.SMS.Verizon");
                    if (pluginDescriptor == null)
                    {
                        throw new Exception("Cannot load the plugin");
                    }
                    var plugin = pluginDescriptor.Instance() as VerizonSmsProvider;
                    if (plugin == null)
                    {
                        throw new Exception("Cannot load the plugin");
                    }

                    if (!plugin.SendSms(model.TestMessage))
                    {
                        model.TestSmsResult = _localizationService.GetResource("Plugins.Sms.Verizon.TestFailed");
                    }
                    else
                    {
                        model.TestSmsResult = _localizationService.GetResource("Plugins.Sms.Verizon.TestSuccess");
                    }
                }
            }
            catch (Exception exc)
            {
                model.TestSmsResult = exc.ToString();
            }

            return(View("Nop.Plugin.SMS.Verizon.Views.SmsVerizon.Configure", model));
        }
Ejemplo n.º 2
0
        public override PlaceOrderResult PlaceOrder(ProcessPaymentRequest processPaymentRequest)
        {
            var placeOrderResult = base.PlaceOrder(processPaymentRequest);

            if (placeOrderResult.Success)
            {
                var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("Widgets.Retargeting");
                if (pluginDescriptor == null)
                {
                    throw new Exception("Cannot load the plugin");
                }

                var plugin = pluginDescriptor.Instance() as RetargetingPlugin;
                if (plugin == null)
                {
                    throw new Exception("Cannot load the plugin");
                }

                plugin.SendOrder(placeOrderResult.PlacedOrder.Id);
            }

            return(placeOrderResult);
        }
Ejemplo n.º 3
0
        public void Execute()
        {
            //is plugin installed?
            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("Moco.SmartSearch");

            if (null == pluginDescriptor)
            {
                return;
            }

            //plugin
            var plugin = pluginDescriptor.Instance() as SmartSearchPlugin;

            if (null == plugin)
            {
                return;
            }

            //TODO: We Should Stop The Execution Trail If An Error Is Occured In The Process
            plugin.GenerateSmartSearchFeed();
            plugin.UploadFeed();
            plugin.InvokeSmartSearchIndexing();
        }
Ejemplo n.º 4
0
        public IActionResult TestSms(SmsClickatellModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("Mobile.SMS.Clickatell");

            if (pluginDescriptor == null)
            {
                throw new Exception("Cannot load the plugin");
            }

            var plugin = pluginDescriptor.Instance() as ClickatellSmsProvider;

            if (plugin == null)
            {
                throw new Exception("Cannot load the plugin");
            }

            //load settings for a chosen store scope
            var storeScope         = _storeContext.ActiveStoreScopeConfiguration;
            var clickatellSettings = _settingService.LoadSetting <ClickatellSettings>(storeScope);

            //test SMS send
            if (plugin.SendSms(model.TestMessage, 0, clickatellSettings))
            {
                SuccessNotification(_localizationService.GetResource("Plugins.Sms.Clickatell.TestSuccess"));
            }
            else
            {
                ErrorNotification(_localizationService.GetResource("Plugins.Sms.Clickatell.TestFailed"));
            }

            return(Configure());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handles the event.
        /// </summary>
        /// <param name="eventMessage">The event message.</param>
        public void HandleEvent(OrderPlacedEvent eventMessage)
        {
            //is enabled?
            if (!_verizonSettings.Enabled)
            {
                return;
            }

            //is plugin installed?
            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("Mobile.SMS.Verizon");

            if (pluginDescriptor == null)
            {
                return;
            }

            var plugin = pluginDescriptor.Instance() as VerizonSmsProvider;

            if (plugin == null)
            {
                return;
            }

            var order = eventMessage.Order;

            //send SMS
            if (plugin.SendSms(String.Format("New order(#{0}) has been placed.", order.Id)))
            {
                order.OrderNotes.Add(new OrderNote()
                {
                    Note = "\"Order placed\" SMS alert (to store owner) has been sent",
                    DisplayToCustomer = false,
                    CreatedOnUtc      = DateTime.UtcNow
                });
                _orderService.UpdateOrder(order);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Load tax provider by system name
        /// </summary>
        /// <param name="systemName">System name</param>
        /// <returns>Found tax provider</returns>
        public virtual ITaxProvider LoadTaxProviderBySystemName(string systemName)
        {
            if (systemName.IsNullOrEmpty())
            {
                return(null);
            }

            ITaxProvider provider;

            if (!_taxProviders.TryGetValue(systemName, out provider))
            {
                var descriptor = _pluginFinder.GetPluginDescriptorBySystemName <ITaxProvider>(systemName);
                if (descriptor != null)
                {
                    provider = descriptor.Instance <ITaxProvider>();
                    if (provider != null)
                    {
                        _taxProviders[systemName] = provider;
                    }
                }
            }

            return(provider);
        }
Ejemplo n.º 7
0
        public ActionResult PaymentInfo()
        {
            var model = new PaymentInfoModel();

            //years
            for (int i = 0; i < 15; i++)
            {
                string year = Convert.ToString(DateTime.Now.Year + i);
                model.ExpireYears.Add(new SelectListItem
                {
                    Text  = year,
                    Value = year,
                });
            }

            //months
            for (int i = 1; i <= 12; i++)
            {
                string text = (i < 10) ? "0" + i : i.ToString();
                model.ExpireMonths.Add(new SelectListItem
                {
                    Text  = text,
                    Value = text,
                });
            }

            ViewBag.PublicKey      = _stripePaymentSettings.PublicApiKey;
            ViewBag.BillingAddress = _workContext.CurrentCustomer.BillingAddress;


            PluginDescriptor nopTemplatesOnePageCheckout = _pluginFinder.GetPluginDescriptorBySystemName("SevenSpikes.Nop.Plugins.RealOnePageCheckout");
            bool             hasNpOpcInstalled           = nopTemplatesOnePageCheckout != null && nopTemplatesOnePageCheckout.Installed;

            if (!hasNpOpcInstalled)
            {
                IList <Country>       countries = new List <Country>();
                IList <StateProvince> provinces = new List <StateProvince>();

                if (!_cacheManager.IsSet(_countriesCacheKey))
                {
                    countries = _countryService.GetAllCountriesForBilling();
                    _cacheManager.Set(_countriesCacheKey, countries, _cacheExpirationInMinutes);
                }
                else
                {
                    countries = _cacheManager.Get <IList <Country> >(_countriesCacheKey);
                }

                if (!_cacheManager.IsSet(_provincesCacheKey))
                {
                    provinces = _stateProvinceService.GetStateProvinces();
                    _cacheManager.Set(_provincesCacheKey, provinces, _cacheExpirationInMinutes);
                }
                else
                {
                    provinces = _cacheManager.Get <IList <StateProvince> >(_provincesCacheKey);
                }

                ViewBag.Countries = countries.Select(c => new { Id = c.Id, TwoLeterIsoCode = c.TwoLetterIsoCode });
                ViewBag.Provinces = provinces.Select(c => new { Id = c.Id, Abbreviation = c.Abbreviation });

                return(View("~/Plugins/Payments.Stripe/Views/Stripe/PaymentInfo.cshtml", model));
            }
            else
            {
                IList <Country>       countries = new List <Country>();
                IList <StateProvince> provinces = new List <StateProvince>();

                if (!_cacheManager.IsSet(_countriesCacheKey))
                {
                    countries = _countryService.GetAllCountriesForBilling();
                    _cacheManager.Set(_countriesCacheKey, countries, _cacheExpirationInMinutes);
                }
                else
                {
                    countries = _cacheManager.Get <IList <Country> >(_countriesCacheKey);
                }

                if (!_cacheManager.IsSet(_provincesCacheKey))
                {
                    provinces = _stateProvinceService.GetStateProvinces();
                    _cacheManager.Set(_provincesCacheKey, provinces, _cacheExpirationInMinutes);
                }
                else
                {
                    provinces = _cacheManager.Get <IList <StateProvince> >(_provincesCacheKey);
                }

                ViewBag.Countries = countries.Select(c => new { Id = c.Id, TwoLeterIsoCode = c.TwoLetterIsoCode });
                ViewBag.Provinces = provinces.Select(c => new { Id = c.Id, Abbreviation = c.Abbreviation });

                return(View("~/Plugins/Payments.Stripe/Views/Stripe/PaymentInfoOpc.cshtml", model));
            }
        }
        public ActionResult GenerateFeed(FeedFroogleModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }


            try
            {
                var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("PromotionFeed.Froogle");
                if (pluginDescriptor == null)
                {
                    throw new Exception("Cannot load the plugin");
                }

                //plugin
                var plugin = pluginDescriptor.Instance() as FroogleService;
                if (plugin == null)
                {
                    throw new Exception("Cannot load the plugin");
                }

                plugin.GenerateStaticFile();

                string clickhereStr = string.Format("<a href=\"{0}content/files/exportimport/{1}\" target=\"_blank\">{2}</a>", _webHelper.GetStoreLocation(false), _froogleSettings.StaticFileName, _localizationService.GetResource("Plugins.Feed.Froogle.ClickHere"));
                string result       = string.Format(_localizationService.GetResource("Plugins.Feed.Froogle.SuccessResult"), clickhereStr);
                model.GenerateFeedResult = result;
            }
            catch (Exception exc)
            {
                model.GenerateFeedResult = exc.Message;
                _logger.Error(exc.Message, exc);
            }


            foreach (var c in _currencyService.GetAllCurrencies(false))
            {
                model.AvailableCurrencies.Add(new SelectListItem()
                {
                    Text  = c.Name,
                    Value = c.Id.ToString()
                });
            }
            model.AvailableGoogleCategories.Add(new SelectListItem()
            {
                Text  = "Select a category",
                Value = ""
            });
            foreach (var gc in _googleService.GetTaxonomyList())
            {
                model.AvailableGoogleCategories.Add(new SelectListItem()
                {
                    Text  = gc,
                    Value = gc
                });
            }

            //task
            ScheduleTask task = FindScheduledTask();

            if (task != null)
            {
                model.GenerateStaticFileEachMinutes = task.Seconds / 60;
                model.TaskEnabled = task.Enabled;
            }

            //file path
            if (System.IO.File.Exists(System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "content\\files\\exportimport", _froogleSettings.StaticFileName)))
            {
                model.StaticFilePath = string.Format("{0}content/files/exportimport/{1}", _webHelper.GetStoreLocation(false), _froogleSettings.StaticFileName);
            }

            return(View("Nop.Plugin.Feed.Froogle.Views.FeedFroogle.Configure", model));
        }
        public void HandleEvent(OrderPlacedEvent eventMessage)
        {
            if (!_smsSettings.Enabled)
            {
                return;
            }
            if (!_smsSettings.EnableOrderPlaced)
            {
                return;
            }

            if (_smsSettings.IgnnoreUserIDs.Split(',').Contains(eventMessage.Order.CustomerId.ToString()))
            {
                eventMessage.Order.OrderNotes.Add(new OrderNote
                {
                    Note = "SMS alert not send. user:"******" in Ignore Lit",
                    DisplayToCustomer = false,
                    CreatedOnUtc      = DateTime.UtcNow
                });
                _orderService.UpdateOrder(eventMessage.Order);
                return;
            }


            string template = "";

            if (eventMessage.Order.CustomerLanguageId == _smsSettings.SecondLanguageID)
            {
                // second language
                template = _smsSettings.TemplateOrderPlaced2;
            }
            else
            {
                if (eventMessage.Order.CustomerLanguageId == _smsSettings.ThirdLanguageID)
                {
                    // Third language
                    template = _smsSettings.TemplateOrderPlaced3;
                }
                else
                {
                    // default
                    template = _smsSettings.TemplateOrderPlaced;
                }
            }
            if (string.IsNullOrEmpty(template))
            {
                template = _smsSettings.TemplateOrderPlaced;
            }

            try
            {
                template = string.Format(template, eventMessage.Order.Id, eventMessage.Order.OrderTotal);
            }
            catch { }
            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("SMS.Notifications");

            if (pluginDescriptor == null)
            {
                return;
            }
            if (!_pluginFinder.AuthenticateStore(pluginDescriptor, _storeContext.CurrentStore.Id))
            {
                return;
            }

            var plugin = pluginDescriptor.Instance() as SMSNotificationsProvider;

            if (plugin == null)
            {
                return;
            }
            string phonenum = string.IsNullOrEmpty(eventMessage.Order.Customer.BillingAddress.PhoneNumber) ?
                              eventMessage.Order.Customer.ShippingAddress.PhoneNumber :
                              eventMessage.Order.Customer.BillingAddress.PhoneNumber;

            phonenum = ParcePhoneNumbe(phonenum);
            string resText = "";

            if (plugin.SendSms(phonenum, template, out resText))
            {
                eventMessage.Order.OrderNotes.Add(new OrderNote
                {
                    Note = "\"Order placed\" SMS alert has been sent to phone:" + phonenum,
                    DisplayToCustomer = false,
                    CreatedOnUtc      = DateTime.UtcNow
                });
                _orderService.UpdateOrder(eventMessage.Order);
            }
            else
            {
                eventMessage.Order.OrderNotes.Add(new OrderNote
                {
                    Note = "\"Order placed\" SMS alert can't send to phone:" + phonenum + ". Error" + resText,
                    DisplayToCustomer = false,
                    CreatedOnUtc      = DateTime.UtcNow
                });
                _orderService.UpdateOrder(eventMessage.Order);
            }
        }
Ejemplo n.º 10
0
        public override IList <string> AddToCart(Customer customer, Product product, ShoppingCartType shoppingCartType, int storeId,
                                                 string attributesXml   = null, decimal customerEnteredPrice = 0, DateTime?rentalStartDate       = null,
                                                 DateTime?rentalEndDate = null, int quantity = 1, bool automaticallyAddRequiredProductsIfEnabled = true)
        {
            var warnings = base.AddToCart(customer, product, shoppingCartType, storeId, attributesXml,
                                          customerEnteredPrice, rentalStartDate, rentalEndDate, quantity, automaticallyAddRequiredProductsIfEnabled);

            if (_httpContext.Session != null)
            {
                var shoppingMigrationInProcess = _httpContext.Session != null &&
                                                 _httpContext.Session["ra_shoppingMigrationInProcess"] != null
                    ? (bool)_httpContext.Session["ra_shoppingMigrationInProcess"]
                    : false;

                if (!shoppingMigrationInProcess && warnings.Count == 0)
                {
                    if (warnings.Count == 0)
                    {
                        var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("Widgets.Retargeting");
                        if (pluginDescriptor == null)
                        {
                            throw new Exception("Cannot load the plugin");
                        }

                        var plugin = pluginDescriptor.Instance() as RetargetingPlugin;
                        if (plugin == null)
                        {
                            throw new Exception("Cannot load the plugin");
                        }

                        object variation = false;
                        string variationCode;
                        Dictionary <string, object> variationDetails;

                        var stock = plugin.IsProductCombinationInStock(product, attributesXml, out variationCode, out variationDetails);
                        if (!string.IsNullOrEmpty(variationCode))
                        {
                            variation = new
                            {
                                code    = variationCode,
                                stock   = stock,
                                details = variationDetails
                            }
                        }
                        ;

                        var addToCartProductInfo = new
                        {
                            shoppingCartType = shoppingCartType,
                            product_id       = product.Id,
                            quantity         = quantity,
                            variation        = variation
                        };

                        if (_httpContext.Session != null)
                        {
                            _httpContext.Session["ra_addToCartProductInfo"] = addToCartProductInfo;
                        }
                    }
                }
            }

            return(warnings);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Load payment provider by system name
        /// </summary>
        /// <param name="systemName">System name</param>
        /// <returns>Found payment provider</returns>
        public virtual IPaymentMethod LoadPaymentMethodBySystemName(string systemName)
        {
            var descriptor = _pluginFinder.GetPluginDescriptorBySystemName <IPaymentMethod>(systemName);

            return(descriptor?.Instance <IPaymentMethod>());
        }
Ejemplo n.º 12
0
        public void Execute()
        {
            //is plugin installed?
            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("Widgets.mobSocial");

            if (pluginDescriptor == null)
            {
                return;
            }

            //plugin
            var plugin = pluginDescriptor.Instance() as MobSocialWebApiPlugin;

            if (plugin == null)
            {
                return;
            }

            //the task will send reminders to customers based on the timezone they are in, we don't want to send ill-timed emails
            //first get all the battles
            int notUsedTotalPages;
            var allBattles = _videoBattleService.GetAll(null, null, null, null, null, null, string.Empty, null, null,
                                                        out notUsedTotalPages, 1, int.MaxValue);


            #region to participants who have not uploaded video, that means only battles with pending status and within settings' threshold

            var pendingBattles = allBattles.Where(x => x.VideoBattleStatus == VideoBattleStatus.Pending &&
                                                  x.VotingStartDate.Subtract(DateTime.UtcNow).TotalDays <= _mobSocialSettings.VideoUploadReminderEmailThresholdDays);

            //TODO: Find a way to improve performance of this feature
            foreach (var battle in pendingBattles)
            {
                //participantVideos for this battle
                var participantVideos = _videoBattleVideoService.GetBattleVideos(battle.Id);

                //the ids of participants who have uploaded videos
                var participantIds = participantVideos.Select(x => x.ParticipantId);

                var battleParticipants = _videoBattleParticipantService.GetVideoBattleParticipants(battle.Id,
                                                                                                   VideoBattleParticipantStatus.ChallengeAccepted);

                //the ids of participants who need to be reminded
                var requireReminderParticipantIds =
                    battleParticipants.Where(x => !participantIds.Contains(x.ParticipantId)).Select(x => x.ParticipantId).ToArray();

                //send reminders to them
                var participantCustomers = _customerService.GetCustomersByIds(requireReminderParticipantIds);

                foreach (var customer in participantCustomers)
                {
                    //get the current time in customer's timezone
                    var customerDateTime = _dateTimeHelper.ConvertToUserTime(DateTime.UtcNow, TimeZoneInfo.Utc,
                                                                             _dateTimeHelper.GetCustomerTimeZone(customer));

                    //make sure it's good time to send email, between 7:00 AM - 5:00 PM should be a good time right?
                    if (customerDateTime.Hour >= 7 && customerDateTime.Hour <= 17)
                    {
                        _mobSocialMessageService.SendXDaysToBattleStartNotificationToParticipant(customer, battle,
                                                                                                 _workContext.WorkingLanguage.Id, _storeContext.CurrentStore.Id);
                    }
                }
            }


            #endregion


            #region to the followers who are following the battle but haven't yet voted

            var openBattles = allBattles.Where(x => x.VideoBattleStatus == VideoBattleStatus.Open &&
                                               x.VotingStartDate.Subtract(DateTime.UtcNow).TotalDays <= _mobSocialSettings.VideoUploadReminderEmailThresholdDays);
            //TODO: Find a way to improve performance of this feature
            foreach (var battle in openBattles)
            {
                //followers of this battle
                var followers = _customerFollowService.GetFollowers <VideoBattle>(battle.Id);

                //get the votes casted so far
                var votes = _videoBattleVoteService.GetVideoBattleVotes(battle.Id, null);
                //their customer ids
                var votesCustomerIds = votes.Select(x => x.ParticipantId);

                //and now the followers who haven't voted, need to be reminded//should not be a battle owner either
                var followersToRemindIds =
                    followers.Where(x => !votesCustomerIds.Contains(x.CustomerId) && x.CustomerId != battle.ChallengerId).Select(x => x.CustomerId).ToArray();

                //send reminders to them
                var followerCustomers = _customerService.GetCustomersByIds(followersToRemindIds);

                foreach (var customer in followerCustomers)
                {
                    //get the current time in customer's timezone
                    var customerDateTime = _dateTimeHelper.ConvertToUserTime(DateTime.UtcNow, TimeZoneInfo.Utc,
                                                                             _dateTimeHelper.GetCustomerTimeZone(customer));

                    //make sure it's good time to send email, between 7:00 AM - 5:00 PM should be a good time right?
                    if (customerDateTime.Hour >= 7 && customerDateTime.Hour <= 17)
                    {
                        _mobSocialMessageService.SendXDaysToBattleEndNotificationToFollower(customer, battle,
                                                                                            _workContext.WorkingLanguage.Id, _storeContext.CurrentStore.Id);
                    }
                }
            }

            #endregion

            //TODO: Send a consolidated email which contains all the battles (to participate and to vote)
        }