<%
if request.QueryString("mode") = "view" then
if request.QueryString("info") <> "" then
strID = request.QueryString("ID")
Set rsCommon = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Merchant"
rsCommon.Open strSQL, adoCon
strEmail = rsCommon("email")
rsCommon.Close
Set rsCommon = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Categories order by category"
rsCommon.Open strSQL, adoCon
%>
<%
rsCommon.close
strSQL = "SELECT * FROM Products Where ID=" & strID & " order by category, subcategory, title " & strSortDirection
rsCommon.Open strSQL, adoCon
strSubCategory = rsCommon("SubCategory")
strSH = rsCommon("SH")
strtitle = rsCommon("title")
strProductID = rsCommon("productID")
strCost = rsCommon("Cost")
strSHCost = rsCommon("SHCost")
strDescription = rsCommon("description")
strImage1 = rsCommon("image1")
strImage2 = rsCommon("image2")
strImage3 = rsCommon("image3")
%>
<%
else
strID = request.QueryString("ID")
Set rsCommon = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Merchant"
rsCommon.Open strSQL, adoCon
strEmail = rsCommon("email")
rsCommon.Close
Set rsCommon = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Categories order by category"
rsCommon.Open strSQL, adoCon
%>
<%
rsCommon.close
strSQL = "SELECT * FROM Products Where CatID=" & strID & " order by category, subcategory, title " & strSortDirection
rsCommon.Open strSQL, adoCon
%>
<%
If rsCommon.EOF then
%>
No Products Exist in the system. |
<%
else
Dim strCount
strCount = 0
While NOT rsCommon.EOF AND NOT rsCommon.BOF
strCount = strCount + 1
rsCommon.MoveNext()
Wend
rsCommon.MoveFirst
DIM intPageRecords, intRecords, intRecordCount, intCurrentPage
DIM intNumberOfPages, intDisplayPage
intPageRecords = Request.Querystring("page")
IF intPageRecords = "" THEN intPageRecords = 1 : intRecords = 1
intRecords = intPageRecords
intPageRecords = ((intPageRecords - 1) * 10) +1
intRecordCount = 0
%>
<%=rsCommon("Category") %>
<%
intCurrentPage = Request.Querystring("page")
IF intCurrentPage = "" THEN intCurrentPage = 1
intNumberOfPages = int(strCount \ 10)
IF rsCommon.RecordCount MOD 10<> 0 THEN intNumberOfPages = intNumberOfPages + 1
Response.Write("[")
FOR intDisplayPage = 1 TO intNumberOfPages
IF Cint(intDisplayPage) = Cint(intCurrentPage) THEN
Response.Write intDisplayPage
ELSE
Response.Write " " & intDisplayPage &_
" "
END IF
NEXT
Response.Write ("]")
%>
|
<%
IF NOT rsCommon.EOF THEN
rsCommon.Move (intPageRecords - 1)
DO WHILE intRecordCount < 10 and NOT rsCommon.EOF
strSubCategory = rsCommon("SubCategory")
strSH = rsCommon("SH")
%>
<%=rsCommon("title") %>
$<%=rsCommon("Cost") %>
|
<%
strDescription = rsCommon("description")
%>
<%
strImage1 = rsCommon("image1")
If strImage1 <> "" then %>
<%end if %>
<%=(Left(strDescription,500)) %>
<%if (Len(strDescription)) > 500 then %>
&info=x">...more info
<%end if %>
|
<%
rsCommon.MoveNext
intRecordCount = intRecordCount +1
Loop
end if
%>
<%=intPageRecords%> - <%=intPageRecords+(intRecordCount-1)%> of <%=strCount%> Products
<%
intCurrentPage = Request.Querystring("page")
IF intCurrentPage = "" THEN intCurrentPage = 1
intNumberOfPages = int(strCount \ 10)
IF rsCommon.RecordCount MOD 10<> 0 THEN intNumberOfPages = intNumberOfPages + 1
Response.Write("Page: [")
FOR intDisplayPage = 1 TO intNumberOfPages
IF Cint(intDisplayPage) = Cint(intCurrentPage) THEN
Response.Write intDisplayPage
ELSE
Response.Write " " & intDisplayPage &_
" "
END IF
NEXT
Response.Write ("]")
%>
|
<%
end if
rsCommon.close
end if
end if
if request.QueryString("mode") = "" then
Set rsCommon = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Categories order by category"
rsCommon.Open strSQL, adoCon
If rsCommon.EOF then
strCheck = "1"
end if
%>
Please select a category from below to browse products
<%
rsCommon.close
end if
if request.QueryString("mode") = "complete" then
Dim Item_name, Item_number, Payment_status, Payment_amount
Dim Txn_id, Receiver_email, Payer_email
Dim objHttp, str
' read post from PayPal system and add 'cmd'
str = Request.Form & "&cmd=_notify-validate"
' post back to PayPal system to validate
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
' set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
' set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send str
' assign posted variables to local variables
Item_name = Request.Form("item_name")
Item_number = Request.Form("item_number")
Payment_status = Request.Form("payment_status")
Payment_amount = Request.Form("mc_gross")
Payment_currency = Request.Form("mc_currency")
Txn_id = Request.Form("txn_id")
Receiver_email = Request.Form("receiver_email")
Payer_email = Request.Form("payer_email")
' Check notification validation
if (objHttp.status <> 200 ) then
' HTTP error handling
elseif (objHttp.responseText = "VERIFIED") then
' check that Payment_status=Completed
' check that Txn_id has not been previously processed
' check that Receiver_email is your Primary PayPal email
' check that Payment_amount/Payment_currency are correct
' process payment
elseif (objHttp.responseText = "INVALID") then
' log for manual investigation
else
' error
end if
set objHttp = nothing
end if
%>