FAQ |
Kalender |
![]() |
#1 | |||
|
||||
Klarade millennium-buggen
|
Har lite problem att förstå mig på Paynova implementationen.
Är det någon som har exempelfiler i ASP som jag skulle kunna få kika på? Har fått manualen på 20 sidor från paynova, och en exempelfil i ASP, men begriper mig inte på det. Jag har kommit så långt att en order skapas i min databas, och den har ett unikt id-nummer, som jag skulle vilja skicka med i min request till Paynova. Men hur gör jag detta? Tacksam för svar! |
|||
![]() |
![]() |
![]() |
#2 | ||
|
|||
Medlem
|
Nu har jag bara kvar kod från det gamla Paynova som fanns (finns kanske fortfarande kvar), med popup och hela baletten.
Antar att du kör på deras nya plattform? |
||
![]() |
![]() |
![]() |
#3 | |||
|
||||
Klarade millennium-buggen
|
Citat:
Men jag kikar gärna på dina exempel ändå, kanske kan lära mig någonting iallafall. Blir jättesnurrig på detta. |
|||
![]() |
![]() |
![]() |
#4 | ||
|
|||
Medlem
|
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 %> |
||
![]() |
![]() |
![]() |
#5 | ||
|
|||
Medlem
|
Jag har tidigare implementerat Paynova i asp och nu planerar jag att göra en lösning i php. Jag minns inte att det var några speciella problem, därför tror jag att en asp-kodare fixar detta på ett nafs. Om du inte har några väldigt specifika frågor tror jag du tjänar på att låta någon annan göra detta. Om inte annat spar du tid.
|
||
![]() |
![]() |
![]() |
#6 | ||
|
|||
Mycket flitig postare
|
För att göra koden funktionell med "nya" Paynova:
Justera strPostData enligt tabell 5.1 i manualen. Efter http_post-anropet ser det lite annorlunda ut. Du får tillbaka en xml-fil, den måste du parsa. Jag är ingen expert på att göra sånt men jag har löst det såhär: Kod:
set xmldoc = server.Createobject("Microsoft.XMLDOM") xmldoc.async=false xmldoc.loadXML(http_response) set status = xmldoc.selectNodes("//responsemessage")(0) paynova_status = status.selectSingleNode("paynova_status").text paynova_substatus = status.selectSingleNode("paynova_substatus").text paynova_session = status.selectSingleNode("paynova_session").text set xmldoc = nothing Kod:
if paynova_status=1 then * *' fixa iframe eller popup, använd parametern paynova_session till url:en elseif paynova_status = -1 then * *if paynova_substatus = 0 then * * * *' Stängt pga driftunderhåll * *elseif .... then * * * *' .... * *end if else * *' fel... end if Kod:
<!--#include file="include/md5.asp"--> paynova_status = Request.Form("paynova_status") paynova_statusmessage = Request.Form("paynova_statusmessage") merchant_orderid = Request.Form("merchant_orderid") paynova_transid = Request.Form("paynova_transid") strChecksumRec = Request.Form("checksum") checksum = MD5(paynova_status&paynova_statusmessage&merchant_orderid&paynova_transid&secretkey) if checksum = strChecksumRec then * *if paynova_status = "1" then * * * *'betalning genomförd * *else * * * *'betalning avbruten * *end if * *'Skriv ut resultat: * * *'<?xml version="1.0" encoding="utf-8" ?> * *'<responsemessage> * *' * *<status>1</status> * *' * *<statusmessage>OK</statusmessage> * *' * *<neworderid></neworderid> * *' * *<batchid></batchid> * *' * *<checksum><%=MD5("1OK"&merchant_orderid&secretkey)%></checksum> * *'</responsemessage> else 'fel checksum * *'Motsvarande xml-reslutat här som ovan, fast med annan statuskod end if |
||
![]() |
![]() |
![]() |
#7 | |||
|
||||
Klarade millennium-buggen
|
Hur skall formen se ut som skall anropa Processing.asp?
|
|||
![]() |
![]() |
![]() |
#8 | ||
|
|||
Mycket flitig postare
|
Det bestämmer du ju själv helt och hållet så länge du får ut all den data som genererar strPostData
|
||
![]() |
![]() |
Svara |
|
|