public ActionResult SpecialistRegisterStep3(Guid id)
        {
            var user = Services.Users.GetUserById(id);
            SpecialistPaymentViewModel model = new SpecialistPaymentViewModel();

            model.Bank.AccountName = user.Profile.AccountName;
            model.Bank.AccountNumber = user.Profile.AccountNumber;
            model.Bank.BSB = user.Profile.BSB;

            Braintree.CreditCard creditCard = Services.Payment.GetPaymentMethod(CurrentUser.Id.ToString());
            if (creditCard != null)
            {
                model.CreditCard = new CreditCardViewModel
                {
                    CardNumber = "************" + creditCard.LastFour,
                    NameCard = creditCard.CardholderName,
                    CardType = creditCard.CardType.ToString(),
                    ExpDate = new ExpirationDate
                    {
                        MonthExp = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat
                            .GetMonthName(Int32.Parse(creditCard.ExpirationMonth)),
                        YearExp = creditCard.ExpirationYear
                    }
                };
            }

            return View(model);
        }
        public ActionResult SpecialistRegisterStep3(SpecialistPaymentViewModel paymentModel, Guid id)
        {
            var user = Services.Users.GetUserById(id);

            if (paymentModel.CreditCard == null)
            {
                @ViewBag.Error = NotificationMessage.MissingPaymentMethod;
                return View("SpecialistRegisterStep3");
            }

            try
            {
                Services.Payment.SetCurrentUser(user.FirstName, user.LastName, user.Email, user.MobilePhone);

                var expiry = paymentModel.CreditCard.ExpDate.MonthExp + paymentModel.CreditCard.ExpDate.YearExp.ToString();

                PaymentCard card = new PaymentCard(paymentModel.CreditCard.NameCard, paymentModel.CreditCard.CardNumber, Convert.ToDateTime(expiry), paymentModel.CreditCard.SecurityCode);

                // Check the existing of current user
                bool isExist = Services.Payment.IsCustomerExists(user.Id.ToString());
                StoreCustomerResult storeResult;
                if (isExist)
                    storeResult = Services.Payment.UpdateCustomerWithCreditCard(card, user.Id);
                else
                    storeResult = Services.Payment.StoreCustomerWithCreditCard(card, user.Id);

                if (string.IsNullOrWhiteSpace(storeResult.ErrorMessage))
                {
                    user.Profile.BSB = paymentModel.Bank.BSB;
                    user.Profile.AccountName = paymentModel.Bank.AccountName;
                    user.Profile.AccountNumber = paymentModel.Bank.AccountNumber;
                    user.CompletedStep = Step.Step3;
                    user.PaymentMethod = PaymentMethod.CreditCard;
                    Services.Users.UpdateUserInfo(user);

                    return RedirectToAction("SpecialistRegisterStep4", new { id = id });
                }
                else
                {
                    @ViewBag.Error = storeResult.ErrorMessage;
                    return View("SpecialistRegisterStep3");
                }
            }
            catch
            {
                @ViewBag.Error = UiHints.WarningMessageTemplates.UnableConnectToPaymentGateway;
                return View("SpecialistRegisterStep3");
            }
        }
 public PartialViewResult GetPartialViewCreditCard()
 {
     string userName = GetUserNameFromCookie();
     var model = new SpecialistPaymentViewModel();
     model.CreditCard = new CreditCardViewModel();
     model.CreditCard.ExpDate = new ExpirationDate { ListMonths = DateTimeHelper.GetMonthList(), ListYears = Code.Helpers.DateTimeHelper.GetYearList() };
     cache["credit_card_" + userName] = model;
     return PartialView("_CreditCardRegisterPartial", model);
 }