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); } }
private HttpResponseMessage PerformPostPaymentJobs(GMOPaymentResponse response) { HttpClient httpClient = new HttpClient(); string baseUrl = ConfigurationManager.AppSettings["PaymentResponseJobsUrl"]; var jsonString = JsonConvert.SerializeObject(response); var content = new StringContent(jsonString, Encoding.UTF8, "application/json"); var result = httpClient.PostAsync(baseUrl, content).Result; return(result); }
public bool ProcessOrderAfterPayment(GMOPaymentResponse content) { if (content == null) { throw new Exception("Invalid information."); } var response = _travellerService.GetBookingDatailsById(content.UniqueReference); if (response == null) { throw new Exception("Invalid request."); } return(ProcessAppointmentAfterPaytmPayment(content, response.Result)); }
private bool ProcessAppointmentAfterPaytmPayment(GMOPaymentResponse response, BookedPassInformationViewModel bookingInfo) { try { if (response != null) { bool pgStatus = false; bool bookingStatus = false; string Vmmp_txn = response.ShopID; bool VpaymentStatus = String.IsNullOrEmpty(response.ErrorCode) ? true : false; _logger.LogError("Payment gateway response status: " + VpaymentStatus); _logger.LogError("Trying to update success booking pass information for id " + bookingInfo.UniqueReferrenceNumber); bookingStatus = _travellerService.UpdateBookingInformation(bookingInfo, VpaymentStatus, response.TranID); _logger.LogInfo("Booking pass information updated successfully for id " + bookingInfo.UniqueReferrenceNumber); ///////////////////////////////// Add New PG Transation Information ///////////////////////// if (bookingStatus) { _logger.LogError("Trying to add new payment gateway transaction for id " + bookingInfo.UniqueReferrenceNumber); pgStatus = _paymentGatewayTransactionService.AddTransactionInformation(bookingInfo, VpaymentStatus, response.TranID); _logger.LogInfo("PG transaction information updated successfully for trans Id " + response.TranID); return(pgStatus); } return(bookingStatus); } else { return(false); } } catch (Exception ex) { _logger.LogError(ex.Message); return(false); } }
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); } }