Ejemplo n.º 1
0
        private static void RefundPayment_Federated()
        {
            Console.WriteLine("Begin RefundFederatedPaymentUX");

            var context   = new AnonymousCustomerBob().Context;
            var container = context.ShopsContainer();
            var orderid   = Scenarios.SimplePhysical2Items.Run(new AnonymousCustomerBob().Context).Result;
            var order     = Orders.GetOrder(container, orderid);
            var paymentId = order.Components.OfType <Sitecore.Commerce.Plugin.Payments.FederatedPaymentComponent>().FirstOrDefault()?.Id;

            Orders.RunPendingOrdersMinion(context);
            Orders.RunReleasedOrdersMinion(context);
            Orders.RunSettleSalesActivitiesMinion(context);
            var view = Proxy.GetValue(ShopsContainer.GetEntityView(orderid, "RefundPayment", "RefundPayment", paymentId));

            var result = Proxy.DoCommand(ShopsContainer.DoAction(view));

            result.Should().NotBeNull();
            result.Messages.Any(m => m.Code.Equals("error", StringComparison.OrdinalIgnoreCase)).Should().BeFalse();

            var updatedOrderView = Proxy.GetValue(ShopsContainer.GetEntityView(orderid, "Master", string.Empty, string.Empty));

            var salesActivities = updatedOrderView.ChildViews.FirstOrDefault(p => p.Name.Equals("SalesActivities")) as EntityView;

            salesActivities.Should().NotBeNull();
            //There should be 2 Sales Activities now. The original one and the one for the refund.
            salesActivities?.ChildViews.Count.Should().Be(2);

            // Get the OrderPayments View and validate that the payment is now gone
            var paymentsView = Proxy.GetValue(ShopsContainer.GetEntityView(orderid, "OrderPayments", string.Empty, string.Empty));

            paymentsView.ChildViews.Count().Should().Be(0);
        }
Ejemplo n.º 2
0
        private static void OrderEntitlements(ShopperContext context)
        {
            Console.WriteLine("Begin OrderEntitlements View");

            var orderId = Scenarios.Simple2PhysicalDigitalItems.Run(context).Result;

            orderId.Should().NotBeNull();

            Orders.RunPendingOrdersMinion(context);
            Orders.RunSettleSalesActivitiesMinion(context);
            Orders.RunReleasedOrdersMinion(context);

            var result = Proxy.GetValue(ShopsContainer.GetEntityView(orderId, "OrderEntitlements", string.Empty, string.Empty));

            result.Should().NotBeNull();
            result.Policies.Should().NotBeEmpty();
            result.Properties.Should().NotBeEmpty();
            result.ChildViews.Should().NotBeEmpty();
            foreach (var childView in result.ChildViews.Cast <EntityView>())
            {
                childView.Should().NotBeNull();
                childView.Policies.Should().BeEmpty();
                childView.Properties.Should().NotBeEmpty();
                childView.Properties.All(p => !string.IsNullOrEmpty(p.Value)).Should().BeTrue();
                childView.ChildViews.Should().BeEmpty();
            }
        }
Ejemplo n.º 3
0
        private static Order CreateCompletedOrder()
        {
            var orderId = Buy1ItemMultipleQuantity.Run(_context);

            orderId.Should().NotBeNullOrEmpty();

            var order = Orders.GetOrder(_context.ShopsContainer(), orderId);

            order.Should().NotBeNull();
            order.Lines.Should().NotBeEmpty();
            order.Lines.FirstOrDefault().Should().NotBeNull();

            var lineId = order.Lines.FirstOrDefault()?.Id;

            lineId.Should().NotBeNullOrEmpty();

            var paymentId = order.Components.OfType <PaymentComponent>().FirstOrDefault()?.Id;

            paymentId.Should().NotBeNullOrEmpty();

            Orders.RunPendingOrdersMinion(_context);
            Orders.RunReleasedOrdersMinion(_context);

            return(order);
        }
Ejemplo n.º 4
0
        private static void OrderEntitlements(ShopperContext context)
        {
            using (new SampleMethodScope())
            {
                var orderId = Simple2PhysicalDigitalItems.Run(context);
                orderId.Should().NotBeNull();

                Orders.RunPendingOrdersMinion(context);
                Orders.RunReleasedOrdersMinion(context);

                var result = Proxy.GetValue(
                    ShopsContainer.GetEntityView(orderId, "OrderEntitlements", string.Empty, string.Empty));
                result.Should().NotBeNull();
                result.Policies.Should().NotBeEmpty();
                result.Properties.Should().NotBeEmpty();
                result.ChildViews.Should().NotBeEmpty();
                foreach (var childView in result.ChildViews.Cast <EntityView>())
                {
                    childView.Should().NotBeNull();
                    childView.Policies.Should().BeEmpty();
                    childView.Properties.Should().NotBeEmpty();
                    childView.Properties.All(p => !string.IsNullOrEmpty(p.Value)).Should().BeTrue();
                    childView.ChildViews.Should().BeEmpty();
                }
            }
        }
