?
Solved

asp.net cart shaking hands with API authorize.net...

Posted on 2011-05-10
5
Medium Priority
?
681 Views
Last Modified: 2012-08-14
I have a cart that shakes hands with authorize.net but my transactions are not posting...I am not sure what else to do at this point I have attached code with dummy data...

On IIS the SSL is configured to 443 and tcp is configured to 80...it worked in test..but now is not working live...

here is the code where hands off...
Session("card_number") = "136789098765434"
        Session("Combined_Expiration") = "0513"
        Session("Purchase_Total") = "1.10"
        Session("First_Name") = "jOHN"
        Session("Last_name") = "sMITH"
        Session("Address_1") = "22368 Riverwoods Rd Smallville"
        Session("dropdpwnlist_State") = "OH"
        Session("Zip_code") = "456213"


        Dim stop_here As String

        stop_here = ""
        ' ---------------------------------------

        Dim post_values As New Dictionary(Of String, String)

        'the API Login ID and Transaction Key must be replaced with valid values
        post_values.Add("x_login", "3ETN68UNJ06HK")
        post_values.Add("x_tran_key", "4RTNM6TDFCBNMLO")

        post_values.Add("x_delim_data", "TRUE")
        post_values.Add("x_delim_char", "|")
        post_values.Add("x_relay_response", "FALSE")

        post_values.Add("x_type", "AUTH_CAPTURE")
        post_values.Add("x_method", "CC")
        post_values.Add("x_card_num", Session("card_number"))
        'post_values.Add("x_exp_date", "0115")
        post_values.Add("x_exp_date", Session("Combined_Expiration"))

        post_values.Add("x_amount", Session("Purchase_Total"))
        post_values.Add("x_description", "abccomp Transaction")

        post_values.Add("x_first_name", Session("First_Name"))
        post_values.Add("x_last_name", Session("Last_name"))
        post_values.Add("x_address", Session("Address_1"))
        post_values.Add("x_state", Session("dropdpwnlist_State"))
        post_values.Add("x_zip", Session("Zip_code"))
        ' Additional fields can be added here as outlined in the AIM integration
        ' guide at: http://developer.authorize.net

        ' This section takes the input fields and converts them to the proper format
        ' for an http post.  For example: "x_login=username&x_tran_key=afg6hjk4"
        Dim post_string As String = ""
        For Each field As KeyValuePair(Of String, String) In post_values
            post_string &= field.Key & "=" & HttpUtility.UrlEncode(field.Value) & "&"
        Next
        post_string = Left(post_string, Len(post_string) - 1)

        ' The following section provides an example of how to add line item details to
        ' the post string.  Because line items may consist of multiple values with the
        ' same key/name, they cannot be simply added into the above array.
        '
        ' This section is commented out by default.
        'Dim line_items() As String = { _
        '    "item1<|>golf balls<|><|>2<|>18.95<|>Y", _
        '    "item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y", _
        '    "item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y"}
        '
        'For Each value As String In line_items
        '   post_string += "&x_line_item=" + HttpUtility.UrlEncode(value)
        'Next

        ' create an HttpWebRequest object to communicate with Authorize.net
        Dim objRequest As HttpWebRequest = CType(WebRequest.Create(post_url), HttpWebRequest)
        objRequest.Method = "POST"
        objRequest.ContentLength = post_string.Length
        objRequest.ContentType = "application/x-www-form-urlencoded"

        ' post data is sent as a stream
        Dim myWriter As StreamWriter = Nothing
        myWriter = New StreamWriter(objRequest.GetRequestStream())
        myWriter.Write(post_string)
        myWriter.Close()

        ' returned values are returned as a stream, then read into a string
        Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse)
        Dim responseStream As New StreamReader(objResponse.GetResponseStream())
        Dim post_response As String = responseStream.ReadToEnd()
        responseStream.Close()

        ' the response string is broken into an array
        Dim response_array As Array = Split(post_response, post_values("x_delim_char"), -1)

        ' the results are output to the screen in the form of an html numbered list.
        'resultSpan.InnerHtml += "<OL>" & vbCrLf
        'For Each value In response_array
        '    resultSpan.InnerHtml += "<LI>" & value & "&nbsp;</LI>" & vbCrLf
        'Next
        'resultSpan.InnerHtml += "</OL>" & vbCrLf
        ' individual elements of the array could be accessed to read certain response
        ' fields.  For example, response_array(0) would return the Response Code,
        ' response_array(2) would return the Response Reason Code.
        ' for a list of response fields, please review the AIM Implementation Guide

        ' ----------------------------------------------------
        ' ORDER IS SUCCESSSFULL...TAKE THEM TO THE NEXT STEP...

        Order_Success()

Open in new window

0
Comment
Question by:GlobaLevel
  • 3
  • 2
5 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 35738075
are you posting to the correct URL for production?  There is one for dev, and a seperate one for production sites.  Along with this, there are seperate credentials
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35739039

are you posting to the correct URL for production?  There is one for dev, and a seperate one for production sites

>>thats a good point...but i am not even sure where to look for it the code above..?
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 2000 total points
ID: 35739267
Whatever the value of post_url is.  Setting this variable is not in the code you posted
0
 
LVL 25

Expert Comment

by:kevp75
ID: 35750588
:)
There API is pretty easy to work with.  I'm building an eCommerce site right now, that is all Authorize.Net.   I ended up programming in the url and test url for to select the right one based on if we were testing in staging, or on production.

Works a champ :)
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35750844
They were very helpful ...the issue turned out to be with the msp
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question