public async void BookPass(BookedPassInformation bookingInfo) { //Add booking information with selected pass await this._context.BookedPassInformations.AddAsync(bookingInfo); await this._unitOfWork.CompleteAsync(); }
public GMOPaymentResponse makePayment(string uniqueId, string paymentModule, string PGType) { GMOPaymentResponse response = new GMOPaymentResponse(); Dictionary <string, string> parameters = new Dictionary <string, string>(); CreditCardRequest creditCardRequest = new CreditCardRequest(); try { BookedPassInformation bookedPassInformations = GetBookedPassInformations(uniqueId); if (bookedPassInformations == null) { throw new Exception("No Booking information found"); } // Get configuaration by ApplicationName,ModuleName,GroupEntityID,PaymentGateWay GMOPGConfiguration pgConfig = GetPGConfiguration(paymentModule, PGType); if (pgConfig == null) { throw new Exception("Payment for this module has not been enabled."); } creditCardRequest = getPaymentRequestInfo(pgConfig, bookedPassInformations); parameters = GeneratePGParams(creditCardRequest); creditCardRequest.PGForm = GeneratePGForm(creditCardRequest.PaymentUrl, parameters); response.Status = true; return(response); } catch (Exception ex) { response.Status = false; response.Message = ex.Message; return(response); } }
public async Task <BookedPassInformation> GetBookingDatailsById(string uId) { //Get Booking Info based on booking id BookedPassInformation bookingInformation = await this._context.BookedPassInformations.Where(p => p.UniqueReferrenceNumber == uId).FirstOrDefaultAsync(); if (bookingInformation == null) { throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.NullException), _messageHandler.GetMessage(ErrorMessagesEnum.NotValidInformations))); } return(bookingInformation); }
public async Task <BookedPassInformation> GetBookingDatails(string uId) { //Get Booking Info based on booking id BookedPassInformation bookingInformation = await this._context.BookedPassInformations.Where(p => p.UniqueReferrenceNumber == uId && p.IsActive && p.PaymentStatus).Include(p => p.QRCode).Include(pi => pi.PassInformation).ThenInclude(passDesc => passDesc.PassDescription).FirstOrDefaultAsync(); if (bookingInformation == null) { throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.NullException), _messageHandler.GetMessage(ErrorMessagesEnum.NotValidInformations))); } return(bookingInformation); }
public async Task <TravellerResponse> ActivatePass(string uId) { _logger.LogInfo("Trying to activate pass with booking id " + uId); try { _logger.LogInfo("Retrieved booking information with booking id " + uId); BookedPassInformation bookingInformation = await _travellerRepository.GetBookingDatails(uId); if (bookingInformation.PassInformation == null) { _logger.LogInfo(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.NullException), " No pass information available")); throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.InValidPassInformation))); } if (bookingInformation.QRCode == null) { _logger.LogInfo(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.NullException), " Invalid QR code information")); throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.InValidQRCode))); } // Check If already pass has expired and trying to activate again then throw exception if (bookingInformation.QRCode.IsActive) { throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.InValidPassInformation))); } bookingInformation.QRCode.PassActivatedDate = DateTime.Now; bookingInformation.QRCode.IsActive = true; bookingInformation.QRCode.ActivatedPassExpiredDate = DateTime.Now; if (bookingInformation.PassInformation.PassValidityInDays > 0) { bookingInformation.QRCode.ActivatedPassExpiredDate = bookingInformation.QRCode.ActivatedPassExpiredDate.AddDays(bookingInformation.PassInformation.PassValidityInDays); } if (bookingInformation.PassInformation.PassValidityInHours > 0) { bookingInformation.QRCode.ActivatedPassExpiredDate = bookingInformation.QRCode.ActivatedPassExpiredDate.AddHours(bookingInformation.PassInformation.PassValidityInHours); } bookingInformation.QRCode.PassExpiredDuraionDate = bookingInformation.PassInformation.PassExpiredDate; bookingInformation.QRCode.QRCodeImage = null; _travellerRepository.ActivatePass(bookingInformation.QRCode); _logger.LogInfo("Successfully activated pass with booking id " + uId); TravellerResponse response = new TravellerResponse(true, string.Format(_messageHandler.GetSuccessMessage(SuccessMessagesEnum.SuccessfullyActivated))); return(response); } catch (Exception ex) { _logger.LogError(ex.Message); return(new TravellerResponse(false, ex.Message)); } }
public ActionResult GMOPamentGateway(string uniqueId, PGModuleEnum pgModule) { GMOPaymentRequest paymentRequest = new GMOPaymentRequest(); try { if (String.IsNullOrEmpty(pgModule.ToString())) { throw new Exception("Invalid payment module selected"); } if (String.IsNullOrEmpty(uniqueId)) { throw new Exception("Invalid unique referrence id."); } Dictionary <string, string> parameters = new Dictionary <string, string>(); paymentModule = pgModule.ToString(); BookedPassInformation bookedPassInformations = _context.BookedPassInformations.FirstOrDefault(t => t.UniqueReferrenceNumber.ToLower() == uniqueId.ToLower()); if (bookedPassInformations == null) { throw new Exception("No booking information found."); } // Get configuaration by ApplicationName,ModuleName,GroupEntityID,PaymentGateWay GMOPGConfiguration pgConfig = _context.GMOPGConfigurations.FirstOrDefault(p => p.PaymentGateway.ToLower() == paymentGateway.ToLower() && p.PaymentModule.ToLower() == paymentModule.ToLower() && p.IsActive); if (pgConfig == null) { throw new Exception("Payment for this module has not been enabled."); } parameters = getPaymentRequestParamsInfo(pgConfig, bookedPassInformations, paymentModule); if (parameters == null) { throw new Exception("Invalid payment option selected."); } paymentRequest.PGForm = generatePGForm(pgConfig.GMOPGPaymentUrl, parameters); return(View(paymentRequest)); } catch (Exception ex) { return(null); } }
public bool UpdateBookingInformation(BookedPassInformationViewModel bookingInfo, bool pgStatus, string transId) { _logger.LogInfo("Trying to update Booking pass information after payment"); try { BookedPassInformation bookingInformation = _travellerRepository.GetBookingDatailsById(bookingInfo.UniqueReferrenceNumber).Result; bookingInformation.PaymentStatus = pgStatus; bookingInformation.TransactionNumber = transId; bookingInformation.IsActive = pgStatus; bookingInformation.PaymentResponse = pgStatus ?"Success":"Failed"; _travellerRepository.UpdateBookingInformation(bookingInformation); _logger.LogInfo("Booking pass information updated successfully for id " + bookingInfo.UniqueReferrenceNumber); return(true); } catch (Exception ex) { _logger.LogError(ex.Message); return(false); } }
public async void UpdateBookingInformation(BookedPassInformation passInformation) { this.GetDbSet <BookedPassInformation>().Attach(passInformation); this._context.Entry(passInformation).State = EntityState.Modified; await this._unitOfWork.CompleteAsync(); }
private static CreditCardRequest getPaymentRequestInfo(GMOPGConfiguration pgConfig, BookedPassInformation bookedPassInformations) { Random generator = new Random(); String randomNumber = generator.Next(0, 999999).ToString("D6"); CreditCardRequest paymentRequest = new CreditCardRequest(); paymentRequest.ShopID = pgConfig.ShopID; paymentRequest.ShopPassword = pgConfig.ShopPassword; paymentRequest.OrderID = randomNumber + DateTime.Now.Millisecond; paymentRequest.Amount = bookedPassInformations.TotalAmout.ToString(); //Convert.ToDecimal("10000").ToString("N"); paymentRequest.Tax = "0"; //Convert.ToDecimal("200").ToString("N"); paymentRequest.DateTime = DateTime.Now.ToString("yyyyMMddHHmmss"); paymentRequest.JobCd = pgConfig.JobCd; paymentRequest.UseCredit = pgConfig.UseCredit; paymentRequest.RetURL = pgConfig.CallbackURL + "?uniqueId=" + bookedPassInformations.UniqueReferrenceNumber; paymentRequest.PaymentUrl = pgConfig.GMOPGPaymentUrl; return(paymentRequest); }
public ActionResult PaymentResponse(string uniqueId) { try { GMOPaymentResponse paymentResponse = new GMOPaymentResponse(); BookedPassInformation bookedPassInformations = _context.BookedPassInformations.FirstOrDefault(t => t.UniqueReferrenceNumber.ToLower() == uniqueId.ToLower()); if (bookedPassInformations == null) { throw new Exception("No record found."); } //Get the Care4uPgConfig with the groupEntityId available in the IntermediarOrderDetail fetched. // Get configuaration by ApplicationName,ModuleName,GroupEntityID,PaymentGateWay GMOPGConfiguration pgConfig = _context.GMOPGConfigurations.FirstOrDefault(t => t.PaymentModule.ToUpper().Equals(paymentModule.ToLower()) && t.PaymentGateway.ToLower().Equals(paymentGateway.ToLower()) && t.IsActive); if (pgConfig == null) { throw new Exception("Payment for this module has not been enabled."); } String merchantKey = pgConfig.ShopID;// "jBIWVeuQ0AKxUU%R"; Dictionary <string, string> parameters = new Dictionary <string, string>(); foreach (string key in Request.Form.Keys) { parameters.Add(key.Trim(), Request.Form[key].Trim()); } paymentResponse.JobCd = parameters["JobCd"]; paymentResponse.ShopID = parameters["ShopID"]; paymentResponse.Amount = parameters["Amount"]; paymentResponse.Tax = parameters["Tax"]; paymentResponse.Currency = parameters["Currency"]; paymentResponse.AccessID = parameters["AccessID"]; paymentResponse.AccessPass = parameters["AccessPass"]; paymentResponse.OrderID = parameters["OrderID"]; paymentResponse.Forwarded = parameters["Forwarded"]; paymentResponse.Method = parameters["Method"]; paymentResponse.PayTimes = parameters["PayTimes"]; paymentResponse.Approve = parameters["Approve"]; paymentResponse.TranID = parameters["TranID"]; paymentResponse.TranDate = parameters["TranDate"]; paymentResponse.CheckString = parameters["CheckString"]; paymentResponse.PayType = parameters["PayType"]; paymentResponse.CardNo = parameters["CardNo"]; paymentResponse.ErrorCode = parameters["ErrCode"]; paymentResponse.ErrorDetails = parameters["ErrInfo"]; paymentResponse.UniqueReference = uniqueId; paymentResponse.PGUrl = pgConfig.GMOPGPaymentUrl; string redirectAction = ""; if (String.IsNullOrEmpty(paymentResponse.ErrorCode)) { redirectAction = "PaymentSuccessResponse"; } else if (!String.IsNullOrEmpty(paymentResponse.ErrorCode)) { redirectAction = "PaymentFailureResponse"; } else { redirectAction = "PaymentFailureResponse"; } var result = PerformPostPaymentJobs(paymentResponse); return(RedirectToAction(redirectAction)); } catch (Exception ex) { return(null); } }
private Dictionary <string, string> getPaymentRequestParamsInfo(GMOPGConfiguration pgConfig, BookedPassInformation bookedPassInformations, string paymentModule) { Dictionary <string, string> parameters = new Dictionary <string, string>(); Random generator = new Random(); String randomNumber = generator.Next(0, 999999).ToString("D6"); GMOPaymentRequest paymentRequest = new GMOPaymentRequest(); paymentRequest.ShopID = pgConfig.ShopID; paymentRequest.ShopPassword = pgConfig.ShopPassword; paymentRequest.OrderID = randomNumber + DateTime.Now.Millisecond; paymentRequest.Amount = bookedPassInformations.TotalAmout.ToString(); //Convert.ToDecimal("10000").ToString("N"); paymentRequest.Tax = taxAmount; //Convert.ToDecimal("200").ToString("N"); paymentRequest.DateTime = DateTime.Now.ToString("yyyyMMddHHmmss"); paymentRequest.RetURL = pgConfig.CallbackURL + "?uniqueId=" + bookedPassInformations.UniqueReferrenceNumber; paymentRequest.PaymentUrl = pgConfig.GMOPGPaymentUrl; parameters.Add("ShopID", paymentRequest.ShopID); parameters.Add("OrderID", paymentRequest.OrderID); parameters.Add("Amount", paymentRequest.Amount); parameters.Add("Tax", paymentRequest.Tax); parameters.Add("DateTime", paymentRequest.DateTime); parameters.Add("RetURL", paymentRequest.RetURL); //This parameter is not mandatory. Use this to pass the callback url dynamically. if (paymentModule == PGModuleEnum.UseCredit.ToString()) { paymentRequest.JobCd = pgConfig.JobCd; paymentRequest.UseCredit = pgConfig.UseCredit; parameters.Add("UseCredit", paymentRequest.UseCredit); parameters.Add("JobCd", paymentRequest.JobCd); string shop_hash_string = string.Empty; string member_hash_string = string.Empty; //[Shop ID+ Order ID+ Amount of money+ Tax/shipping+ Shop password+ Date information] in // MD5 hashed character string. // shop information shop_hash_string = paymentRequest.ShopID + "|" + paymentRequest.OrderID + "|" + paymentRequest.Amount + "|" + paymentRequest.Tax + "|" + paymentRequest.ShopPassword + "|" + paymentRequest.DateTime; string shopPassString = GenerateMD5SignatureForGMO(shop_hash_string).ToLower(); //[Site ID+ Member ID+ Site password+ Date information] in MD5 hashed character string. // member information //member_hash_string = PaymentRequest.SiteID + PaymentRequest.MemberID + PaymentRequest.SitePassword + PaymentRequest.DateTime; //string memberPassString = GenerateMD5SignatureForPayU(member_hash_string).ToLower(); paymentRequest.ShopPassString = shopPassString; //PaymentRequest.MemberPassString = memberPassString; parameters.Add("ShopPassString", shopPassString); } else if (paymentModule == PGModuleEnum.UseDocomo.ToString()) { paymentRequest.UseDocomo = "1"; parameters.Add("UseDocomo", paymentRequest.UseDocomo); // parameters = getDocomoMobileRequestParam(paymentRequest); } else if (paymentModule == PGModuleEnum.UseAu.ToString()) { string s_unicode = "バスサービス"; // Convert a string to utf-8 bytes. byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(s_unicode); paymentRequest.UseAu = "1"; paymentRequest.Commodity = utf8Bytes; paymentRequest.ServiceName = utf8Bytes; paymentRequest.ServiceTel = utf8Bytes; parameters.Add("UseAu", paymentRequest.UseAu); parameters.Add("Commodity", ""); parameters.Add("ServiceName", ""); parameters.Add("ServiceName", ""); //parameters = getKantanKessaiRequestParam(paymentRequest); } else if (paymentModule == PGModuleEnum.UseSb.ToString()) { paymentRequest.UseSb = "1"; //parameters = getSoftbankMatometeShiharaiRequestParam(paymentRequest); } else { return(null); } return(parameters); }