コード例 #1
0
        // Factory Method
        public static IPayment GetPaymentObject(int objType)
        {
            IPayment _IPayment;

            if (objType == Constant.PaymentType.PhysicalProduct.GetHashCode())
            {
                _IPayment = new PhysicalProductPayment();
            }
            else if (objType == Constant.PaymentType.Book.GetHashCode())
            {
                _IPayment = new BookPayment();
            }
            else if (objType == Constant.PaymentType.MembershipActivate.GetHashCode())
            {
                _IPayment = new MembershipActivatePayment();
            }
            else if (objType == Constant.PaymentType.MembershipUpgrade.GetHashCode())
            {
                _IPayment = new MembershipUpgradePayment();
            }
            else if (objType == Constant.PaymentType.Video.GetHashCode())
            {
                _IPayment = new VideoPayment();
            }
            else
            {
                _IPayment = null;
            }
            return(_IPayment);
        }
コード例 #2
0
        public static IProcessOrder GetPaymentMethod(PaymentFor type)
        {
            IProcessOrder _processOrder = null;

            switch (type)
            {
            case PaymentFor.PHYSICALPRODUCT:
                _processOrder = new PhysicalProductPayment();
                break;

            case PaymentFor.BOOK:
                _processOrder = new BookPayment();
                break;

            case PaymentFor.BOOKORPHYSICAL:
                _processOrder = new PhysicalorBookPayment();
                break;

            case PaymentFor.VIDEO:
                _processOrder = new VideoPayment();
                break;

            default:
                break;
            }
            return(_processOrder);
        }
コード例 #3
0
        public async Task ChangeStatus()
        {
            var cartId     = Guid.NewGuid().ToString();
            var customerId = Guid.NewGuid().ToString();

            var submitOrder = new SubmitOrder {
                CartId = cartId, Customer = customerId, Items = new List <Filling>()
            };

            var bookPayment = new BookPayment {
                Id = Guid.NewGuid(), CartId = cartId, Customer = customerId
            };

            var cancelPayment = new CancelPayment {
                Id = Guid.NewGuid(), CartId = cartId, Customer = customerId
            };

            await SendInOrder(new IMessage[]
            {
                submitOrder,
                bookPayment,
                cancelPayment,
                bookPayment
            }
                              );

            var(order, _) = await ordersRepository.Get <Order>(customerId, cartId);

            Assert.AreEqual(order.PaymentBooked, false);
        }
コード例 #4
0
        public IPayment CreatePayment(Product pProduct)
        {
            IPayment payment = null;

            switch (pProduct.Category)
            {
            case (Int16)enmCategory.Physical:
                if (pProduct.ProductType == "Books")
                {
                    payment = new BookPayment(_commission);
                }
                else
                {
                    payment = new ProductPayment(_commission);
                }
                break;

            case (Int16)enmCategory.Membership:
                if (pProduct.ProductType == "New")
                {
                    payment = new NewMembershipPayment(_membership, _notification);
                }
                else
                {
                    payment = new UpgradeMembershipPayment(_membership, _notification);
                }
                break;

            case (Int16)enmCategory.Video:
                payment = new VideoPayment();
                break;
            }
            return(payment);
        }
コード例 #5
0
        public static IProcessOrder GetPaymentMethod(PaymentType type)
        {
            IProcessOrder _processOrder = null;

            switch (type)
            {
            case PaymentType.PHYSICAL_PRODUCT:
                _processOrder = new PhysicalProductPayment();
                break;

            case PaymentType.BOOK:
                _processOrder = new BookPayment();
                break;

            case PaymentType.BOOKORPHYSICAL:
                _processOrder = new PhysicalorBookPayment();
                break;

            case PaymentType.VIDEO:
                _processOrder = new VideoPayment();
                break;

            case PaymentType.MEMBERSHIP:
                _processOrder = new MemberShipPayment();
                break;

            default:
                break;
            }
            return(_processOrder);
        }
コード例 #6
0
ファイル: Paymenthub.cs プロジェクト: labbumahi/Productengine
        public static IPayment GetPayment(int obj)
        {
            IPayment _payment;

            if (obj == Payment_constant.Paymenttype.Book.GetHashCode())
            {
                _payment = new BookPayment();
            }
            else if (obj == Payment_constant.Paymenttype.PhysicalProduct.GetHashCode())
            {
                _payment = new Paymentforphysicalpayment();
            }
            else if (obj == Payment_constant.Paymenttype.MembershipActivate.GetHashCode())
            {
                _payment = new Membership_activatepayment();
            }
            else if (obj == Payment_constant.Paymenttype.MembershipUpgrade.GetHashCode())
            {
                _payment = new Membership_Upgrade();
            }
            else if (obj == Payment_constant.Paymenttype.Video.GetHashCode())
            {
                _payment = new videopayment();
            }

            else
            {
                _payment = null;
            }
            return(_payment);
        }
