HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/web/vintagedoorknobs/worldpay-webhook.asp
<%Option Explicit%>
<%
' =========================================================================
' THE PROXY: Safely captures JSON, forwards it, and silences Worldpay
' =========================================================================
' (SS & Gemini,4/3/2026)
Dim byteCount, rawBytes, jsonPayload, stream, xmlHttp, url

byteCount = Request.TotalBytes
If byteCount > 0 Then
  ' 1. Safely read the raw JSON (No includes here, so no crashes!)
  rawBytes = Request.BinaryRead(byteCount)
  
  Set stream = Server.CreateObject("ADODB.Stream")
  stream.Type = 1 
  stream.Open
  stream.Write rawBytes
  stream.Position = 0
  stream.Type = 2 
  stream.CharSet = "utf-8"
  jsonPayload = stream.ReadText
  stream.Close
  Set stream = Nothing
  
  ' 2. Forward it to your existing callback file
  url = "https://" & Request.ServerVariables("HTTP_HOST") & "/worldpay-callback.asp"
  
  ' Capture original URL and Real IP
  Dim originalUrl : originalUrl = "https://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("URL")
  If Request.ServerVariables("QUERY_STRING") <> "" Then originalUrl = originalUrl & "?" & Request.ServerVariables("QUERY_STRING")
  Dim realIP : realIP = Request.ServerVariables("REMOTE_ADDR")
  
  Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
  xmlHttp.Open "POST", url, False
  xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  
  ' Package the JSON, URL, and IP into the form post
  xmlHttp.Send "wp_payload=" & Server.URLEncode(jsonPayload) & "&wp_original_url=" & Server.URLEncode(originalUrl) & "&wp_original_ip=" & Server.URLEncode(realIP)
  Set xmlHttp = Nothing
  
  ' 3. SILENCE WORLDPAY
  Response.Status = "200 OK"
  Response.Write "OK"
  Response.End  
End If

%>