public Task <PaymentTransaction> GetPaymentTransaction(MakeAPaymentRequest request) { return(Task.FromResult( _paymentTransactions .SingleOrDefault(x => x.TransactionDate == request.TransactionDate && x.MerchantId == request.MerchantId && x.TerminalId == request.TerminalId && x.PaymentReference == request.PaymentReference && x.PaymentAmount == request.PaymentAmount && x.IsoCurrencyCode == request.IsoCurrencyCode && x.Card.CardNumber == request.Card.CardNumber ))); }
public static PaymentTransaction ToPaymentTransaction(this MakeAPaymentRequest request, IBankTransactionResponse responseFromBank) { return(new PaymentTransaction { TransactionId = request.TransactionId, MerchantId = request.MerchantId, TerminalId = request.TerminalId, BankTransactionId = responseFromBank.TransactionId, PaymentStatus = responseFromBank.PaymentStatus, PaymentAmount = request.PaymentAmount, PaymentReference = request.PaymentReference, IsoCurrencyCode = request.IsoCurrencyCode, TransactionSucessful = responseFromBank.TransactionSucessful, BankTransactionMessage = responseFromBank.Message, TransactionDate = request.TransactionDate, Card = request.Card }); }
public async Task <IBankTransactionResponse> PayAsync(MakeAPaymentRequest request) { var fakeBankTransactionId = Guid.NewGuid(); if (request.PaymentAmount > 200) { _logger.Warning("Payment request to the bank failed"); return(await Task.FromResult(new FailedBankPaymentResponse { TransactionId = fakeBankTransactionId, PaymentStatus = PaymentStatus.NotEnoughFunds, Message = "Not enough funds to make the payment" })); } return(await Task.FromResult(new SuccessfulBankPaymentResponse { TransactionId = fakeBankTransactionId })); }