MikeHeuss.com - The eclectic repository of my life. Programming, writing, and other stuff.

AuthNetClass

I wanted a quick and dirty way to simply use the AuthorizeNet AIM interface to process payments. I didn't find a php routine readily available, So I wrote one.

This script takes care of all the basics - it will generate the POST request, and parse the POST results.

Below is an example of a credit card transaction:

Example:

require_once ("AuthNetClass.php");

$tp = new authNetClass("7nqsdff3z4122", //TransKey "6JSHSD5K", //Login true);

//Use the AIM manual to determine the necessary field names.

$tp->SetElement("x_card_num", "43123231111225"); //Credit Card Number

$tp->SetElement("x_exp_date", "1209"); //Expiration Date

$tp->SetElement ("x_amount", "1.03"); //Amount of trans

$tp->SetElement ("x_type", "AUTH_CAPTURE"); //We want to do an auth capture

$tp->SetElement ("x_method","CC"); //This is a CC transation

//Send to the server

$tp->DoTransaction();

//Here is my response code

print ("RV: ".$tp->GetReturnedValues("Response Code"));

We created an instance of AuthNet, passing in the login and transaction key. Both of these are obtained from AuthorizeNet Member Settings. You can also specify true for the debug, which proceeds to print out information useful for testing/debugging.

Set a few of the required elements (see AuthorizeNet's AIM documentation), and then throw in a doTransaction.

By using getReturnedValues, you get access to the values passed back from the authorizenet server.

Documentation

The full class documentation can be found here.

Download

To download: Tar.gz Zip

My disclaimer: I don't guarantee that it will work or do anything, it is provided as is. AuthNetClass.php is made available under the BSD License.

Last Updated: 12 Aug 2005

© 1998 - 2010 Mike Heuss   |   mike@mikeheuss.com  |  386 418 0075  |  6823 NW 218th Street Alachua FL 32615