Need Help Understanding ASP Code

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2009
Posts: 34
Reputation: neoseeker191 is an unknown quantity at this point 
Solved Threads: 0
neoseeker191 neoseeker191 is offline Offline
Light Poster

Need Help Understanding ASP Code

 
0
  #1
Feb 9th, 2009
I took over a website for a family friend. The business that created the site prior used ASP to run the Orderform on the site. I am not very familiar with ASP. I was wondering if I posted the html orderform and the ASP handler, if someone could explain to me what is happening. I've started looking at the code but the commands are foreign to me. Any help would be greatly appreciated as I'd like to know what is actually happening rather than just copy and pasting it.

The orderform is at link

The ASP handler code is:

  1. <%
  2. '**************************************************************
  3. ' VALUES THAT YOU NEED TO MODIFY
  4. '**************************************************************
  5. Const x_login = "Enter your login ID here"
  6. Const x_tran_key = "Enter Transaction Key here"
  7. '**************************************************************
  8.  
  9. '**************************************************************
  10. ' VARIABLES USED THROUGHOUT THIS SCRIPT
  11. '**************************************************************
  12. Dim x_version
  13. Dim x_test_request
  14. Dim x_delim_data
  15. Dim x_delim_char
  16. Dim x_relay_response
  17. Dim x_first_name
  18. Dim x_last_name
  19. Dim x_company
  20. Dim x_address
  21. Dim x_city
  22. Dim x_state
  23. Dim x_zip
  24. Dim x_country
  25. Dim x_phone
  26. Dim x_fax
  27. Dim x_cust_id
  28. Dim x_customer_ip
  29. Dim x_customer_tax_id
  30. Dim x_email
  31. Dim x_email_customer
  32. Dim x_merchant_email
  33. Dim x_invoice_num
  34. Dim x_description
  35. Dim x_ship_to_first_name
  36. Dim x_ship_to_last_name
  37. Dim x_ship_to_company
  38. Dim x_ship_to_address
  39. Dim x_ship_to_city
  40. Dim x_ship_to_state
  41. Dim x_ship_to_zip
  42. Dim x_ship_to_country
  43. Dim x_amount
  44. Dim x_currency_code
  45. Dim x_method
  46. Dim x_type
  47. Dim x_recurring_billing
  48. Dim x_bank_aba_code
  49. Dim x_bank_acct_num
  50. Dim x_bank_acct_type
  51. Dim x_bank_name
  52. Dim x_bank_acct_name
  53. Dim x_echeck_type
  54. Dim x_card_num
  55. Dim x_exp_date
  56. Dim x_card_code
  57. Dim x_trans_id
  58. Dim x_auth_code
  59. Dim x_authentication_indicator
  60. Dim x_cardholder_authentication_value
  61. Dim x_customer_organization_type
  62. Dim x_drivers_license_num
  63. Dim x_drivers_license_state
  64. Dim x_drivers_license_dob
  65. '*************************************************************
  66. ' Level 2 Data
  67. '*************************************************************
  68. Dim x_po_num
  69. Dim x_tax
  70. Dim x_tax_exempt
  71. Dim x_freight
  72. Dim x_duty
  73. '*************************************************************
  74.  
  75. x_version = "3.1"
  76. x_test_request = "true"
  77. x_delim_data = "true"
  78. x_delim_char = "|"
  79. x_relay_response = "false"
  80. x_first_name = "Charles"
  81. x_last_name = "DeGaulle"
  82. x_company = "DeGaulle Inc."
  83. x_address = "123 First Avenue"
  84. x_city = "American Fork"
  85. x_state = "UT"
  86. x_zip = "84003"
  87. x_country = "US"
  88. x_phone = "(123)123-1234"
  89. x_fax = "(123)555-1234"
  90. x_cust_id = "2544"
  91. x_customer_ip = request.servervariables("remote_addr")
  92. x_customer_tax_id = "111111111"
  93. x_email = "customersemailaddress@theirdomain.com"
  94. x_email_customer = "true"
  95. x_merchant_email = "youremailaddress@yourdomain.com"
  96. x_invoice_num = "000120"
  97. x_description = "Recycled Toner Cartridges"
  98. x_ship_to_first_name = "Bob"
  99. x_ship_to_last_name = "Smith"
  100. x_ship_to_company = "DeGaulle Inc."
  101. x_ship_to_address = "123 First Avenue"
  102. x_ship_to_city = "American Fork"
  103. x_ship_to_state = "UT"
  104. x_ship_to_zip = "84003"
  105. x_ship_to_country = "US"
  106. x_amount = "8.75"
  107. x_currency_code = "USD"
  108. x_method = "CC"
  109. x_type = "AUTH_CAPTURE"
  110. x_recurring_billing = "no"
  111. x_bank_aba_code = "122101191"
  112. x_bank_acct_num = "00000000000000000"
  113. x_bank_acct_type = "BUSINESS CHECKING"
  114. x_bank_name = "My First Bank"
  115. x_bank_acct_name = "Charles E. DeGaulle"
  116. x_echeck_type = "WEB"
  117. x_card_num = "4111111111111111"
  118. x_exp_date = "05/09"
  119. x_card_code = "212"
  120. x_trans_id = ""
  121. x_auth_code = ""
  122. x_authentication_indicator = "2"
  123. x_cardholder_authentication_value = "E0Mvq8AAABEiMwARIjNEVWZ3iJk"
  124. x_customer_organization_type = "B"
  125. x_drivers_license_num = "000000000"
  126. x_drivers_license_state = "UT"
  127. x_drivers_license_dob = "1960/10/26"
  128. '*************************************************************
  129. ' Level 2 Data
  130. '*************************************************************
  131. x_po_num = "PO 2512"
  132. x_tax = "5%"
  133. x_tax_exempt = "false"
  134. x_freight = "20.00"
  135. x_duty = "5.00"
  136. '*************************************************************
  137.  
  138. '**************************************************************
  139. ' Optional: You can also supply merchant-defined values.
  140. '**************************************************************
  141.  
  142. Dim my_own_variable_name
  143. Dim another_field_name
  144.  
  145. my_own_variable_name = "Inkjet Cartridge 22 DPI"
  146. another_field_name = "Color: Black"
  147.  
  148. '**************************************************************
  149. ' REQUEST STRING THAT WILL BE SUBMITTED BY WAY OF
  150. ' THE HTTPS POST OPERATION
  151. '**************************************************************
  152. Dim vPostData
  153. vPostData = "x_login=" & x_login & "&x_tran_key=" & x_tran_key & "&x_version=" & x_version & "&x_method=" & x_method & "&x_test_request=" & x_test_request &"&x_delim_data=" & x_delim_data & "&x_delim_char=" & x_delim_char & "&x_relay_response=" & x_relay_response & "&x_first_name=" & x_first_name & "&x_last_name=" & x_last_name &"&x_company=" & x_company &"&x_address=" & x_address &"&x_city=" & x_city &"&x_state=" & x_state &"&x_zip=" & x_zip & "&x_country=" & x_country &"&x_phone=" & x_phone &"&x_fax=" & x_fax &"&x_cust_id=" & x_cust_id & "&x_customer_ip=" & x_customer_ip & "&x_customer_tax_id=" & x_customer_tax_id &"&x_email=" & x_email &"&x_email_customer=" & x_email_customer &"&x_merchant_email=" & x_merchant_email &"&x_invoice_num=" & x_invoice_num &"&x_description=" & x_description & "&x_ship_to_first_name=" & x_ship_to_first_name &"&x_ship_to_last_name=" & x_ship_to_last_name &"&x_ship_to_company=" & x_ship_to_company &"&x_ship_to_address=" & x_ship_to_address &"&x_ship_to_city=" & x_ship_to_city &"&x_ship_to_state=" & x_ship_to_state &"&x_ship_to_zip=" & x_ship_to_zip &"&x_ship_to_country=" & x_ship_to_country &"&x_amount=" & x_amount &"&x_currency_code=" & x_currency_code &"&x_method=" & x_method &"&x_type=" & x_type &"&x_recurring_billing=" & x_recurring_billing &"&x_bank_aba_code=" & x_bank_aba_code & "&x_bank_acct_num=" & x_bank_acct_num &"&x_bank_acct_type=" & x_bank_acct_type &"&x_bank_name=" & x_bank_name &"&x_bank_acct_name=" & x_bank_acct_name &"&x_echeck_type=" & x_echeck_type &"&x_card_num=" & x_card_num &"&x_exp_date=" & x_exp_date &"&x_card_code=" & x_card_code &"&x_trans_id=" & x_trans_id &"&x_auth_code=" & x_auth_code &"&x_authentication_indicator=" & x_authentication_indicator &"&x_cardholder_authentication_value=" & x_cardholder_authentication_value &"&x_customer_organization_type=" & x_customer_organization_type &"&x_drivers_license_num=" & x_drivers_license_num &"&x_drivers_license_state=" & x_drivers_license_state &"&x_drivers_license_dob=" & x_drivers_license_dob &"&my_own_variable_name=" & my_own_variable_name &"&another_field_name=" & another_field_name &"&x_po_num=" & x_po_num &"&x_tax=" & x_tax &"&x_tax_exempt=" & x_tax_exempt &"&x_freight=" & x_freight &"&x_duty=" & x_duty
  154.  
  155. '**************************************************************
  156. ' USING WINHTTP TO PERFORM A POST OPERATION
  157. '**************************************************************
  158. ' SEND DATA VIA HTTPS POST TO AUTHORIZE.NET
  159. '
  160. ' WINHTTP:
  161. ' IF YOUR IIS WEB SERVER HAS WINHHTP INSTALLED, YOU CAN USE
  162. ' WINHTTP TO PERFORM THE HTTPS POST OPERATION AS LONG AS YOU
  163. ' KNOW:
  164. ' 1) WHICH VERSION OF WINHTTP IS INSTALLED
  165. ' 2) HOW TO REFER TO THAT SPECIFIC VERSION
  166. ' IF YOU DO NOT KNOW ANY OF THIS INFORMATION, PLEASE CHECK WITH
  167. ' YOUR IIS ADMINISTRATOR OR REFER TO REFERENCE MATERIALS AT
  168. ' WWW.MICROSOFT.COM
  169. '
  170. ' Here is an example of using WINHTTP Version 5:
  171. ' Dim objHttp
  172. ' Set objHTTP = Server.CreateObject("WinHttp.WinHttpRequest.5")
  173. '**************************************************************
  174.  
  175. ' OR
  176.  
  177. '**************************************************************
  178. ' USING XMLHTTP TO PERFORM A POST OPERATION
  179. '**************************************************************
  180. ' SEND DATA VIA HTTPS POST TO AUTHORIZE.NET
  181. '
  182. ' XMLHTTP:
  183. ' IF YOUR IIS WEB SERVER HAS XMLHHTP INSTALLED, YOU CAN USE
  184. ' XMLHTTP TO PERFORM THE HTTPS POST OPERATION AS LONG AS YOU
  185. ' KNOW:
  186. ' 1) WHICH VERSION OF XMLHTTP IS INSTALLED
  187. ' 2) HOW TO REFER TO THAT SPECIFIC VERSION
  188. ' IF YOU DO NOT KNOW ANY OF THIS INFORMATION, PLEASE CHECK WITH
  189. ' YOUR IIS ADMINISTRATOR OR REFER TO REFERENCE MATERIALS AT
  190. ' WWW.MICROSOFT.COM
  191. '
  192. ' Below is an example of using XMLHTTP:
  193.  
  194. Dim xml
  195. Dim strStatus
  196. Dim strRetval
  197. Set xml = Server.CreateObject("Microsoft.XMLHTTP")
  198. xml.open "POST", "https://test.authorize.net/gateway/transact.dll", false
  199. ' Uncomment the line ABOVE for test accounts OR the line BELOW for LIVE accounts
  200. ' xml.open "POST", "https://secure.authorize.net/gateway/transact.dll", false
  201. xml.send vPostData
  202. strStatus = xml.Status
  203. strRetval = xml.responseText
  204. Set xml = nothing
  205.  
  206. '**************************************************************
  207. ' USING AN UPDATED VERSION OF XMLHTTP TO PERFORM AN HTTPS POST
  208. ' OPERATION
  209. '**************************************************************
  210. '
  211. ' AGAIN, YOU NEED TO VERIFY WHICH VERSION OF XMLHTTP IS
  212. ' INSTALLED ON YOUR IIS WEB SERVER, BECAUSE DIFFERENT VERSIONS
  213. ' REQUIRE DIFFERENT SYNTAX
  214. '
  215. ' Below is an example of using a more recent version of XMLHTTP
  216. 'dim xmlhttp
  217. 'set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
  218. 'xmlhttp.Open "POST","https://test.authorize.net/gateway/transact.dll?" & vPostData & "",false
  219. 'xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  220. 'xmlhttp.send ""
  221. 'Response.ContentType = "text/xml"
  222. 'strRetval = xmlhttp.responsexml.xml
  223. 'Set xmlhttp = nothing
  224. '**************************************************************
  225.  
  226.  
  227. '**************************************************************
  228. ' DONE PERFORMING THE HTTPS POST OPERATION
  229. ' At this point, you have submitted the transaction data to
  230. ' Authorize.Net and Authorize.Net has already sent you a
  231. ' response string back by way of the HTTPS POST operation.
  232. '**************************************************************
  233.  
  234.  
  235. '**************************************************************
  236. ' PARSING THE RESPONSE STRING
  237. '
  238. ' It's entirely up to you to decide what you want to do with
  239. ' the payment gateway response. You can parse the string (and
  240. ' that's all it is -- one long string, not an array or any other
  241. ' object) and take specific actions based on certain parameters.
  242. '
  243. ' Below is an example of how to parse the string, convert it and
  244. ' display the returned payment gateway response.
  245. '
  246. '**************************************************************
  247. '
  248. 'First we'll create an array from the return value by splitting on the
  249. 'x_delim_char and then we'll assign each member of the array to values that
  250. 'better describe them for the reader. Of course we'd probably want to
  251. 'do something else with these values like save them to a database,
  252. 'create an email to send to the webmaster and/or the user
  253. '**************************************************************
  254.  
  255. Dim strArrayVal
  256. strArrayVal = split(strRetVal, "|", -1)
  257.  
  258. %>
  259.  
  260. <html>
  261. <head>
  262. <title>ASP Example :: Authorize.Net AIM</title>
  263.  
  264. <style type="text/css" media="all">
  265. <!--
  266. BODY {
  267. background-color: #ffffff;
  268. font-family: Arial, Verdana, Helvetica, Geneva, sans-serif;
  269. font-size: 8pt;
  270. }
  271.  
  272. TD {
  273. font-family: Arial, Verdana, Helvetica, Geneva, sans-serif;
  274. font-size: 12px;
  275. }
  276.  
  277. .small {
  278. font-family: Arial, Verdana, Helvetica, Geneva, sans-serif;
  279. font-size: 10px;
  280. }
  281.  
  282. .copy {
  283. font-family: Arial, Verdana, Helvetica, Geneva, sans-serif;
  284. font-size: 12px;
  285. }
  286.  
  287. //-->
  288. </style>
  289.  
  290. <head>
  291.  
  292. <body marginheight="10" marginwidth="10" topmargin="10" leftmargin="10" rightmargin="10" link="#73757B" vlink="#73757B" alink="#73757B" bgcolor="#ffffff">
  293. <%
  294. ' Begin code to get the last modified date of the current document
  295. ' Get the location of the root directory for the server
  296. file_info = request.servervariables("appl_physical_path")
  297. ' Get the location of the current file on the server
  298. file_info = file_info + right(request.servervariables("script_name"),(len(request.servervariables("script_name"))-1))
  299. ' create a file scripting object on the server
  300. set fso = createobject("scripting.filesystemobject")
  301. ' Assign a variable to contain the document date last modified
  302. document_date=fso.getfile(file_info).datelastmodified
  303. response.write "This code was last updated: "
  304. response.write datevalue(document_date)
  305. ' End code to get the last modified date of the current document
  306. Response.Write "<br><br>"
  307. Response.Write "Length of the return string: "&len(strRetVal)
  308. Response.Write "<br></br>"
  309.  
  310. Response.Write "<hr>"
  311.  
  312. Dim arrData, iq
  313. arrData = strArrayVal
  314.  
  315. ' The following few variables are simply to facilitate the display of the information
  316. Dim tr1, tr2
  317. tr1 = "<tr class='small' bgcolor='#EEEEEE'>"
  318. tr2 = "</tr>"
  319. td1 = "<td>"
  320. td2 = "</td>"
  321.  
  322. Response.Write "<table width='100%' border='0' cellspacing='0' cellpadding='1'>"
  323.  
  324. for i=0 to ubound(arrData)
  325. ' the next line trims out leading and trailing spaces if the data is not null or zero-length
  326. If arrData(i)<>"" and not IsNull(arrData(i)) then arrData(i) = trim(arrData(i))
  327.  
  328. ' alternating table row colors
  329. If i MOD 2 = 0 Then
  330. tr1 = "<tr class='small' bgcolor='#eeeeee'>"
  331. Else
  332. tr1 = "<tr class='small' bgcolor='#ffffff'>"
  333. End If
  334.  
  335. iq = i + 1
  336. Select Case iq
  337. Case 1,2,3,4,5,6,7
  338. Response.Write tr1
  339. Response.Write td1
  340. Response.Write iq & " - Authorize.Net Response: " & arrData(i)
  341. 'br()
  342. Response.Write "<br>"
  343. Response.Write td2
  344. Response.Write tr2
  345. Case 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37
  346. Response.Write tr1
  347. Response.Write td1
  348. Response.Write iq & " - Returned Values: " & arrData(i)
  349. 'br()
  350. Response.Write "<br>"
  351. Response.Write td2
  352. Response.Write tr2
  353. Case 38
  354. Response.Write tr1
  355. Response.Write td1
  356. Response.Write iq & " - MD5 Hash: " & arrData(i)
  357. 'br()
  358. Response.Write "<br>"
  359. Response.Write td2
  360. Response.Write tr2
  361. Case Else
  362. If iq >= 69 then
  363. Response.Write tr1
  364. Response.Write td1
  365. Response.Write iq & " - Merchant-defined: " & arrData(i)
  366. 'br()
  367. Response.Write "<br>"
  368. Response.Write td2
  369. Response.Write tr2
  370. Else
  371. Response.Write tr1
  372. Response.Write td1
  373. Response.Write iq & " - Other: " & arrData(i)
  374. 'br()
  375. Response.Write "<br>"
  376. Response.Write td2
  377. Response.Write tr2
  378. End If
  379. End Select
  380.  
  381. next
  382.  
  383. Response.Write "</table>"
  384.  
  385.  
  386. Response.Write "<hr>"
  387.  
  388.  
  389.  
  390. sub br()
  391. Response.Write("<br>")
  392. end sub
  393.  
  394.  
  395. %>
  396.  
  397.  
  398. <br>
  399. <br>
  400.  
  401.  
  402. </body>
  403. </html>
  404.  
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 17
Reputation: atinobrian is an unknown quantity at this point 
Solved Threads: 2
atinobrian's Avatar
atinobrian atinobrian is offline Offline
Newbie Poster

