Example #1
0
        public override bool Execute(OrderTaskContext context)
        {
            if (context.Order.IsRecurring)
            {
                return(true);
            }

            if (context.PreviousPaymentStatus == OrderPaymentStatus.Paid &&
                context.Order.PaymentStatus != OrderPaymentStatus.Paid)
            {
                var statusCode  = OrderStatusCode.Received;
                var orderStatus = OrderStatusCode.FindByBvin(statusCode);
                if (orderStatus != null && orderStatus.Bvin != string.Empty)
                {
                    context.Order.StatusCode = orderStatus.Bvin;
                    context.Order.StatusName = orderStatus.StatusName;
                }
                else
                {
                    EventLog.LogEvent("Change Order Status When Payment Removed",
                                      "Could not find order status with id of " + statusCode, EventLogSeverity.Error);
                }
            }

            return(true);
        }
Example #2
0
 public override bool Execute(OrderTaskContext context)
 {
     if (context.Inputs["PreviousShippingStatus"] != null)
     {
         var val    = 0;
         var parsed = int.TryParse(context.Inputs["PreviousShippingStatus"].Value, out val);
         if (parsed && val == (int)OrderShippingStatus.FullyShipped)
         {
             if (context.Order.ShippingStatus != OrderShippingStatus.NonShipping &&
                 context.Order.ShippingStatus != OrderShippingStatus.FullyShipped)
             {
                 var statusCode  = OrderStatusCode.Received;
                 var orderStatus = OrderStatusCode.FindByBvin(statusCode);
                 if (orderStatus != null && orderStatus.Bvin != string.Empty)
                 {
                     context.Order.StatusCode = orderStatus.Bvin;
                     context.Order.StatusName = orderStatus.StatusName;
                 }
                 else
                 {
                     EventLog.LogEvent("Change Order Status When Shipment Removed",
                                       "Could not find order status with id of " + statusCode, EventLogSeverity.Error);
                 }
             }
         }
     }
     return(true);
 }
        public override bool Execute(OrderTaskContext context)
        {
            if (context.Order.IsPlaced)
            {
                return(true);
            }
            if (context.Order.Items.Count == 0)
            {
                context.Errors.Add(new WorkflowMessage("Order already placed.",
                                                       GlobalLocalization.GetString("OrderAlreadyPlaced"), true));
                return(false);
            }

            context.Order.IsPlaced       = true;
            context.Order.TimeOfOrderUtc = DateTime.UtcNow;

            var errors = new List <string>();

            if (!context.HccApp.OrdersReserveInventoryForAllItems(context.Order, errors))
            {
                foreach (var item in errors)
                {
                    context.Errors.Add(new WorkflowMessage("Stock Too Low", item, true));
                }
                return(false);
            }

            if (context.HccApp.CurrentRequestContext.RoutingContext.HttpContext != null)
            {
                var request = context.HccApp.CurrentRequestContext.RoutingContext.HttpContext.Request;
                var note    = new OrderNote();
                note.IsPublic = false;
                note.Note     = "Customer IP: " + request.UserHostAddress;
                note.Note    += "<br> Customer Host: " + request.UserHostName;
                note.Note    += "<br> Browser: " + request.UserAgent;
                context.Order.Notes.Add(note);

                context.Order.UserDeviceType = DetermineDeviceType(request);
            }

            var c = OrderStatusCode.FindByBvin(OrderStatusCode.Received);

            if (c != null)
            {
                var affiliateId = context.HccApp.ContactServices.GetCurrentAffiliateId();

                context.Order.StatusName  = c.StatusName;
                context.Order.StatusCode  = c.Bvin;
                context.Order.AffiliateID = affiliateId;

                if (affiliateId.HasValue)
                {
                    context.HccApp.ContactServices.UpdateProfileAffiliateId(affiliateId.Value);
                }
            }
            return(true);
        }
Example #4
0
        protected void lstStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (CurrentOrder != null)
            {
                var prevStatusCode = CurrentOrder.StatusCode;
                var newStatusCode  = OrderStatusCode.FindByBvin(lstStatus.SelectedValue);

                CurrentOrder.StatusCode = newStatusCode.Bvin;
                CurrentOrder.StatusName = newStatusCode.StatusName;

                HccApp.OrderServices.Orders.Update(CurrentOrder);
                HccApp.OrderServices.OrderStatusChanged(CurrentOrder, prevStatusCode);
            }
        }
 public override bool Execute(OrderTaskContext context)
 {
     if (!context.Order.IsRecurring &&
         context.Order.ShippingStatus == OrderShippingStatus.FullyShipped &&
         context.Order.PaymentStatus == OrderPaymentStatus.Paid)
     {
         var orderStatus = OrderStatusCode.FindByBvin(OrderStatusCode.Completed);
         if (orderStatus != null)
         {
             context.Order.StatusCode = orderStatus.Bvin;
             context.Order.StatusName = orderStatus.StatusName;
         }
     }
     return(true);
 }
