<%
strCount=0
'amount to add for a surcharge of shipping and handling
strChosen=1
'add an arbitrary date I use mySQL here so I needed to put it into mySQL format
strUKDate=DateAdd("d",1,Date())
MYdd = DatePart("d", strUKDate)
MYmm = DatePart("m", strUKDate)
MYyy = DatePart("yyyy", strUKDate)
strUKDate = (MYyy & "-" & MYmm & "-" & MYdd)
'construct request for Express rates
strXML="<?xml version='1.0' encoding='UTF-8' ?>"
strXML=strXML & "<FDXRateAvailableServicesRequest xmlns:api='http://www.fedex.com/fsmapi' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='FDXRateAvailableServicesRequest.xsd'>"
strXML=strXML & "<RequestHeader>"
strXML=strXML & "<AccountNumber>999999999</AccountNumber>"
strXML=strXML & "<MeterNumber>9999999</MeterNumber>"
strXML=strXML & "<CarrierCode>FDXE</CarrierCode>"
strXML=strXML & "</RequestHeader>"
strXML=strXML & "<ShipDate>" & strUKDate & "</ShipDate>"
strXML=strXML & "<DropoffType>REGULARPICKUP</DropoffType>"
strXML=strXML & "<Packaging>YOURPACKAGING</Packaging>"
strXML=strXML & "<WeightUnits>LBS</WeightUnits>"
strXML=strXML & "<Weight>" & formatnumber(orderWeight,1) & "</Weight>"
strXML=strXML & "<ListRate>false</ListRate>"
strXML=strXML & "<OriginAddress>"
strXML=strXML & "<StateOrProvinceCode>" & strCompanyState & "</StateOrProvinceCode>"
strXML=strXML & "<PostalCode>" & strCompanyPostCode & "</PostalCode>"
strXML=strXML & "<CountryCode>US</CountryCode>"
strXML=strXML & "</OriginAddress>"
strXML=strXML & "<DestinationAddress>"
strXML=strXML & "<StateOrProvinceCode>" & BDQuotes(request("txtShipState")) & "</StateOrProvinceCode>"
strXML=strXML & "<PostalCode>" & BDQuotes(request("txtShipPostCode")) & "</PostalCode>"
strXML=strXML & "<CountryCode>US</CountryCode>"
strXML=strXML & "</DestinationAddress>"
strXML=strXML & "<Payment>"
strXML=strXML & "<PayorType>SENDER</PayorType>"
strXML=strXML & "</Payment>"
strXML=strXML & "<PackageCount>1</PackageCount>"
strXML=strXML & "</FDXRateAvailableServicesRequest>"
'send it
Set strXMLhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
strXMLhttp.Open "POST","https://gatewaybeta.fedex.com:443/GatewayDC",false
strXMLhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
strXMLhttp.send strXML
strXMLResponse=strXMLhttp.responseText
intHTTPStatusCode = strXMLhttp.status
strHTTPStatusText = strXMLhttp.statusText
Set mydoc=Server.CreateObject("Microsoft.xmlDOM")
mydoc.loadxml(strXMLResponse)
IF mydoc.documentElement.nodeName = "Error" then 'top level error
session("svFEDEXSelect")="##"
ELSE
Set NodeList = mydoc.documentElement.selectNodes("Entry")
For strCount = 0 To NodeList.length - 1
Select case NodeList.Item(strCount).selectSingleNode("Service").Text
case "FEDEXEXPRESSSAVER"
Session("svFEDEX1")="FedEx Express Saver (3 day)"
Session("svFEDEXCost1")=(cdbl(NodeList.Item(strCount).selectSingleNode("EstimatedCharges/DiscountedCharges/NetCharge").Text)+cdbl(strChosen))
Session("svFEDEXOrder1")=1
strCount2=strCount2+1
CASE "FEDEX2DAY"
Session("svFEDEX2")="FedEx 2 Day"
Session("svFEDEXCost2")=(cdbl(NodeList.Item(strCount).selectSingleNode("EstimatedCharges/DiscountedCharges/NetCharge").Text)+cdbl(strChosen))
Session("svFEDEXOrder2")=1
strCount2=strCount2+1
CASE "STANDARDOVERNIGHT"
Session("svFEDEX3")="FedEx Standard Overnight"
Session("svFEDEXCost3")=(cdbl(NodeList.Item(strCount).selectSingleNode("EstimatedCharges/DiscountedCharges/NetCharge").Text)+cdbl(strChosen))
Session("svFEDEXOrder3")=1
strCount2=strCount2+1
END SELECT
NEXT
'construct for ground rates
strXML="<?xml version='1.0' encoding='UTF-8' ?>"
strXML=strXML & "<FDXRateAvailableServicesRequest xmlns:api='http://www.fedex.com/fsmapi' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='FDXRateAvailableServicesRequest.xsd'>"
strXML=strXML & "<RequestHeader>"
strXML=strXML & "<AccountNumber>999999999</AccountNumber>"
strXML=strXML & "<MeterNumber>9999999</MeterNumber>"
strXML=strXML & "<CarrierCode>FDXG</CarrierCode>"
strXML=strXML & "</RequestHeader>"
strXML=strXML & "<ShipDate>" & strUKDate & "</ShipDate>"
strXML=strXML & "<DropoffType>REGULARPICKUP</DropoffType>"
strXML=strXML & "<Packaging>YOURPACKAGING</Packaging>"
strXML=strXML & "<WeightUnits>LBS</WeightUnits>"
strXML=strXML & "<Weight>" & formatnumber(orderWeight,1) & "</Weight>"
strXML=strXML & "<ListRate>false</ListRate>"
strXML=strXML & "<OriginAddress>"
strXML=strXML & "<StateOrProvinceCode>" & strCompanyState & "</StateOrProvinceCode>"
strXML=strXML & "<PostalCode>" & strCompanyPostCode & "</PostalCode>"
strXML=strXML & "<CountryCode>US</CountryCode>"
strXML=strXML & "</OriginAddress>"
strXML=strXML & "<DestinationAddress>"
strXML=strXML & "<StateOrProvinceCode>" & BDQuotes(request("txtShipState")) & "</StateOrProvinceCode>"
strXML=strXML & "<PostalCode>" & BDQuotes(request("txtShipPostCode")) & "</PostalCode>"
strXML=strXML & "<CountryCode>US</CountryCode>"
strXML=strXML & "</DestinationAddress>"
strXML=strXML & "<Payment>"
strXML=strXML & "<PayorType>SENDER</PayorType>"
strXML=strXML & "</Payment>"
strXML=strXML & "<PackageCount>1</PackageCount>"
strXML=strXML & "</FDXRateAvailableServicesRequest>"
'send it
Set strXMLhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
strXMLhttp.Open "POST","https://gatewaybeta.fedex.com:443/GatewayDC",false
strXMLhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
strXMLhttp.send strXML
strXMLResponse=strXMLhttp.responseText
intHTTPStatusCode = strXMLhttp.status
strHTTPStatusText = strXMLhttp.statusText
Set mydoc=Server.CreateObject("Microsoft.xmlDOM")
mydoc.loadxml(strXMLResponse)
IF mydoc.documentElement.nodeName = "Error" then 'top level error
session("svFEDEXSelect")="##"
ELSE
Set NodeList = mydoc.documentElement.selectNodes("Entry")
For strCount = 0 To NodeList.length - 1
Select case NodeList.Item(strCount).selectSingleNode("Service").Text
case "FEDEXGROUND"
Session("svFEDEX0")="FedEx Ground"
Session("svFEDEXCost0")=(cdbl(NodeList.Item(strCount).selectSingleNode("EstimatedCharges/DiscountedCharges/NetCharge").Text)+cdbl(strChosen))
Session("svFEDEXOrder0")=1
strCount2=strCount2+1
END SELECT
NEXT
session("svFEDEXCount")=clng(strCount2)
IF clng(session("svFEDEXCount"))>0 THEN
session("svFEDEXSelect")=""
ELSE
Session("svFEDEXSelect")="##"
END IF
For strCount=0 to (clng(session("svFEDEXCount"))-1)
IF BDQuotes(request("txtShipping"))= Session("svFEDEX"&strCount) THEN
session("svFEDEXSelect")=session("svFEDEXSelect") & "<option value=""" & Session("svFEDEX"&strCount) & """ selected>"
session("svFEDEXSelect")=session("svFEDEXSelect") & Session("svFEDEX"&strCount) & " - " & formatcurrency((Session("svFEDEXCost"&strCount)),2)
session("svFEDEXSelect")=session("svFEDEXSelect") & "</option>" & vbcrlf
Session("svShippingCost")=session("svFEDEXCost"&strCount)
ELSE
session("svFEDEXSelect")=session("svFEDEXSelect") & "<option value=""" & Session("svFEDEX"&strCount) & """>"
session("svFEDEXSelect")=session("svFEDEXSelect") & Session("svFEDEX"&strCount) & " - " & formatcurrency((Session("svFEDEXCost"&strCount)),2)
session("svFEDEXSelect")=session("svFEDEXSelect") & "</option>" & vbcrlf
END IF
Session.Contents.Remove "svFEDEX"&strCount
Session.Contents.Remove "svFEDEXCost"&strCount
Session.Contents.Remove "svFEDEXOrder"&strCount
Next
END IF
END IF
session.Contents.Remove "svFEDEXCount"
strCount=0
strCount2=0
response.write session("svFEDEXSelect")
%>
<%
BDConn.close()
set BDConn=nothing
Function BDQuotes(strQuotes)
strQuoteOutput=replace(strQuotes,chr(34), "''")
strQuoteOutput=replace(strQuoteOutput,"'","''")
BDQuotes=strQuoteOutput
END FUNCTION
%>