Fra ASP til ASP.NET
Hejsa...200points til den der hurtigst kan oversætte nedenstående kode fra klassisk ASP til ASP.NET 2.0Const payTimeout = 15 'sec
Function RegExpGet(pattern, txt)
On Error Resume Next
Dim regEx
Dim Match
Dim Matches
Dim n : n = ""
txt = REPLACE(txt,vbCrlf," ")
txt = REPLACE(txt,Chr(10)," ")
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
Side 18
regEx.Pattern = pattern
Set Matches = regEx.Execute(txt)
IF Matches.Count > 0 THEN
For Each Match in Matches
n = Match.SubMatches(0)
Exit For
Next
END IF
Set regEx = Nothing
RegExpGet = n
End Function
' *******************
' job = capture/cancel
' oid = Order ID.
'
' url = https://pay.scannet.dk/shop/ordre.aml?Ordre=<oid>&Nummer=<oid>&<event>
'
' Example:
' C
' *******************
Function SendToPay(job, oid)
On Error Resume Next
Dim payQuery : payQuery = ""
Select Case LCase(job)
Case "capture"
payQuery = "&approveorder=1&Ekspeder=1"
Case "cancel"
payQuery = "&declineorder=1&Afvis=1"
End Select
Dim h
Set h = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
h.Open "GET", "https://pay.scannet.dk/shop/ordre.aml?Nummer=" & oid & "&Ordre=" & oid & payQuery, false, payUsername, payPassword
h.SetTimeouts (payTimeout*1000), (payTimeout*1000), (payTimeout*1000), (payTimeout*1000)
h.Send()
IF Err.Number = 0 THEN
SendToPay = RegExpGet("ActionCode=([0-9]+)", h.responseText)
END IF
Set h = Nothing
End Function
%>
<strong>Hæv penge:</strong><br>
Retur kode: <%=SendToPay(todo,oid)%>