private MessageClass RaveGateWay() { var bc = new MessageClass(); var xpresspaytransIds = Session["transidno"].ObjectToString(); var icmapublickey = Global.Raveconfigs.Publickey; var icmaprivatekey = Global.Raveconfigs.Privatekey; var decodedicmaprivatekey = Hash512Helper.GenerateSha256String(icmaprivatekey); var stateUrl = Session["url"].ObjectToString(); var baseUrl = Request.Url.GetLeftPart(UriPartial.Authority); var returnUrl = baseUrl + "/" + Global.Raveconfigs.Callbackurl; var callbackurl = returnUrl; const string proceedButton = "Proceed to payment"; //Get parameter to post var ravePararameters = new RavePararameters { Txref = xpresspaytransIds, PbfPubKey = icmapublickey, CustomerEmail = txtEmail.Value, Amount = Convert.ToDecimal(txtpayeamt.Text).ToString(CultureInfo.InvariantCulture), Currency = Global.Raveconfigs.RaveCountrycurrency, Redirecturl = callbackurl, Paybuttontext = proceedButton }; //Instatiate the baseurl var client = _helper.InitializeClient(); var content = new StringContent(JsonConvert.SerializeObject(ravePararameters), Encoding.UTF8, "application/json"); var res = client.PostAsync("flwv3-pug/getpaidx/api/v2/hosted/pay", content).Result; if (res.IsSuccessStatusCode) { var messageClass = res.Content.ReadAsAsync <RaveResponseClass.ResponseObject>().Result; if (messageClass != null && messageClass.Status == "success") { bc.StatusId = 1; bc.StatusMessage = "Service return a successfully response"; var ravelink = messageClass.Data.Link; Session["ravelink"] = ravelink; } else { bc.StatusId = -1; bc.StatusMessage = $"Service return null - {messageClass?.Status}"; } } return(bc); }
private MessageClass VerifyRaveResponse(string dbTransValue) { var bc = new MessageClass(); var secretKey = Global.Raveconfigs.Privatekey; var raveVerifyPararameters = new RavePararameters() { Txref = dbTransValue, Secretkey = secretKey }; //Instatiate the baseurl var client = _helper.InitializeClient(); var content = new StringContent(JsonConvert.SerializeObject(raveVerifyPararameters), Encoding.UTF8, "application/json"); var res = client.PostAsync("flwv3-pug/getpaidx/api/v2/verify", content).Result; if (res.IsSuccessStatusCode) { var messageClass = res.Content.ReadAsAsync <RaveResponseClass.ResponseObject>().Result; if (messageClass != null && messageClass.Status == "success" && messageClass.Data.Chargecode == "00" && messageClass.Message == "Tx Fetched") { bc = new MessageClass(); try { bc.StatusId = 1; bc.StatusMessage = $"Service return a successfully response - {messageClass?.Message}"; var raveTransId = dbTransValue; bc = CompareResponse(raveTransId); } catch (Exception exception) { Console.WriteLine(exception); var err = new CreateLogFiles(); err.ErrorLog(Server.MapPath("~/Logs/ErrorLog"), exception.Message); ExceptionLogging.SendErrorTomail(exception, HttpContext.Current.Request.Url.ToString()); bc.StatusMessage = exception.Message; bc.StatusId = -1; } } else { bc = new MessageClass(); try { var raveTransId = Session["transidno"].ObjectToString(); if (messageClass != null) { bc.StatusMessage = messageClass.Message; } bc = UpdateFalseTransLog(raveTransId); } catch (Exception exception) { Console.WriteLine(exception); var err = new CreateLogFiles(); err.ErrorLog(Server.MapPath("~/Logs/ErrorLog"), exception.Message); ExceptionLogging.SendErrorTomail(exception, HttpContext.Current.Request.Url.ToString()); bc.StatusMessage = $"TransactionError:: {exception.Message}"; bc.StatusId = -1; } if (messageClass != null) { bc.StatusMessage = messageClass.Message; } bc.StatusId = -1; bc.StatusMessage = $"Service return a successfully response - {messageClass?.Message}"; } } else { bc = new MessageClass(); try { var raveTransId = Session["transidno"].ObjectToString(); bc = UpdateFalseTransLog(raveTransId); } catch (Exception exception) { Console.WriteLine(exception); var err = new CreateLogFiles(); err.ErrorLog(Server.MapPath("~/Logs/ErrorLog"), exception.Message); ExceptionLogging.SendErrorTomail(exception, HttpContext.Current.Request.Url.ToString()); bc.StatusMessage = $"TransactionError:: {exception.Message}"; bc.StatusId = -1; } bc.StatusId = -1; bc.StatusMessage = "Service return unsuccessful message"; } return(bc); }