private static bool SetOfflineParametersInSession(string sessionId, string authenticationId, Token token, string voucherCode) { ISessionService sessionService = new SessionService(); var sessionDataResponse = sessionService.GetSessionData(authenticationId, sessionId); if (sessionDataResponse != null && string.IsNullOrEmpty(sessionDataResponse.ErrorMessage) && sessionDataResponse.SessionData != null) { var paymentService = new PaymentService(); var voucherRedemptionAmount = paymentService.GetVoucherAmount(sessionId, voucherCode); var amount = token.PayableAmount - voucherRedemptionAmount; sessionDataResponse.SessionData.ToPayAmount = amount; sessionDataResponse.SessionData.PaymentTransaction = new PaymentTransaction(token.PaymentReferenceNumber); sessionDataResponse.SessionData.Token = token; sessionDataResponse.SessionData.VoucherCode = voucherCode; sessionService.UpdateSessionData(sessionId, sessionDataResponse.SessionData); return true; } return false; }
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); string postData = PostData; var cookieManager = new RequestCookieManager(Request.Cookies); var billingAddress = cookieManager.GetBillingAddress(); var sessionId = cookieManager.GetSessionId(); var authenticationId = cookieManager.GetAuthenticationId(); if (string.IsNullOrEmpty(authenticationId) || string.IsNullOrEmpty(sessionId) || billingAddress == null) { RedirectToPreviousPage(); } else { var isOfflineBooking = cookieManager.IsOfflineBooking; var voucherCode = cookieManager.GetVoucherCode(); if (isOfflineBooking) { var token = cookieManager.GetToken(); if (token == null) { RedirectToPreviousPage(); } else { var isOfflineDataSet = SetOfflineParametersInSession(sessionId, authenticationId, token, voucherCode); if (isOfflineDataSet == false) { RedirectToPreviousPage(); } } } var paymentService = new PaymentService(); postData = paymentService.GetPostData(authenticationId, sessionId, billingAddress); } Response.Clear(); Response.Write(postData); Response.End(); }
protected override void Page_Load(object sender, EventArgs e) { try { var header = Request.Headers.ToString(); Logger.LogMessage(new Log("Headers", header, "PaymentResponse.aspx")); Logger.LogMessage(new Log("FormData", Request.Form.ToString(), "PaymentResponse.aspx")); Logger.LogMessage(new Log("QueryString", Request.QueryString.ToString(), "PaymentResponse.aspx")); } catch (Exception) { } base.Page_Load(sender, e); string response = Request.QueryString["DR"]; var provider = "EBS"; var variables = Request.QueryString; if (string.IsNullOrEmpty(response)) { //Check PayU response = Request.Form["hash"]; provider = "PayU"; variables = Request.Form; } var cookieManager = new RequestCookieManager(Request.Cookies); var sessionId = cookieManager.GetSessionId(); var authenticationId = cookieManager.GetAuthenticationId(); var isOfflineBooking = cookieManager.IsOfflineBooking; var voucherCode = cookieManager.GetVoucherCode(); if (!string.IsNullOrEmpty(response) && !string.IsNullOrEmpty(sessionId)) { var paymentService = new PaymentService(); string errorMessage; if (!paymentService.ValidateResponse(response, provider, authenticationId, sessionId, variables, voucherCode, out errorMessage)) { Response.Write(errorMessage); Response.End(); } else { if (isOfflineBooking == false) { var travelService = new TravelService(); BookResponse bookResponse = travelService.Book(sessionId, authenticationId); if (bookResponse != null && bookResponse.IsSuccess) { HttpContext.Current.Response.Redirect("Confirm.aspx"); } else { string error = bookResponse == null ? string.Empty : "Error: " + bookResponse.ErrorMessage; HttpContext.Current.Response.Redirect("BookingFailed.aspx?error=" + error); } } else { HttpContext.Current.Response.Redirect("OfflinePaymentConfirm.aspx"); } } } else { Response.Write("Sorry, invalid response received. Please login again and restart."); Response.End(); } }