Beispiel #1
0
 public string GenerateStripeAccessToken(string authorization_code,
                                         Contracts.Enums.Channels channel,
                                         long eventId)
 {
     try
     {
         var eventStripeAccount = _eventStripeAccountMappingRepository.GetByEventId(eventId);
         StripeConfiguration.ApiKey = _settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Stripe.Feel.SecretKey);
         if (channel == Contracts.Enums.Channels.Feel && eventStripeAccount != null && eventStripeAccount.StripeAccountId == Contracts.Enums.StripeAccount.StripeAustralia) // If event belongs to StripeAustralia
         {
             StripeConfiguration.ApiKey = _settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Stripe.FeelAustralia.SecretKey);
         }
         else if (channel == Contracts.Enums.Channels.Feel && eventStripeAccount != null && eventStripeAccount.StripeAccountId == Contracts.Enums.StripeAccount.StripeIndia) // If event belongs to StripeIndia
         {
             StripeConfiguration.ApiKey = _settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Stripe.FeelIndia.SecretKey);
         }
         if (channel == Contracts.Enums.Channels.Website)
         {
             StripeConfiguration.ApiKey = _settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Stripe.SecretKey);
         }
         var options = new OAuthTokenCreateOptions
         {
             GrantType = "authorization_code",
             Code      = authorization_code,
         };
         var service  = new OAuthTokenService();
         var response = service.Create(options);
         return(response.StripeUserId);
     }
     catch (Exception e)
     {
         _logger.Log(FIL.Logging.Enums.LogCategory.Error, e);
         return("");
     }
 }
Beispiel #2
0
        public void SaveEventStripeMappings(long eventId, long currencyId)
        {
            var eventStripeMaster          = new EventStripeAccountMapping();
            var eventStripeAccountMappings = _eventStripeAccountMappingRepository.GetByEventId(eventId);

            eventStripeMaster.Id              = eventStripeAccountMappings != null ? eventStripeAccountMappings.Id : 0;
            eventStripeMaster.Channeld        = Channels.Feel;
            eventStripeMaster.SiteId          = Contracts.Enums.Site.ComSite;
            eventStripeMaster.EventId         = eventId;
            eventStripeMaster.CreatedUtc      = DateTime.UtcNow;
            eventStripeMaster.CreatedBy       = Guid.NewGuid();
            eventStripeMaster.StripeAccountId = GetStripeAccount(currencyId);
            eventStripeMaster.IsEnabled       = true;
            _eventStripeAccountMappingRepository.Save(eventStripeMaster);
        }
 public FIL.Contracts.Enums.StripeAccount GetEventStripeAccount(long EventId, FIL.Contracts.Enums.Channels channel)
 {
     try
     {
         var eventStripeAccount = _eventStripeAccountMappingRepository.GetByEventId(EventId);
         if (eventStripeAccount != null)
         {
             return(eventStripeAccount.StripeAccountId);
         }
         else
         {
             return(Contracts.Enums.StripeAccount.None);
         }
     }
     catch (Exception e)
     {
         _logger.Log(FIL.Logging.Enums.LogCategory.Error, e);
         return(Contracts.Enums.StripeAccount.None);
     }
 }
Beispiel #4
0
 public FinanceQueryResult Handle(FinanceQuery query)
 {
     try
     {
         var eventData = _eventRepository.Get(query.EventId);
         if (eventData == null)
         {
             return(new FinanceQueryResult
             {
                 EventId = query.EventId,
                 IsDraft = true
             });
         }
         var eventStripeAccount = _eventStripeAccountMappingRepository.GetByEventId(query.EventId);
         if (eventStripeAccount.StripeAccountId == Contracts.Enums.StripeAccount.StripeIndia)
         {
             var masterFinanceDetail = _masterFinanceDetailsRepository.GetByEventId(query.EventId);
             return(new FinanceQueryResult
             {
                 EventFinanceDetailModel = AutoMapper.Mapper.Map <FIL.Contracts.Models.CreateEventV1.EventFinanceDetailModel>(masterFinanceDetail),
                 EventId = query.EventId,
                 IsDraft = false,
                 IsValidLink = true,
                 StripeAccount = Contracts.Enums.StripeAccount.StripeIndia,
                 StripeConnectAccountId = null,
                 EventAltId = eventData.AltId,
                 Success = true
             });
         }
         else
         {
             var eventCurrency            = _eventCurrencyProvider.GetEventCurrency(eventData);
             var country                  = _countryRepository.Get(eventCurrency.CountryId);
             var eventStripeConnectMaster = _eventStripeConnectMasterRepository.GetByEventId(query.EventId);
             if (eventStripeConnectMaster != null)
             {
                 return(new FinanceQueryResult
                 {
                     EventId = query.EventId,
                     IsDraft = false,
                     IsValidLink = true,
                     StripeAccount = eventStripeAccount.StripeAccountId,
                     StripeConnectAccountId = eventStripeConnectMaster.StripeConnectAccountID,
                     EventAltId = eventData.AltId,
                     IsoAlphaTwoCode = country.IsoAlphaTwoCode,
                     Success = true
                 });
             }
             else
             {
                 return(new FinanceQueryResult
                 {
                     EventId = query.EventId,
                     IsDraft = false,
                     IsValidLink = true,
                     StripeAccount = eventStripeAccount.StripeAccountId,
                     StripeConnectAccountId = null,
                     CurrencyType = eventCurrency,
                     IsoAlphaTwoCode = country.IsoAlphaTwoCode,
                     EventAltId = eventData.AltId,
                     Success = true
                 });
             }
         }
     }
     catch (Exception e)
     {
         return(new FinanceQueryResult {
         });
     }
 }