public ActionResult Payment(PaymentParam model) { try { HttpCookie reqCookies = Request.Cookies["MemberLoginCookie"]; ResponseMemberLogin login = JsonConvert.DeserializeObject <ResponseMemberLogin>(reqCookies.Value.ToString().UrlDecode()); if (login == null || login.ID == 0) { return(Json(new PaymentResult { Status = -1, Uri = "" })); } double reduce = 0; var tour = _tourBusiness.GetDetail(model.TourID); if (tour != null && tour.ID != 0) { var steps = _stepBusiness.GetAll(tour.ID); if (model.PCode != "") { var promotion = _promotionBusiness.ApplyPromotion(model.PCode); if (promotion != null && promotion.ID != 0) { if (promotion.TourApply == "" || promotion.TourApply == null) { if (promotion.Type == 1) { reduce = promotion.AmountReduced; } else { reduce = (tour.Price * promotion.PercentReduced) / 100; } } else { if (promotion.TourApply.Contains(tour.ID.ToString())) { if (promotion.Type == 1) { reduce = promotion.AmountReduced; } else { reduce = (tour.Price * promotion.PercentReduced) / 100; } } } } } OrderView order = new OrderView(); order.Amount = tour.Price - reduce; order.Code = $"{DateTime.Now.ToString("ddMMyy")}{RandomUtils.RandomString(6, 8, true, true, false)}"; order.Date = DateTime.Now; order.IsPayment = false; order.Member = login.ID; order.MemberName = login.Name; order.Price = tour.Price; order.Reduce = reduce; order.Status = 0; order.Step = 0; order.Tour = tour.ID; if (_orderBusiness.Add(order)) { _orderBusiness.Save(); long oID = _orderBusiness.GetID(order.Code); if (steps != null && steps.Count() > 0 && oID != 0) { int max = steps.Count(); int count = 1; foreach (var item in steps) { OrderDetailView detail = new OrderDetailView(); detail.IsAccomplish = false; if (count == max) { detail.IsLastStep = true; } else { detail.IsLastStep = false; } detail.OrderID = oID; detail.Rank = count; detail.StepID = item.ID; detail.StepName = item.Name; if (_orderDetailBusiness.Add(detail)) { _orderDetailBusiness.Save(); } count++; } } if (model.TypePay == 0) { string uri = CreateRequestPaymentPort(order.Amount.ToString(), order.Code, login.ID.ToString()); return(Json(new PaymentResult { Status = 1, Uri = uri })); } if (model.TypePay == 1) { string uri = CreateRequestPaymentPortGlobal(order.Amount.ToString(), order.Code, login.ID.ToString()); return(Json(new PaymentResult { Status = 1, Uri = uri })); } } } return(Json(new PaymentResult { Status = -1, Uri = "" })); } catch (Exception) { return(Json(new PaymentResult { Status = -1, Uri = "" })); } }