public PartialViewResult GetPartialViewPrepayment(PaymentViewModel model) { //var model = new PaymentViewModel(); //model.Prepayment = new PrepaymentViewModel(); model.Prepayment.ExpDate = new ExpirationDate { ListMonths = DateTimeHelper.GetMonthList(), ListYears = DateTimeHelper.GetYearList() }; return PartialView("_Prepayment", model); }
public async Task<ActionResult> CreateStep2(PaymentViewModel model, string btnNext) { if (btnNext != null) { if (ModelState.IsValid) { UserDto user = Services.Users.GetByUserName(model.UserName); if (user != null) { // -------Payment---------- if (model.CreditCard != null && !string.IsNullOrWhiteSpace(model.CreditCard.CardNumber)) { try { Services.Payment.SetCurrentUser(user.FirstName, user.LastName, user.Email, user.MobilePhone); var expiry = model.CreditCard.ExpDate.MonthExp + model.CreditCard.ExpDate.YearExp.ToString(); PaymentCard card = new PaymentCard(model.CreditCard.NameCard, model.CreditCard.CardNumber, Convert.ToDateTime(expiry), model.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.PaymentMethod = PaymentMethod.CreditCard; } else { ViewBag.Error = storeResult.ErrorMessage; } } catch (Exception e) { ViewBag.Error = e.Message; } } else if (model.Prepayment != null) { try { var expiry = model.Prepayment.ExpDate.MonthExp + model.Prepayment.ExpDate.YearExp.ToString(); try { var amount = Convert.ToDecimal(model.Prepayment.Amount); if (amount > 0) { PaymentResult prepayResult = Services.Payment.Transaction(new PaymentCard(model.Prepayment.NameCard, model.Prepayment.CardNumber, Convert.ToDateTime(expiry), model.Prepayment.SecurityCode), amount); if (prepayResult.Success) { user.PrePaymentAmount = amount; user.PaymentMethod = PaymentMethod.PrePayment; var invoice = Services.Invoices.CreatePrepaymentInvoice(amount, user); } else { ViewBag.Error = prepayResult.ErrorMessage; } } else { ViewBag.Error = NotificationMessage.AmountError; } } catch (Exception e) { ViewBag.Error = e.Message; } } catch { ViewBag.Error = NotificationMessage.PrepaymentError; } } if (ViewBag.Error == null) { // Save account user.CompletedStep = Step.Step2; user.Status = Status.InActive; if (user.IsPhoneConfirmed && user.IsEmailConfirmed) { user.Status = Status.Active; } if (Services.Users.UpdateUserInfo(user)) { return RedirectToAction("ListBooking", "Booking"); } else { Log.Error("Update account failed at cus-registration step 2. UserId: " + user.Id); ViewBag.Error = "Update account failed"; } } else { return View(model); } } else { ViewBag.Error = "Account does not exists"; } } } return View(model); }
public PartialViewResult GetPartialViewCreditCard(PaymentViewModel model) { //var model = new PaymentViewModel(); //model.CreditCard = new CreditCardViewModel(); model.CreditCard.ExpDate = new ExpirationDate { ListMonths = DateTimeHelper.GetMonthList(), ListYears = DateTimeHelper.GetYearList() }; //model.UserName = userName; return PartialView("_CreditCard", model); }
public ActionResult CreateStep2(string userName) { PaymentViewModel model = new PaymentViewModel(); model.UserName = userName; model.PaymentMethod = PaymentMethod.CreditCard; return View(model); }