<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Assigning Response Request Field values to variables in VB.Net in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Assigning-Response-Request-Field-values-to-variables-in-VB-Net/m-p/49143#M24752</link>
    <description>&lt;P&gt;I see. Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Dec 2014 15:29:16 GMT</pubDate>
    <dc:creator>mj168</dc:creator>
    <dc:date>2014-12-12T15:29:16Z</dc:date>
    <item>
      <title>Assigning Response Request Field values to variables in VB.Net</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Assigning-Response-Request-Field-values-to-variables-in-VB-Net/m-p/49140#M24749</link>
      <description>&lt;P&gt;I was able to submit a credit card transaction and get a response. However, I need to be able to retrieve the values of the Response Request Fields and assign them to my own custom variables.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;My Custom Variable Value = Response Request Field Value&lt;/P&gt;&lt;P&gt;Below is my code. It is an AIM API using VB.Net.&lt;BR /&gt;--------------------------------------------------------------------------------------&lt;BR /&gt;Protected Sub Page_Load(sender As Object, e As System.EventArgs)&lt;BR /&gt;' By default, this sample code is designed to post to our test server for&lt;BR /&gt;' developer accounts: &lt;A target="_blank" href="https://test.authorize.net/gateway/transact.dll"&gt;https://test.authorize.net/gateway/transact.dll&lt;/A&gt;&lt;BR /&gt;' for real accounts (even in test mode), please make sure that you are&lt;BR /&gt;' posting to: &lt;A target="_blank" href="https://secure.authorize.net/gateway/transact.dll"&gt;https://secure.authorize.net/gateway/transact.dll&lt;/A&gt;&lt;BR /&gt;Dim post_url As String&lt;BR /&gt;post_url = "&lt;A target="_blank" href="https://test.authorize.net/gateway/transact.dll&amp;quot;"&gt;https://test.authorize.net/gateway/transact.dll"&lt;/A&gt;&lt;BR /&gt;Session.Add("OrderTotal", "25.00")&lt;/P&gt;&lt;P&gt;Dim post_values As New Dictionary(Of String, String)&lt;BR /&gt;'the API Login ID and Transaction Key must be replaced with valid values&lt;BR /&gt;post_values.Add("x_login", Login)&amp;nbsp;&lt;BR /&gt;post_values.Add("x_tran_key", Transaction Key)&amp;nbsp;&lt;BR /&gt;post_values.Add("x_delim_data", "TRUE")&lt;BR /&gt;post_values.Add("x_delim_char", "|")&lt;BR /&gt;post_values.Add("x_relay_response", "TRUE")&lt;/P&gt;&lt;P&gt;'post_values.Add("x_relay_url", "&lt;A target="_blank" href="https://developer.authorize.net/tools/paramdump/index.php&amp;quot;)"&gt;https://developer.authorize.net/tools/paramdump/index.php")&lt;/A&gt;&lt;BR /&gt;post_values.Add("x_type", "AUTH_CAPTURE")&lt;BR /&gt;post_values.Add("x_method", "CC")&lt;BR /&gt;post_values.Add("x_card_num", "4111111111111111")&lt;BR /&gt;post_values.Add("x_exp_date", "0115")&lt;BR /&gt;post_values.Add("x_amount", "19.99")&lt;BR /&gt;post_values.Add("x_description", "Sample Transaction")&lt;BR /&gt;post_values.Add("x_first_name", "John")&lt;BR /&gt;post_values.Add("x_last_name", "Doe")&lt;BR /&gt;post_values.Add("x_address", "1234 Street")&lt;BR /&gt;post_values.Add("x_state", "WA")&lt;BR /&gt;post_values.Add("x_zip", "98004")&lt;BR /&gt;' Additional fields can be added here as outlined in the AIM integration&lt;BR /&gt;' guide at: &lt;A target="_blank" href="http://developer.authorize.net"&gt;http://developer.authorize.net&lt;/A&gt;&lt;BR /&gt;' This section takes the input fields and converts them to the proper format&lt;BR /&gt;' for an http post. For example: "x_login=username&amp;amp;x_tran_key=a1B2c3D4"&lt;BR /&gt;Dim post_string As String = ""&lt;BR /&gt;For Each field As KeyValuePair(Of String, String) In post_values&lt;BR /&gt;post_string &amp;amp;= field.Key &amp;amp; "=" &amp;amp; HttpUtility.UrlEncode(field.Value) &amp;amp; "&amp;amp;"&lt;BR /&gt;Next&lt;BR /&gt;post_string = Left(post_string, Len(post_string) - 1)&lt;BR /&gt;' The following section provides an example of how to add line item details to&lt;BR /&gt;' the post string. Because line items may consist of multiple values with the&lt;BR /&gt;' same key/name, they cannot be simply added into the above array.&lt;BR /&gt;'&lt;BR /&gt;' This section is commented out by default.&lt;BR /&gt;'Dim line_items() As String = { _&lt;BR /&gt;' "item1&amp;lt;|&amp;gt;golf balls&amp;lt;|&amp;gt;&amp;lt;|&amp;gt;2&amp;lt;|&amp;gt;18.95&amp;lt;|&amp;gt;Y", _&lt;BR /&gt;' "item2&amp;lt;|&amp;gt;golf bag&amp;lt;|&amp;gt;Wilson golf carry bag, red&amp;lt;|&amp;gt;1&amp;lt;|&amp;gt;39.99&amp;lt;|&amp;gt;Y", _&lt;BR /&gt;' "item3&amp;lt;|&amp;gt;book&amp;lt;|&amp;gt;Golf for Dummies&amp;lt;|&amp;gt;1&amp;lt;|&amp;gt;21.99&amp;lt;|&amp;gt;Y"}&lt;BR /&gt;'&lt;BR /&gt;'For Each value As String In line_items&lt;BR /&gt;' post_string += "&amp;amp;x_line_item=" + HttpUtility.UrlEncode(value)&lt;BR /&gt;'Next&lt;BR /&gt;' create an HttpWebRequest object to communicate with Authorize.net&lt;BR /&gt;Dim objRequest As HttpWebRequest = CType(WebRequest.Create(post_url), HttpWebRequest)&lt;BR /&gt;objRequest.Method = "POST"&lt;BR /&gt;objRequest.ContentLength = post_string.Length&lt;BR /&gt;objRequest.ContentType = "application/x-www-form-urlencoded"&lt;BR /&gt;' post data is sent as a stream&lt;BR /&gt;Dim myWriter As StreamWriter = Nothing&lt;BR /&gt;myWriter = New StreamWriter(objRequest.GetRequestStream())&lt;BR /&gt;myWriter.Write(post_string)&lt;BR /&gt;myWriter.Close()&lt;BR /&gt;' returned values are returned as a stream, then read into a string&lt;BR /&gt;Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse)&lt;BR /&gt;Dim responseStream As New StreamReader(objResponse.GetResponseStream())&lt;BR /&gt;Dim post_response As String = responseStream.ReadToEnd()&lt;BR /&gt;responseStream.Close()&lt;BR /&gt;' the response string is broken into an array&lt;BR /&gt;Dim response_array As Array = Split(post_response, post_values("x_delim_char"), -1)&lt;BR /&gt;' the results are output to the screen in the form of an html numbered list.&lt;BR /&gt;Message.InnerHtml += "&amp;lt;OL&amp;gt;" &amp;amp; vbCrLf&lt;BR /&gt;For Each value In response_array&lt;BR /&gt;Message.InnerHtml += "&amp;lt;LI&amp;gt;" &amp;amp; value &amp;amp; "&amp;amp;nbsp;&amp;lt;/LI&amp;gt;" &amp;amp; vbCrLf&lt;BR /&gt;Next&lt;BR /&gt;Message.InnerHtml += "&amp;lt;/OL&amp;gt;" &amp;amp; vbCrLf&lt;BR /&gt;' individual elements of the array could be accessed to read certain response&lt;BR /&gt;' fields. For example, response_array(0) would return the Response Code,&lt;BR /&gt;' response_array(2) would return the Response Reason Code.&lt;BR /&gt;' for a list of response fields, please review the AIM Implementation Guide&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim FirstName As String = Request.Form("x_first_name")&lt;BR /&gt;Label1.Text = FirstName&lt;BR /&gt;End Sub&lt;BR /&gt;--------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Above is where I "seem" to be having problems. As a test I am trying to retrieve the value for Response Request Field: First Name. However Request.Form("x_first_name") is empty. Does anyone know how I can get the response values and assign them to my own variables?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Dec 2014 14:19:06 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Assigning-Response-Request-Field-values-to-variables-in-VB-Net/m-p/49140#M24749</guid>
      <dc:creator>mj168</dc:creator>
      <dc:date>2014-12-12T14:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning Response Request Field values to variables in VB.Net</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Assigning-Response-Request-Field-values-to-variables-in-VB-Net/m-p/49142#M24751</link>
      <description>&lt;P&gt;The response is in the response_array array&lt;/P&gt;&lt;P&gt;AIM return just an array of values&lt;/P&gt;&lt;PRE&gt;For Each value In response_array
Message.InnerHtml += "&amp;lt;LI&amp;gt;" &amp;amp; value &amp;amp; "&amp;amp;nbsp;&amp;lt;/LI&amp;gt;" &amp;amp; vbCrLf
Next&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Dec 2014 14:59:10 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Assigning-Response-Request-Field-values-to-variables-in-VB-Net/m-p/49142#M24751</guid>
      <dc:creator>RaynorC1emen7</dc:creator>
      <dc:date>2014-12-12T14:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning Response Request Field values to variables in VB.Net</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Assigning-Response-Request-Field-values-to-variables-in-VB-Net/m-p/49143#M24752</link>
      <description>&lt;P&gt;I see. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Dec 2014 15:29:16 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Assigning-Response-Request-Field-values-to-variables-in-VB-Net/m-p/49143#M24752</guid>
      <dc:creator>mj168</dc:creator>
      <dc:date>2014-12-12T15:29:16Z</dc:date>
    </item>
  </channel>
</rss>

