public void Setup() { _externalRefId = Guid.NewGuid(); _accountId = 1; _merchantId = 1; _cardNumer = "12323232"; _cardPaymentResponse = new CardPaymentResponse { AuthCode = "AuthCode01", ExternalRefId = _externalRefId, Status = "Accepted" }; _cardDetail = new CardPaymentDetail { //AccountId = _accountId, //MerchantId = _merchantId, CardNumber = _cardNumer, CardExpiry_Month = "02", CardExpiry_Year = "2020", CVV = "123" }; _checkOutHttpClientResponse = new CheckOutHttpClientResponse(); _checkOutHttpClientResponse.Data = JsonConvert.SerializeObject(_cardPaymentResponse); _checkOutHttpClientResponse.IsSuccessFull = true; _checkOutHttpClientResponse.StatusCode = HttpStatusCode.OK; _url = "anyURL"; //_mockcheckoutHttpClient = new Mock<IHttpClient>().Object; _mockcheckoutHttpClient.Setup(x => x.Post <CardPaymentDetail, CheckOutHttpClientResponse>(_url, _cardDetail)).ReturnsAsync(_checkOutHttpClientResponse); _cardApiService = new CardApiService(_mockcheckoutHttpClient.Object); }
public void CardPayment_InValidPayments(Card card, BankAccount bankAccount, TransactionStatus resulTransactionStatus) { var fakeCardRepository = new FakeCardRepository(); var fakeBankAccountRepository = new FakeBankAccountRepository(); var inMemPaymentRepository = new InMemoryPaymentRepository(); var service = new CardPaymentService(fakeCardRepository, fakeBankAccountRepository, inMemPaymentRepository); CardPaymentResponse response = service.DoPayment(new CardPaymentRequest(requestId1, card, bankAccount)); Assert.Equal(resulTransactionStatus, response.TransactionStatus); }
public CardPaymentResponse Execute(CardPaymentRequest request) { CardPaymentResponse responseMessage = new CardPaymentResponse { AuthCode = Guid.NewGuid().ToString().Substring(0, 4).ToUpper() }; Console.WriteLine("Worker activated to process response =>" + responseMessage.AuthCode, Color.Azure); return(responseMessage); }
public void CardPayment_DoublePayment() { // arrange var fakeCardRepository = new FakeCardRepository(); var fakeBankAccountRepository = new FakeBankAccountRepository(); var inMemPaymentRepository = new InMemoryPaymentRepository(); // act var service = new CardPaymentService(fakeCardRepository, fakeBankAccountRepository, inMemPaymentRepository); CardPaymentResponse response = service.DoPayment(new CardPaymentRequest(requestId1, FakeCardRepository.GenerateCard_JohnDoe(), FakeBankAccountRepository.GenerateBankAccount_Amazon())); service = new CardPaymentService(new FakeCardRepository(), new FakeBankAccountRepository(), inMemPaymentRepository); // act-assert Assert.Throws <RequestAlreadyProcessedException>(() => service.DoPayment(new CardPaymentRequest(requestId1, FakeCardRepository.GenerateCard_JohnDoe(), FakeBankAccountRepository.GenerateBankAccount_Amazon()))); }
public async Task <string> GetPaymentUrlAsync(CardPaymentRequest request) { CardPaymentResponse result = await SendRequestAsync <CardPaymentResponse>(request, Link4PayApiType.ClientAuth, request.Transaction.TxnReference); if (result == null) { return(string.Empty); } string url = _encryptionService.Decrypt(result.Payload); string gatewayReference = url.Replace("//", "/").Split('/')[2]; string data = GetRedirectData(gatewayReference, request.Transaction.TxnReference); return($"{_link4PaySettings.ExternalUrl}/redirect?payload={data}&url={url.ToBase64()}"); }