Пример #1
0
        public Task <AcquirerResponse> ProcessAsync(AcquirerRequest request)
        {
            if (_mockedResponse.TryGetValue(request.CardDetails.SecurityCode, out var response))
            {
                return(Task.FromResult(response));
            }

            throw new NotImplementedException();
        }
Пример #2
0
        public void SetUp()
        {
            _fixture          = new Fixture();
            _acquirerRequest  = _fixture.Create <AcquirerRequest>();
            _acquirerResponse = _fixture.Create <AcquirerResponse>();
            _authoriseRequest = _fixture.Create <AuthoriseRequest>();
            _authoriseRequest.CardDetails.CardNumber = "4242 4242 4242 4242";

            _repositoryMock        = new Mock <IRepository <Payment> >();
            _acquirerHandlerMock   = new Mock <IAcquirerHandler>();
            _cardDetailsMaskerMock = new Mock <ICardDetailsMasker>();
            _mapperMock            = new Mock <IMapper>();

            _authorisationProcessor = new PaymentAuthorisationProcessor(_repositoryMock.Object, _acquirerHandlerMock.Object, _cardDetailsMaskerMock.Object, _mapperMock.Object);

            _mapperMock.Setup(x => x.Map <AuthoriseRequest, AcquirerRequest>(It.IsAny <AuthoriseRequest>())).Returns(_acquirerRequest);
            _acquirerHandlerMock.Setup(x => x.ProcessAsync(_acquirerRequest)).ReturnsAsync(_acquirerResponse);
        }
        public async Task <AcquirerResponse> ProcessAsync(AcquirerRequest request)
        {
            //_monitor.AddParameter(request.PaymentOperation);
            //_monitor.AddParameter(request.DesignatedAccount);
            //_monitor.AddParameter(request.CurrencyCode);
            //_monitor.AddParameter(request.Amount);
            //_monitor.AddParameter(request.CardDetails.CardNumber);
            //_monitor.AddParameter(request.CardDetails.ExpiryDate);

            AcquirerResponse acquirerResponse;

            //using (_monitor.Timer(nameof(IAcquirerHandler)))
            //{
            acquirerResponse = await _inner.ProcessAsync(request);

            //}

            //_monitor.AddParameter(_acquirerResponse.Id);
            //_monitor.AddParameter(_acquirerResponse.Status);

            return(acquirerResponse);
        }
        public Task <AcquirerResponse> ProcessAsync(AcquirerRequest request)
        {
            //have a dedicated routing class in the future for business rules.
            _logger.LogInformation($"Routing {request.PaymentOperation} for {request.DesignatedAccount} to Barclays as is trigger business rule: cheaper processing fees");

            //fail anything not expected for now
            var response = new AcquirerResponse()
            {
                Id     = Guid.NewGuid().ToString(),
                Status = "Failed"
            };

            if (request.CardDetails.CardNumber == TestActivationCardNumber && _mockResponses.ContainsKey(request.CardDetails.SecurityCode))
            {
                _logger.LogInformation($"{request.PaymentOperation} for {request.DesignatedAccount} is activating test scenario");

                response.Status = _mockResponses[request.CardDetails.SecurityCode];
            }

            _logger.LogInformation($"{nameof(FakeBarclaysBankAcquirerHandler)} is return {response.Status} with reference id {response.Id}");

            return(Task.FromResult(response));
        }