Пример #1
0
 public SponsorApiController(IWorkContext workContext,
                             ISponsorService sponsorService,
                             ISponsorPassService sponsorPassService,
                             IOrderService orderService,
                             IVideoBattleService videoBattleService,
                             ICustomerService customerService,
                             IPictureService pictureService,
                             IPriceFormatter priceFormatter,
                             IDateTimeHelper dateTimeHelper,
                             ILocalizationService localizationService,
                             ICurrencyService currencyService,
                             MediaSettings mediaSettings, IMobSocialMessageService mobSocialMessageService, IStoreContext storeContext, IVideoBattlePrizeService videoBattlePrizeService, IPaymentProcessingService paymentProcessingService)
 {
     _workContext              = workContext;
     _sponsorPassService       = sponsorPassService;
     _sponsorService           = sponsorService;
     _orderService             = orderService;
     _videoBattleService       = videoBattleService;
     _customerService          = customerService;
     _pictureService           = pictureService;
     _priceFormatter           = priceFormatter;
     _dateTimeHelper           = dateTimeHelper;
     _localizationService      = localizationService;
     _currencyService          = currencyService;
     _mediaSettings            = mediaSettings;
     _mobSocialMessageService  = mobSocialMessageService;
     _storeContext             = storeContext;
     _videoBattlePrizeService  = videoBattlePrizeService;
     _paymentProcessingService = paymentProcessingService;
 }
Пример #2
0
 public WebSocketServiceMiddleware(
     IPaymentWebSocketsService socketsService,
     IPaymentProcessingService processingService,
     ILoggerFactory loggerFactory)
 {
     _socketsService = socketsService;
     _loggerFactory  = loggerFactory;
 }
Пример #3
0
 public PaymentsController(
     IPaymentService paymentService,
     IPaymentProcessingService paymentProcessing,
     ILogger <PaymentsController> logger)
 {
     _paymentService    = paymentService;
     _paymentProcessing = paymentProcessing;
     _logger            = logger;
 }
Пример #4
0
 public PaymentController(
     IPaymentProcessingService paymentProcessingService,
     IPaymentRequestService paymentRequestService,
     ILogger <PaymentController> log)
 {
     _paymentProcessingService = paymentProcessingService;
     _paymentRequestService    = paymentRequestService;
     _log = log;
 }
Пример #5
0
 public PaymentService(
     IBasketRepository basketRepository,
     IUnitOfWork unitOfWork,
     IConfiguration config,
     IPaymentProcessingService paymentProcessing
     )
 {
     _basketRepository  = basketRepository;
     _unitOfWork        = unitOfWork;
     _paymentProcessing = paymentProcessing;
     // Come from "dotnet user-secrets"
     _stripeKeys = config.GetSection("StripeSettings");
 }
 public VideoBattleController(
     IVideoBattleService videoBattleService,
     IVideoBattleParticipantService videoBattleParticipantService,
     IVideoBattleVideoService videoBattleVideoService,
     IVideoBattleVoteService videoBattleVoteService,
     IVideoBattlePrizeService videoBattlePrizeService,
     IUserService userService,
     IWatchedVideoService watchedVideoService,
     IMediaService pictureService,
     ISponsorService sponsorService,
     ITimelineAutoPublisher timelineAutoPublisher,
     ISettingService settingService,
     IPaymentProcessingService paymentProcessingService,
     IFollowService followService,
     ICreditService creditService,
     IFormatterService formatterService,
     IEmailSender emailSender,
     IMobSocialVideoProcessor videoProcessor,
     MediaSettings mediaSettings,
     PaymentSettings paymentSettings,
     BattleSettings battleSettings,
     GeneralSettings generalSettings)
 {
     _videoBattleService = videoBattleService;
     _videoBattleParticipantService = videoBattleParticipantService;
     _videoBattleVideoService = videoBattleVideoService;
     _videoBattleVoteService = videoBattleVoteService;
     _videoBattlePrizeService = videoBattlePrizeService;
     _userService = userService;
     _watchedVideoService = watchedVideoService;
     _timelineAutoPublisher = timelineAutoPublisher;
     _settingService = settingService;
     _paymentProcessingService = paymentProcessingService;
     _followService = followService;
     _creditService = creditService;
     _paymentSettings = paymentSettings;
     _battleSettings = battleSettings;
     _formatterService = formatterService;
     _emailSender = emailSender;
     _generalSettings = generalSettings;
     _videoProcessor = videoProcessor;
     _sponsorService = sponsorService;
     _pictureService = pictureService;
     _mediaSettings = mediaSettings;
 }
