public UCGApiController(ITransactionLogService transactionLogService, IEventStageService eventStageService, IEventArchiveService eventArchiveService, IExchangeContractMappingService exchangeContractMappingService) { this.unameChorus = ConfigurationManager.AppSettings["unameChorus"]; this.psswdChorus = ConfigurationManager.AppSettings["psswdChorus"]; this.apiChorus = ConfigurationManager.AppSettings["apiChorus"]; this.unameBMP = ConfigurationManager.AppSettings["unameBMP"]; this.psswdBMP = ConfigurationManager.AppSettings["psswdBMP"]; this.apiBMP = ConfigurationManager.AppSettings["apiBMP"]; this.apiGoogleAddress = ConfigurationManager.AppSettings["apiGoogleAddress"]; this.coordsGooglePath = ConfigurationManager.AppSettings["coordsGooglePath"]; this.keyGoogleAddress = ConfigurationManager.AppSettings["keyGoogleAddress"]; this.chorusOrderLimit = Convert.ToInt32(ConfigurationManager.AppSettings["chorusOrderLimit"]); this.chorusLimitEnable = ConfigurationManager.AppSettings["chorusLimitEnable"]; this.transactionLogService = transactionLogService; this.eventStageService = eventStageService; this.eventArchiveService = eventArchiveService; this.exchangeContractMappingService = exchangeContractMappingService; }
public async Task CanGenerateTransactionReference() { HostingEnvironment hostEnvironment = new HostingEnvironment(); hostEnvironment.ContentRootPath = "C:\\Users\\LENOVO\\Documents\\Repositories\\lms-gateway\\src\\Presentation\\LmsGateway.Web"; hostEnvironment.ContentRootFileProvider = new PhysicalFileProvider(hostEnvironment.ContentRootPath); hostEnvironment.EnvironmentName = "Development"; Startup startup = new Web.Startup(hostEnvironment); ServiceCollection sc = new ServiceCollection(); startup.ConfigureServices(sc); IServiceProvider serviceProvider = sc.BuildServiceProvider(); ITransactionLogService transactionLogService = serviceProvider.GetService <ITransactionLogService>(); IGatewayLuncher gatewayLuncher = serviceProvider.GetService <IGatewayLuncher>(); ISettingService settingService = serviceProvider.GetService <ISettingService>(); IWidgetProvider widgetProvider = serviceProvider.GetService <IWidgetProvider>(); var transactionRef = new TransactionReference(transactionLogService, gatewayLuncher, settingService, widgetProvider); var response = await transactionRef.InvokeAsync(); var result = (ViewViewComponentResult)response; //Assert.NotNull(result); //Assert.NotNull(response); //Assert.IsType<ViewViewComponentResult>(response); //Assert.IsType<string>(result.ViewData.Model); }
//Service for making Payment with ADMIN public bool AdminPaymentService(PaymentRequest model) { string nonceFromTheClient = model.ExternalCardIdNonce; int currentTransactionId = 0; //Temporary code below ITransactionLogService _transactionLogService = UnityConfig.GetContainer().Resolve <ITransactionLogService>(); currentTransactionId = _transactionLogService.BillingTransactionInsert(model); TransactionRequest request = new TransactionRequest { Amount = model.ItemCost, PaymentMethodToken = nonceFromTheClient, Options = new TransactionOptionsRequest { SubmitForSettlement = true } }; Result <Transaction> result = _Gateway.Transaction.Sale(request); var transactionJson = new JavaScriptSerializer().Serialize(result); //Instantiate values into Transaction Log Model BillingTransactionLog LogModel = new BillingTransactionLog(); LogModel.Id = currentTransactionId; LogModel.RawResponse = transactionJson; if (result.Message == null && result.Errors == null) { //Instatiate Success Values LogModel.AmountConfirmed = result.Target.Amount; LogModel.TransactionId = result.Target.Id; LogModel.CardExpirationDate = result.Target.CreditCard.ExpirationDate; LogModel.CardLastFour = result.Target.CreditCard.LastFour; ActivityLogRequest Activity = new ActivityLogRequest(); Activity.ActivityType = ActivityTypeId.MadePayment; _ActivityLogService.InsertActivityToLog(model.UserId, Activity); return(_transactionLogService.TransactionLogUpdateSuccess(LogModel)); } else { //Instatiate Error Values LogModel.ErrorCode = result.Message; bool response = _transactionLogService.TransactionLogUpdateError(LogModel); throw new System.ArgumentException(result.Message, "CreditCard"); } }
public GatewayLuncher(ITransactionLogService transactionLogService, ILocalizationService localizationService) { _localizationService = localizationService; _transactionLogService = transactionLogService; _manInTheMiddleAttackMessage = string.Format(_localizationService.GetResource("Plugins.SmartStore.GTPay.ManInTheMiddleAttackMessage"), "<a href=\"{0}\"><i class=\"fa fa-home\"></i><span>", "</span></a>"); }
public PaystackProvider(IGatewayLuncher gatewayLuncher, ISupportedCurrencyService supportedCurrencyService, ITransactionLogService transactionLogService, ISettingService settingService) { Guard.NotNull(settingService, nameof(settingService)); Guard.NotNull(gatewayLuncher, nameof(gatewayLuncher)); Guard.NotNull(supportedCurrencyService, nameof(supportedCurrencyService)); Guard.NotNull(transactionLogService, nameof(transactionLogService)); _settingService = settingService; _gatewayLuncher = gatewayLuncher; _supportedCurrencyService = supportedCurrencyService; _transactionLogService = transactionLogService; _metadata = new PaymentMetadata() { Name = "Paystack", SystemName = "LmsGateway.Paystack", Author = "Daniel Egenti", IsActive = true, Version = "1.0.0", Category = "Payments", Company = "Nitware Solutions Ltd.", Website = "http://www.nitware.com.ng" }; }
public PaystackController(ITransactionStatusService transactionStatusService , ISupportedCurrencyService supportedCurrencyService , IHostingEnvironment env , IGatewayLuncher gatewayLuncher //, HttpContext httpContext , ITransactionLogService transactionLogService , IHttpContextAccessor httpContextAccessor , ISettingService settingService) { Guard.NotNull(env, nameof(env)); //Guard.NotNull(httpContext, nameof(httpContext)); Guard.NotNull(settingService, nameof(settingService)); Guard.NotNull(gatewayLuncher, nameof(gatewayLuncher)); Guard.NotNull(transactionLogService, nameof(transactionLogService)); Guard.NotNull(transactionStatusService, nameof(transactionStatusService)); Guard.NotNull(supportedCurrencyService, nameof(supportedCurrencyService)); Guard.NotNull(httpContextAccessor, nameof(httpContextAccessor)); _hostEnvironment = env; _settingService = settingService; _gatewayLuncher = gatewayLuncher; _transactionLogService = transactionLogService; _transactionStatusService = transactionStatusService; _supportedCurrencyService = supportedCurrencyService; _httpContext = httpContextAccessor.HttpContext; }
public LoggingEntityApp(string schema = "log", LogModules includeModules = LogModules.All, UserSessionSettings sessionSettings = null) : base("LoggingApp", CurrentVersion) { var area = base.AddArea(schema); ActiveModules = includeModules; // DbInfo module is not shared with main app, it is local for the database var dbInfo = new DbInfoModule(area); // ErrorLog is property in EntityApp, will be set there automatically if (ActiveModules.IsSet(LogModules.ErrorLog)) { var errLog = new ErrorLogModule(area); } if (ActiveModules.IsSet(LogModules.OperationLog)) { OperationLog = new OperationLogModule(area); } if (ActiveModules.IsSet(LogModules.IncidentLog)) { IncidentLog = new IncidentLogModule(area); } if (ActiveModules.IsSet(LogModules.TransactionLog)) { TransactionLog = new TransactionLogModule(area, trackHostApp: false); //do not track changes for LoggingApp itself } if (ActiveModules.IsSet(LogModules.NotificationLog)) { NotificationLog = new NotificationLogModule(area); } if (ActiveModules.IsSet(LogModules.LoginLog)) { LoginLog = new LoginLogModule(area); } if (ActiveModules.IsSet(LogModules.DbUpgradeLog)) { DbUpgradeLog = new DbUpgradeLogModule(area); } if (ActiveModules.IsSet(LogModules.UserSession)) { SessionService = new UserSessionModule(area, sessionSettings); } if (ActiveModules.IsSet(LogModules.EventLog)) { EventLogService = new EventLogModule(area); } if (ActiveModules.IsSet(LogModules.WebCallLog)) { WebCallLog = new WebCallLogModule(area); } if (ActiveModules.IsSet(LogModules.WebClientLog)) { WebClientLogService = new WebClientLogModule(area); } }
public UploadTransactionHandler( IFormFileValidator fileValidator, ITransactionService transactionService, ITransactionLogService transactionLogService, ICacheManager cacheManager) { _fileValidator = fileValidator; _transactionService = transactionService; _transactionLogService = transactionLogService; _cacheManager = cacheManager; }
public PollyTestingController(ILogger <PollyTestingController> logger, ITransactionLogService transactionLogService, ICachingService cachingService, IWeatherForecastApiService weatherForecastApiService, IWeatherForecastApiNotUsingPollyService weatherForecastApiNotUsingPollyService ) : base(logger, transactionLogService, cachingService) { _logger = logger; _weatherForecastApiService = weatherForecastApiService; _weatherForecastApiNotUsingPollyService = weatherForecastApiNotUsingPollyService; }
public TransactionReference(ITransactionLogService transactionLogService, IGatewayLuncher gatewayLuncher, ISettingService settingService, IWidgetProvider widgetProvider) { Guard.NotNull(widgetProvider, nameof(widgetProvider)); Guard.NotNull(settingService, nameof(settingService)); Guard.NotNull(gatewayLuncher, nameof(gatewayLuncher)); Guard.NotNull(transactionLogService, nameof(transactionLogService)); _widgetProvider = widgetProvider; _settingService = settingService; _gatewayLuncher = gatewayLuncher; _transactionLogService = transactionLogService; }
/// <summary> /// Constructor for BaseApiController. /// </summary> /// <param name="logger">The logger.</param> /// <param name="transactionLogService">The transactionLogService.</param> /// <param name="cachingService">The cachingService.</param> public BaseApiController(ILogger <BaseApiController> logger, ITransactionLogService transactionLogService, ICachingService cachingService) { _logger = logger; _transactionLogService = transactionLogService; _cachingService = cachingService; var controller = GetType().Name; ControllerName = controller.Substring(0, controller.Length - "Controller".Length); }
public LoggingEntityApp(string schema = "log", UserSessionSettings sessionSettings = null) : base("LoggingApp", CurrentVersion) { var area = base.AddArea(schema); var errorLog = new ErrorLogModule(area); OperationLog = new OperationLogModule(area); IncidentLog = new IncidentLogModule(area); TransactionLog = _transactionLogModule = new TransactionLogModule(area); WebCallLog = new WebCallLogModule(area); NotificationLog = new NotificationLogModule(area); LoginLog = new LoginLogModule(area); DbModelChangeLog = new DbUpgradeLogModule(area); SessionService = new UserSessionModule(area, sessionSettings); DbInfoService = new DbInfoModule(area); EventLogService = new EventLogModule(area); }
public GatewayHappyResponse(ITransactionLogService transactionLogService, IGatewayLuncher gatewayLuncher, ISettingService settingService, IWidgetProvider widgetProvider, IHttpContextAccessor httpContextAccessor) { Guard.NotNull(widgetProvider, nameof(widgetProvider)); Guard.NotNull(settingService, nameof(settingService)); Guard.NotNull(gatewayLuncher, nameof(gatewayLuncher)); Guard.NotNull(transactionLogService, nameof(transactionLogService)); Guard.NotNull(httpContextAccessor, nameof(httpContextAccessor)); _widgetProvider = widgetProvider; _settingService = settingService; _gatewayLuncher = gatewayLuncher; _transactionLogService = transactionLogService; _httpContext = httpContextAccessor.HttpContext; }
public async Task c() { HostingEnvironment hostEnvironment = new HostingEnvironment(); hostEnvironment.ContentRootPath = "C:\\Users\\LENOVO\\Documents\\Repositories\\lms-gateway\\src\\Presentation\\LmsGateway.Web"; hostEnvironment.ContentRootFileProvider = new PhysicalFileProvider(hostEnvironment.ContentRootPath); hostEnvironment.EnvironmentName = "Development"; Startup startup = new Web.Startup(hostEnvironment); IServiceCollection sc = new ServiceCollection(); startup.ConfigureServices(sc); IServiceProvider serviceProvider = sc.BuildServiceProvider(); ISupportedCurrencyService supportedCurrencyService = serviceProvider.GetService <ISupportedCurrencyService>(); IGatewayLuncher gatewayLuncher = serviceProvider.GetService <IGatewayLuncher>(); ITransactionLogService transactionLogService = serviceProvider.GetService <ITransactionLogService>(); ITransactionStatusService transactionStatusService = serviceProvider.GetService <ITransactionStatusService>(); ISettingService settingService = serviceProvider.GetService <ISettingService>(); //PaystackController paystackController = new PaystackController(transactionStatusService // , supportedCurrencyService // , hostEnvironment // , gatewayLuncher // , transactionLogService // , settingService); //var response = await paystackController.InvokeAsync(); //var result = (ViewViewComponentResult)response; //Assert.NotNull(result); //Assert.NotNull(response); //Assert.IsType<ViewViewComponentResult>(response); //Assert.IsType<PaymentInfoModel>(result.ViewData.Model); //Assert.True((result.ViewData.Model as PaymentInfoModel).IconUrl != null); }
private Action <IApplicationBuilder> CustomExceptionHandlerMiddleware(IServiceScopeFactory serviceScopeFactory, bool isDevelopment) { return(applicationBuilder => applicationBuilder.Run(async httpContext => { var exceptionHandlerPathFeature = httpContext.Features.Get <IExceptionHandlerPathFeature>(); Exception specificException = exceptionHandlerPathFeature.Error; _logger.LogError("Api Unhandle Exception: {0}", JsonConvert.SerializeObject(specificException)); using (var scope = serviceScopeFactory.CreateScope()) { ICachingService cachingService = scope.ServiceProvider.GetService <ICachingService>(); ITransactionLogService transactionLogService = scope.ServiceProvider.GetService <ITransactionLogService>(); if (await cachingService.IsLoggingDatabaseAsync()) { await transactionLogService.AddTransactionLogAsync(TransactionLogStep.CustomExceptionHandlerMiddleware, TransactionLogStatus.Error, JsonConvert.SerializeObject(specificException), string.Empty, specificException.Message, specificException.StackTrace); } } var code = HttpStatusCode.InternalServerError; var responseObject = new BaseResponseObject { Status = false, ErrorCode = ResponseErrorCode.UnhandleException, Message = specificException.Message, StackTrace = isDevelopment ? specificException.StackTrace : string.Empty, Data = specificException.Data }; switch (specificException) { case ArgumentNullException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.ArgumentNullException; break; case ArgumentOutOfRangeException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.ArgumentOutOfRangeException; break; case ArgumentException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.ArgumentException; break; case NotFoundException _: code = HttpStatusCode.NotFound; responseObject.ErrorCode = ResponseErrorCode.NotFound; break; case InvalidOperationException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.InvalidOperationException; break; case AuthenticationException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.AuthenticationException; break; } var result = JsonConvert.SerializeObject(responseObject); httpContext.Response.ContentType = "application/json"; httpContext.Response.StatusCode = (int)code; await httpContext.Response.WriteAsync(result); } )); }
public async Task Invoke(HttpContext httpContext) { string requestData = string.Empty; try { requestData = await GetRequestData(httpContext); } catch (Exception ex) { _logger.LogError($"Api Unhandle Exception: {nameof(GetRequestData)}", JsonConvert.SerializeObject(ex)); } try { await _next(httpContext); } catch (Exception ex) { _logger.LogError("Api Unhandle Exception", JsonConvert.SerializeObject(ex)); using (var scope = _serviceScopeFactory.CreateScope()) { ICachingWorkerService cachingService = scope.ServiceProvider.GetService <ICachingWorkerService>(); ITransactionLogService transactionLogService = scope.ServiceProvider.GetService <ITransactionLogService>(); if (cachingService.IsLoggingDatabase()) { await transactionLogService.AddTransactionLogAsync(TransactionLogStep.CustomExceptionHandlerMiddleware, TransactionLogStatus.Error, requestData, ex.Message, JsonConvert.SerializeObject(ex), Guid.Empty); } } var code = HttpStatusCode.InternalServerError; var responseObject = new BaseResponseObject { Status = false, ErrorCode = ResponseErrorCode.UnhandleException, Message = ex.Message, StackTrace = !_settings.IsProduction ? ex.StackTrace : string.Empty, Data = ex.Data }; switch (ex) { case ArgumentNullException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.ArgumentNullException; break; case ArgumentOutOfRangeException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.ArgumentOutOfRangeException; break; case ArgumentException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.ArgumentException; break; case NotFoundException _: code = HttpStatusCode.NotFound; responseObject.ErrorCode = ResponseErrorCode.NotFound; break; case InvalidOperationException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.InvalidOperationException; break; case AuthenticationException _: code = HttpStatusCode.BadRequest; responseObject.ErrorCode = ResponseErrorCode.AuthenticationException; break; } var result = JsonConvert.SerializeObject(responseObject); httpContext.Response.ContentType = "application/json"; httpContext.Response.StatusCode = (int)code; await httpContext.Response.WriteAsync(result); } }
public GatewayLuncher(ITransactionLogService transactionLogService) { Guard.NotNull(transactionLogService, nameof(transactionLogService)); _transactionLogService = transactionLogService; }
public TransactionLogAppService(ITransactionLogService transactionLogService) { _service = transactionLogService; }