@@ -9,9 +9,8 @@ public partial class nochexapccsharp : System.Web.UI.Page
9
9
{
10
10
protected void Page_Load ( object sender , EventArgs e )
11
11
{
12
-
13
12
14
- NameValueCollection nvc = Request . Form ;
13
+ NameValueCollection nvc = Request . Form ;
15
14
string postdetails = nvc . ToString ( ) ;
16
15
17
16
// Create a request using a URL that can receive a post.
@@ -43,37 +42,26 @@ protected void Page_Load(object sender, EventArgs e)
43
42
// Read the content.
44
43
string responseFromServer = reader . ReadToEnd ( ) ;
45
44
46
-
47
-
48
- if ( responseFromServer == "AUTHORISED" )
49
- {
50
- //lbltransaction.Text = "Authorised";
51
- MailMessage mail = new MailMessage ( "[email protected] " , "[email protected] " ) ;
45
+ MailMessage mail = new MailMessage ( "[email protected] " , "[email protected] " ) ;
52
46
SmtpClient client = new SmtpClient ( ) ;
53
47
client . Port = 25 ;
54
48
client . DeliveryMethod = SmtpDeliveryMethod . Network ;
55
49
client . UseDefaultCredentials = false ;
56
50
client . Host = "mail.nochex.com" ;
51
+
52
+ if ( responseFromServer == "AUTHORISED" )
53
+ {
54
+ //lbltransaction.Text = "Authorised";
57
55
mail . Subject = "Callback was " + responseFromServer ;
58
-
59
56
mail . Body = "Callback Response was: " + responseFromServer + ", for order:" + Request . Form [ "order_id" ] + ". amount:" + Request . Form [ "amount" ] ;
60
-
61
57
client . Send ( mail ) ;
62
58
63
59
}
64
60
else // If the Callback response is DECLINED email results and investigate
65
61
{
66
- //lbltransaction.Text = "Declined";
67
- MailMessage mail = new MailMessage ( "[email protected] " , "[email protected] " ) ;
68
- SmtpClient client = new SmtpClient ( ) ;
69
- client . Port = 25 ;
70
- client . DeliveryMethod = SmtpDeliveryMethod . Network ;
71
- client . UseDefaultCredentials = false ;
72
- client . Host = "mail.nochex.com" ;
73
- mail . Subject = "Callback was " + responseFromServer ;
74
-
62
+ //lbltransaction.Text = "Declined";
63
+ mail . Subject = "Callback was " + responseFromServer ;
75
64
mail . Body = "Callback Response was: " + responseFromServer + " for order:" + Request . Form [ "order_id" ] + ", amount:" + Request . Form [ "amount" ] ;
76
-
77
65
client . Send ( mail ) ;
78
66
79
67
}
@@ -82,82 +70,6 @@ protected void Page_Load(object sender, EventArgs e)
82
70
reader . Close ( ) ;
83
71
dataStream . Close ( ) ;
84
72
response . Close ( ) ;
85
-
86
-
87
-
88
-
89
-
90
-
91
- // NameValueCollection nvc = Request.Form;
92
- // string postdetails = nvc.ToString();
93
- //
94
- //
95
- // // Create a request using a URL that can receive a post.
96
- // WebRequest request = WebRequest.Create("https://www.nochex.com/apcnet/apc.aspx");
97
- // // Set the Method property of the request to POST.
98
- // request.Method = "POST";
99
- // // Create POST data and convert it to a byte array.
100
- //
101
- // byte[] byteArray = Encoding.UTF8.GetBytes(postdetails);
102
- // // Set the ContentType property of the WebRequest.
103
- // request.ContentType = "application/x-www-form-urlencoded";
104
- // // Set the ContentLength property of the WebRequest.
105
- // request.ContentLength = byteArray.Length;
106
- // // Get the request stream.
107
- // Stream dataStream = request.GetRequestStream();
108
- // // Write the data to the request stream.
109
- // dataStream.Write(byteArray, 0, byteArray.Length);
110
- // // Close the Stream object.
111
- // dataStream.Close();
112
- //
113
- // // Get the response.
114
- // WebResponse response = request.GetResponse();
115
- //
116
- // // Get the stream containing content returned by the server.
117
- // dataStream = response.GetResponseStream();
118
- // // Open the stream using a StreamReader for easy access.
119
- // StreamReader reader = new StreamReader(dataStream);
120
- // // Read the content.
121
- // string responseFromServer = reader.ReadToEnd();
122
- //
123
- //
124
- //
125
- // if (responseFromServer == "AUTHORISED")
126
- // {
127
- //
128
- // MailMessage mail = new MailMessage("[email protected] ", "[email protected] ");
129
- // SmtpClient client = new SmtpClient();
130
- // client.Port = 25;
131
- // client.DeliveryMethod = SmtpDeliveryMethod.Network;
132
- // client.UseDefaultCredentials = false;
133
- // client.Host = "mail.nochex.com";
134
- // mail.Subject = "APC was " + responseFromServer;
135
- //
136
- // mail.Body = "APC Response was: " + responseFromServer + ", for order:" + Request.Form["order_id"] + ". amount:" + Request.Form["amount"] + ". This was a " + Request.Form["status"] + " transaction";
137
- //
138
- // client.Send(mail);
139
- //
140
- // }
141
- // else // If the APC response is DECLINED email results and investigate
142
- // {
143
- //
144
- // MailMessage mail = new MailMessage("[email protected] ", "[email protected] ");
145
- // SmtpClient client = new SmtpClient();
146
- // client.Port = 25;
147
- // client.DeliveryMethod = SmtpDeliveryMethod.Network;
148
- // client.UseDefaultCredentials = false;
149
- // client.Host = "mail.nochex.com";
150
- // mail.Subject = "APC was " + responseFromServer;
151
- //
152
- // mail.Body = "APC Response was: " + responseFromServer + " for order:" + Request.Form["order_id"] + ", amount:" + Request.Form["amount"] + ". This was a " + Request.Form["status"] + " transaction";
153
- //
154
- // client.Send(mail);
155
- //
156
- // }
157
- //
158
- // // Clean up the streams.
159
- // reader.Close();
160
- // dataStream.Close();
161
- // response.Close();
73
+
162
74
}
163
75
}
0 commit comments