public async Task <AcquirerStatus> AcquireAsync(Card card, string currency, decimal amount) { var request = CreateRequest(card, currency, amount); var response = await _client.SendAsync(request); return(_statusFactory.Create(response)); }
public void SetUp() { _mockInnerAcquirerService = new Mock <IAcquirerService>(); _mockLogger = new Mock <ILogger <LoggingAcquirerService> >(); _card = new Card("6923847329847", "0220", "123", "J Bloggs"); _amount = 101.12m; _currency = "GBP"; _sut = new LoggingAcquirerService(_mockInnerAcquirerService.Object, _mockLogger.Object); }
public async Task Create(GatewayPaymentId gatewayPaymentId, PaymentGateway.Domain.Card card) { //Simulate IO await Task.Delay(1); if (!_storage.TryAdd(gatewayPaymentId, new PaymentDetails(new Domain.Card(Mask(card.Number), card.Expiry, card.Cvv)))) { // Can happen only if the read projected receive twice the same `PaymentRequested` // For a real distributed message bus, it can never deliver once and only once for a message // We should ensure the operation on duplicated message is idempotent, just log in this case _logger.LogInformation($"{nameof(PaymentRequested)} of gateway id {gatewayPaymentId} has already been handled. We received duplicated message from message bus"); } }
private PaymentRequest CreateRequest(Card card, string currency, decimal amount) { var requestCard = new PaymentAcquirer.Contract.Requests.Card { CardNumber = card.CardNumber, ExpiryDate = card.ExpiryDate, Cvv = card.Cvv, Name = card.Name }; return(new PaymentRequest { Card = requestCard, Currency = currency, Amount = amount }); }
public void SetUp() { _mockAcquirerClient = new Mock <IPaymentAcquirerClient>(); _card = new Card("6923847329847", "0220", "123", "J Bloggs"); _amount = 101.12m; _currency = "GBP"; _sut = new AcquirerService(_mockAcquirerClient.Object, new AcquirerStatusFactory()); //setup for success by default _paymentResponse = new PaymentResponse { Id = Guid.NewGuid().ToString(), Success = true }; _mockAcquirerClient.Setup(x => x.SendAsync(It.IsAny <PaymentRequest>())) .Callback <PaymentRequest>(pr => _sentRequest = pr) .ReturnsAsync(_paymentResponse); }