public ActionResult Billing(Britespokes.Services.Orders.BillingDetails billingDetails)
        {
            //decimal GiftAmount = 0;
            //int OrderDetailId = 0;

            var order = _orderService.FindOrder(billingDetails.OrderId, UserContext.UserId);
            if (!billingDetails.AcceptedTermsAndConditions)
                ModelState.AddModelError("AcceptedTermsAndConditions", "you must accept the terms and conditions to purchase a tour");
            if (order.OrderStatus != _orderService.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");

            //Gift Code Validation and also it returns the amount of gift
            if (!string.IsNullOrWhiteSpace(billingDetails.GiftCode) && !_orderService.ValidateGiftCode(billingDetails.GiftCode, billingDetails.Email, ref billingDetails.GiftAmount, ref billingDetails.GiftOrderDetailId))
                ModelState.AddModelError("GiftCode", "gift code either used or doesn't exists");

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

                //Saving detail of gift card used
                if (billingDetails.GiftOrderDetailId != 0)
                {
                    _orderService.AddGiftCardSummaries(billingDetails);
                }
                _orderService.UpdateBillingDetails(billingDetails);

                //For gift code
                billingDetails.PaymentRequest = new PaymentRequest(order.Total, AuthorizeNetConfig.ApiLogin, AuthorizeNetConfig.TransactionKey, AuthorizeNetConfig.TestMode);

                //To be remove only for testing
                // _orderConfirmationMailer.SendOrderConfirmationEmail(order);

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

            billingDetails.BillingOverview = _orderService.BuildBillingOverview(order);
            billingDetails.PaymentRequest = new PaymentRequest(order.Total, AuthorizeNetConfig.ApiLogin, AuthorizeNetConfig.TransactionKey, AuthorizeNetConfig.TestMode);
            return Json(new { BillingDetails = billingDetails, Errors = ModelStateErrorsForJson() });
        }
        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() });
        }