<% function SendMail(conf) Dim Mail dim conn, rs, rs2, rs3 set conn = Server.Createobject("adodb.connection") set rs = server.createobject("adodb.recordset") set rs2 = server.createobject("adodb.recordset") set rs3 = server.createobject("adodb.recordset") conn.open connstr rs.open "select * from orders where id = "&session("orderid"),conn,3,1 if rs.eof then exit function end if email=rs("email")&"" shippingname = rs("shippingname")&"" shippingaddress1 = rs("shippingaddress1")&"" shippingaddress2 = rs("shippingaddress2")&"" shippingcity = rs("shippingcity")&"" shippingstate = rs("shippingstate")&"" shippingzip = rs("shippingzip")&"" shippingcountry = rs("shippingcountry")&"" billingname = rs("billingname")&"" billingaddress1 = rs("billingaddress1")&"" billingaddress2 = rs("billingaddress2")&"" billingcity = rs("billingcity")&"" billingstate = rs("billingstate")&"" billingzip = rs("billingzip")&"" billingcountry = rs("billingcountry")&"" shippingmethod = rs("shippingmethod")&"" shipping = rs("shipping")&"" subtotalprice = rs("subtotalprice")&"" tax = rs("tax")&"" ordertotal = rs("ordertotal")&"" instructions = rs("instructions")&"" if shippingmethod=2 then method= "UPS" else method = "USPS" end if rs.close rs2.open "select count(*) from orderdetail where orderid = " & orderid, conn,3,3 count = rs2(0) rs2.close redim code(count), desc(count), qtys(count),prices(count),totalprice(count) totwt=0 totprice=0 i=0 numitems=0 rs2.open "select * from orderdetail where orderid = " & orderid, conn, 3,3 do while not rs2.eof rs3.open "select * from products where id = " & rs2("productid"),conn,3,1 if not rs3.eof then qty = rs2("qty") unitprice = rs2("unitprice") totalprice1 = rs2("totalprice") code(i)=rs3("code") desc(i)=rs3("name") if rs2("altcode") &"" <> "" then code(i)=rs2("altcode")&"" desc(i)= desc(i) & " - " &rs2("option") end if prices(i)=unitprice qtys(i)=qty totalprice(i)=totalprice1 i=i+1 end if rs3.close rs2.movenext loop rs2.close conn.close Set Mail = Server.CreateObject("Persits.MailSender") Mail.Host = "mail.luckysupply.com" Mail.Port = 25 ' Optional. Port is 25 by default Mail.From = "webmaster@luckysupply.com" 'Mail.AddAddress "juan@webfoot.net" Mail.AddAddress email Mail.Subject = "Your Lucky Supply Order - ID " & session("orderID") s = "Order ID: " & session("orderID") & chr(13) & chr(10) s = s & "Thank you for your order with LuckySupply.Com"&chr(13)&chr(10)&chr(13)&chr(10) s = s & "Your order will be shipped by "& method &" to: "&chr(13)&chr(10) s = s & shippingname &chr(13)&chr(10) s = s & shippingaddress1 &chr(13)&chr(10) if shippingaddress2 <>"" then s = s & shippingaddress2 &chr(13)&chr(10) end if s = s & shippingcity & ", " & shippingstate &" " & shippingzip &chr(13)&chr(10) s = s & shippingcountry &chr(13)&chr(10) s = s & chr(13)&chr(10)&chr(13)&chr(10) s = s & "Your order will be billed to: "&chr(13)&chr(10) s = s & billingname &chr(13)&chr(10) s = s & billingaddress1 &chr(13)&chr(10) if billingaddress2 <>"" then s = s & billingaddress2 &chr(13)&chr(10) end if s = s & billingcity & ", " & billingstate &" " & billingzip &chr(13)&chr(10) s = s & shippingcountry &chr(13)&chr(10) s = s & chr(13)&chr(10)&chr(13)&chr(10) if instructions <> "" then s = s & "Your special instructions: "&chr(13)&chr(10) s = s & instructions & chr(13) & chr(10) end if s = s & chr(13)&chr(10)& "Confirmation number: "& conf &chr(13)&chr(10) s = s & chr(13)&chr(10)&chr(13)&chr(10) s = s & "Your ordered items are: "&chr(13)&chr(10) for i = 0 to count -1 s = s &" " & code(i) &" - " & desc(i) &chr(13)&chr(10) s = s &" " & qtys(i) & " at " & formatcurrency(prices(i)) & " each" if qtys(i) > 1 then s = s & " ===> " & formatcurrency(totalprice(i)) end if s = s & chr(13) & chr(10) next s = s & chr(13)&chr(10)&chr(13)&chr(10) s = s & "Subtotal: "&formatcurrency(subtotalprice) & chr(13)&chr(10) if isnumeric(tax &"") then s = s & "Tax: "&formatcurrency(tax) & chr(13)&chr(10) end if s = s & "Shipping: "&formatcurrency(shipping) & chr(13)&chr(10) s = s & "Total: "&formatcurrency(ordertotal) & chr(13)&chr(10) s = s & chr(13)&chr(10)&chr(13)&chr(10) s = s & chr(13)&chr(10)&chr(13)&chr(10) s = s & "If you have any questions, please contact us at "& chr(13)&chr(10) s = s & "webmaster@luckysupply.com"&chr(13)&chr(10) s = s & chr(13)&chr(10)&chr(13)&chr(10) On Error Resume Next Mail.Body = s Mail.Send If Err <> 0 Then SendMail= False else SendMail = True End If set Mail = nothing end function Function ChargeCard(ccnum, exp1, exp2, amount, comment,respmsg,email,comment2,pnref) fdebug=0 ExpireMe = ""&Exp1&""&Exp2&"" Exp3 = "'"&Exp1&chr(47)&Exp2&"'" merchantPW="morris123" serverpfp="test-payflow.verisign.com" 'serverpfp="connect.signio.com" merchantId="luckysupply" Vendor = "luckysupply" Partner = "webfoot" if fdebug <> 1 then 'Create the Signio COM Client Set client = Server.CreateObject("PFProCOMControl.PFProCOMControl.1") 'set the host address client.HostAddress = serverpfp 'set the host port client.HostPort = 443 'set the timeout value client.TimeOut = 30 'turn on debug mode... see COM Client docs for more information client.DebugMode = 1 'build the parameter list, such that we have a sale transaction and 'a credit card tender. parmList = "TRXTYPE=S&TENDER=C" parmList = parmList + "&ACCT=" & ccnum 'set the account form the html form parmList = parmList + "&PWD=" & merchantPW 'set the password from the html form parmList = parmList + "&USER=" & merchantId 'set the userid from the HTML form parmList = parmList + "&PARTNER=" & Partner 'set the Partner parmList = parmList + "&VENDOR=" & Vendor 'set the Vendor parmList = parmList + "&EXPDATE=" & ExpireMe 'set the expiration date form the HTML form parmList = parmList + "&AMT=" & amount 'set the amount from the HTML form parmList = parmList + "&COMMENT1=" & comment 'set the OrderID from the HTML form parmList = parmList + "&COMMENT2=" & comment2 'set the OrderID from the HTML form parmList = parmList + "&EMAIL=" & email Ctx1 = client.CreateContext(serverpfp, 443, 30, "", 0, "", "") curString = client.SubmitTransaction(Ctx1, parmList, Len(parmList)) client.DestroyContext (Ctx1) else curString = "RESULT=0&PNREF=aa&RESPMSG=aa&AUTHCODE=aa" end if ' handle the response 'loop until we're done processing the entire string done = 0 Do while Len(curString) <> 0 'get the next name value pair if InStr(curString,"&") Then varString = Left(curString, InStr(curString , "&" ) -1) else varString = curString end if 'get the name part of the name/value pair name = Left(varString, InStr(varString, "=" ) -1) 'get the value out of the name/value pair value = Right(varString, Len(varString) - (Len(name)+1)) If name = "RESULT" then If value = "0" then myvalue2 = "1" Else myvalue2 = "0" End If Result = myvalue2 Result2 = value End If If name = "PNREF" then Pnref = value End If If name = "RESPMSG" then Respmsg = value End If If name = "Authcode" then Authcode = value End If 'skip over the & if Len(curString) <> Len(varString) Then curString = Right(curString, Len(curString) - (Len(varString)+1)) else curString = "" end if Loop If Result2 = "0" then If Authcode = "" then Authcode = "x" End If desc="OK" End If If Result = "1" then ChargeCard = true else ChargeCard = false end if End Function dim conn, rs set conn = Server.Createobject("adodb.connection") set rs = server.createobject("adodb.recordset") conn.open connstr if session("orderid") = "" then orderid="0" else orderid = session("orderid") end if if orderid = "0" then session("errmsg")="Your shopping cart is empty" response.redirect "http://www.spiritfitness.com/shop/form.asp" else rs.open "select * from orders where id = " & orderid, conn,3,3 if rs.eof then rs.close conn.close session("errmsg")="Order has not been created, can't update, please try again" response.redirect "http://www.spiritfitness.com/shop/abandon.asp" end if if rs("approved") then rs.close conn.close session("errmsg")="Order has been completed and paid for, can't update" response.redirect "http://www.spiritfitness.com/shop/abandon.asp" end if end if if request("ccnum")="" then amount = rs("ordertotal") rs("cardtype")=request("cardtype") rs("ccnum")=request("ccnum") rs("expmonth")=request("expmonth") rs("expyear")=request("expyear") rs("instructions")=request("instructions") rs.update rs.close conn.close session("errmsg")= "Credit card number is required" response.redirect "cc.asp" end if if request("expmonth")="" or request("expyear")="" then amount = rs("ordertotal") rs("cardtype")=request("cardtype") rs("ccnum")=request("ccnum") rs("expmonth")=request("expmonth") rs("expyear")=request("expyear") rs("instructions")=request("instructions") rs.update rs.close conn.close session("errmsg")= "Expiration date is required" response.redirect "cc.asp" end if email = rs("email") amount = int(rs("ordertotal")*100)/100 rs("cardtype")=request("cardtype") rs("ccnum")=request("ccnum") rs("expmonth")=request("expmonth") rs("expyear")=request("expyear") rs("instructions")=request("instructions") 'process credit card and choose value for approved comment="Online Order " &orderID comment2="" pnref="" respmsg="" approved = ChargeCard(request("ccnum"),request("expmonth"),request("expyear"), amount, comment,respmsg,email,comment2,pnref) 'approved = chargecard(request("ccnum"),request("expmonth"),request("expyear"),amount) rs("approved") = approved rs.update rs.close conn.close if approved then SendMail pnref response.redirect "confirmation.asp?f=0" else response.redirect "confirmation.asp?f=1&msg=" & server.urlencode(respmsg) end if %>