From b7e44318167cf2321c1e975cde185fa348f0dc71 Mon Sep 17 00:00:00 2001 From: NochexDevTeam <36759878+NochexDevTeam@users.noreply.github.com> Date: Mon, 9 Apr 2018 11:45:59 +0100 Subject: [PATCH] Update nochexapccsharp.aspx.cs --- CSharp/nochexapccsharp.aspx.cs | 106 +++------------------------------ 1 file changed, 9 insertions(+), 97 deletions(-) diff --git a/CSharp/nochexapccsharp.aspx.cs b/CSharp/nochexapccsharp.aspx.cs index e6c2bea..bf37248 100644 --- a/CSharp/nochexapccsharp.aspx.cs +++ b/CSharp/nochexapccsharp.aspx.cs @@ -9,9 +9,8 @@ public partial class nochexapccsharp : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { - - NameValueCollection nvc = Request.Form; + NameValueCollection nvc = Request.Form; string postdetails = nvc.ToString(); // Create a request using a URL that can receive a post. @@ -43,37 +42,26 @@ protected void Page_Load(object sender, EventArgs e) // Read the content. string responseFromServer = reader.ReadToEnd(); - - - if (responseFromServer == "AUTHORISED") - { - //lbltransaction.Text = "Authorised"; - MailMessage mail = new MailMessage("apc@nochex.com", "james.lugton@nochex.com"); + MailMessage mail = new MailMessage("apc@nochex.com", "your_email@example.com"); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "mail.nochex.com"; + + if (responseFromServer == "AUTHORISED") + { + //lbltransaction.Text = "Authorised"; mail.Subject = "Callback was " + responseFromServer; - mail.Body = "Callback Response was: " + responseFromServer + ", for order:" + Request.Form["order_id"] + ". amount:" + Request.Form["amount"]; - client.Send(mail); } else // If the Callback response is DECLINED email results and investigate { - //lbltransaction.Text = "Declined"; - MailMessage mail = new MailMessage("apc@nochex.com", "james.lugton@nochex.com"); - SmtpClient client = new SmtpClient(); - client.Port = 25; - client.DeliveryMethod = SmtpDeliveryMethod.Network; - client.UseDefaultCredentials = false; - client.Host = "mail.nochex.com"; - mail.Subject = "Callback was " + responseFromServer; - + //lbltransaction.Text = "Declined"; + mail.Subject = "Callback was " + responseFromServer; mail.Body = "Callback Response was: " + responseFromServer + " for order:" + Request.Form["order_id"] + ", amount:" + Request.Form["amount"]; - client.Send(mail); } @@ -82,82 +70,6 @@ protected void Page_Load(object sender, EventArgs e) reader.Close(); dataStream.Close(); response.Close(); - - - - - - -// NameValueCollection nvc = Request.Form; -// string postdetails = nvc.ToString(); -// -// -// // Create a request using a URL that can receive a post. -// WebRequest request = WebRequest.Create("https://www.nochex.com/apcnet/apc.aspx"); -// // Set the Method property of the request to POST. -// request.Method = "POST"; -// // Create POST data and convert it to a byte array. -// -// byte[] byteArray = Encoding.UTF8.GetBytes(postdetails); -// // Set the ContentType property of the WebRequest. -// request.ContentType = "application/x-www-form-urlencoded"; -// // Set the ContentLength property of the WebRequest. -// request.ContentLength = byteArray.Length; -// // Get the request stream. -// Stream dataStream = request.GetRequestStream(); -// // Write the data to the request stream. -// dataStream.Write(byteArray, 0, byteArray.Length); -// // Close the Stream object. -// dataStream.Close(); -// -// // Get the response. -// WebResponse response = request.GetResponse(); -// -// // Get the stream containing content returned by the server. -// dataStream = response.GetResponseStream(); -// // Open the stream using a StreamReader for easy access. -// StreamReader reader = new StreamReader(dataStream); -// // Read the content. -// string responseFromServer = reader.ReadToEnd(); -// -// -// -// if (responseFromServer == "AUTHORISED") -// { -// -// MailMessage mail = new MailMessage("james.lugton@nochex.com", "james.lugton@nochex.com"); -// SmtpClient client = new SmtpClient(); -// client.Port = 25; -// client.DeliveryMethod = SmtpDeliveryMethod.Network; -// client.UseDefaultCredentials = false; -// client.Host = "mail.nochex.com"; -// mail.Subject = "APC was " + responseFromServer; -// -// mail.Body = "APC Response was: " + responseFromServer + ", for order:" + Request.Form["order_id"] + ". amount:" + Request.Form["amount"] + ". This was a " + Request.Form["status"] + " transaction"; -// -// client.Send(mail); -// -// } -// else // If the APC response is DECLINED email results and investigate -// { -// -// MailMessage mail = new MailMessage("james.lugton@nochex.com", "james.lugton@nochex.com"); -// SmtpClient client = new SmtpClient(); -// client.Port = 25; -// client.DeliveryMethod = SmtpDeliveryMethod.Network; -// client.UseDefaultCredentials = false; -// client.Host = "mail.nochex.com"; -// mail.Subject = "APC was " + responseFromServer; -// -// mail.Body = "APC Response was: " + responseFromServer + " for order:" + Request.Form["order_id"] + ", amount:" + Request.Form["amount"] + ". This was a " + Request.Form["status"] + " transaction"; -// -// client.Send(mail); -// -// } -// -// // Clean up the streams. -// reader.Close(); -// dataStream.Close(); -// response.Close(); + } }