Пример #7
0
 public PaymentController(IUserPaymentMethodService paymentMethodService, 
     IPaymentProcessingService paymentProcessingService, 
     ICryptographyService cryptographyService, 
     IVideoBattleService videoBattleService, 
     ISponsorService sponsorService, 
     ICreditService creditService, 
     PaymentSettings paymentSettings, 
     IPaymentTransactionService paymentTransactionService)
 {
     _paymentMethodService = paymentMethodService;
     _paymentProcessingService = paymentProcessingService;
     _cryptographyService = cryptographyService;
     _videoBattleService = videoBattleService;
     _sponsorService = sponsorService;
     _creditService = creditService;
     _paymentSettings = paymentSettings;
     _paymentTransactionService = paymentTransactionService;
 }
 public PaymentController(IUserPaymentMethodService paymentMethodService,
                          IPaymentProcessingService paymentProcessingService,
                          ICryptographyService cryptographyService,
                          IVideoBattleService videoBattleService,
                          ISponsorService sponsorService,
                          ICreditService creditService,
                          PaymentSettings paymentSettings,
                          IPaymentTransactionService paymentTransactionService)
 {
     _paymentMethodService      = paymentMethodService;
     _paymentProcessingService  = paymentProcessingService;
     _cryptographyService       = cryptographyService;
     _videoBattleService        = videoBattleService;
     _sponsorService            = sponsorService;
     _creditService             = creditService;
     _paymentSettings           = paymentSettings;
     _paymentTransactionService = paymentTransactionService;
 }
