Exemplo n.º 1
0
        public AcquiringBankClientTests()
        {
            var httpMessageHandlerMock = new Mock <HttpMessageHandler>();

            httpMessageHandlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("{'transactionId':'65a83e69-6741-4970-ab7c-433beb3837cb','transactionStatus':'ok'}"),
            });

            var httpClient = new HttpClient(httpMessageHandlerMock.Object);

            httpClient.BaseAddress = new Uri("https://localhost");

            this.httpClientFactoryMock = new Mock <IHttpClientFactory>();
            this.httpClientFactoryMock
            .Setup(s => s.CreateClient(It.IsAny <string>()))
            .Returns(httpClient);

            this.loggerMock = new Mock <ILogger <AcquiringBankClient> >();

            this.bankConfiguration = new BankConfiguration
            {
                BaseAddress = "https://localhost",
                Endpoint    = "/api/endpoint",
                ServiceName = "serviceName",
                Timeout     = 1000
            };

            this.target = new AcquiringBankClient(this.httpClientFactoryMock.Object, this.loggerMock.Object, this.bankConfiguration);
        }
Exemplo n.º 2
0
        //private readonly ITransactionService transactionService;

        public BankAccountsController(
            IBankAccountService bankAccountService,
            IUserService userService,
            IOptions <BankConfiguration> bankConfigurationOptions)
        {
            this.bankAccountService = bankAccountService;
            this.userService        = userService;
            this.bankConfiguration  = bankConfigurationOptions.Value;
        }
Exemplo n.º 3
0
 public GlobalTransferHelper(
     IBankAccountService bankAccountService,
     IMoneyTransferService moneyTransferService,
     IOptions <BankConfiguration> bankConfigurationOptions)
 {
     this.bankAccountService   = bankAccountService;
     this.moneyTransferService = moneyTransferService;
     this.bankConfiguration    = bankConfigurationOptions.Value;
 }
Exemplo n.º 4
0
 public AcquiringBankClient(
     IHttpClientFactory httpClientFactory,
     ILogger <AcquiringBankClient> logger,
     BankConfiguration bankConfiguration)
 {
     this.httpClientFactory = httpClientFactory;
     this.logger            = logger;
     this.bankConfiguration = bankConfiguration;
 }
Exemplo n.º 5
0
 public GlobalTransactionHelper(
     IBankAccountService bankAccountService,
     ITransactionService transactionService,
     IOptions <BankConfiguration> bankConfigurationOptions)
 {
     this.bankAccountService = bankAccountService;
     this.TransactionService = transactionService;
     this.bankConfiguration  = bankConfigurationOptions.Value;
 }
Exemplo n.º 6
0
 public PaymentsController(
     IOptions <BankConfiguration> bankConfigurationOptions,
     IBankAccountService bankAccountService,
     IUserService userService,
     IGlobalTransferHelper globalTransferHelper)
 {
     this.bankConfiguration    = bankConfigurationOptions.Value;
     this.bankAccountService   = bankAccountService;
     this.userService          = userService;
     this.globalTransferHelper = globalTransferHelper;
 }
 public BankAccountsController(
     IBankAccountService bankAccountService,
     IMoneyTransferService moneyTransferService,
     IOptions <BankConfiguration> bankConfigurationOptions,
     IMapper mapper)
 {
     this.bankAccountService   = bankAccountService;
     this.moneyTransferService = moneyTransferService;
     this.mapper            = mapper;
     this.bankConfiguration = bankConfigurationOptions.Value;
 }
Exemplo n.º 8
0
        private bool IsValidRequest(
            ActionExecutingContext context)
        {
            var request       = context.HttpContext.Request;
            var configOptions = request.HttpContext.RequestServices
                                .GetService <IOptions <BankConfiguration> >();

            this.configuration = configOptions.Value;

            var actionArguments = context.ActionArguments;
            var model           = actionArguments.Values.First();

            if (model == null)
            {
                return(false);
            }

            try
            {
                var     incomingData     = Encoding.UTF8.GetString(Convert.FromBase64String(model.ToString()));
                dynamic deserializedData = JsonConvert.DeserializeObject(incomingData);
                string  encryptedKey     = deserializedData.EncryptedKey;
                string  encryptedIv      = deserializedData.EncryptedIv;
                string  data             = deserializedData.Data;
                string  signature        = deserializedData.Signature;

                var decryptedData = SignatureVerificationUtil
                                    .DecryptDataAndVerifySignature(new SignatureVerificationModel
                {
                    DecryptionPrivateKey = this.configuration.Key,
                    SignaturePublicKey   = this.configuration.CentralApiPublicKey,
                    EncryptedKey         = encryptedKey,
                    EncryptedIv          = encryptedIv,
                    Data      = data,
                    Signature = signature
                });

                if (decryptedData == null)
                {
                    return(false);
                }

                // Modify body
                var key = actionArguments.Keys.First();
                actionArguments.Remove(key);
                actionArguments.Add(key, decryptedData);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public virtual void ConfigureServices(IServiceCollection services)
        {
            services.AddHealthChecks();
            services.AddControllers();
            services.AddAutoMapper(typeof(PaymentGatewayAPIMapper));
            services.AddTransient <IPaymentService, PaymentService>();
            services.AddTransient <IPaymentRepository, PaymentRepository>();

            var bankConfig = new BankConfiguration();

            Configuration.GetSection(BankConfiguration.ConfigurationName).Bind(bankConfig);
            services.AddSingleton <IBankConfiguration>(bankConfig);
        }
Exemplo n.º 10
0
        public ActionResult SetupConfig()
        {
            var bankConfig = new BankConfiguration
            {
                FinancialDate  = DateTime.Today,
                IsBusinessOpen = false,
                DayCount       = 0,
                MonthCount     = 0,
                YearCount      = 0
            };

            Session["isBusinessOpen"] = false;
            Session.Remove("setup");
            _context.Save(bankConfig);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 11
0
 public CardHelper(IOptions <BankConfiguration> bankConfigurationOptions)
 {
     this.bankConfiguration = bankConfigurationOptions.Value;
     this.random            = new Random();
 }
Exemplo n.º 12
0
 public BankAccountUniqueIdHelper(IOptions <BankConfiguration> bankConfigurationOptions)
 {
     this.bankConfiguration = bankConfigurationOptions.Value;
 }
Exemplo n.º 13
0
 public void Update(BankConfiguration config)
 {
     _db.Save(config);
 }
Exemplo n.º 14
0
 public void Save(BankConfiguration config)
 {
     _db.Add(config);
     _db.Save(config);
 }