%
'***************************************************************
' Result from PayPal transaction
' Either updated that is was successful or return to shopcheckout
' VP-ASP 6.50 Dec 1, 2005
' Remove result check since it is not always returned
'************************************************************
result = ""
dim field
Perror="" ' no errors
PAuthCode="" ' null authorization code
Dim poid
dim canceled
setsess "paymenterror","" ' no payment error
backurl=getsess("currenturl")
if backurl="" then
'VP-ASP 6.50 - get checkout value from shop$config.asp rather than config table
if xcheckout <> "" then
backurl=xcheckout
else
backurl=Getconfig("xcheckout")
end if
end if
forwardurl="shopthanks.asp" 'go forward when finished
Poid=getsess("oid")
if Poid="" then
Poid=request("item_number")
Session("oid")=poid
end if
'VP-ASP 6.09 - security update
if not isnumeric(poid) then
pod = ""
perror = "Your Order ID was invalid."
end if
'GetResults
canceled=request("cancel")
If canceled<>"" then
PError="Your transaction was canceled
Either retry it or select another payment method"
end if
result=ucase(request("payment_status"))
'if Result="FAILED" or result="" then
if Result="FAILED" then
PError="Your transaction failed
Either retry it or select another payment method"
end if
If Perror="" then ' no error
UpdateAuthorization ' add authorization to database
responseredirect ForwardURL ' go to shopthanks
else
setsess "PaymentError",PError
responseredirect BackURL
end if
'***************************************************************
' Updates Authorization field in order
' PAuthcode has authorization value
' Proably no change required here
' txn_id" value="2XV64665W48127432">
' payment_status value="Completed">
'**************************************************************
Sub UpdateAuthorization
Dim sqltemp
Dim rstemp
Dim Pauthcode,refno, paymentstatus
refno=request("txn_id")
paymentstatus=request("payment_status")
PauthCode="refno=" & refno & " status=" & paymentstatus & " " & request("txn_type")
OpenOrderDB dbc
sql="Update orders set "
sql=sql & " oauthorization='" & PAuthCode &"'"
sql=sql & " ,ocardtype='" & "PayPal" &"'"
sql=sql & " where orderid=" & poid
dbc.execute(sql)
ShopCloseDatabase dbc
end sub
'
Sub GetResults
for each field in request.querystring
debugwrite field &"=" & request.querystring(field)
next
debugwrite "form"
for each field in request.form
debugwrite field &"=" & request.form(field)
next
end sub
%>