cancel
Showing results for 
Search instead for 
Did you mean: 

ASP.NET/VB.NET - Can't post a transaction....First time live set up

A little new..just got started with Authorize.net...I can't seem to post a transaction...not getting any error msgs...be nice to have that..code portion below.  

 

 

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()

 

 

Globalevel
Member
9 REPLIES 9

You mean post_response is blank?

RaynorC1emen7
Expert

yes...that will give me error return/debugging?  uncomment this;?

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

 

....also...I dont have the post_url...should it be this..customer service just sent it to me:

 

post_url = https://secure.authorize.net/gateway/transactdll

oopps..I meant this:

 

 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 & " Response Code: " & response_array(0) & _
 ", Response Reason Code: " & response_array(2) & "."
        '   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

fyi..I am using the AIM...

That will put the result on the screen. The production url is(there is a period before the dll)

https://secure.authorize.net/gateway/transact.dll

 

And the test site url is

https://test.authorize.net/gateway/transact.dll

 

Production LoginID, transactionKey will not work on the test site or vice versa

okay so i made the necessary changes....got some errors:

 

Response Code: 2

 

Response Reason Code: 205

 

Response Reason Code: 205

Response Reason Text: This transaction has been declined.

Other Suggestions: This error code applies only to merchants on FDC Omaha. The value submitted in the merchant number field is invalid.

 

So I very my API login(x_login) and transaction(x_tran_key) ....it created another tran key..okay and confirmed that info...thats good to go...so not sure what else to do here...I also that that I should have the state collexted in the post_values.add...

okay..I see this in your link:

Tell whoever provides your merchant account that you need the document that contains all of the details about your account so that you can pass it on to Authorize.Net to configure your payment gateway account.  This document will contain information like your "Acquirer BIN", "Store Number", "Merchant Number", and a bunch of other fields.

 

If you already have an Authorize.Net account, then you should have already received one of these and given it to Authorize.Net when you first established your account.  If you can find that, and it just needs to be refreshed for some reason, then having the older one would help describe what you are looking for.

 

.......

 

a few things:

1. I thought authorize.net provided the details of the account...I thought authorize.net had my merchant account...

 

>>>If you already have an Authorize.Net account, then you should have already received one of these and given it to Authorize.net...dont they have it already???

2. I do have an authorize.net account....I guess I recieved one of these??

 

....do I need to contact someone like the bank??

Call authorize.net up and tell them the error message, and see what they tell you.