Пример #1
0
        public void ForwardToCheckout(CartViewModel model)
        {
            if (Request["paypalexpress"] != null && Request["paypalexpress"] == "true")
            {
                ForwardToPayPalExpress(model);
            }

            OrderTaskContext c = new OrderTaskContext(MTApp);
            c.UserId = SessionManager.GetCurrentUserId(MTApp.CurrentStore);
            c.Order = model.CurrentOrder;
            if (Workflow.RunByName(c, WorkflowNames.CheckoutSelected))
            {
                Response.Redirect(MTApp.StoreUrl(true, false) + "checkout");
            }
            else
            {
                bool customerMessageFound = false;
                foreach (WorkflowMessage msg in c.Errors)
                {
                    EventLog.LogEvent(msg.Name, msg.Description, EventLogSeverity.Error);
                    if (msg.CustomerVisible)
                    {
                        customerMessageFound = true;
                        this.FlashFailure(msg.Description);
                    }
                }
                if (!customerMessageFound)
                {
                    EventLog.LogEvent("Checkout Selected Workflow", "Checkout failed but no errors were recorded.", EventLogSeverity.Error);
                    this.FlashFailure("Checkout Failed. If problem continues, please contact customer support.");
                }
            }
        }
Пример #2
0
        public void ForwardToPayPalExpress(CartViewModel model)
        {
            Order Basket = model.CurrentOrder;

            // Save as Order
            MerchantTribe.Commerce.BusinessRules.OrderTaskContext c
                     = new MerchantTribe.Commerce.BusinessRules.OrderTaskContext(MTApp);
            c.UserId = SessionManager.GetCurrentUserId(MTApp.CurrentStore);
            c.Order  = Basket;
            bool checkoutFailed = false;

            if (!MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.CheckoutSelected))
            {
                checkoutFailed = true;
                bool customerMessageFound = false;
                foreach (MerchantTribe.Commerce.BusinessRules.WorkflowMessage msg in c.Errors)
                {
                    EventLog.LogEvent(msg.Name, msg.Description, EventLogSeverity.Error);
                    if (msg.CustomerVisible)
                    {
                        customerMessageFound = true;
                        FlashWarning(msg.Description);
                    }
                }
                if (!customerMessageFound)
                {
                    EventLog.LogEvent("Checkout Selected Workflow", "Checkout failed but no errors were recorded.", EventLogSeverity.Error);
                    FlashWarning("Checkout Failed. If problem continues, please contact customer support.");
                }
            }

            if (!checkoutFailed)
            {
                c.Inputs.Add("bvsoftware", "Mode", "PaypalExpress");
                if (!MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ThirdPartyCheckoutSelected))
                {
                    bool customerMessageFound = false;
                    EventLog.LogEvent("Paypal Express Checkout Failed", "Specific Errors to follow", EventLogSeverity.Error);
                    foreach (MerchantTribe.Commerce.BusinessRules.WorkflowMessage item in c.Errors)
                    {
                        EventLog.LogEvent("Paypal Express Checkout Failed", item.Name + ": " + item.Description, EventLogSeverity.Error);
                        if (item.CustomerVisible)
                        {
                            FlashWarning(item.Description);
                            customerMessageFound = true;
                        }
                    }
                    if (!customerMessageFound)
                    {
                        FlashWarning("Paypal Express Checkout Failed. If this problem persists please notify customer support.");
                    }
                }
            }
        }
 public override bool Execute(OrderTaskContext context)
 {
     if (context.MTApp.CurrentStore.Settings.Avalara.Enabled)
     {
         if (string.IsNullOrEmpty(context.Order.CustomProperties.GetProperty("bvsoftware",BVAvaTax.AvalaraOrderEditedPropertyName)))
         {
             if (context.Order.PaymentStatus != OrderPaymentStatus.Paid)
             {
                 if (!string.IsNullOrEmpty(context.Order.CustomProperties.GetProperty("bvsoftware", BVAvaTax.AvalaraTaxPropertyName)))
                 {
                     Utilities.AvalaraUtilities.CancelAvalaraTaxDocument(context.Order, context.MTApp);
                 }
             }
         }                
     }
     return true;
 }
