<%@ Language=VBScript %>
<%
' ****************************************************
' Payment.asp - The shopper will enter in their
' payment information including credit card data.
' ****************************************************
' Check to ensure that the user only came to this page from the
' shipping page, validate payment page (back button or error), or a refresh
' of this page. We utilize the ServerVariables to read the HTTP header.
if instr(lcase(Request.ServerVariables("HTTP_REFERER")),
"shipping.asp") = 0 and _
instr(lcase(Request.ServerVariables("HTTP_REFERER")), "validatepayment.asp") = 0 and _
instr(lcase(Request.ServerVariables("HTTP_REFERER")), "payment.asp") = 0 then
' Send the user back to the basket
Response.Redirect "basket.asp"
end if
' Create an ADO database connection
set dbBasket = server.createobject("adodb.connection")
' Create the record set
set rsBasket = server.CreateObject("adodb.recordset")
' Open the connection using our SQL Server DSN-less connection string
dbBasket.ConnectionString="Driver={SQL Server}; Server=cisdev.quinnipiac.edu;" & _
"Database=WildWillies;UID=cis; PWD=csatqu"
dbBasket.Open
' Build the SQL stored procedure to retrieve the basket subtotal
sql = "execute sp_BasketSubtotal " & session("idBasket")
' Execute the statement
set rsBasket = dbBasket.Execute(sql)
' Retrieve the subtotal and store in a session variable.
SubTotal = rsBasket("subtotal")
session("Subtotal") = Subtotal
' Now build a query to retrieve the basket quantity
sql = "execute sp_BasketQuantity " & session("idBasket")
' Execute the statement
set rsBasket = dbBasket.Execute(sql)
' Check the quantity returned from the database
if rsBasket("quantity") > 0 then
' The snippet will calculate the appropriate shipping
' within Payment.asp. The amount is based on the quantity of items in the order.
' Create an ADO database connection
set dbShipping = server.createobject("adodb.connection")
' Create the record set
set rsShipping = server.CreateObject("adodb.recordset")
' Open the connection
dbShipping.ConnectionString = "Driver={SQL Server}; Server=cisdev.quinnipiac.edu;" & _
"Database=WildWillies;UID=cis; PWD=csatqu"
dbShipping.Open
' Declare the SQL statement
strSQL = "execute sp_GetShippingRate"
' Retrieve the record set
Set rsShipping = dbShipping.Execute(strSQL)
' Start out with a shipping rate of $0
Shipping = 0
' Loop through the quantity settings
Do Until rsShipping.EOF
' Check to see if the quantity is between the current low and high values
If rsBasket("quantity") >= rsShipping("intLowQuantity") And
_
rsBasket("quantity") <= rsShipping("intHighQuantity") Then
' If so set the shipping fee.
Shipping = rsShipping("intFee")
End If
' Move to the next row
rsShipping.MoveNext
Loop
else
' Redirect to the basket page since the quantity is 0
Response.Redirect("Basket.asp")
end if
' Store the shipping value in a session variable
session("Shipping") = Shipping
' Store the quantity in a session variable
session("Quantity") = rsBasket("quantity")
' This tax snippet will be used in Payment.asp
' Create an ADO database connection
set dbTax = server.createobject("adodb.connection")
' Create the record set
set rsTax = server.CreateObject("adodb.recordset")
' Open the DSN-less connection
dbTax.ConnectionString = "Driver={SQL Server}; Server=cisdev.quinnipiac.edu;" & _
"Database=WildWillies;UID=cis; PWD=csatqu"
dbTax.Open
' Creat the SQL statement and pass in the
' state to get the appropriate rate
strSQL = "execute sp_GetTaxRate '" & session("chrShipState") & "'"
' Get the record set.
Set rsTax = dbTax.Execute(strSQL)
' See if a rate was returned.
If rsTax.EOF = False Then
' Set the amount of tax.
Tax = (rsTax("fltTaxRate") * session("Subtotal"))
Else
' Return no tax.
Tax = 0
End If
session("Tax") = Tax
' Calculate the total and store in a session variable.
Total = SubTotal + Shipping + Tax
session("Total") = Total
%>
<HTML>
<!-- #include file="include/header.asp" -->
<BR>
<center>
<font size="5"><b>Billing Information</b></font>
</center>
<BR>
<b>Order Recap:</b>
<BR><BR>
<!-- Build a table to display the order total -->
<table>
<!-- Display the Subtotal -->
<tr>
<td align="right">Subtotal:</td>
<td><%=formatcurrency(Subtotal/100, 2)%></td>
</tr>
<!-- Display the Shipping Value -->
<tr>
<td align="right">Shipping:</td>
<td><%=formatcurrency(Shipping/100, 2)%></td>
</tr>
<!-- Display the Tax Value -->
<tr>
<td align="right">Tax:</td>
<td><%=formatcurrency(Tax/100, 2)%></td>
</tr>
<!-- Display the Total -->
<tr>
<td align="right"><B>Total:</b></td>
<td><b><%=formatcurrency(Total/100, 2)%></b></td>
</tr>
</table>
<!-- Enter in the credit card information -->
<BR>
<b>Enter your Credit Card information:</b>
<BR><BR>
<!-- The form will post the data to the validate payment page -->
<form method="post" action="ValidatePayment.asp" id=form1 name=form1>
<!-- Table to display the credit card data -->
<table>
<!-- Name on credit card -->
<tr>
<td align="right">Name on Card:</td>
<td><input type="text" value="<%=session("chrCCName")%>"
name="chrCCName" size="55"></td>
</tr>
<!-- Number on credit card -->
<tr>
<td align="right">Card Number:</td>
<td><input type="text" value="<%=session("chrCCNumber")%>"
name="chrCCNumber" size="55"></td>
</tr>
<!-- Type of credit card -->
<tr>
<td align="right">Card Type:</td>
<td>
<!-- Check to see which card was previously selected -->
<%
' Check to see which card was selected previously
' if there was an error.
if session("chrCCType") = "Visa" then
SelVisa = "Selected"
end if
if session("chrCCType") = "MasterCard" then
SelMasterCard = "Selected"
end if
if session("chrCCType") = "Amex" then
SelAmex = "Selected"
end if
%>
<!-- Select box with the selected card defaulted -->
<select name="chrCCType">
<option value="Visa" <%=SelVisa%>>Visa
<option value="MasterCard" <%=SelMasterCard%>>Master Card
<option value="Amex" <%=SelAmex%>>American Express
</select>
<%
' Check to see which month was selected previously
' if there was an error.
if session("chrCCExpMonth") = "1" then
SelJan = "Selected"
end if
if session("chrCCExpMonth") = "2" then
SelFeb = "Selected"
end if
if session("chrCCExpMonth") = "3" then
SelMar = "Selected"
end if
if session("chrCCExpMonth") = "4" then
SelApr = "Selected"
end if
if session("chrCCExpMonth") = "5" then
SelMay = "Selected"
end if
if session("chrCCExpMonth") = "6" then
SelJun = "Selected"
end if
if session("chrCCExpMonth") = "7" then
SelJul = "Selected"
end if
if session("chrCCExpMonth") = "8" then
SelAug = "Selected"
end if
if session("chrCCExpMonth") = "9" then
SelSep = "Selected"
end if
if session("chrCCExpMonth") = "10" then
SelOct = "Selected"
end if
if session("chrCCExpMonth") = "11" then
SelNov = "Selected"
end if
if session("chrCCExpMonth") = "12" then
SelDec = "Selected"
end if
%>
<!-- Select option box to allow the user to select a card expiration month -->
Month:
<select name="chrCCExpMonth">
<option value="1" <%=SelJan%>>January
<option value="2" <%=SelFeb%>>February
<option value="3" <%=SelMar%>>March
<option value="4" <%=SelApr%>>April
<option value="5" <%=SelMay%>>May
<option value="6" <%=SelJun%>>June
<option value="7" <%=SelJul%>>July
<option value="8" <%=SelAug%>>August
<option value="9" <%=SelSep%>>September
<option value="10" <%=SelOct%>>October
<option value="11" <%=SelNov%>>November
<option value="12" <%=SelDec%>>December
</select>
<%
' Check to see which year was selected previously if there was an error.
if session("chrCCExpYear") = "2004" then
Sel2004 = "Selected"
end if
if session("chrCCExpYear") = "2005" then
Sel2005 = "Selected"
end if
if session("chrCCExpYear") = "2006" then
Sel2006 = "Selected"
end if
if session("chrCCExpYear") = "2007" then
Sel2007 = "Selected"
end if
%>
<!-- Option box to select the card expiration year -->
Year:
<select name="chrCCExpYear">
<option value="2004" <%=Sel2004%>>2004
<option value="2005" <%=Sel2005%>>2005
<option value="2006" <%=Sel2006%>>2006
<option value="2007" <%=Sel2007%>>2007
</select>
</td>
</tr>
</table>
<%
' Check to see if there was an error.
if session("Error") <> "" then
%>
<!-- Diplay the error message -->
<BR>
<b>You have an error in your billing form,
please correct the data:</b><BR><BR>
<!-- Write out the error. -->
<table>
<tr>
<td width="70"> </td>
<td><i><%=Response.Write(session("Error"))%></i></td>
</tr>
</table>
<BR><BR>
<%
' Show the error.
session("Error") = ""
else
%>
<BR>
<b>Enter your billing address:</b>
<BR><BR>
<%
end if
%>
<center>
<!-- Table that will display the billing information -->
<table>
<!-- Billing first name -->
<tr>
<td align="right">First Name:</td>
<td><input type="text" value="<%=session("chrBillFirstName")%>"
name="chrBillFirstName" size="30"></td>
</tr>
<!-- Billing last name -->
<tr>
<td align="right">Last Name:</td>
<td><input type="text" value="<%=session("chrBillLastName")%>"
name="chrBillLastName" size="30"></td>
</tr>
<!-- Billing address -->
<tr>
<td align="right">Address:</td>
<td><input type="text" value="<%=session("chrBillAddress")%>"
name="chrBillAddress" size="30"></td>
</tr>
<!-- Billing city -->
<tr>
<td align="right">City:</td>
<td><input type="text" value="<%=session("chrBillCity")%>"
name="chrBillCity" size="30"></td>
</tr>
<!-- Billing state -->
<tr>
<td align="right">State:</td>
<td>
<%
' Check to see which state was selected previously
' if there was an error.
if session("chrBillState") = "AL" then
SelAL = "Selected"
end if
if session("chrBillState") = "AK" then
SelAK = "Selected"
end if
if session("chrBillState") = "AZ" then
SelAZ = "Selected"
end if
if session("chrBillState") = "AR" then
SelAR = "Selected"
end if
if session("chrBillState") = "CA" then
SelCA = "Selected"
end if
if session("chrBillState") = "CT" then
SelCT = "Selected"
end if
if session("chrBillState") = "CO" then
SelCO = "Selected"
end if
if session("chrBillState") = "DC" then
SelDC = "Selected"
end if
if session("chrBillState") = "DE" then
SelDE = "Selected"
end if
if session("chrBillState") = "FL" then
SelFL = "Selected"
end if
if session("chrBillState") = "GA" then
SelGA = "Selected"
end if
if session("chrBillState") = "HI" then
SelHI = "Selected"
end if
if session("chrBillState") = "ID" then
SelID = "Selected"
end if
if session("chrBillState") = "IL" then
SelIL = "Selected"
end if
if session("chrBillState") = "IN" then
SelIN = "Selected"
end if
if session("chrBillState") = "IA" then
SelIA = "Selected"
end if
if session("chrBillState") = "KS" then
SelKS = "Selected"
end if
if session("chrBillState") = "KY" then
SelKY = "Selected"
end if
if session("chrBillState") = "LA" then
SelLA = "Selected"
end if
if session("chrBillState") = "ME" then
SelME = "Selected"
end if
if session("chrBillState") = "MA" then
SelMA = "Selected"
end if
if session("chrBillState") = "MD" then
SelMD = "Selected"
end if
if session("chrBillState") = "MI" then
SelMI = "Selected"
end if
if session("chrBillState") = "MN" then
SelMN = "Selected"
end if
if session("chrBillState") = "MS" then
SelMS = "Selected"
end if
if session("chrBillState") = "MO" then
SelMO = "Selected"
end if
if session("chrBillState") = "MT" then
SelMT = "Selected"
end if
if session("chrBillState") = "NE" then
SelNE = "Selected"
end if
if session("chrBillState") = "NV" then
SelNV = "Selected"
end if
if session("chrBillState") = "NH" then
SelNH = "Selected"
end if
if session("chrBillState") = "NJ" then
SelNJ = "Selected"
end if
if session("chrBillState") = "NM" then
SelNM = "Selected"
end if
if session("chrBillState") = "NY" then
SelNY = "Selected"
end if
if session("chrBillState") = "NC" then
SelNC = "Selected"
end if
if session("chrBillState") = "ND" then
SelND = "Selected"
end if
if session("chrBillState") = "OH" then
SelOH = "Selected"
end if
if session("chrBillState") = "OK" then
SelOK = "Selected"
end if
if session("chrBillState") = "OR" then
SelOR = "Selected"
end if
if session("chrBillState") = "PA" then
SelPA = "Selected"
end if
if session("chrBillState") = "RI" then
SelRI = "Selected"
end if
if session("chrBillState") = "SC" then
SelSC = "Selected"
end if
if session("chrBillState") = "SD" then
SelSD = "Selected"
end if
if session("chrBillState") = "TN" then
SelTN = "Selected"
end if
if session("chrBillState") = "TX" then
SelTX = "Selected"
end if
if session("chrBillState") = "UT" then
SelUT = "Selected"
end if
if session("chrBillState") = "VT" then
SelVT = "Selected"
end if
if session("chrBillState") = "VA" then
SelVA = "Selected"
end if
if session("chrBillState") = "WY" then
SelWY = "Selected"
end if
if session("chrBillState") = "WI" then
SelWI = "Selected"
end if
if session("chrBillState") = "WV" then
SelWV = "Selected"
end if
if session("chrBillState") = "WA" then
SelWA = "Selected"
end if
%>
<!-- Option box to select the billing state -->
<select name="chrBillState">
<option value="">Select a State
<option value="AL" <%=SelAL%>>Alabama
<option value="AK" <%=SelAK%>>Alaska
<option value="AZ" <%=SelAZ%>>Arizona
<option value="AR" <%=SelAR%>>Arkansas
<option value="CA" <%=SelCA%>>California
<option value="CT" <%=SelCT%>>Connecticut
<option value="CO" <%=SelCO%>>Colorado
<option value="DC" <%=SelDC%>>D.C.
<option value="DE" <%=SelDE%>>Delaware
<option value="FL" <%=SelFL%>>Florida
<option value="GA" <%=SelGA%>>eorgia
<option value="HI" <%=SelHI%>>Hawaii
<option value="ID" <%=SelID%>>Idaho
<option value="IL" <%=SelIL%>>Illinois
<option value="IN" <%=SelIN%>>Indiana
<option value="IA" <%=SelIA%>>Iowa
<option value="KS" <%=SelKS%>>Kansas
<option value="KY" <%=SelKY%>>Kentucky
<option value="LA" <%=SelLA%>>Louisiana
<option value="ME" <%=SelME%>>Maine
<option value="MA" <%=SelMA%>>Massachusetts
<option value="MD" <%=SelMD%>>Maryland
<option value="MI" <%=SelMI%>>Michigan
<option value="MN" <%=SelMN%>>Minnesota
<option value="MS" <%=SelMS%>>Mississippi
<option value="MO" <%=SelMO%>>Missouri
<option value="MT" <%=SelMT%>>Montana
<option value="NE" <%=SelNE%>>Nebraska
<option value="NV" <%=SelNV%>>Nevada
<option value="NH" <%=SelNH%>>New Hampshire
<option value="NJ" <%=SelNJ%>>New Jersey
<option value="NM" <%=SelNM%>>New Mexico
<option value="NY" <%=SelNY%>>New York
<option value="NC" <%=SelNC%>>North Carolina
<option value="ND" <%=SelND%>>North Dakota
<option value="OH" <%=SelOH%>>Ohio
<option value="OK" <%=SelOK%>>Oklahoma
<option value="OR" <%=SelOR%>>Oregon
<option value="PA" <%=SelPA%>>Pennsylvania
<option value="RI" <%=SelRI%>>Rhode Island
<option value="SC" <%=SelSC%>>South Carolina
<option value="SD" <%=SelSD%>>South Dakota
<option value="TN" <%=SelTN%>>Tennessee
<option value="TX" <%=SelTX%>>Texas
<option value="UT" <%=SelUT%>>Utah
<option value="VT" <%=SelVT%>>Vermont
<option value="VA" <%=SelVA%>>Virginia
<option value="WA" <%=SelWA%>>Washington
<option value="WY" <%=SelWY%>>Wyoming
<option value="WI" <%=SelWI%>>Wisconsin
<option value="WV" <%=SelWV%>>West Virginia
</select>
<!-- Or allow the user to select a billing province -->
or Province:<input type="text" value="<%=session("chrBillProvince")%>"
name="chrBillProvince" size="15">
</td>
</tr>
<!-- Country selection -->
<tr>
<td align="right">Country:</td>
<td>
<%
' Check to see which country was selected previously
' if there was an error.
if session("chrBillCountry") = "US" then
SelUS = "Selected"
end if
if session("chrBillCountry") = "CA" then
SelCA = "Selected"
end if
if session("chrBillCountry") = "MX" then
SelMX = "Selected"
end if
%>
<!-- Option box for the billing country -->
<select name="chrBillCountry">
<option value="">Select a Country
<option value="US" <%=SelUS%>>United States
<option value="CA" <%=SelCA%>>Canada
<option value="MX" <%=SelMX%>>Mexico
</select>
</td>
</tr>
<!-- Billing postal code -->
<tr>
<td align="right">Zip/Postal Code:</td>
<td><input type="text" value="<%=session("chrBillZipCode")%>"
name="chrBillZipCode" size="30"></td>
</tr>
<!-- Billing phone number -->
<tr>
<td align="right">Phone:</td>
<td><input type="text" value="<%=session("chrBillPhone")%>"
name="chrBillPhone" size="30"></td>
</tr>
<!-- Billing email address -->
<tr>
<td align="right">Email:</td>
<td><input type="text" value="<%=session("chrBillEmail")%>"
name="chrBillEmail" size="30"></td>
</tr>
<!-- Cookie option to save the profile -->
<tr>
<td align="right">Save Profile Cookie?</td>
<td>
<%
' Check to see if a previous setting was selected.
if session("intCookie") = 1 then
YesChecked = "CHECKED"
else
NoChecked = "CHECKED"
end if
%>
<!-- Radio boxes to select the cookie setting -->
<input type="radio" value="1" name="intCookie"
<%=YesChecked%>> Yes
<input type="radio" value="0" name="intCookie"
<%=NoChecked%>> No
</td>
</tr>
<!-- Password field -->
<tr>
<td align="right">Password for Shopper Profile:</td>
<td><input type="password" value="<%=session("chrPassword")%>"
name="chrPassword" size="10"></td>
</tr>
<!-- Submit button -->
<tr>
<td colspan="2" align="center">
<input type="Submit" value="Submit" name="Submit">
</td>
</tr>
</table>
</form>
</center>
<!-- #include file="include/footer.asp" -->
</BODY>
</HTML>
|