<%@ Language=VBScript %>
<%
'*************************************************************************
' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK!
' Function : Generic "Thank You" and "Error with Payment" page.
' Product : CandyPress Store Frontend
' Version : 4.1
' Modified : May 2007
' Copyright: Copyright (C) 2004 Webs Unlimited, Inc.
' See "license.txt" for this product for details regarding
' licensing, usage, disclaimers, distribution and general
' copyright requirements. If you don't have a copy of this
' file, you may request one at http://www.candypress.com
'*************************************************************************
'1. No database updates are performed in this script.
'2. This script is called upon return from a payment processor.
'3. This script is very "forgiving" in that it only shows the "Error
' with Payment" message if explicitly told to do so by the payment
' processor. If some of the return values are missing but no error
' was reported by the payment processor, the customer will still
' see a "Thank You" message, but some of the links will not be
' displayed.
'*************************************************************************
' Date Description
' 10/23/05 Corrected code so that custom gateway would work
'
'*************************************************************************
Option explicit
Response.Buffer = true
%>
<!--#include file="_INCconfig_.asp"-->
<!--#include file="_INCappDBConn_.asp"-->
<!--#include file="_INCappFunctions_.asp"-->
<!--#include file="_INCupdStatus_.asp"-->
<!--#include file="_INCappEmail_.asp"-->
<%
'Work Fields
dim statusInd
dim qIdOrder
dim qTotal
dim orderStatus
dim payMessage
dim payMessageVar
'Database
dim mySQL
dim conntemp
dim rstemp
dim rstemp2
'Session
dim idOrder
dim idCust
'*************************************************************************
'Open Database Connection
call openDb()
'Store Configuration
if loadConfig() = false then
call errorDB(LangText("ErrConfig",""),"")
end if
'--> PayPal IPN
if len(qIdOrder) = 0 then
'Get Order Number (PayPal Only)
qIdOrder = trim(Request.Form("item_number"))
if len(qIdOrder) = 0 then
qIdOrder = trim(validHTMl(Request.QueryString("item_number")))
end if
'Get Order Number
if len(qIdOrder) = 0 then
qIdOrder = trim(Request.QueryString("CP_idOrder"))
end if
'Get Status
if len(qIdOrder) > 0 then
statusInd = lCase(trim(validHTML(Request.QueryString("CP_Status"))))
end if
end if
'--> 2Checkout Payments
if len(qIdOrder) = 0 then
'Get Order Number
qIdOrder = trim(Request.Form("cart_order_id"))
'Get Status
if len(qIdOrder) > 0 then
statusInd = trim(Request.Form("credit_card_processed"))
if UCase(statusInd) = "Y" then
statusInd = "success"
else
statusInd = "error"
end if
end if
end if
'--> Authorize.Net SIM Payments
if len(qIdOrder) = 0 then
'Get Order Number
qIdOrder = trim(Request.Form("x_invoice_num"))
'Get Status
if len(qIdOrder) > 0 then
statusInd = trim(Request.Form("x_response_code"))
if UCase(statusInd) = "1" then
statusInd = "success"
else
statusInd = "error"
end if
end if
end if
idCust = sessionCust()
'--> Custom Payments
if len(qIdOrder) = 0 then
qIdOrder = trim(Request.Form("oid"))
end if
dim formattedDateTime
'Get a Date and Time formatted to the user's specifications
formattedDateTime = formatTheDate(currDateTime("DT",timeOffSet)) & " " & currDateTime("T",timeOffSet)
'--> Set to zero length string if still incorrect
if len(qIdOrder) = 0 or not(IsNumeric(qIdOrder)) then
qIdOrder = ""
statusInd = ""
end if
'--> Retrieve Order Total
if len(qIdOrder) > 0 and IsNumeric(qIdOrder) then
mySQL = "SELECT total,orderStatus " _
& "FROM " & tablePrefix & "cartHead " _
& "WHERE idOrder = " & validSQL(qIdOrder,"I") & " "
set rsTemp = openRSexecute(mySQL)
if not rstemp.eof then
qTotal = rsTemp("total")
orderStatus = rsTemp("orderStatus")
end if
call closeRS(rsTemp)
end if
%>
<!--#include file="../UserMods/_INCtemplate_.asp"-->
<%
'Close Database Connection
call closeDB()
'**********************************************************************
'Main Shopping Cart Display Area
'**********************************************************************
sub cartMain()
%>
<!-- Outer Table Cell -->
<table border="0" cellpadding="0" cellspacing="0" width=450><tr><td>
<!-- Heading -->
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr><td nowrap valign=middle class="CPpageHead">
<% if statusInd = "error" then %>
<b><font color=red><%=LangText("GenPayErrorHdr","")%></font></b>
<% else %>
<b><%=LangText("GenPaySuccessHdr","")%></b>
<% end if %>
</td></tr>
</table><br>
<!-- Links -->
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr><td valign=middle class="CPgenHeadings">
<%
'If Order Total is available, show it
if len(qTotal) > 0 and IsNumeric(qTotal) then %>
<b><%=LangText("GenTotal","")%> : <%=moneyS(Exchange(qTotal))%></b>
<% end if
'If Order Number is available, link to it
if len(qIdOrder) > 0 and IsNumeric(qIdOrder) then %>
» <b><a href="<%=urlSSL%>custViewOrders.asp?idOrder=<%=qIdOrder%>"><%=LangText("GenOrder","") & " " & pOrderPrefix & "-" & qIdOrder%></a></b>
<% end if %>
» <b><a href="<%=urlSSL%>custListOrders.asp"><%=LangText("GenYourAccount","")%></a></b>
</td></tr>
</table><br>
<!-- Message -->
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr><td>
<%
'Get appropriate payment message from database
select case orderStatus
case "0"
payMessageVar = "payPendingMsg_"
case "1"
payMessageVar = "paySuccessMsg_"
end select
' if error get error message
if LCase(statusInd) = "error" then payMessageVar = "payErrorMsg_"
mySQL = "SELECT configValLong " _
& "FROM " & tablePrefix & "storeAdmin " _
& "WHERE configVar='" & payMessageVar & session("language") & "' " _
& "AND adminType='T'"
set rsTemp = openRSexecute(mySQL)
if not rstemp.eof then
payMessage = trim(rsTemp("configValLong"))
end if
call closeRS(rsTemp)
'Check for tags and replace
payMessage = replace(payMessage,"#STORE#",pCompany)
payMessage = replace(payMessage,"#SALES#","<a href=""mailto:" & pEmailSales & """>" & pEmailSales & "</a>")
payMessage = replace(payMessage,"#ERROR#","<a href=""50_paysubmit.asp"">" & trim(Request("RESPMSG")) & "</a>")
'Display Message
Response.Write payMessage
session(storeID & "idOrder") = null
%>
</td></tr>
</table>
<!-- End Outer Table Cell -->
</td></tr></table>
<br>
<%
end sub
%>
So at the moment, I have taken the #include out of the custom routine and replaced with code to collect the oid returned, but this still doesn't work. The page loads, and just shows a link to "My Account" which when clicked, takes me to all of my orders, BUT I believe that there should also be a section with links with the actual order itself and showing the status and order total. I do get a Thank You message, so parts seem to be working, but not the parts that is coming from the database results.
Is there any way within this code that I could possibly echo out values to see if there are indeed values in the variables? I tried a response.write but this just seems to write whatever i type including the response.write bit
Everything else is working, and emails are correctly being sent advising that the status has been changed to Paid, so I know that the response handler code is working and updating the database, i would just like to get the data and messages displayed on the Thank You page, just for that additional peace of mind, as I believe that it should do this.