cancel
Showing results for 
Search instead for 
Did you mean: 

Help with MS Access API

Hi,

 

I'm new to this and need a way to connect to authorize.net from MS Access. Can anyone point me to some informaion or sample code for VBA?

 

Thanks,

Jason

dark11star
Member
12 REPLIES 12

Have you solved your problem yet. I am also using Access and the solution is fairly simple (after trying to do it the hard way).

stanjones0net
Member

I would like some more information about this.  We cant find any MS Access sample code to connect to authorize.net anywhere.  Is it even possible?

Yes it is possible. Look at the sample code page.

 

Under the first heading Advanced Integration Method (AIM) download the AIM - ASP Classic code.

 

This is actually vb script code (almost VBA). Copy and paste into a Access module, delete or comment out the HTML, and make the vb script a public subroutine called "test."

 

I removed the reference to "Scripting.Dictionary" and built post_values (as a string) manually, just for testing purposes.

 

Also set a reference to "Microsoft XML, v6.0" then remove the line:

 

 Set objRequest = Server.CreateObject("Microsoft.XMLHTTP")

 

and add the lines:

 

 Dim     objRequest            As    MSXML2.XMLHTTP

 Set     objRequest     =   New   MSXML2.XMLHTTP

 

At the end of the code replace the Response.Write routine with Debug.Print in a loop.

 

It been a while since I did this so you will have to clean up some of the other code also.

 

Add your testing credentials and run the code. Keep me posted with your results.

 

 

 

 

Thanks for this i was looking for such help for a while.

 

1 thing i canot figure out is the line below:

 

I removed the reference to "Scripting.Dictionary" and built post_values (as a string) manually, just for testing purposes.

 

how to built the post_values, if you can please give some detail instrutions.

 

Thanks so much

 

You are building the post_string something like:

Public Sub test()
    Dim Post_Url
    Post_Url = "https://test.authorize.net/gateway/transact.dll"
    'post_url = "https://secure.authorize.net/gateway/transact.dll"
    Dim post_string         As String
    Dim post_response       As String
    'the API Login ID and Transaction Key must be replaced with valid values
    post_string = ""
    post_string = post_string & "x_login=" & URLEncode("API_LOGIN_ID") & "&"
    post_string = post_string & "x_tran_key=" & URLEncode("TRANSACTION_KEY") & "&"
    post_string = post_string & "x_delim_data=" & URLEncode("TRUE") & "&"
    post_string = post_string & "x_delim_char=" & URLEncode("|") & "&"
    post_string = post_string & "x_relay_response=" & URLEncode("FALSE") & "&"
    post_string = post_string & "x_type=" & URLEncode("AUTH_CAPTURE") & "&"
    post_string = post_string & "x_method=" & URLEncode("CC") & "&"
    post_string = post_string & "x_card_num=" & URLEncode("4111111111111111") & "&"
    post_string = post_string & "x_exp_date=" & URLEncode("0115") & "&"
    post_string = post_string & "x_amount=" & URLEncode("19.98") & "&"
    post_string = post_string & "x_description=" & URLEncode("Sample Transaction") & "&"
    post_string = post_string & "x_first_name=" & URLEncode("John") & "&"
    post_string = post_string & "x_last_name=" & URLEncode("Doe") & "&"
    post_string = post_string & "x_address=" & URLEncode("1234 Street") & "&"
    post_string = post_string & "x_state=" & URLEncode("WA") & "&"
    post_string = post_string & "x_zip=" & URLEncode("98004") & "&"
    ' Additional fields can be added here as outlined in the AIM integration
    ' guide at: http://developer.authorize.net
    post_string = Left(post_string, Len(post_string) - 1)
    ' We use xmlHTTP to submit the input values and record the response
    Dim objRequest          As New MSXML2.XMLHTTP
    objRequest.Open "POST", Post_Url, False
    objRequest.send post_string
    post_response = objRequest.responseText
    Debug.Print post_response
    Set objRequest = Nothing
    ' the response string is broken into an array using the specified delimiting character
    Dim response_array '(100) As String
    response_array = Split(post_response, "|", -1)
' now use Debug.Print to write out response_array
End Sub

Public Function URLEncode(xxx As String) As String
    URLEncode = Replace(xxx, " ", "%20")
End Function


This really old code I found laying around but it still works.

 

 

Thank you. This code works perfect. I did not put the code in a module. Instead i put it directly behind a form. Easier I think. :smileyhappy:

Actually I built a complete set of Class modules which are referenced from my application. This way I can fill out the request to Authorize.Net with regular looking code and not a lot of string manipulation in the Form itself. The class also includes any encryption and base 64 coding necessary.

Do you have an sample VBA code for the Transaction Details API (downloading the settled batch list , transacion list for speicified batches, unsettled transactions list etc)

 

Thanis

I don't have any code for Transactions. I briefly looked at the sample code but didn't find anything appropriate. My code is directed at charging cards. You could try working with MSXML2 methods and properties, e.g. responseXML. If you have any success please let me know.