public string ValidatePayRequest(string CustomerID) { try { dynamic AgentObj = new JObject(); AgentObj.CustomerID = CustomerID; Internetserviceprovider.InternetServiceObj cusdataobj = new Internetserviceprovider.InternetServiceObj(); string soapResult = ""; var Resp = ""; string MethodName = ""; MethodName = ConfigurationManager.AppSettings["Fetchuser"]; // var CustomerID = AgentObj.CustomerID; Internetserviceprovider.CustomerObj ispObject = new Internetserviceprovider.CustomerObj(); //Customer Validation if (string.IsNullOrEmpty(CustomerID)) { soapResult = new JObject( new JProperty("status", "error"), new JProperty("message", "Empty CustomerID"), new JProperty("data", new JObject(soapResult))).ToString(); //return Json(soapResult); return(soapResult.ToString()); } var req = Request; var headers = req.Headers; string myAgentID = ""; try { myAgentID = headers.GetValues("agentID").First() ?? ""; } catch { WebLog.Log("Cannot Read AgentID as header"); } var agentID = headers.GetValues("agentID").First() ?? ""; var agentKey = headers.GetValues("agentKey").First() ?? ""; var signature = headers.GetValues("signature").First() ?? ""; AgentObj.AgentID = agentID; AgentObj.AgentKey = agentKey; AgentObj.Signature = signature; var Authenticated = IsTransactionAutheticated(AgentObj); if (Authenticated == false) { soapResult = new JObject( new JProperty("status", "Error"), new JProperty("message", "Authentication Failed"), new JProperty("data", new JObject())).ToString(); // return Json(soapResult); return(soapResult.ToString()); } //var CustomerID = ispObject.CustomerID; Internetserviceprovider intnets = new Internetserviceprovider(); HttpWebRequest request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName); request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName); //var val = ChekMyIP(); using (WebResponse response = request.GetResponse()) { using (StreamReader rd = new StreamReader(response.GetResponseStream())) { soapResult = rd.ReadToEnd(); soapResult = soapResult.Replace(@"\", ""); var soapResults = soapResult.Substring(1); } } if (soapResult == null) { //return Json(soapResult); return(soapResult.ToString()); } if (soapResult != null) { // return Json(soapResult); return(soapResult.ToString()); } // return Json(soapResult); return(soapResult.ToString()); } catch (Exception ex) { WebLog.Log(ex); var obj = new JObject( new JProperty("status", "error"), new JProperty("message", $"{ex.Message}"), new JProperty("data", new JObject())); //return Json(obj); return(obj.ToString()); } }
public ActionResult Check(FormCollection form) { try { Internetserviceprovider.InternetServiceObj cusdataobj = new Internetserviceprovider.InternetServiceObj(); string soapResult = ""; MethodName = ConfigurationManager.AppSettings["Fetchuser"]; var CustomerID = Convert.ToString(form["CustomerId"]); Internetserviceprovider.CustomerObj ispObject = new Internetserviceprovider.CustomerObj(); //var CustomerID = ispObject.CustomerID; Internetserviceprovider intnets = new Internetserviceprovider(); HttpWebRequest request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName); request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName); //var val = ChekMyIP(); using (WebResponse response = request.GetResponse()) { using (StreamReader rd = new StreamReader(response.GetResponseStream())) { soapResult = rd.ReadToEnd(); soapResult = soapResult.Replace(@"\", ""); var soapResults = soapResult.Substring(1); string sp = soapResults.Substring(0, soapResults.Length - 1); // JArray jObj = JArray.Parse(sp); // var value = jObj[0]; // soapResult = soapResult.Replace(@"\", ""); dynamic jobj = JObject.Parse(sp); if (jobj != null && $"{jobj?.soapenvBody?.ns1processResponse?.processReturn?.errorCode}".ToLower() == "0") { var soapObj = jobj?.soapenvBody?.ns1processResponse?.processReturn?.keyParam?.keyParam; var lastname = ""; var firstname = ""; foreach (var item in soapObj) { var keys = item.key; //if(keys == "lastTotalTime") //{ // var keyvalue = item.value; //} if (keys == "userName") { cusdataobj.userName = item.value; var value = item.value; } if (keys == "lastName") { lastname = item.value; //var value = item.value; } if (keys == "email") { cusdataobj.Email = item.value; var value = item.value; } if (keys == "userId") { cusdataobj.CustomerID = item.value; } if (keys == "firstName") { firstname = item.value; //var value = item.value; } cusdataobj.customerName = firstname + lastname; TempData["cusdataobj"] = cusdataobj; //return RedirectToAction(""); } return(RedirectToAction("Buy")); } else if (jobj == null) { TempData["message"] = "Please Try Again"; return(RedirectToAction("Check")); } else if (jobj != null && $"{jobj?.soapenvBody?.ns1processResponse?.processReturn?.errorCode}".ToLower() == "-103") { TempData["Msg"] = $"{jobj?.soapenvBody?.ns1processResponse?.processReturn?.errorMessage}".ToLower(); return(RedirectToAction("Check")); } } } return(View()); } catch (Exception ex) { WebLog.Log(ex.Message.ToString()); return(null); } }