<%@ LANGUAGE = VBScript %> <% '============================================================================== 'Copy this code to the place where you receive customer orders '============================================================================== dim strURL dim nID dim sLogEmail dim sLogPassword dim sCustEmail dim sCustName dim sCustAddress dim sCustCity dim sCustState dim sCustZip dim sCustCountry dim sSpecialText dim sInvoice dim nPrice dim sCo dim nQuantity dim sMode dim sTypeShipping dim bUsePriceOnCustomsForm '==================================================== 'This is where you will have your customer information handy as a database record or 'from input variables to this page. ' 'For example purposes, we have hard coded values. We assume you will be getting these 'values from your customer database or some other resource ' '==================================================== nID = request("id") 'an example of how to get it off the url. '==================================== 'ProductID '==================================== 'The specific ID of your project (login and look at the item# listed next to the title on each of your projects) 'You may also order multiple products on a single customer order. for example, if a customer ordered 3 of your products 'with this order, string the TrepStar project id together separated by an x. For example: 'nID = "40030x40050x40010". This will order "Quantity" of EACH product and we will place them in the same package. 'See Quantity section Below. '==================================== if nid = "" then nID = "40030" '<--- This should be the ID of your project! Login to your account, and see the list of projects that show the id# end if '==================================== 'Quantity '==================================== 'Quantity Values are 1 to 100. 'If you need more than 100, order twice with a different invoice value on the 2nd order 'You can group quantities together if you have a multiple project order 'for example, if a customer ordered 3 of your products, in quantities 1, 3, and 5 respectively, 'The values of productID would be (for example): 'productID=40030x40040x40050 'To signify the user wanted quantity 1 of the first product, quantity 3 of the 2nd, and quantity 5 of the 3rd, the quantity value would be: 'quantity=1x3x5 'See ProductID section above. '==================================== nQuantity = "1" sLogEmail = "yourLoginEmail@yourDomain.com" 'Email you used when signing up for a TrepStar.com account sLogPassword = "yourLoginPassword" 'password you created when signing up for a TrepStar.com account sCustEmail = "yourcustomer@gmail.com" 'customer email where email receipt and tracking info sent sCustName = "Jon Smith" 'customer full name e.g. John M. Smith esq. or Kelly Johnson. sCustAddress = "123 street, suite#2" 'place entire street and all line1 and/or line2 info on this single field. sCustCity = "Apple Valley" ' city /province sCustState = "MN" sCustZip = "55124" 'zip or postal code sCustCountry = "US" 'If you leave blank, we assume USA. Our system is pretty good at recognizing common variations on country names. Try to use two letter Codes if possible. US,CA,UK,AU etc. sSpecialText = "Put customer specific instructions here. e.g. Your registration unlock code is 2234-234-234-aaab '==================================== 'Invoice '==================================== 'Create a unique alpha numeric invoice for this customer (use a time stamp or create some kind of guid at order time) 'Invoice is very important! You can leave this blank, but then we use the customer email as the unique id. We do not allow multiple orders 'from the same invoice or email (if invoice is missing). If you leave off a unique invoice#, the same customer can not order from you again 'because we will reject it based on their email. The reason is so we avoid companies accidentally sending us a lot of duplicate orders! '==================================== sInvoice = "123ABC" '==================================== 'nPrice '==================================== 'This price is printed on the invoice/receipt the customer receives. If you have the option set on (on by default), we send the customer 'an email saying they are receiving a package from you, and that they've 'already paid $nPrice ...' for the product. 'The value is any dollar amount you choose. 0 (zero) is ok as well. 'If this field is blank, we assume 0 '==================================== nPrice = "12.95" '0 is accepted or blank. '=================================== 'bUsePriceOnCustomsForm '=================================== 'Optional: Leave this field out or set to 0 (zero) (the default setting). 'Values are 0 or 1 'This field has meaning for International orders only: Some countries charge VAT tax (value added tax) 'to your customer based on the value of the goods sent. If your 'nPrice' (field above) is a large amount, 'the customer MAY have to pay extra taxes and the package may be held up in customs. By default, we print the value of 'the package at $6.00 (roughly the replacement cost for fulfillment). Setting this value to 0, or leaving it out entirely 'has the same effect. We print customs forms required for all INTL orders. If you require the 'nPrice' to be printed on the 'customs form, set this value to 1 instead of 0. On other words, if this field is set to 1, we print the 'nPrice' value (above) 'on the customs form, otherwise we print $6.00. '=================================== bUsePriceOnCustomsForm = "0" sCo = "CustomerCompany Name" 'can be blank '==================================== 'typeMailMethod '==================================== 'Values are Standard, rtrackstandard, priority or express. If you leave this blank, we assume standard 'Values are not case sensitive. ' 'USA Addresses: ' ' * Standard: Standard First Class via U.S. Post office - No tracking (3-5 days average, 2 weeks max). ' * rTrackStandard: Standard First Class with Delivery Confirmation (only for USA destinations) (Extra $0.29) - Includes Customer Tracking Email ' confirming package delivered (3-5 days average, 2 weeks max). ' * priority: Priority Mail USPS - Email to customer with tracking for delivery confirmation (2 to 4 day maximum). ' * express: Express Mail USPS - Email to customer with FULL tracking (similar to UPS or Fedex) (1 to 2 days maximum). ' 'International Addresses: ' ' * standard: Standard INTL - No tracking (6 days to 4 weeks maximum) ' * rTrackStandard: NOT VALID for INTL addresses: Standard with Delivery Confirmation is only available for USA destinations ' * priority: Priority INTL - Email to customer with tracking for delivery confirmation (6 to 10 days maximum) ' * express: Express INTL - Email to customer with FULL tracking (similar to UPS or Fedex) (3 to 5 days maximum) ' '==================================== sTypeShipping = "Standard" '=================================== 'sMode '=================================== 'Values are test or prod 'prod means we actually make and ship the package and you will be charged. 'test means a purchase record will be created so you can test this integration, but nothing will be made or sent ever. You will not be charged for testing. '=================================== sMode = "test" 'values are test or prod. '=========================================================== 'Form the URL that will be called from your server or software to request 'the order from our server 'IT'S THESE URL VARIABLE NAMES THAT ARE IMPORTANT. YOU SET THE VALUES ABOVE, 'BUT WE EXPECT THE VARIABLES TO BE NAMED THIS WAY (IN ANY ORDER) 'i.e. some of our expected variable names are: productid, ordermethod, quantity... 'The variable names are NOT CaSe SeNsItIvE. For example, you may use 'productID or PRODUCTid. Any combination of upper and lower case letters will be accepted. '=========================================================== strURL = "https://www.trepstar.com/custdata.asp" strURL = strURL & "?productID=" & nID strURL = strURL & "&ordermethod=url" strURL = strURL & "&quantity=" & nQuantity strURL = strURL & "&CoLoginEmail=" & server.urlencode(sLogEmail) strURL = strURL & "&CoLoginPassword=" & server.urlencode(sLogPassword) strURL = strURL & "&source=cdfulfill" strURL = strURL & "&mode=" & sMode strURL = strURL & "&email=" & server.urlencode(sCustEmail) strURL = strURL & "&name=" & server.urlencode(sCustName) strURL = strURL & "&nprice=" & nPrice strURL = strURL & "&bUsePriceOnCustomsForm=" & bUsePriceOnCustomsForm strURL = strURL & "&co=" & server.urlencode(sCo) strURL = strURL & "&addr=" & server.urlencode(sCustAddress) strURL = strURL & "&city=" & server.URLEncode(sCustCity) strURL = strURL & "&st=" & server.urlencode (sCustState) strURL = strURL & "&zip=" & sCustZip strURL = strURL & "&typeMailMethod=" & sTypeShipping strURL = strURL & "&country=" & server.URLEncode (sCustCountry) strURL = strURL & "&specialtext=" & server.URLEncode (sSpecialText) strURL = strURL & "&invoice=" & server.urlencode(sInvoice) dim sResponse, nErr, strOutErr '======================================== 'This is the actual call to the server '======================================== sResponse = getURLResponse(strURL,nErr,strOutErr) Response.Write "

To test, Append ?id=xxxx to the URL to change the project ID; where xxxx is your product id

" if instr(1, sResponse,"[SUCCESS]") > 0 then 'the order went through ok Response.Write "Success: The following was returned from the server:" else 'the order did not go through. 'THIS MAY BE A SIGN OF A DUPLICATE ORDER WHICH IS A NORMAL CASE THAT WE CONSIDER A FAILURE Response.Write "Failure: The following was returned from the server:" end if Response.Write "
" Response.Write sResponse %> <% function getURLResponse(URL,nErr,strOutErr) dim xmlhttp set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP") on error resume next err.Clear nErr = 0 '************************ 'See if the target url exist '************************ call xmlhttp.setTimeouts( 3000,3000,3000,3000) '<<--- these are wait times. Increase this value if you like (5000 = 5 seconds) xmlhttp.open "GET", URL, false ' <<--- false is important. This makes the call wait for the open to complete instead of running async 'send GET request xmlhttp.send if err.number <> 0 then 'errors from component if instr(1,err.Description,"A connection with the server could not be established") > 0 then 'timeout so this could be good because it's possible the server was just down but slow getURLResponse = "" strOutErr = err.number & ": A connection to the server could not be established." elseif instr(1,err.Description, "The server name or address could not be resolved") > 0 then 'bad host name/ip etc. just bad getURLResponse = "" strOutErr = err.number & ":Bad host name or ip address" else getURLResponse = "" strOutErr = err.number & ": " & err.description end if nErr = err.number else 'no errors from component if lcase(xmlhttp.statusText) = "ok" then 'ok getURLResponse = xmlhttp.responseText 'response.Write "OK, file existed" strOutErr = "" nErr = 0 else 'no errors, but something went wrong, like a 404 etc. strOutErr = "File Not found: " & xmlhttp.statusText nErr = 20152 getURLResponse = "" end if end if end function %>