Okej, då kommer det här.
Jag valde att behålla alla kommentarer jag hade i dokumentet om det skulle vara till någon nytta
Processing.asp - Skickar data till paynovas server och behandlar svaren
Kod:
<%
'###################################################
'################# PAYNOVA START ###################
'###################################################
icpaccountid = "xxxxxx" 'Replace with your own
secretkey = "xxxxxxxxxxxx" ' Replace with your own. It's more secure to read this from a database.
ShopBaseUrl = "https://www.domän.se/"
PNserverUrl = "https://www.paynova.com/"
notifypage = ShopBaseUrl & "teknik/paynova/notifypage.asp"
redirecturlok = ShopBaseUrl & "order_kvitto.asp?ID="& intOrderId
redirecturlcancel = ShopBaseUrl & "teknik/payment.asp?data="& intOrderId &"&status=cancelled"
strCurrency = "SEK"
amount = CInt(intPris * 100) ' = 10,00
orderid = intOrderId
paymentdata = session("siteuserid") &"|"& session("AffiliateID")
'Contract text. This text is displayed in the wallet and should describe what the customer is paying for.
strContractText = request.form("contracttext")
' Create a MD5 checksum on all values
strData = icpaccountid & amount & strCurrency & notifypage & redirecturlok & redirecturlcancel _
& orderid & paymentdata & strContractText & secretkey
checksum = MD5(strData)
'*************** Construct POST String ************************
'IcpAccountID
strPostData = strPostData & "icpaccountid=" & icpaccountid
'Amount
strPostData = strPostData & "&amount=" & amount
'Currency
strPostData = strPostData & "¤cy=" & strCurrency
' The web page that will recieve the payment confirmation post. Send a complete Use with http:// or https://
strPostData = strPostData & "¬ifypage=" & Server.URLEncode(notifypage)
' The web page that the customer will be redirected to if the payment has been successful. Use a complete URL with http:// or https://
strPostData = strPostData & "&redirecturlok=" & Server.URLEncode(redirecturlok)
' The web page that the customer will be redirected to if the payment has not been successful. Use a complete URL with http:// or https://
strPostData = strPostData & "&redirecturlcancel=" & Server.URLEncode(redirecturlcancel)
'OrderID from the shop.
' This is stored by Paynova and can be used as a search criteria in Merchant Services.
strPostData = strPostData & "&orderid=" & Server.URLEncode(orderid)
'Payment data
' This field could be used for some kind of session data.
' Not stored by Paynova.
' It will be sent back in the notifypage call.
' In this example we will send the customer's email.
strPostData = strPostData & "&paymentdata=" & paymentdata
'Contract
strPostData = strPostData & "&contracttext=" & Server.URLEncode(strContractText)
'Checksum
strPostData = strPostData & "&checksum=" & checksum
'*********************************************************************
' Printa(strPostData)
'Make the payment request (IcpPOST) and read the sessionkey returned.
strSessionKey = http_post(PNserverUrl & "payment/startpayment.asp", strPostData)
'Check that the sessionkey is correct. Always 37 characters.
'If the sessionkey <> 37 characters, it may contain an error message.
if len(strSessionKey) = 37 then
Response.Redirect(PNserverUrl & "wallet/?sessionKey=" & strSessionKey)
else
' Illegal sessionkey
Response.Write("An error occurred. Please contact the shop administrator.")
Response.Write("<br>" & strSessionKey)
end if
' Finished!
'************** Helper functions *************************************
function http_post(Url,DataToSend)
dim xmlhttp
'Microsoft XML Core Services 4.0 RTM
'http://msdn.microsoft.com/library/default.asp?url=/downloads/list/xmlgeneral.asp
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST",Url,false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send DataToSend
http_post = xmlhttp.responseText
Set xmlhttp = nothing
end function
%>
////////////////////////////////////////////////////////////////////////////////////////
Notifypage.asp - Behandlar resultatet från Processing.asp
Kod:
<%
Response.ContentType = "text/html; charset=iso-8859-1"
dim strTransID
dim strName
dim strPaymentData
dim strBody
dim lngStatus
dim strFromAddress
dim strPass
dim strOrderID
dim strChecksumRec 'Recieved checksum
dim strChecksumComp 'Computed checksum
dim bolChecksumOK
dim strDataCrypt
dim secretkey
dim logfilename
dim msg
logfilename = server.MapPath("confirmation.log")
secretkey = "****************" ' Replace with your own. It's more secure to read this from a database.
lngStatus = Request.Form("paymentstatus") ' 1 = OK , -1 = Failed
strOrderID = Request.Form("order_id") ' Not used in this example.
strPaymentData = Request.Form("paymentdata") ' In this example the customer's email address.
strTransID = Request.Form("trans_id") ' The Paynova transaction ID. Length 18 characters.
strChecksumRec = Request.Form("checksum") ' Checksum
strDataCrypt = lngStatus & strOrderID & strPaymentData & strTransID & secretkey
strChecksumComp = MD5(strDataCrypt)
dumplog logfilename, "*************************************************************************"
dumplog logfilename, strTransID & "|" & lngStatus & "|" & strPaymentData & "|" & strOrderID
dumplog logfilename, strChecksumRec
dumplog logfilename, strChecksumComp
if strChecksumRec = strChecksumComp then
dumplog logfilename, "checksum match OK"
if lngStatus = "1" then
'###################################################
'###### SKAPAR ORDERBEKRÄFTELSE TILL KUND ########
'###################################################
varArray = Split(strPaymentData, "|") 'Array från Paynova
'HÄR SKAPAS MAIL ELLER VAD MAN NU KA TÄNKAS VILJA GÖRA
'###################################################
'###################################################
response.write("OK|OK")
dumplog logfilename, "Mail sent"
else
'###################################################
'############### DIVERSE FELKODER ################
'###################################################
Response.Write("FEL!")
'###################################################
'###################################################
response.write("OK|Cancelled")
dumplog logfilename, "Payment cancelled"
end if
else
dumplog logfilename, "Checksum mismatch"
response.write("Error|Checksum mismatch!")
end if
function dumplog(strFilename,strMsg)
dim sFile, fso, f
Const ForReading = 1, ForWriting = 2, ForAppending = 8
sFile = strFilename
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(sFile, ForAppending, True)
f.WriteLine Now() & "|" & strMsg
f.Close
end function
%>
Inte säkert att detta ger dig någon hjälp över huvudtaget, men lycka till!