/// <summary> /// This method gets called when user clicks for payment. /// </summary> /// <param name="bookingDetailsViewModel">booking details</param> /// <param name="orderID">transactionID generated before redirecting to payment gateway</param> /// <param name="userID">userID of logged on user</param> /// <param name="bookingFromDate">date from which user wants to book the bed</param> /// <returns>number of rows changed</returns> public int AddTransaction(BookingDetailsViewModel bookingDetailsViewModel, string orderID, long userID,DateTime bookingFromDate) { //get all the beds of the room which is empty var dbBed = (from bed in bedRepository.Get() where bed.RoomID == bookingDetailsViewModel.RoomID && bed.Status == true && bed.BedStatus == (int)Constants.Bed_Status.Vacant && ((bed.UserID == 0) || (((DateTime)bed.BookingToDate - bookingFromDate).Days >= 30))//Status active for Bed and bed is empty (zero) select bed ).FirstOrDefault(); if (dbBed != null && dbBed.BedID > 0) { //Lock the bed for the current transaction dbBed.BedStatus = (int)Constants.Bed_Status.InProgress; bedRepository.Update(dbBed); //add a record in Transaction table Data.DBEntity.Transaction dbTransaction = new Data.DBEntity.Transaction() { OrderID = orderID, TransactionStatusID = (int)Constants.Transaction_Status.inprogress, amount = bookingDetailsViewModel.Price, productinfo = bookingDetailsViewModel.Address, IsValidTransaction=false, CreatedOn = DateTime.Now, LastUpdatedOn = DateTime.Now, UserID = userID, BedID = dbBed.BedID }; transactionRepository.Insert(dbTransaction);//Inserting new lead } return unitOfWork.SaveChanges();//Saving the changes to DB }
public void RedirectToPayumoney(BookingDetailsViewModel bookingDetailsViewModel) { var user = SessionManager.GetSessionUser(); var searchCriteria = (SearchViewModel)Session["SearchCriteria"]; if (user == null && user.Id == 0) { //user session time out } else if (searchCriteria == null && searchCriteria.BookingFromDate == null) { //search criteria is removed...redirect user for search again } else { string txnid = Generatetxnid(); //transaction management if (transactionManagement.AddTransaction(bookingDetailsViewModel, txnid, user.Id, searchCriteria.BookingFromDate) > 1) { string firstName = user.FirstName; string amount = bookingDetailsViewModel.Price.ToString(); string productInfo = bookingDetailsViewModel.RoomID.ToString(); string email = user.Email; string phone = user.PhoneNumber; string surl = Url.Action("Payment", "Success"); string furl = Url.Action("Payment", "Success"); RemotePost myremotepost = new RemotePost(); string key = LYSConfig.PayUmoneyKey; string salt = LYSConfig.PayUmoneySalt; //posting all the parameters required for integration. myremotepost.Url = LYSConfig.PayUmoneyRedirectURL; myremotepost.Add("key", key); myremotepost.Add("txnid", txnid); myremotepost.Add("amount", bookingDetailsViewModel.Price.ToString()); myremotepost.Add("productinfo", productInfo); myremotepost.Add("firstname", firstName); myremotepost.Add("phone", phone); myremotepost.Add("email", email); myremotepost.Add("surl", surl);//Change the success url here depending upon the port number of your local system. myremotepost.Add("furl", furl);//Change the failure url here depending upon the port number of your local system. myremotepost.Add("service_provider", "payu_paisa"); string hashString = key + "|" + txnid + "|" + amount + "|" + productInfo + "|" + firstName + "|" + email + "|||||||||||" + salt; //string hashString = "3Q5c3q|2590640|3053.00|OnlineBooking|vimallad|[email protected]|||||||||||mE2RxRwx"; string hash = Generatehash512(hashString); myremotepost.Add("hash", hash); myremotepost.Post(); } else { //bed not available } } }