|
| 1 | +<%@ Language=VBScript %> |
| 2 | + |
| 3 | +<% |
| 4 | +
|
| 5 | +'requires Microsoft XML Parser http://msdn.microsoft.com/xml |
| 6 | +Dim objHttp 'object used for posting form data to nochex |
| 7 | +Dim nochexformdata 'variable used to store form data sent from Nochex |
| 8 | +Dim NochexResponse 'stores the response from the Nochex server |
| 9 | +Dim objEmail |
| 10 | +dim smtpServer |
| 11 | +
|
| 12 | +' smtpServer = "mail.nochex.com" |
| 13 | +
|
| 14 | +nochexformdata = request.Form 'copy the form data from Nochex into the variable |
| 15 | +
|
| 16 | +set objHttp = Server.CreateObject("Microsoft.XMLHTTP") 'create an instance of the XML object library |
| 17 | +objHttp.open "POST", "https://www.nochex.com/apcnet/apc.aspx", false 'set the page to post the form data to the Nochex server |
| 18 | +objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" |
| 19 | +objHttp.Send nochexformdata 'send the form data received from Nochex to the NOCHEX server |
| 20 | +
|
| 21 | +' Check notification validation |
| 22 | +if (objHttp.status = 200 ) then |
| 23 | + if (objHttp.responseText = "AUTHORISED") then |
| 24 | + NochexResponse = "AUTHORISED" |
| 25 | +
|
| 26 | + 'check the transaction_id to make sure it is not a duplicate |
| 27 | + 'process transaction |
| 28 | + elseif (objHttp.responseText = "DECLINED") then |
| 29 | + NochexResponse = "DECLINED" |
| 30 | + 'log and investigate incorrect data |
| 31 | + end if |
| 32 | +else |
| 33 | + NochexResponse = "NO RESPONSE " |
| 34 | +end if |
| 35 | +
|
| 36 | +'Response.Write(NochexResponse) |
| 37 | + |
| 38 | +Set objEmail = CreateObject("CDO.Message") |
| 39 | + objEmail.From = "[email protected]" |
| 40 | + |
| 41 | +
|
| 42 | + objEmail.Configuration.Fields.Item _ |
| 43 | + ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 |
| 44 | + objEmail.Configuration.Fields.Item _ |
| 45 | + ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ |
| 46 | + "mail.nochex.com" |
| 47 | + objEmail.Configuration.Fields.Item _ |
| 48 | + ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 |
| 49 | + objEmail.Configuration.Fields.Update |
| 50 | + |
| 51 | + objEmail.Subject = "Your APC was " & NochexResponse |
| 52 | + objEmail.TextBody = "APC Response was: " & NochexResponse & " for order:" & Request.Form("order_id") & ", amount:" & Request.Form("amount") & ". This was a " & Request.Form("status") & " transaction" |
| 53 | + objEmail.Send |
| 54 | +
|
| 55 | +%> |
0 commit comments