Beispiel #1
0
        public ActionResult Index()
        {
            var order = RouteData.Values["order"] as Order;
            var model = new EditBillingViewModel {
                OrderId = order.bvin
            };

            LoadPaymentModel(model, order);
            LoadAddress(model, order);

            return(View(model));
        }
Beispiel #2
0
        public JsonResult Save(FormCollection form)
        {
            var model = new EditBillingViewModel();

            if (TryUpdateModel(model))
            {
                var orderId    = model.OrderId;
                var o          = HccApp.OrderServices.Orders.FindForCurrentStore(orderId);
                var payManager = new OrderPaymentManager(o, HccApp);

                model.AddressModel.CopyTo(o.BillingAddress);
                HccApp.OrderServices.Orders.Update(o);

                var cardForm = model.PaymentModel.CreditCardForm;

                var cardData = new CardData
                {
                    CardNumber      = cardForm.CardNumber,
                    ExpirationMonth = cardForm.ExpirationMonth,
                    ExpirationYear  = cardForm.ExpirationYear,
                    SecurityCode    = cardForm.SecurityCode,
                    CardHolderName  = cardForm.CardHolderName
                };

                foreach (var li in o.Items)
                {
                    li.RecurringBilling.LoadPaymentInfo(HccApp);

                    if (!li.RecurringBilling.IsCancelled)
                    {
                        var result = payManager.RecurringSubscriptionUpdate(li.Id, cardData);

                        if (!result.Succeeded)
                        {
                            ModelState.AddModelError("rbUpdate",
                                                     string.Format("Subscription '{0}' update failed.", li.ProductName));
                        }
                    }
                }

                if (ModelState.IsValid)
                {
                    return(Json(new { Status = "OK", Message = string.Empty }));
                }
            }

            return(Json(new { Status = "Invalid", Message = GetValidationSummaryMessage() }));
        }
Beispiel #3
0
        private void LoadPaymentModel(EditBillingViewModel model, Order order)
        {
            var payManager = new OrderPaymentManager(order, HccApp);
            var pModel     = new PaymentViewModel
            {
                PaymentMethods = PaymentMethods.EnabledMethods(HccApp.CurrentStore, true),
                CreditCardForm = { AcceptedCardTypes = HccApp.CurrentStore.Settings.PaymentAcceptedCards }
            };

            var trInfo = payManager.GetLastCreditCardTransaction();

            pModel.CreditCardForm.ExpirationMonth = trInfo.CreditCard.ExpirationMonth;
            pModel.CreditCardForm.ExpirationYear  = trInfo.CreditCard.ExpirationYear;
            pModel.CreditCardForm.CardHolderName  = trInfo.CreditCard.CardHolderName;
            pModel.CreditCardForm.CardNumber      = "XXXXXXXXXXXX" + trInfo.CreditCard.CardNumberLast4Digits;

            model.PaymentModel = pModel;
        }
Beispiel #4
0
        private void LoadAddress(EditBillingViewModel model, Order order)
        {
            var aModel = new AddressViewModel(order.BillingAddress)
            {
                Countries = HccApp.GlobalizationServices.Countries.FindActiveCountries()
            };

            var country = HccApp.GlobalizationServices.Countries.Find(aModel.CountryBvin);

            aModel.Regions = new List <Region>(country.Regions);

            var notSelectedRegion = new Region
            {
                DisplayName  = Localization.GetString("NotSelectedItem"),
                Abbreviation = aModel.Regions.Count == 0 ? "_" : string.Empty
            };

            aModel.Regions.Insert(0, notSelectedRegion);

            model.AddressModel = aModel;
        }