示例#1
0
        public PaymentProcessViewModel Post(PaymentViewModel model)
        {
            // validation
            if (ModelState.IsValid == false)
            {
                throw new HttpRequestException();
            }

            // map the payment
            Payment payment = new Payment
            {
                CreatedDate = model.CreatedDate,
                Id          = 1,
                Price       = model.Price,
                Product     = _ProductTagservice.FindInclude(x => x.Id == model.ProductTagId, x => x.Products).SingleOrDefault().Products.Find(x => x.Id == model.ProductId),
                Status      = model.Status
            };

            // process the payment
            _RuleEngine.ProcessPayment(payment, model.Description);

            // read the log and delete it
            string content = Logger.ReadLog(_PathMapper);

            return(new Models.PaymentProcessViewModel
            {
                Content = content,
                CreatedDate = DateTime.Now
            });
        }
示例#2
0
        public void TestGenerateComission()
        {
            //Data Set Up
            PaymentInfo payment = new PaymentInfo()
            {
                PaymentType = "Book", CustomerId = 100, OrderId = 10, PaymentId = 101
            };
            PaymentRuleEngine pr = new PaymentRuleEngine();

            //Execute
            var result = pr.ProcessPayment(payment);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Contains("CommisionGenerated"));
        }
示例#3
0
        public void TestMembershipActivation()
        {
            //Data Set Up
            PaymentInfo payment = new PaymentInfo()
            {
                PaymentType = "Membership", CustomerId = 100, OrderId = 10, PaymentId = 101
            };
            PaymentRuleEngine pr = new PaymentRuleEngine();

            //Execute
            var result = pr.ProcessPayment(payment);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Contains("MembershipActivated"));
        }