Re: Need Help Understanding ASP Code

 
0
  #2
Feb 10th, 2009
what part are you not able to understand we can go part by part on this ,comments are making it self explanatory, anyways kindly start with what part of this code are u finding hard to understand
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 34
Reputation: neoseeker191 is an unknown quantity at this point 
Solved Threads: 0
neoseeker191 neoseeker191 is offline Offline
Light Poster

Re: Need Help Understanding ASP Code

 
0
  #3
Feb 10th, 2009
Still some things are a bit confusing. I understand declaring the variables, but im not sure what Dim means. Also why would you set the variables equal to just a random value? I'll start with that for now.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 17
Reputation: atinobrian is an unknown quantity at this point 
Solved Threads: 2
atinobrian's Avatar
atinobrian atinobrian is offline Offline
Newbie Poster

Re: Need Help Understanding ASP Code

 
0
  #4
Feb 10th, 2009
Dim is used for declaring a variable without dim you won't be able to use the variable.
Now setting of variables to random value might be for testing purposes or , avoiding the null error
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 34
Reputation: neoseeker191 is an unknown quantity at this point 
Solved Threads: 0
neoseeker191 neoseeker191 is offline Offline
Light Poster

Re: Need Help Understanding ASP Code

 
0
  #5
Feb 10th, 2009
Alright that makes sense. After the form is submitted a email is sent to the seller with a list of the products purchased. I am trying to find that part in this code.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 54
Reputation: chriscross86 is an unknown quantity at this point 
Solved Threads: 0
chriscross86 chriscross86 is offline Offline
Junior Poster in Training

Re: Need Help Understanding ASP Code

 
0
  #6
Feb 11th, 2009
im developing a software using asp.net... i want to know how to code when it comes to protecting passwords especially when the function is for normal users as well as the administrator's login
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 54
Reputation: chriscross86 is an unknown quantity at this point 
Solved Threads: 0
chriscross86 chriscross86 is offline Offline
Junior Poster in Training

Re: Need Help Understanding ASP Code

 
0
  #7
Feb 11th, 2009
im developing a software using asp.net... i want to know how to code when it comes to giving access of report contents to users according to their needs.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC