Beispiel #1
0
        //public Tour FindByCode(string code)
        //{
        //    return _giftCardRepository.FindBy(t => t.Code == code).SingleOrDefault();
        //}


        public GiftOrder UpdateBillingDetails(BillingDetails billingDetails)
        {
            var order          = FindOrder(billingDetails.GiftOrderId, billingDetails.UserId);
            var billingAddress = order.BillingAddress ?? new Address();

            billingAddress.InjectFrom(billingDetails);
            order.BillingAddress      = billingAddress;
            order.SpecialInstructions = billingDetails.SpecialInstructions;


            _giftCardOrderRepository.Update(order);

            var user = order.User;

            if (string.IsNullOrEmpty(user.FirstName))
            {
                user.FirstName = billingDetails.FirstName;
            }
            if (string.IsNullOrEmpty(user.LastName))
            {
                user.LastName = billingDetails.LastName;
            }
            _userService.UpdateUser(user);

            return(order);
        }
Beispiel #2
0
        public BillingDetails BuildBillingDetails(GiftOrder order, User user = null)
        {
            var billingOverview = BuildBillingOverview(order);

            var billingDetails = new BillingDetails
            {
                GiftOrderId     = order.Id,
                GiftOrderNumber = order.OrderNumber,
                UserId          = order.UserId,
                CountryId       = 226, // TODO: hardcoded country for now
                BillingOverview = billingOverview
            };

            if (user != null)
            {
                billingDetails.FirstName = user.FirstName;
                billingDetails.LastName  = user.LastName;
                billingDetails.Email     = user.Email;

                var lastOrder = LastOrderForUser(user);
                if (lastOrder != null)
                {
                    var billingAddress = lastOrder.BillingAddress;
                    if (billingAddress != null)
                    {
                        billingDetails.Address1        = billingAddress.Address1;
                        billingDetails.Address2        = billingAddress.Address2;
                        billingDetails.City            = billingAddress.City;
                        billingDetails.StateOrProvince = billingAddress.StateOrProvince;
                        billingDetails.ZipCode         = billingAddress.ZipCode;
                    }
                }
            }

            return(billingDetails);
        }
        //[ProductionRequireHttps]
        public ActionResult Billing(Britespokes.Services.GiftCards.BillingDetails billingDetails)
        {
            //decimal GiftAmount = 0;
            //int OrderDetailId = 0;

            var order = _giftCardOrderService.FindOrder(billingDetails.GiftOrderId, UserContext.UserId);

            if (!billingDetails.AcceptedTermsAndConditions)
            {
                ModelState.AddModelError("AcceptedTermsAndConditions", "you must accept the terms and conditions to purchase a tour");
            }
            if (order.OrderStatus != _giftCardOrderService.StatusPending())
            {
                ModelState.AddModelError("", "This order is no longer pending");
            }
            if (UserContext.IsGuest && string.IsNullOrEmpty(billingDetails.Password))
            {
                ModelState.AddModelError("Password", "required");
            }

            if (string.CompareOrdinal(billingDetails.Password, billingDetails.ConfirmPassword) != 0)
            {
                ModelState.AddModelError("ConfirmPassword", "doesn't match");
            }


            if (ModelState.IsValid)
            {
                if (UserContext.IsGuest)
                {
                    var user = _userService.Find(UserContext.UserId);
                    _registrationService.PromoteGuest(user, billingDetails.Email, billingDetails.Password);
                    _userMailer.SendWelcomeEmail(UserContext.Organization, user);
                }
                _giftCardOrderService.UpdateBillingDetails(billingDetails);

                //Campaign Monitor -Adding subscriber to Gift card recipients List

                AuthenticationDetails auth          = new ApiKeyAuthenticationDetails(ConfigurationManager.AppSettings["CampaignMonitorAPI_key"]);
                Subscriber            objSubscriber = new Subscriber(auth, ConfigurationManager.AppSettings["CampaignMonitorListID"]);

                for (int i = 0; i < order.GiftOrderDetail.Count; i++)
                {
                    List <SubscriberCustomField> customFields = new List <SubscriberCustomField>();
                    customFields.Add(new SubscriberCustomField()
                    {
                        Key = "Amount", Value = order.GiftOrderDetail[i].Amount == null? "":order.GiftOrderDetail[i].Amount.ToString()
                    });
                    customFields.Add(new SubscriberCustomField()
                    {
                        Key = "Your Name", Value = order.GiftOrderDetail[i].YourName == null ? "" : order.GiftOrderDetail[i].YourName.ToString()
                    });
                    customFields.Add(new SubscriberCustomField()
                    {
                        Key = "Gift Code", Value = order.GiftOrderDetail[i].RecipientGiftCode == null ? "" : order.GiftOrderDetail[i].RecipientGiftCode.ToString()
                    });
                    customFields.Add(new SubscriberCustomField()
                    {
                        Key = "Message", Value = order.GiftOrderDetail[i].Message == null ? "" : order.GiftOrderDetail[i].Message.ToString()
                    });

                    string newSubscriberID = objSubscriber.Add(order.GiftOrderDetail[i].RecipientEmail.ToString(), null, customFields, false);
                }

                return(Json(new { BillingDetails = billingDetails, Errors = new object[0] }));
            }

            billingDetails.BillingOverview = _giftCardOrderService.BuildBillingOverview(order);
            billingDetails.PaymentRequest  = new PaymentRequest(order.Total, AuthorizeNetConfig.ApiLogin, AuthorizeNetConfig.TransactionKey, AuthorizeNetConfig.TestMode);
            return(Json(new { BillingDetails = billingDetails, Errors = ModelStateErrorsForJson() }));
        }