Пример #9
0
 public PaymentController(IWorkContext workContext,
                          IWebHelper webHelper,
                          IStoreContext storeContext,
                          ICustomerService customerService,
                          IProductService productService,
                          IGiftCardService giftCardService,
                          IOrderService orderService,
                          ICustomerPaymentMethodService paymentMethodService,
                          IMobSecurityService mobSecurityService,
                          IPaymentProcessingService paymentProcessingService,
                          IVideoBattleService videoBattleService,
                          IVoterPassService voterPassService,
                          ISponsorPassService sponsorPassService,
                          mobSocialSettings mobSocialSettings, IAddressAttributeService addressAttributeService, AddressSettings addressSettings, ILocalizationService localizationService, IAddressAttributeParser addressAttributeParser, ICountryService countryService, IStateProvinceService stateProvinceService)
 {
     _workContext              = workContext;
     _storeContext             = storeContext;
     _customerService          = customerService;
     _productService           = productService;
     _giftCardService          = giftCardService;
     _orderService             = orderService;
     _paymentMethodService     = paymentMethodService;
     _mobSecurityService       = mobSecurityService;
     _paymentProcessingService = paymentProcessingService;
     _videoBattleService       = videoBattleService;
     _voterPassService         = voterPassService;
     _sponsorPassService       = sponsorPassService;
     _mobSocialSettings        = mobSocialSettings;
     _addressAttributeService  = addressAttributeService;
     _addressSettings          = addressSettings;
     _localizationService      = localizationService;
     _addressAttributeParser   = addressAttributeParser;
     _countryService           = countryService;
     _stateProvinceService     = stateProvinceService;
     _webHelper = webHelper;
 }
 public void Setup()
 {
     _target = new FakePaymentProcessingService();
 }
        public static string GetConsolidatedPrizesString(this VideoBattle battle,
                                                         List <VideoBattlePrize> allPrizes,
                                                         int?winnerPosition,
                                                         ISponsorService sponsorService,
                                                         ISettingService settingService,
                                                         IPaymentProcessingService paymentProcessingService,
                                                         IFormatterService formatterService,
                                                         ICreditService creditService,
                                                         BattleSettings battleSettings)
        {
            var battleOwnerPrizes = allPrizes.Where(x => !x.IsSponsored && (!winnerPosition.HasValue || x.WinnerPosition == winnerPosition.Value));
            var sponsoredPrizes   = allPrizes.Where(x => x.IsSponsored && (!winnerPosition.HasValue || x.WinnerPosition == winnerPosition.Value));

            var videoBattlePrizes      = battleOwnerPrizes as VideoBattlePrize[] ?? battleOwnerPrizes.ToArray();
            var totalPrizesAmountFixed = videoBattlePrizes.Where(x => x.PrizeType == BattlePrizeType.FixedAmount).Sum(x => x.PrizeAmount);

            var totalPrizesAmountPercentage = 0m;

            if (videoBattlePrizes.Any(x => x.PrizeType == BattlePrizeType.PercentageAmount))
            {
                var contextKeyName = string.Format(CreditContextKeyNames.BattleVote, battle.Id);
                //get spent credits for battle votes
                var credits = creditService.GetCredits(contextKeyName, null, CreditTransactionType.Spent);

                var orderSum    = credits.Sum(x => x.CreditCount);
                var netOrderSum = paymentProcessingService.GetNetAmountAfterPaymentProcessing(orderSum);

                var totalWinners = videoBattlePrizes.Count();

                //total voting amount from percentage
                totalPrizesAmountPercentage = netOrderSum -
                                              totalWinners * netOrderSum * battle.ParticipantPercentagePerVote / 100;
            }

            var sponsorships = sponsorService.GetSponsorsGrouped(null, battle.Id, BattleType.Video,
                                                                 SponsorshipStatus.Accepted);

            var sponsorshipAmount = sponsorships.Sum(x => x.SponsorshipAmount);

            //amount after payment processing
            var netSponsorshipAmount = paymentProcessingService.GetNetAmountAfterPaymentProcessing(sponsorshipAmount);

            var siteOwnerShare = netSponsorshipAmount * battleSettings.SiteOwnerVideoBattleSponsorshipPercentage / 100;

            //it may be possible that battle host himself is sponsor, he won't be getting commissions for that :)
            var battleHostAsSponsorAmount =
                sponsorships.Where(x => x.UserId == battle.ChallengerId).Sum(x => x.SponsorshipAmount);


            var battleHostShare = (netSponsorshipAmount - battleHostAsSponsorAmount) * battleSettings.BattleHostVideoBattleSponsorshipPercentage / 100;

            //amount available for winners
            var winnerPrizePool = netSponsorshipAmount - siteOwnerShare - battleHostShare;

            if (winnerPosition.HasValue)
            {
                winnerPrizePool = PrizeDistributionHelper.GetPrizeDistributionPercentage(winnerPosition.Value,
                                                                                         allPrizes.Count(x => !x.IsSponsored), settingService) * winnerPrizePool;
            }

            var totalAmount = Math.Round(totalPrizesAmountFixed + totalPrizesAmountPercentage + winnerPrizePool);

            var totalPrizeString = totalAmount > 0 ? formatterService.FormatCurrency(totalAmount, ApplicationContext.Current.ActiveCurrency) : "";


            if (allPrizes.Any(x => x.PrizeType == BattlePrizeType.FixedProduct || x.PrizeType == BattlePrizeType.Other))
            {
                if (!winnerPosition.HasValue)
                {
                    totalPrizeString += "+";
                }
                else
                {
                    //now append each product as prize with it's name to the prize string
                    foreach (var prize in videoBattlePrizes.Where(x => x.PrizeType == BattlePrizeType.FixedProduct || x.PrizeType == BattlePrizeType.Other))
                    {
                        if (prize.PrizeType == BattlePrizeType.FixedProduct)
                        {
                            //todo: do something for fixed product
                        }
                        else
                        {
                            totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther;
                        }
                    }
                    //and sponsored products
                    foreach (var prize in sponsoredPrizes.Where(x => x.PrizeType == BattlePrizeType.Other))
                    {
                        totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther + "*";
                    }
                }
            }

            return(totalPrizeString);
        }