コード例 #7
0
        public void Test_BookPayment()
        {
            var order = new BookPayment()
            {
                Id = Guid.NewGuid()
            };
            var task   = _ruleEngineOrder.ProcessOrder(order.OrderTypeId);
            var result = task.ExecuteTask(order);

            Assert.Contains(ActivityConstants.PackagingSlip, result);
            Assert.Contains(ActivityConstants.CommissionAgent, result);
        }
コード例 #8
0
        public async Task IssueCouponCardAfterFirst100USDSpent()
        {
            var cartId     = Guid.NewGuid().ToString();
            var customerId = Guid.NewGuid().ToString();

            var submitFirstOrder = new SubmitOrder
            {
                CartId   = cartId,
                Customer = customerId,
                Items    = new List <Filling>
                {
                    Filling.Meat,
                    Filling.Mushrooms,
                    Filling.QuarkAndPotatoes
                }
            };

            var submitSecondOrder = new SubmitOrder
            {
                CartId   = cartId,
                Customer = customerId,
                Items    = new List <Filling>
                {
                    Filling.Strawberry,
                    Filling.SwissCheese
                }
            };

            var bookFirstPayment = new BookPayment {
                Id = Guid.NewGuid(), CartId = cartId, Customer = customerId
            };
            var bookSecondPayment = new BookPayment {
                Id = Guid.NewGuid(), CartId = cartId, Customer = customerId
            };

            await SendInOrder(new IMessage[] {
                submitFirstOrder,
                bookFirstPayment,
                submitSecondOrder,
                bookSecondPayment,
                bookFirstPayment     //HINT: this is a retried message
            }
                              );

            var(_, version) = await marketingRepository.Get <Coupon>(customerId, Coupon.RowId);

            Assert.IsNotNull(version);
        }
コード例 #9
0
        public void TestMethod1()
        {
            Customer customer = new Customer();

            customer.MembershipType = MembershipPayment.MembershipTypeEnum.Activate;
            customer.VideoText      = "Learning to ski";

            MembershipPayment membershipPayment = new MembershipPayment(MembershipPayment.MembershipTypeEnum.Activate);

            BookPayment              bookPayment              = new BookPayment();
            VideoPAyment             videoPayment             = new VideoPAyment();
            PhysicalProductPaymentcs physicalProductPaymentcs = new PhysicalProductPaymentcs();


            //Below code to test with varios payment types and assert
            ProcessOrder order = new ProcessOrder(bookPayment, customer);
        }
コード例 #10
0
        public ActionResult CompleteBuy(int id, string userName, int buyCost)
        {
            KnihovnaUserDao d       = new KnihovnaUserDao();
            BookPaymentDao  dao     = new BookPaymentDao();
            BookPayment     payment = new BookPayment();

            payment.Id           = Books.Counter();
            payment.DateUnlocked = DateTime.Now;
            payment.IsPreview    = false;
            payment.PostId       = id;
            payment.UserId       = d.GetByLogin(userName).Id;

            KnihovnaUser user = d.GetByLogin(userName);

            user.Money -= buyCost;

            dao.Create(payment);
            d.Update(user);

            return(Redirect(Request.UrlReferrer.ToString()));
        }
コード例 #11
0
        public async Task TrackTotalPaymentsValue()
        {
            var cartId     = Guid.NewGuid().ToString();
            var customerId = Guid.NewGuid().ToString();

            var submitOrder = new SubmitOrder
            {
                CartId   = cartId,
                Customer = customerId,
                Items    = new List <Filling>
                {
                    Filling.Meat,
                    Filling.Mushrooms,
                    Filling.QuarkAndPotatoes
                }
            };

            var bookPayment = new BookPayment {
                Id = Guid.NewGuid(), CartId = cartId, Customer = customerId
            };

            var cancelPayment = new CancelPayment {
                Id = Guid.NewGuid(), CartId = cartId, Customer = customerId
            };

            await SendInOrder(new IMessage[]
            {
                submitOrder,
                bookPayment,
                cancelPayment,
                bookPayment
            }
                              );

            var(payment, _) = await marketingRepository.Get <Payments>(customerId, Payments.RowId);

            Assert.AreEqual(0, payment.TotalValue);
        }
コード例 #12
0
 public BookPayProcess(BookPayment bookPayment)
 {
     this._bookPayment = bookPayment;
 }