Пример #4
0
        public ActionResult IndexPost()
        {
            CheckoutViewModel model = IndexSetup();

            DisplayPaypalExpressMode(model);
            LoadShippingMethodsForOrder(model);

            if (ValidatePage(model))
            {
                SaveShippingSelections(model);
                // Save Payment Information
                SavePaymentInfo(model);
                MTApp.OrderServices.Orders.Update(model.CurrentOrder);

                // Save as Order
                MerchantTribe.Commerce.BusinessRules.OrderTaskContext c
                         = new MerchantTribe.Commerce.BusinessRules.OrderTaskContext(MTApp);
                c.UserId = SessionManager.GetCurrentUserId(MTApp.CurrentStore);
                c.Order  = model.CurrentOrder;

                if (MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrder))
                {
                    // Clear Cart ID because we're now an order
                    SessionManager.SetCurrentCartId(MTApp.CurrentStore, string.Empty);

                    // Process Payment
                    if (MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrderPayments))
                    {
                        MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrderAfterPayments);
                        Order tempOrder = MTApp.OrderServices.Orders.FindForCurrentStore(model.CurrentOrder.bvin);
                        MerchantTribe.Commerce.Integration.Current().OrderReceived(tempOrder, MTApp);
                        Response.Redirect("~/checkout/receipt?id=" + model.CurrentOrder.bvin);
                    }
                }
            }
            // Render Error Summary
            foreach (var v in model.Violations)
            {
                FlashFailure(v.ErrorMessage);
            }

            ViewBag.HideEditButton = true;
            return(View(model));
        }
Пример #5
0
 public override bool Execute(OrderTaskContext context)
 {
     if (context.MTApp.CurrentStore.Settings.Avalara.Enabled)
     {
         if (string.IsNullOrEmpty(context.Order.CustomProperties.GetProperty("bvsoftware",BVAvaTax.AvalaraOrderEditedPropertyName)))
         {
             try
             {
                 var originationAddress = Utilities.AvalaraUtilities.ConvertAddressToAvalara(context.MTApp.ContactServices.Addresses.FindStoreContactAddress());
                 var destinationAddress = Utilities.AvalaraUtilities.ConvertAddressToAvalara(context.Order.ShippingAddress);
                 var lines = Utilities.AvalaraUtilities.ConvertOrderLines(context.Order.Items);
                 var OrderIdentifier = Utilities.AvalaraUtilities.GetOrderIdentifier(context.Order, context.MTApp);
                 Utilities.AvalaraUtilities.CommitAvalaraTaxes(context.Order, OrderIdentifier, originationAddress, destinationAddress, lines, context.MTApp);
             }
             finally
             {
                 context.MTApp.OrderServices.Orders.Update(context.Order);
             }                    
         }
     }
     return true;
 }