Пример #12
0
        public static string GetConsolidatedPrizesString(this VideoBattle battle, 
            List<VideoBattlePrize> allPrizes, 
            int? winnerPosition,
            ISponsorService sponsorService,
            ISettingService settingService,
            IPaymentProcessingService paymentProcessingService,
            IFormatterService formatterService,
            ICreditService creditService,
            BattleSettings battleSettings)
        {
            var battleOwnerPrizes = allPrizes.Where(x => !x.IsSponsored  && (!winnerPosition.HasValue || x.WinnerPosition == winnerPosition.Value));
            var sponsoredPrizes = allPrizes.Where(x => x.IsSponsored && (!winnerPosition.HasValue || x.WinnerPosition == winnerPosition.Value));

            var videoBattlePrizes = battleOwnerPrizes as VideoBattlePrize[] ?? battleOwnerPrizes.ToArray();
            var totalPrizesAmountFixed = videoBattlePrizes.Where(x => x.PrizeType == BattlePrizeType.FixedAmount).Sum(x => x.PrizeAmount);

            var totalPrizesAmountPercentage = 0m;
            if (videoBattlePrizes.Any(x => x.PrizeType == BattlePrizeType.PercentageAmount))
            {
                var contextKeyName = string.Format(CreditContextKeyNames.BattleVote, battle.Id);
                //get spent credits for battle votes
                var credits = creditService.GetCredits(contextKeyName, null, CreditTransactionType.Spent);

                var orderSum = credits.Sum(x => x.CreditCount);
                var netOrderSum = paymentProcessingService.GetNetAmountAfterPaymentProcessing(orderSum);

                var totalWinners = videoBattlePrizes.Count();

                //total voting amount from percentage
                totalPrizesAmountPercentage = netOrderSum -
                                              totalWinners*netOrderSum*battle.ParticipantPercentagePerVote/100;

            }

            var sponsorships = sponsorService.GetSponsorsGrouped(null, battle.Id, BattleType.Video,
                SponsorshipStatus.Accepted);

            var sponsorshipAmount = sponsorships.Sum(x => x.SponsorshipAmount);

            //amount after payment processing
            var netSponsorshipAmount = paymentProcessingService.GetNetAmountAfterPaymentProcessing(sponsorshipAmount);

            var siteOwnerShare = netSponsorshipAmount * battleSettings.SiteOwnerVideoBattleSponsorshipPercentage / 100;

            //it may be possible that battle host himself is sponsor, he won't be getting commissions for that :)
            var battleHostAsSponsorAmount =
                sponsorships.Where(x => x.UserId == battle.ChallengerId).Sum(x => x.SponsorshipAmount);

            var battleHostShare = (netSponsorshipAmount - battleHostAsSponsorAmount) * battleSettings.BattleHostVideoBattleSponsorshipPercentage / 100;

            //amount available for winners
            var winnerPrizePool = netSponsorshipAmount - siteOwnerShare - battleHostShare;

            if (winnerPosition.HasValue)
            {
                winnerPrizePool = PrizeDistributionHelper.GetPrizeDistributionPercentage(winnerPosition.Value,
                    allPrizes.Count(x => !x.IsSponsored), settingService) * winnerPrizePool;
            }

            var totalAmount = Math.Round(totalPrizesAmountFixed + totalPrizesAmountPercentage + winnerPrizePool);

            var totalPrizeString = totalAmount > 0 ? formatterService.FormatCurrency(totalAmount, ApplicationContext.Current.ActiveCurrency) : "";

            if (allPrizes.Any(x => x.PrizeType == BattlePrizeType.FixedProduct || x.PrizeType == BattlePrizeType.Other))
            {
                if (!winnerPosition.HasValue)
                    totalPrizeString += "+";
                else
                {
                    //now append each product as prize with it's name to the prize string
                    foreach (var prize in videoBattlePrizes.Where(x => x.PrizeType == BattlePrizeType.FixedProduct || x.PrizeType == BattlePrizeType.Other))
                    {
                        if (prize.PrizeType == BattlePrizeType.FixedProduct)
                        {
                            //todo: do something for fixed product
                        }
                        else
                        {
                            totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther;
                        }
                    }
                    //and sponsored products
                    foreach (var prize in sponsoredPrizes.Where(x => x.PrizeType == BattlePrizeType.Other))
                    {
                        totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther + "*";
                    }
                }
            }

            return totalPrizeString;
        }
Пример #13
0
 public PaymentWebSocketsService(IPaymentProcessingService paymentProcessing,
                                 ILogger <PaymentWebSocketsService> logger)
 {
     _logger            = logger;
     _paymentProcessing = paymentProcessing;
 }