Example #6
0
        public override bool Execute(OrderTaskContext context)
        {
            var result = true;

            if (context.Order != null)
            {
                var d = new FraudCheckData();
                PopulateFraudData(d, context);

                var scorer = new FraudScorer(context.HccApp.CurrentRequestContext);

                context.Order.FraudScore = scorer.ScoreData(d);

                if (context.Order.FraudScore >= 5)
                {
                    var s = OrderStatusCode.FindByBvin(OrderStatusCode.OnHold);
                    context.Order.StatusCode = s.Bvin;
                    context.Order.StatusName = s.StatusName;
                    context.HccApp.OrderServices.Orders.Update(context.Order);
                }

                if (d.Messages.Count > 0)
                {
                    var n = new OrderNote();
                    n.IsPublic = false;
                    n.Note     = "Fraud Check Failed";
                    foreach (var m in d.Messages)
                    {
                        n.Note += " | " + m;
                    }
                    context.Order.Notes.Add(n);
                }

                context.HccApp.OrderServices.Orders.Update(context.Order);
            }

            return(result);
        }
Example #7
0
        public override bool Execute(OrderTaskContext context)
        {
            bool result = true;

            if (context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth > 0)
            {
                //Use the last transaction entered by customer first
                List <OrderTransaction> transactions = context.HccApp.OrderServices.Transactions
                                                       .FindForOrder(context.Order.bvin)
                                                       .OrderByDescending(x => x.TimeStampUtc)
                                                       .ToList();

                decimal dueAmount = context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth;

                foreach (OrderTransaction p in transactions)
                {
                    if (p.Action == ActionType.CreditCardInfo)
                    {
                        // if we already have an auth or charge on the card, skip
                        if (p.HasSuccessfulLinkedAction(ActionType.CreditCardCharge, transactions) ||
                            p.HasSuccessfulLinkedAction(ActionType.CreditCardHold, transactions))
                        {
                            OrderNote note = new OrderNote();
                            note.IsPublic = false;
                            note.Note     = "Skipping receive for credit card info because auth or charge already exists. Transaction " + p.Id;
                            context.Order.Notes.Add(note);
                            continue;
                        }
                        result &= ProcessTransaction(context, p);

                        if (result == true)
                        {
                            dueAmount = context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth;
                            //Due amount is already charged, no need to charge other cards
                            if (dueAmount <= 0)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                OrderNote note = new OrderNote();
                note.IsPublic = false;
                note.Note     = "Amount due was less than zero. Skipping receive credit cards";
                context.Order.Notes.Add(note);
            }

            if (!result)
            {
                string errorString = "An error occurred while attempting to process your credit card. Please check your payment information and try again";
                context.Errors.Add(new WorkflowMessage("Receive Card Failed", errorString, true));

                string          failCode = OrderStatusCode.OnHold;
                OrderStatusCode c        = OrderStatusCode.FindByBvin(failCode);
                if (c != null)
                {
                    context.Order.StatusCode = c.Bvin;
                    context.Order.StatusName = c.StatusName;
                }
            }
            return(result);
        }
        public override bool Execute(OrderTaskContext context)
        {
            var result = true;

            if (context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth > 0)
            {
                List <OrderTransaction> transactions = context.HccApp.OrderServices.Transactions
                                                       .FindForOrder(context.Order.bvin)
                                                       .OrderByDescending(x => x.TimeStampUtc)
                                                       .ToList();

                decimal dueAmount = context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth;

                foreach (OrderTransaction p in transactions)
                {
                    if (p.Action == ActionType.GiftCardInfo)
                    {
                        // if we already have an auth or charge on the card, skip
                        if (p.HasSuccessfulLinkedAction(ActionType.GiftCardDecrease, transactions) ||
                            p.HasSuccessfulLinkedAction(ActionType.GiftCardCapture, transactions) ||
                            p.HasSuccessfulLinkedAction(ActionType.GiftCardHold, transactions))
                        {
                            var note = new OrderNote();
                            note.IsPublic = false;
                            note.Note     = "Skipping receive for gift card info because auth or charge already exists. Transaction " + p.Id;
                            context.Order.Notes.Add(note);
                            continue;
                        }

                        try
                        {
                            var         payManager    = new OrderPaymentManager(context.Order, context.HccApp);
                            var         storeSettings = context.HccApp.CurrentStore.Settings;
                            Transaction t             = payManager.CreateEmptyTransaction();
                            t.GiftCard.CardNumber = p.GiftCard.CardNumber;
                            t.Amount = p.Amount;

                            GiftCardGateway proc = storeSettings.PaymentCurrentGiftCardProcessor();

                            if (storeSettings.PaymentGiftCardAuthorizeOnly && proc.CanAuthorize)
                            {
                                t.Action = ActionType.GiftCardHold;
                            }
                            else
                            {
                                t.Action = ActionType.GiftCardDecrease;
                            }

                            proc.ProcessTransaction(t);

                            OrderTransaction ot = new OrderTransaction(t);
                            ot.LinkedToTransaction = p.IdAsString;
                            context.HccApp.OrderServices.AddPaymentTransactionToOrder(context.Order, ot);

                            if (t.Result.Succeeded == false)
                            {
                                result = false;
                            }
                        }
                        catch (Exception ex)
                        {
                            context.Errors.Add(new WorkflowMessage("Exception During Receive Gift Card", ex.Message + ex.StackTrace, false));
                            OrderNote note = new OrderNote();
                            note.IsPublic = false;
                            note.Note     = "EXCEPTION: " + ex.Message + " | " + ex.StackTrace;
                            context.Order.Notes.Add(note);
                        }

                        dueAmount = context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth;
                        //Amount required in order is already charged. No need to charge on other transactions
                        if (dueAmount <= 0)
                        {
                            break;
                        }
                    }
                }
            }
            else
            {
                var note = new OrderNote();
                note.IsPublic = false;
                note.Note     = "Amount due was less than zero. Skipping receive gift cards";
                context.Order.Notes.Add(note);
            }

            if (!result)
            {
                string errorString = "An error occurred while attempting to process your gift card. Please check your payment information and try again";
                context.Errors.Add(new WorkflowMessage("Receive Gift Card Failed", errorString, true));

                // Failure Status Code
                string          failCode = OrderStatusCode.OnHold;
                OrderStatusCode c        = OrderStatusCode.FindByBvin(failCode);
                if (c != null)
                {
                    context.Order.StatusCode = c.Bvin;
                    context.Order.StatusName = c.StatusName;
                }
            }
            return(result);
        }
        public override bool Execute(OrderTaskContext context)
        {
            bool result = true;

            if (context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth > 0)
            {
                //Use the last transaction entered by customer first
                List <OrderTransaction> transactions = context.HccApp.OrderServices.Transactions
                                                       .FindForOrder(context.Order.bvin)
                                                       .OrderByDescending(x => x.TimeStampUtc)
                                                       .ToList();

                decimal dueAmount = context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth;

                foreach (OrderTransaction p in transactions)
                {
                    if (p.Action == ActionType.PayPalExpressCheckoutInfo)
                    {
                        // if we already have an auth or charge on the card, skip
                        if (p.HasSuccessfulLinkedAction(ActionType.PayPalHold, transactions) ||
                            p.HasSuccessfulLinkedAction(ActionType.PayPalCharge, transactions))
                        {
                            continue;
                        }

                        try
                        {
                            OrderPaymentManager payManager = new OrderPaymentManager(context.Order, context.HccApp);
                            decimal             amount     = context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth;
                            result = context.HccApp.CurrentRequestContext.CurrentStore.Settings.PayPal.ExpressAuthorizeOnly ? payManager.PayPalExpressHold(p, amount) : payManager.PayPalExpressCharge(p, amount);

                            if (result == true)
                            {
                                dueAmount = context.HccApp.OrderServices.PaymentSummary(context.Order).AmountDueWithAuth;
                                //Amount required in order is already charged. No need to charge on other transactions
                                if (dueAmount <= 0)
                                {
                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            context.Errors.Add(new WorkflowMessage("Exception During Receive Paypal Express Payments", ex.Message + ex.StackTrace, false));
                        }
                    }
                }
            }

            if (result == false)
            {
                var errorString = "An error occurred while attempting to process your Paypal Express payment. Please check your payment information and try again";
                context.Errors.Add(new WorkflowMessage("Receive Card Failed", errorString, true));

                // Failure Status Code
                var failCode = OrderStatusCode.OnHold;
                var c        = OrderStatusCode.FindByBvin(failCode);
                if (c != null)
                {
                    context.Order.StatusCode = c.Bvin;
                    context.Order.StatusName = c.StatusName;
                }
            }
            return(result);
        }