Пример #6
0
        public void ForwardToPayPalExpress(CartViewModel model)
        {
            Order Basket = model.CurrentOrder;
            // Save as Order
            MerchantTribe.Commerce.BusinessRules.OrderTaskContext c
                = new MerchantTribe.Commerce.BusinessRules.OrderTaskContext(MTApp);
            c.UserId = SessionManager.GetCurrentUserId(MTApp.CurrentStore);
            c.Order = Basket;
            bool checkoutFailed = false;
            if (!MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.CheckoutSelected))
            {
                checkoutFailed = true;
                bool customerMessageFound = false;
                foreach (MerchantTribe.Commerce.BusinessRules.WorkflowMessage msg in c.Errors)
                {
                    EventLog.LogEvent(msg.Name, msg.Description, EventLogSeverity.Error);
                    if (msg.CustomerVisible)
                    {
                        customerMessageFound = true;
                        FlashWarning(msg.Description);
                    }
                }
                if (!customerMessageFound)
                {
                    EventLog.LogEvent("Checkout Selected Workflow", "Checkout failed but no errors were recorded.", EventLogSeverity.Error);
                    FlashWarning("Checkout Failed. If problem continues, please contact customer support.");
                }
            }

            if (!checkoutFailed)
            {
                c.Inputs.Add("bvsoftware", "Mode", "PaypalExpress");
                if (!MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ThirdPartyCheckoutSelected))
                {
                    bool customerMessageFound = false;
                    EventLog.LogEvent("Paypal Express Checkout Failed", "Specific Errors to follow", EventLogSeverity.Error);
                    foreach (MerchantTribe.Commerce.BusinessRules.WorkflowMessage item in c.Errors)
                    {
                        EventLog.LogEvent("Paypal Express Checkout Failed", item.Name + ": " + item.Description, EventLogSeverity.Error);
                        if (item.CustomerVisible)
                        {
                            FlashWarning(item.Description);
                            customerMessageFound = true;
                        }
                    }
                    if (!customerMessageFound)
                    {
                        FlashWarning("Paypal Express Checkout Failed. If this problem persists please notify customer support.");
                    }
                }
            }
        }
        private void ProcessPaymentErrorOrder(CheckoutViewModel model)
        {
            // Save as Order
            OrderTaskContext c = new OrderTaskContext(MTApp);
            c.UserId = MTApp.CurrentCustomerId;
            c.Order = model.CurrentOrder;

            if (Workflow.RunByName(c, WorkflowNames.ProcessNewOrderPayments) == true)
            {
                // Clear Pending Cart ID because payment is good
                SessionManager.SetCurrentPaymentPendingCartId(MTApp.CurrentStore, string.Empty);

                // Process Post Payment Stuff
                MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrderAfterPayments);
                Order tempOrder = MTApp.OrderServices.Orders.FindForCurrentStore(model.CurrentOrder.bvin);
                MTApp.CurrentRequestContext.IntegrationEvents.OrderReceived(tempOrder, MTApp);
                Response.Redirect("~/checkout/receipt?id=" + model.CurrentOrder.bvin);
            }
        }
        private void ProcessOrder(CheckoutViewModel model)
        {
            // Save as Order
            OrderTaskContext c = new OrderTaskContext(MTApp);
            c.UserId = MTApp.CurrentCustomerId;
            c.Order = model.CurrentOrder;

            // Check for PayPal Request
            bool paypalCheckoutSelected = model.PaymentViewModel.SelectedPayment == "paypal";
            if (paypalCheckoutSelected)
            {
                c.Inputs.Add("bvsoftware", "Mode", "PaypalExpress");
                c.Inputs.Add("bvsoftware", "AddressSupplied", "1");
                if (!Workflow.RunByName(c, WorkflowNames.ThirdPartyCheckoutSelected))
                {
                    EventLog.LogEvent("Paypal Express Checkout Failed", "Specific Errors to follow", EventLogSeverity.Error);
                    // Show Errors
                    List<MerchantTribe.Web.Validation.RuleViolation> violations = new List<MerchantTribe.Web.Validation.RuleViolation>();
                    foreach (WorkflowMessage item in c.GetCustomerVisibleErrors())
                    {
                        violations.Add(new MerchantTribe.Web.Validation.RuleViolation("Workflow", item.Name, item.Description));
                    }
                }
            }
            else
            {
                if (Workflow.RunByName(c, WorkflowNames.ProcessNewOrder) == true)
                {
                    // Clear Cart ID because we're now an order
                    SessionManager.SetCurrentCartId(MTApp.CurrentStore, string.Empty);

                    // Process Payment
                    if (MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrderPayments))
                    {
                        MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrderAfterPayments);
                        Order tempOrder = MTApp.OrderServices.Orders.FindForCurrentStore(model.CurrentOrder.bvin);
                        MTApp.CurrentRequestContext.IntegrationEvents.OrderReceived(tempOrder, MTApp);
                        Response.Redirect("~/checkout/receipt?id=" + model.CurrentOrder.bvin);
                    }
                    else
                    {
                        // Redirect to Payment Error
                        SessionManager.SetCurrentPaymentPendingCartId(MTApp.CurrentStore, model.CurrentOrder.bvin);
                        Response.Redirect("~/checkout/paymenterror");
                    }
                }
                else
                {
                    // Show Errors
                    List<MerchantTribe.Web.Validation.RuleViolation> violations = new List<MerchantTribe.Web.Validation.RuleViolation>();
                    foreach (WorkflowMessage item in c.GetCustomerVisibleErrors())
                    {
                        violations.Add(new MerchantTribe.Web.Validation.RuleViolation("Workflow", item.Name, item.Description));
                    }
                    if (violations.Count < 1)
                    {
                        violations.Add(new MerchantTribe.Web.Validation.RuleViolation("Workflow", "Internal Error",
                            "An internal error occured while attempting to place your order. Please contact the store owner directly to complete your order."));
                    }
                }
            }
        }
        public ActionResult IndexPost()
        {
            CheckoutViewModel model = IndexSetup();
            DisplayPaypalExpressMode(model);
            LoadShippingMethodsForOrder(model);

            if (ValidatePage(model))
            {
                SaveShippingSelections(model);
                // Save Payment Information
                SavePaymentInfo(model);
                MTApp.OrderServices.Orders.Update(model.CurrentOrder);

                // Save as Order
                MerchantTribe.Commerce.BusinessRules.OrderTaskContext c
                    = new MerchantTribe.Commerce.BusinessRules.OrderTaskContext(MTApp);
                c.UserId = SessionManager.GetCurrentUserId(MTApp.CurrentStore);
                c.Order = model.CurrentOrder;

                if (MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrder))
                {
                    // Clear Cart ID because we're now an order
                    SessionManager.SetCurrentCartId(MTApp.CurrentStore, string.Empty);

                    // Process Payment
                    if (MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrderPayments))
                    {
                        MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(c, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ProcessNewOrderAfterPayments);
                        Order tempOrder = MTApp.OrderServices.Orders.FindForCurrentStore(model.CurrentOrder.bvin);
                        MerchantTribe.Commerce.Integration.Current().OrderReceived(tempOrder, MTApp);
                        Response.Redirect("~/checkout/receipt?id=" + model.CurrentOrder.bvin);
                    }
                }
            }
            // Render Error Summary
            foreach (var v in model.Violations)
            {
                FlashFailure(v.ErrorMessage);
            }

            ViewBag.HideEditButton = true;
            return View(model);
        }
 public override bool Rollback(OrderTaskContext context)
 {
     return true;
 }
 public bool OrdersShipPackage(OrderPackage p, Order o)
 {
     p.HasShipped = true;
     OrdersShipItems(p, o);
     BusinessRules.OrderTaskContext c = new BusinessRules.OrderTaskContext(this);
     c.Order = o;
     c.UserId = this.CurrentCustomerId;
     if (!BusinessRules.Workflow.RunByName(c, BusinessRules.WorkflowNames.PackageShipped))
     {
         EventLog.LogEvent("PackageShippedWorkflow", "Package Shipped Workflow Failed", EventLogSeverity.Debug);
         foreach (BusinessRules.WorkflowMessage item in c.Errors)
         {
             EventLog.LogEvent("PackageShippedWorkflow", item.Description, EventLogSeverity.Debug);
         }
     }
     return true;
 }
Пример #12
0
		public abstract bool Rollback(OrderTaskContext context);
Пример #13
0
		public abstract bool Execute(OrderTaskContext context);
Пример #14
0
		public override bool Execute(OrderTaskContext context)
		{
            return context.MTApp.OrderServices.Orders.Update(context.Order);
		}
Пример #15
0
 public abstract bool Rollback(OrderTaskContext context);
Пример #16
0
 public abstract bool Execute(OrderTaskContext context);