Skip to content

Commit

Permalink
Update nochexapccsharp.aspx.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
NochexDevTeam committed Apr 9, 2018
1 parent 6ac8850 commit b7e4431
Showing 1 changed file with 9 additions and 97 deletions.
106 changes: 9 additions & 97 deletions CSharp/nochexapccsharp.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);

}
Expand All @@ -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();

}
}

0 comments on commit b7e4431

Please sign in to comment.