public ProcessPaymentCommand(ProcessPaymentRequest request)
        {
            var paymentRequestValidator = new ProcessPaymentRequestValidator();
            var paymentValidationResult = paymentRequestValidator.Validate(request);

            if (!paymentValidationResult.IsValid)
            {
                throw new StatusCodeException(HttpStatusCode.BadRequest,
                                              paymentValidationResult.Errors.Select(x => x.ErrorMessage).ToList());
            }

            Request = request;
        }
예제 #2
0
        public void PaymentIsValid()
        {
            var ppr = new ProcessPaymentRequest()
            {
                Amount           = 2.4M,
                CardHolder       = "qazwsxedcrfvt",
                CreditCardNumber = "1qazxsw2#EDCr",
                ExpirationDate   = DateTime.Today.AddYears(3),
                SecurityCode     = "098",
            };

            var vr = pv.Validate(ppr);

            Assert.IsTrue(vr.IsValid);
        }