public IActionResult Create(AgreementViewModel model) { if (ModelState.IsValid) { var newAgreement = new Agreement(); newAgreement.Amount = model.Amount; newAgreement.AgreementDuration = model.AgreementDuration; newAgreement.BaseRateCode = model.BaseRateCode; newAgreement.Margin = model.Margin; newAgreement.BaseRate = _baseRateReposirory.GetRate(model.BaseRateCode).Result; var customer = _customerData.GetAllCustomers().FirstOrDefault(c => c.PersonalId == model.Customer.PersonalId); if (customer == null) { var newCustomer = new Customer(); newCustomer.FirstName = model.Customer.FirstName; newCustomer.LastName = model.Customer.LastName; newCustomer.PersonalId = model.Customer.PersonalId; newCustomer.Agreements.Add(newAgreement); newCustomer = _customerData.Add(newCustomer); _customerData.Save(); return(RedirectToAction("AgreementDetails", new { id = newCustomer.Agreements.Max(a => a.Id) })); } customer.Agreements.Add(newAgreement); _customerData.Save(); return(RedirectToAction("AgreementDetails", new { id = customer.Agreements.Max(a => a.Id) })); } return(View()); }
public JsonResult CancelToPay(AgreementViewModel vm) { // Build the failure url and redirect back to Arcadier var url = DbContext.CancelUrl(vm.CashKey); return(Json(new { result = url }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Agreement(AgreementViewModel model) { if (ModelState.IsValid) { db.ProvidingAgencies.Add(model.ProvidingAgency); db.Jails.Add(model.Jail); db.BondTransfers.Add(model.BondTransfer); db.RequestingAgencies.Add(model.RequestingAgency); db.Defendants.Add(model.Defendant); db.Indemnitors.Add(model.Indemnitor); await db.SaveChangesAsync(); db.Agreements.Add(new Agreement { ProvidingAgencyId = model.ProvidingAgency.Id, JailId = model.Jail.Id, BondTransferId = model.BondTransfer.Id, RequestingAgencyId = model.RequestingAgency.Id, DefendantId = model.Defendant.Id, IndemnitorId = model.Indemnitor.Id, AdditionalInformation = model.AdditionalInformation }); await db.SaveChangesAsync(); return(RedirectToAction(nameof(Agreement))); } else { return(View()); } }
public JsonResult AgreeToPay(AgreementViewModel vm) { // Build the success url and redirect back to Arcadier var url = DbContext.SuccessUrl(vm.CashKey, vm.Note); return(Json(new { result = url }, JsonRequestBehavior.AllowGet)); }
public ActionResult RentCar(int CarDtoId, DateTime firstDayRent, DateTime lastDayRent, int PickUpLocationId, int ReturnLocationId) { var carDto = carService.Get(CarDtoId); carDto.ManufacturerDto = manufacurerService.Get(carDto.ManufacturerId); var numberOfDaysInRent = NumberOfDaysInRent(firstDayRent, lastDayRent); var rentViewModel = new RentViewModel() { firstDayRent = firstDayRent, lastDayRent = lastDayRent, PickUpLocationId = PickUpLocationId, ReturnLocationId = ReturnLocationId, Locations = placeService.GetAll() }; var agreementViewModel = new AgreementViewModel() { CarDto = carDto, CarId = CarDtoId, UserName = User.Identity.Name, NumberOfDays = numberOfDaysInRent, TotalPrice = numberOfDaysInRent * carDto.PricePerDay, DateOfAgreement = DateTime.Now, rentViewModel = rentViewModel }; return(View("RentForm", agreementViewModel)); }
public ActionResult Agreement(AgreementViewModel model) { try { if (ModelState.IsValid) { //Bit of bad practice, should be refactored since we're consuming resources with each request var user = System.Web.HttpContext.Current.GetOwinContext() .GetUserManager <ApplicationUserManager>() .FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); if (user == null) { throw new UnauthorizedAccessException("Unauthorized"); } _studentBusinessLogic.ValidateAndSaveStudentAgreement(user, model); } else { return(Json(new { type = "error", message = ModelState.Values.Where(x => x.Errors.Any()).FirstOrDefault().Errors.FirstOrDefault().ErrorMessage }, JsonRequestBehavior.AllowGet)); } } catch (ValidationException e) { return(Json(new { type = "error", message = e.Message }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { type = "error", message = e.Message }, JsonRequestBehavior.AllowGet)); } return(Json(new { type = "success", message = "Agreement saved successfully." }, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> ViewAgreement(string formid, string formtitle, string date) { AgreementViewModel viewModel = new AgreementViewModel(); viewModel.FormID = formid; viewModel.FormTitle = formtitle; viewModel.Date = date; return(View("Agreement", viewModel)); }
public ActionResult Edit(AgreementViewModel agreementViewModel) { if (ModelState.IsValid) { _agreementService.UpdateAgreement(_mapperToBysinessModel.Map(agreementViewModel)); } else { return(View(agreementViewModel)); } return(RedirectToAction(nameof(AgreementManager))); }
public async Task <IActionResult> Agreement([Bind("AgreePolicy")] AgreementViewModel agreement) { if (ModelState.IsValid) { var member = new Member() { AgreePolicy = agreement.AgreePolicy }; TempData["member"] = JsonConvert.SerializeObject(member, Formatting.Indented); return(RedirectToAction("Accept1")); } return(View(agreement)); }
public ActionResult Save(AgreementViewModel agreementViewModel) { var agreementId = agreementViewModel.Id; var isConfirmed = agreementViewModel.IsConfirmd; var isDeleted = agreementViewModel.IsDeleted; var managersComment = agreementViewModel.ManagerComment; var isPickUped = agreementViewModel.IsPickUped; var isReturned = agreementViewModel.IsReturned; rentService.UpdateAgreement(agreementId, isConfirmed, isDeleted, managersComment, isPickUped, isReturned); return(RedirectToAction("Details", routeValues: new { agreementDtoId = agreementId })); }
public async Task <IActionResult> Reset(AgreementViewModel model, CancellationToken token) { var result = await _mediatr.Process(new ResetAgreementStatusToCommand(await GetRequestUserAsync(token)) { AgreementId = model.Id }, token); if (!result.Succeeded) { throw result.Exception; } return(RedirectToAction("Edit", new { model.Id })); }
public AgreementViewModel GetStudentAgreementViewModel(string userId) { var model = new AgreementViewModel(); using (var db = new ErasmusDbContext()) { var user = db.Users.SingleOrDefault(x => x.Id == userId); model.SourceUniversities = new SelectList(new List <SelectListItem>() { new SelectListItem() { Text = user.University.Name, Value = user.University.Id.ToString() } }, "Value", "Text"); } return(model); }
public async Task <IActionResult> Edit(AgreementViewModel model, CancellationToken token) { var entity = await _context.Agreements.SingleAsync(a => a.Id == model.Id, token); if (model.CatalogId.HasValue && entity.CatalogId != model.CatalogId) { var catalogResult = await _mediatr.Process( new ChangeAgreementCatalogCommand(new RequestUser() { Id = entity.ProducerId }) { AgreementId = entity.Id, CatalogId = model.CatalogId.Value }, token); if (!catalogResult.Succeeded) { throw catalogResult.Exception; } } if (model.DeliveryModeId.HasValue && entity.DeliveryModeId != model.DeliveryModeId) { var deliveryResult = await _mediatr.Process( new ChangeAgreementDeliveryCommand(new RequestUser() { Id = entity.ProducerId }) { AgreementId = entity.Id, DeliveryId = model.DeliveryModeId.Value }, token); if (!deliveryResult.Succeeded) { throw deliveryResult.Exception; } } if (model.Status != entity.Status && entity.Status != AgreementStatus.Cancelled && (model.Status == AgreementStatus.Accepted || model.Status == AgreementStatus.Refused)) { Command command = null; switch (model.Status) { case AgreementStatus.Accepted: command = new AcceptAgreementCommand(new RequestUser() { Id = entity.CreatedByKind == ProfileKind.Producer ? entity.StoreId : entity.ProducerId }) { AgreementId = entity.Id, CatalogId = model.CatalogId, DeliveryId = model.DeliveryModeId }; break; case AgreementStatus.Refused: command = new RefuseAgreementCommand(new RequestUser() { Id = entity.CreatedByKind == ProfileKind.Producer ? entity.StoreId : entity.ProducerId }) { AgreementId = entity.Id }; break; } if (command != null) { var result = await _mediatr.Process(command, token); if (!result.Succeeded) { throw result.Exception; } } } return(RedirectToAction("Edit", new { entity.Id })); }
public JsonResult CancelToPay(AgreementViewModel vm) { var url = DbContext.CancelUrl(vm.CashKey); return(Json(new { result = url }, JsonRequestBehavior.AllowGet)); }
public JsonResult AgreeToPay(AgreementViewModel vm) { string redirectUrl = ""; string errorMessage = ""; var db = new DbContext(); try { //DEBUG //Logger.GetInstance().Write(JsonConvert.SerializeObject(vm)); var details = db.GetDetails(vm.CashKey); if (details != null) { details.AgreedDateTime = DateTime.UtcNow; var info = new RequestInfo(); info.Merchant_id = ConfigCode.GetInstance().MerchantID; info.Merchant_password = ConfigCode.GetInstance().MerchantPassword; info.Receiver_email = ConfigCode.GetInstance().ReceiverEmail; info.cur_code = "vnd"; info.Payment_method = vm.OptionPayment; info.bank_code = vm.BankCode; info.Order_code = details.InvoiceNo; info.Total_amount = details.Total; info.Buyer_fullname = vm.FullName; info.Buyer_email = vm.Email; info.Buyer_mobile = vm.Phone; //Optional fields info.fee_shipping = "0"; info.Discount_amount = "0"; info.order_description = ""; // End of optional fields string host = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority; string baseUrl = string.Format("{0}/nganluong/return?", host); info.return_url = baseUrl + "key=" + vm.CashKey; info.cancel_url = baseUrl + "key=" + vm.CashKey + "&type=" + ReturnType.Cancel.GetHashCode(); info.time_limit = baseUrl + "key=" + vm.CashKey + "&type=" + ReturnType.Timeout.GetHashCode(); //DEBUG //Logger.GetInstance().Write("RequestInfo"); //Logger.GetInstance().Write(JsonConvert.SerializeObject(info)); var objApiCheckout = new APICheckoutV3(); ResponseInfo checkoutRs = objApiCheckout.GetUrlCheckout(info, vm.OptionPayment); //DEBUG //Logger.GetInstance().Write("Check out response:"); //Logger.GetInstance().Write(JsonConvert.SerializeObject(checkoutRs)); if (checkoutRs.Error_code == "00") { details.ProviderTransRefId = checkoutRs.Token; bool result = db.SetDetails(vm.CashKey, details); if (result) { redirectUrl = checkoutRs.Checkout_url; } else { errorMessage = Resources.Application.CommonErrorMessage; Logger.GetInstance().Write(string.Format("[Key={0}] Check out succeeded but failed to update NL Token", vm.CashKey)); } } else { ; errorMessage = string.Format("Error Description: {0}. <br/> {1}", checkoutRs.Description, Resources.Application.CommonErrorMessage); Logger.GetInstance().Write(string.Format("[Key={0}] Failed to check out(Code={1};Desc={2})", vm.CashKey, checkoutRs.Error_code, checkoutRs.Description)); } } } catch (Exception ex) { Logger.GetInstance().Write(ex, string.Format("[Key={0}]Exception thrown in AgreeToPay", vm.CashKey)); ViewBag.ErrorMessage = ex.Message; redirectUrl = ""; } // Use js to redirect to NL check out URL. return(Json(new { result = redirectUrl, message = errorMessage }, JsonRequestBehavior.AllowGet)); }
public ActionResult Save(AgreementViewModel agreementVieModel) { var rentViewModel = agreementVieModel.rentViewModel; if (!ModelState.IsValid) { return(RedirectToAction("RentCar", new { CarDtoId = agreementVieModel.CarId, firstDayRent = rentViewModel.firstDayRent, lastDayRent = rentViewModel.lastDayRent, PickUpLocationId = rentViewModel.PickUpLocationId, ReturnLocationId = rentViewModel.ReturnLocationId })); } var agreementDto = Mapper.Map <AgreementDto>(agreementVieModel); if (agreementDto.WithDriver) { agreementDto.TotalPrice += 50 * agreementDto.NumberOfDays; } switch (agreementDto.InsuranceType) { case InsuranceType.Standard: { double percent = agreementDto.TotalPrice * 0.05; percent = percent - percent % 1; try { agreementDto.TotalPrice = checked (agreementDto.TotalPrice + (int)percent); } catch (OverflowException ex) { // logging agreementDto.TotalPrice = int.MaxValue; } break; } case InsuranceType.Lux: { double percent = agreementDto.TotalPrice * 0.10; percent = percent - percent % 1; try { agreementDto.TotalPrice = checked (agreementDto.TotalPrice + (int)percent); } catch (OverflowException ex) { // logging agreementDto.TotalPrice = int.MaxValue; } break; } } agreementDto.IsPayed = true; var id = rentService.AddAgreement(agreementDto); var pickUpCarDelivery = new CarDeliveryDto() { AgreementId = id, DateOfDelivery = rentViewModel.firstDayRent, IsDeliveryToUser = true, NoDamage = true, PlaceId = rentViewModel.PickUpLocationId, CarId = agreementVieModel.CarId }; rentService.AddCarDelivery(pickUpCarDelivery); var returnCarDelivery = new CarDeliveryDto() { AgreementId = id, DateOfDelivery = rentViewModel.lastDayRent, IsDeliveryToUser = false, NoDamage = false, PlaceId = rentViewModel.ReturnLocationId, CarId = agreementVieModel.CarId }; rentService.AddCarDelivery(returnCarDelivery); return(RedirectToAction("Result")); }
public AgreementViewModel GetStudentAgreementViewModel(string userId, int agreementId) { try { using (var db = new ErasmusDbContext()) { var agreement = db.Agreements.Where(x => x.Id == agreementId).Include(x => x.SourceUniversity) .Include(x => x.SourceUniversity.Faculties).Include(x => x.TargetUniversity) .Include(x => x.TargetUniversity.Faculties).SingleOrDefault(); if (agreement == null) { throw new FormValidationException("Agreement not found"); } if (agreement.ErasmusUserId != userId) { throw new FormValidationException("You are not allowed to view this agreement"); } if (agreement.State != AgreementState.New) { throw new FormValidationException("Only allowed to edit agreements that are new"); } var model = new AgreementViewModel() { From = agreement.StartDate, To = agreement.EndDate, Language = agreement.Language, LanguageLevel = agreement.LanguageLevel, SelectedSemester = agreement.Semester, SelectedSourceUniversity = agreement.SourceUniversityId, SelectedTargetUniversity = agreement.TargetUniversityId, SelectedSourceFaculty = agreement.SourceFacultyId, SelectedTargetFaculty = agreement.TargetFacultyId, SelectedSourceFieldOfStudy = agreement.SourceFieldOfStudyId, SelectedTargetFieldOfStudy = agreement.TargetFieldOfStudyId, SelectedSourceStudySubjects = agreement.SourceSubjects.Select(x => x.Id).ToList(), SelectedTargetStudySubjects = agreement.TargetSubjects.Select(x => x.Id).ToList(), }; var universities = db.Universities.ToList(); model.SourceUniversities = new SelectList(universities.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = model.SelectedSourceUniversity == x.Id }).ToList(), "Value", "Text"); var targetUniversities = db.UniversityAgreements .Where(x => x.SourceUniversityId == model.SelectedSourceUniversity) .Select(x => x.TargetUniversity).ToList(); model.TargetUniversities = new SelectList(targetUniversities.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = model.SelectedTargetUniversity == x.Id }), "Value", "Text"); model.SourceFaculties = new SelectList(agreement.SourceUniversity.Faculties.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = model.SelectedSourceFaculty == x.Id }), "Value", "Text"); model.TargetFaculties = new SelectList(agreement.TargetUniversity.Faculties.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = model.SelectedSourceFaculty == x.Id }), "Value", "Text"); var sourceStudyFields = agreement.SourceUniversity.Faculties.SingleOrDefault(x => x.Id == model.SelectedSourceFaculty).StudyFields; var selectedSourceField = sourceStudyFields.Single(x => x.Id == model.SelectedSourceFieldOfStudy); model.SourceFieldsOfStudy = new SelectList(sourceStudyFields.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = model.SelectedSourceFieldOfStudy == x.Id }), "Value", "Text"); var targetStudyFields = agreement.TargetUniversity.Faculties.SingleOrDefault(x => x.Id == model.SelectedTargetFieldOfStudy).StudyFields; var selectedTargetField = targetStudyFields.Single(x => x.Id == model.SelectedTargetFieldOfStudy); model.TargetFieldsOfStudy = new SelectList(targetStudyFields.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = model.SelectedTargetFieldOfStudy == x.Id }), "Value", "Text"); var semesterData = GetSemesterData(selectedSourceField.Id, selectedTargetField.Id); model.Semesters = new SelectList(semesterData.Select(x => new SelectListItem() { Text = x.Value, Value = x.Key.ToString(), Selected = model.SelectedSemester == x.Key }), "Value", "Text"); model.SourceStudySubjects = new MultiSelectList(selectedSourceField.StudySubjects.Where(x => x.Semester == model.SelectedSemester).Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = model.SelectedSourceStudySubjects.Contains(x.Id) }), "Value", "Text"); model.TargetStudySubjects = new MultiSelectList(selectedTargetField.StudySubjects.Where(x => x.Semester == model.SelectedSemester).Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = model.SelectedTargetStudySubjects.Contains(x.Id) }), "Value", "Text"); return(model); } } catch (Exception e) { return(null); } }
public void ValidateAndSaveStudentAgreement(ErasmusUser user, AgreementViewModel model) { using (var db = new ErasmusDbContext()) { #region Validation var sourceUniversity = db.Universities.SingleOrDefault(x => x.Id == model.SelectedSourceUniversity); var targetUniversity = db.Universities.SingleOrDefault(x => x.Id == model.SelectedTargetUniversity); if (sourceUniversity == null) { throw new ValidationException("Invalid source university"); } if (targetUniversity == null) { throw new ValidationException("Invalid target university"); } var agreement = db.UniversityAgreements.SingleOrDefault(x => x.SourceUniversityId == sourceUniversity.Id && x.TargetUniversityId == targetUniversity.Id); if (agreement == null) { throw new ValidationException("Invalid selection, agreement for selected universities not found"); } var sourceFaculty = sourceUniversity.Faculties.SingleOrDefault(x => x.Id == model.SelectedSourceFaculty); var targetFaculty = targetUniversity.Faculties.SingleOrDefault(x => x.Id == model.SelectedTargetFaculty); if (sourceFaculty == null) { throw new ValidationException("Invalid source faculty"); } if (targetFaculty == null) { throw new ValidationException("Invalid target faculty"); } var sourceFos = sourceFaculty.StudyFields.SingleOrDefault(x => x.Id == model.SelectedSourceFieldOfStudy); var targetFos = targetFaculty.StudyFields.SingleOrDefault(x => x.Id == model.SelectedTargetFieldOfStudy); if (sourceFos == null) { throw new ValidationException("Invalid source field of study"); } if (targetFos == null) { throw new ValidationException("Invalid target field of study"); } var sourceStudySubjects = sourceFos.StudySubjects.Where(x => model.SelectedSourceStudySubjects.Contains(x.Id)).ToList(); var targetStudySubjects = targetFos.StudySubjects.Where(x => model.SelectedTargetStudySubjects.Contains(x.Id)).ToList(); var srcSsIds = sourceStudySubjects.Select(x => x.Id).ToList(); var trgSsIds = targetStudySubjects.Select(x => x.Id).ToList(); /*if (!srcSsIds.All(model.SelectedSourceStudySubjects.Contains) || srcSsIds.Count != model.SelectedSourceStudySubjects.Count) * throw new ValidationException("Invalid source study subjects found"); * if (!trgSsIds.All(model.SelectedTargetStudySubjects.Contains) || trgSsIds.Count != model.SelectedTargetStudySubjects.Count) * throw new ValidationException("Invalid target study subjects found");*/ var sourceCreditCount = sourceStudySubjects.Sum(x => x.Credits); var targetCreditCount = targetStudySubjects.Sum(x => x.Credits); if (sourceCreditCount != targetCreditCount) { throw new ValidationException("Credit count must match"); } if (model.From < DateTime.UtcNow) { throw new ValidationException("Date from can't be earlier than today"); } if (model.To < model.From) { throw new ValidationException("Date to can't be earlier than date from"); } //TODO add whatever else is needed. Semester, min credit count, language, time range etc. #endregion var storageModel = new AgreementStorage() { Student = user, LanguageLevel = model.LanguageLevel, SourceUniversity = sourceUniversity, TargetUniversity = targetUniversity, Semester = model.SelectedSemester, Language = model.Language, TargetStudySubjects = targetStudySubjects, EndDate = model.To, FinancingSource = "", Scholarship = 0, SourceFaculty = sourceFaculty, SourceFieldOfStudy = sourceFos, SourceStudySubjects = sourceStudySubjects, StartDate = model.From, State = "NEW", StoragePath = "", TargetFaculty = targetFaculty, TargetFieldOfStudy = targetFos }; var path = SaveAgreementToStorage(storageModel); db.Agreements.Add(new Agreement() { EndDate = model.To, ErasmusUserId = user.Id, FinancingSource = "", Scholarship = 0, StartDate = model.From, State = AgreementState.New, StoragePath = path, StudyField = sourceFos.Id, SourceUniversityId = sourceUniversity.Id, TargetUniversityId = targetUniversity.Id, Language = model.Language, LanguageLevel = model.LanguageLevel, Semester = model.SelectedSemester, SourceFieldOfStudyId = model.SelectedSourceFieldOfStudy, TargetFieldOfStudyId = model.SelectedTargetFieldOfStudy, SourceFacultyId = sourceFaculty.Id, TargetFacultyId = targetFaculty.Id, SourceSubjects = sourceStudySubjects, TargetSubjects = targetStudySubjects }); db.SaveChanges(); } }
public JsonResult PayWithPayPal(AgreementViewModel vm) { string ppurl = ""; var db = new DbContext(); try { var details = db.GetDetails(vm.CashKey); if (details != null) { details.AgreedDateTime = DateTime.UtcNow; details.Note = vm.Note; // Get a reference to the config var config = ConfigManager.Instance.GetProperties(); // Use OAuthTokenCredential to request an access token from PayPal var accessToken = new OAuthTokenCredential(config).GetAccessToken(); string host = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority; // Build the PayPal payment var payment = new Payment() { intent = "sale", payer = new Payer() { payment_method = "paypal" }, transactions = new List <Transaction>() { new Transaction() { amount = new Amount() { currency = details.Currency, total = details.Total }, //reference_id = details.InvoiceNo, description = "Invoice " + details.InvoiceNo, invoice_number = vm.CashKey, note_to_payee = vm.Note ?? "", item_list = new ItemList() } }, redirect_urls = new RedirectUrls() { return_url = host + "/paypal/return?key=" + vm.CashKey, cancel_url = host + "/paypal/return?cancel=true&key=" + vm.CashKey }, }; // Create an APIContext var apiContext = new APIContext(accessToken); // Create a payment using a valid APIContext var createdPayment = payment.Create(apiContext); if (createdPayment != null && createdPayment.links.Count > 0) { var id = createdPayment.id; details.ProviderTransRefId = id; bool result = db.SetDetails(vm.CashKey, details); if (result) { var links = createdPayment.links.GetEnumerator(); while (links.MoveNext()) { var link = links.Current; if (link != null && link.rel.ToLower().Trim().Equals("approval_url")) { ppurl = link.href; } } } } } } catch (Exception ex) { ViewBag.ErrorMessage = ex.Message; ppurl = ""; } // Use js to redirect to PayPal with the received approval_url above return(Json(new { result = ppurl }, JsonRequestBehavior.AllowGet)); }