Ejemplo n.º 5
0
        private static Order CreateCompletedOrder()
        {
            var orderId = Scenarios.Buy1ItemMultipleQuantity.Run(_context).Result;

            orderId.Should().NotBeNullOrEmpty();

            var order = Orders.GetOrder(_context.ShopsContainer(), orderId);

            order.Should().NotBeNull();
            order.Lines.Should().NotBeEmpty();
            order.Lines.FirstOrDefault().Should().NotBeNull();

            var lineId = order.Lines.FirstOrDefault()?.Id;

            lineId.Should().NotBeNullOrEmpty();

            var paymentId = order.Components.OfType <Sitecore.Commerce.Plugin.Payments.PaymentComponent>().FirstOrDefault()?.Id;

            paymentId.Should().NotBeNullOrEmpty();

            Orders.RunPendingOrdersMinion(_context);
            Orders.RunSettleSalesActivitiesMinion(_context);
            Orders.RunReleasedOrdersMinion(_context);
            WriteListCounts(_context.ShopsContainer());

            return(order);
        }
Ejemplo n.º 6
0
        private static Order CreateDigitalCompletedOrder()
        {
            var orderId = BuyWarranty.Run(_context, 2);

            orderId.Should().NotBeNullOrEmpty();

            var order = Orders.GetOrder(_context.ShopsContainer(), orderId);

            order.Should().NotBeNull();

            Orders.RunPendingOrdersMinion(_context);
            Orders.RunReleasedOrdersMinion(_context);

            return(order);
        }
Ejemplo n.º 7
0
        private static Order CreateDigitalCompletedOrder()
        {
            var orderId = Scenarios.BuyWarranty.Run(_context, 2).Result;

            orderId.Should().NotBeNullOrEmpty();

            var order = Orders.GetOrder(_context.ShopsContainer(), orderId);

            order.Should().NotBeNull();

            Orders.RunPendingOrdersMinion(_context);
            Orders.RunSettleSalesActivitiesMinion(_context);
            Orders.RunReleasedOrdersMinion(_context);

            return(order);
        }
Ejemplo n.º 8
0
        private static void RefundPayment_Federated()
        {
            using (new SampleMethodScope())
            {
                var context   = new AnonymousCustomerBob().Context;
                var container = context.ShopsContainer();
                var orderid   = SimplePhysical2Items.Run(new AnonymousCustomerBob().Context);
                var order     = Orders.GetOrder(container, orderid);
                var paymentId = order.Components.OfType <FederatedPaymentComponent>()
                                .FirstOrDefault()
                                ?.Id;

                Orders.RunPendingOrdersMinion(context);
                Orders.RunReleasedOrdersMinion(context);
                var view = Proxy.GetValue(
                    ShopsContainer.GetEntityView(orderid, "RefundPayment", "RefundPayment", paymentId));

                var result = Proxy.DoCommand(ShopsContainer.DoAction(view));

                result.Should().NotBeNull();
                result.Messages.Should().NotContainErrors();

                var updatedOrderView = Proxy.GetValue(
                    ShopsContainer.GetEntityView(orderid, "Master", string.Empty, string.Empty));

                var salesActivities =
                    updatedOrderView.ChildViews.FirstOrDefault(p => p.Name.Equals("SalesActivities")) as EntityView;
                salesActivities.Should().NotBeNull();

                //There should be 2 Sales Activities now. The original one and the one for the refund.
                salesActivities?.ChildViews.Count.Should().Be(2);

                // Get the OrderPayments View and validate that the payment is now gone
                var paymentsView = Proxy.GetValue(
                    ShopsContainer.GetEntityView(orderid, "OrderPayments", string.Empty, string.Empty));
                paymentsView.ChildViews.Count().Should().Be(0);
            }
        }
 private static void RunMinions(ShopperContext context)
 {
     Orders.RunPendingOrdersMinion(context);
     Orders.RunReleasedOrdersMinion(context);
 }
Ejemplo n.º 10
0
 private static void RunMinions(ShopperContext context)
 {
     Orders.RunPendingOrdersMinion(context);
     Orders.RunSettleSalesActivitiesMinion(context);
     Orders.RunReleasedOrdersMinion(context);
 }