Пример #14
0
        public static string GetConsolidatedPrizesString(this VideoBattle Battle,
                                                         List <VideoBattlePrize> allPrizes,
                                                         int?WinnerPosition,
                                                         IWorkContext _workContext,
                                                         IProductService _productService,
                                                         ISponsorService _sponsorService,
                                                         IVoterPassService _voterPassService,
                                                         IVideoBattlePrizeService _videoBattlePrizeService,
                                                         IPriceFormatter _priceFormatter,
                                                         ISettingService _settingService,
                                                         IPaymentProcessingService _paymentProcessingService,
                                                         mobSocialSettings _mobSocialSettings)
        {
            var battleOwnerPrizes = allPrizes.Where(x => !x.IsSponsored && (!WinnerPosition.HasValue || x.WinnerPosition == WinnerPosition.Value));
            var sponsoredPrizes   = allPrizes.Where(x => x.IsSponsored && (!WinnerPosition.HasValue || x.WinnerPosition == WinnerPosition.Value));

            var totalPrizesAmountFixed =
                battleOwnerPrizes.Where(x => x.PrizeType == VideoBattlePrizeType.FixedAmount).Sum(x => x.PrizeAmount);

            var totalPrizesAmountPercentage = 0m;

            if (battleOwnerPrizes.Any(x => x.PrizeType == VideoBattlePrizeType.PercentageAmount))
            {
                var orders      = _voterPassService.GetAllVoterPassOrders(BattleType.Video, Battle.Id, PassStatus.Used);
                var orderSum    = orders.Sum(x => x.OrderTotal);
                var netOrderSum = _paymentProcessingService.GetNetAmountAfterPaymentProcessing(orderSum);

                var totalWinners = battleOwnerPrizes.Count();

                //total voting amount from percentage
                totalPrizesAmountPercentage = netOrderSum -
                                              totalWinners * netOrderSum * Battle.ParticipantPercentagePerVote / 100;
            }

            var sponsorships = _sponsorService.GetSponsorsGrouped(null, Battle.Id, BattleType.Video,
                                                                  SponsorshipStatus.Accepted);

            var sponsorshipAmount = sponsorships.Sum(x => x.SponsorshipAmount);

            //amount after payment processing
            var netSponsorshipAmount = _paymentProcessingService.GetNetAmountAfterPaymentProcessing(sponsorshipAmount);

            var siteOwnerShare = netSponsorshipAmount * _mobSocialSettings.SiteOwnerSponsorshipPercentage / 100;

            //it may be possible that battle host himself is sponsor, he won't be getting commissions for that :)
            var battleHostAsSponsorAmount =
                sponsorships.Where(x => x.CustomerId == Battle.ChallengerId).Sum(x => x.SponsorshipAmount);


            var battleHostShare = (netSponsorshipAmount - battleHostAsSponsorAmount) * _mobSocialSettings.BattleHostSponsorshipPercentage / 100;

            //amount available for winners
            var winnerPrizePool = netSponsorshipAmount - siteOwnerShare - battleHostShare;

            if (WinnerPosition.HasValue)
            {
                winnerPrizePool = PrizeDistributionHelper.GetPrizeDistributionPercentage(WinnerPosition.Value,
                                                                                         allPrizes.Count(x => !x.IsSponsored), _settingService) * winnerPrizePool;
            }

            var totalAmount = Math.Round(totalPrizesAmountFixed + totalPrizesAmountPercentage + winnerPrizePool);

            var totalPrizeString = totalAmount > 0 ? _priceFormatter.FormatPrice(totalAmount, true, _workContext.WorkingCurrency) : "";


            if (allPrizes.Any(
                    x => x.PrizeType == VideoBattlePrizeType.FixedProduct || x.PrizeType == VideoBattlePrizeType.Other))
            {
                if (!WinnerPosition.HasValue)
                {
                    totalPrizeString += "+";
                }
                else
                {
                    //now append each product as prize with it's name to the prize string
                    foreach (var prize in battleOwnerPrizes.Where(x => x.PrizeType == VideoBattlePrizeType.FixedProduct || x.PrizeType == VideoBattlePrizeType.Other))
                    {
                        if (prize.PrizeType == VideoBattlePrizeType.FixedProduct)
                        {
                            var product = _productService.GetProductById(prize.PrizeProductId);
                            if (product != null)
                            {
                                totalPrizeString += (totalPrizeString != "" ? " + " : "") + product.Name;
                            }
                            else
                            {
                                totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeProductId;
                            }
                        }
                        else
                        {
                            totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther;
                        }
                    }
                    //and sponsored products
                    foreach (var prize in sponsoredPrizes.Where(x => x.PrizeType == VideoBattlePrizeType.Other))
                    {
                        totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther + "*";
                    }
                }
            }

            return(totalPrizeString);
        }