public ActionResult Payment(int id, string q, string name, int?passenger) { if (passenger == null) { TempData["message"] = "لطفا اطلاعات خواسته شده را تکمیل کنید"; //return RedirectToAction("SearchFlight", "Search", new { @id = id }); return(RedirectToAction("SearchFlight", "Search", new { @q = UrlParameter.Optional.Equals(q) })); } name = User.Identity.Name; var flight = flightRepository.GetFlightById(id); FlightReserve flightReserve = new FlightReserve(); flightReserve.DateTime = DateTime.Now.ToString(); flightReserve.IsFinally = false; flightReserve.Price = (flight.Price) * passenger.Value; flightReserve.FlightID = flight.FlightID; flightReserve.UserID = name; flightReserve.Passengers = passenger.Value; flightReserveRepository.InsertFlightReserve(flightReserve); flightReserveRepository.Save(); flight.Capacity -= passenger.Value; flightRepository.UpdateFlight(flight); flightRepository.Save(); System.Net.ServicePointManager.Expect100Continue = false; RahaAirline.ZarinPal.PaymentGatewayImplementationServicePortTypeClient zp = new RahaAirline.ZarinPal.PaymentGatewayImplementationServicePortTypeClient(); string Authority; int Status = zp.PaymentRequest("YOUR-ZARINPAL-MERCHANT-CODE", flightReserve.Price, " درگاه پرداخت زرین پال ", "*****@*****.**", "09356821874", "http://localhost:58820/Flight/Verify/" + flightReserve.ReserveID, out Authority); if (Status == 100) { // Response.Redirect("https://www.zarinpal.com/pg/StartPay/" + Authority); Response.Redirect("https://sandbox.zarinpal.com/pg/StartPay/" + Authority); } else { ViewBag.Error = "Error : " + Status; } return(View()); }
public ActionResult Payment(int id, string name, int?passenger, int?roomNumber, string Checkin, string Checkout) { var Hotels = residenceRepository.GetResidenceById(id); if (passenger == null || roomNumber == null || Checkin == "" || Checkout == "") { TempData["message"] = "لطفا اطلاعات خواسته شده را تکمیل کنید"; // ModelState.AddModelError("", "لطفا اطلاعات خواسته شده را تکمیل کنید"); return(RedirectToAction("ShowResidenceDetail", "HotelDetails", new { @id = id })); } name = User.Identity.Name; DateTime chin = DateTime.ParseExact(Checkin, "dd/MM/yyyy", null); DateTime chout = DateTime.ParseExact(Checkout, "dd/MM/yyyy", null); int chinint = int.Parse(chin.ToString("yyyyMMdd")); int choutint = int.Parse(chout.ToString("yyyyMMdd")); int days = choutint - chinint; Reserve reserve = new Reserve(); reserve.Passengers = passenger.Value; reserve.RoomNumber = roomNumber.Value; reserve.CheckIn = Checkin; reserve.CheckOut = Checkout; reserve.DateTime = DateTime.Now.ToString(); reserve.IsFinally = false; if (days > 0 && passenger.Value > 0 && roomNumber.Value > 0) { reserve.Price = (((Hotels.Price) * passenger.Value) * roomNumber.Value) * days; } else { TempData["message"] = "لطفا اطلاعات خواسته شده را به طور صحیح تکمیل کنید"; return(RedirectToAction("ShowResidenceDetail", "HotelDetails", new { @id = id })); } reserve.ResidenceID = Hotels.ResidenceID; reserve.UserID = name; reserveRepository.InsertReserve(reserve); reserveRepository.Save(); System.Net.ServicePointManager.Expect100Continue = false; RahaAirline.ZarinPal.PaymentGatewayImplementationServicePortTypeClient zp = new RahaAirline.ZarinPal.PaymentGatewayImplementationServicePortTypeClient(); string Authority; int Status = zp.PaymentRequest("YOUR-ZARINPAL-MERCHANT-CODE", reserve.Price, " درگاه پرداخت زرین پال ", "*****@*****.**", "09356821874", "http://localhost:58820/HotelDetails/Verify/" + reserve.ReserveID, out Authority); if (Status == 100) { // Response.Redirect("https://www.zarinpal.com/pg/StartPay/" + Authority); Response.Redirect("https://sandbox.zarinpal.com/pg/StartPay/" + Authority); } else { ViewBag.Error = "Error : " + Status; } return(View()); }