Esempio n. 1
0
        public void should_fail_with_credit_card_number_null()
        {
            // arrange
            var paymentRequest = GetPaymentRequest(1.2m, null);

            // act
            var maskedRequest = paymentRequestProcessor.Process(paymentRequest);

            // assert
            Assert.IsFalse(maskedRequest.IsValid);
        }
Esempio n. 2
0
        public async Task <PaymentResponse> Submit(PaymentRequest paymentRequest)
        {
            var paymentId = _paymentIdProvider.Get();

            Log.Information("Submit payment {paymentId}", paymentId);

            var paymentResponse = PaymentResponse.InvalidCreditCard(paymentId);
            var maskedRequest   = _paymentRequestPreProcessor.Process(paymentRequest);

            if (maskedRequest.IsValid)
            {
                var bankPaymentResult = await _bank.ProceedPayment(paymentRequest);

                paymentResponse = PaymentResponse.FromBankResult(paymentId, bankPaymentResult);
            }

            Log.Information("Payment {paymentId} and {paymentResponse}", paymentId, paymentResponse);

            await _paymentRepository.Store(paymentId, maskedRequest, paymentResponse);

            return(paymentResponse);
        }