AIM Class

Update: I have decided to place the files to download in SourceForge.Net. There I will be able to create new versions and to control them in a more organized way. The download link has been updated. Check bellow.

I have finally created the AIM class. This is by far one of the most used payment gateways around and the AIM (Advanced Integration Method) is one of the most used methods for online shopping.

Here are some features for the Class:

  • Work with all types of the Advanced Integration Method
  • Work only with credit cards, but can be easily adapted to work with e-checks (only needs to place more fields and validation for bank information)
  • Work with Zend Framework to retrieve configuration for login, transaction key and gateway url –
  • Parsing for the error code returned

These are some features that is missing, but would be awesome to place at:

  • Integration for the ARB method (auto recurring billing)
  • Adapt to accept e-checks

Feel free to use the class and if you got some new change on it, please post here so we can update it (after carefully consideration of the script I will place it on the new version of the class and reference your name and blog/site).

P.S. If you don’t have a transaction key and login, you can get one with their developer program:


About mcloide

Making things simpler, just check: View all posts by mcloide

11 responses to “ AIM Class

  • Alex Morales

    Great Job!!!

    Do you have examples on how to use it?

    • mcloide

      Thanks. Unfortunately I don’t have any examples that can be published, but is very straight forward. The best scenario is creating a AUTH_ONLY request and if the request is successful, save the order and create a CAPTURE_ONLY request. Hardly enough you will have one giving success and the other one giving error, but if it happens, you should alert the system managers to place the order manually (on Virtual Terminal or by the system). Just one detail, at the moment that you do a AUTH_ONLY request it will hold the users funds his account, so you will need to use the same id to process the CAPTURE_ONLY. Check manuals for more information about the process with the AIM.

  • Alex Morales

    Thanks… I guess i was being lazy and did not want to read source… I got it working, I checked everything against $error to see if the gateway response was successful… however I had to add a bit of code to change $error to FALSE if there was a success because there as no way for me to determine the response in your source from what I can find.

    Around line 400 you have a debug commented out for a var_dump of $responseAuthNet… just below that I added this:

    if($responseAuthNet[3] == ‘(TESTMODE) This transaction has been approved.’ || $responseAuthNet[3] == ‘This transaction has been approved.’) {
    $this->error = FALSE;

    I hope this helps someone and great work once again… I just cannot believe this is not in Zend, Kohana(they have one but does not work as of version 2.3) or Codeigniter.

  • Alex Morales

    Also… here is an example for anyone else who is as lazy as me… 🙂 It is very easy as mcloide has mentioned..

    $gateway = new AuthorizeNet();

    $gateway->__set(‘x_exp_date’,$_REQUEST[‘cc_exp_month’] . $_REQUEST[‘cc_exp_year’]);
    $gateway->__set(‘x_amount’, ’50’);
    $gateway->__set(‘x_address’, $_REQUEST[‘address’]);
    $gateway->__set(‘x_city’, $_REQUEST[‘city’]);
    $gateway->__set(‘x_state’, $_REQUEST[‘state’]);
    $gateway->__set(‘x_zip’, $_REQUEST[‘zip’]);
    $gateway->__set(‘x_card_code’, $_REQUEST[‘cvv_code’]);
    $gateway->__set(‘x_type’, ‘AUTH_CAPTURE’); # Authorization w/ Auto Capture


    if (! $gateway->__get(‘error’)) {
    # transaction passed
    else {
    # transaction failed

  • mcloide

    Great work.

    I’m going to check your modifications against the class and maybe a new class will rise up. I have been planning in creating one for the ARB method.

    Again great work.

  • BlueMine

    I found your link while searching for a similar code, but for windows server. My site is hosted on a windows platform and I want to insert a donation form, where beside the user details, they will be able to insert a “message” to be sent to us and also after successful donation, a print receipt page.

    Can you help me?

    • mcloide

      Go to and check the Section 3. There you will find all fields available for use. As suggestion you can use the order description as an informational field.

      After the transaction is successfully submitted and accepted it will return a code. At that time you can display a page with some user information, description, value donated so the user can print.

      It would be a 3 layer proccess:

      1) Enter billing information / message.
      1.1) Submit and store all on session.
      2) Display for the user information on page to confirm.
      2.1) Submit and get transaction code (store transaction code in session) OR back to previous page
      3) Display receipt for the user with order #, invoice # and AIM transaction code

      Since you are on Windows, make sure that you have CURL and PHP5 installed, otherwise it will not work.

  • BlueMine

    PHP is NOT available on my server. Is there a way around it. Do you have a ASP solution?

    • mcloide

      No. In this case you would need to create something from scratch or try to find something in ASP that can help you. Anyway, it’s not hard, all you need to do is a request to their API, passing the required parameters and get the response back.

      Look at to see if you can find something for it in ASP.

  • vishal

    can i use this in zend framework….or do you have any idea that zend provide its own library for integration………..pls help someone to implement me in zend framework…..with zends norms and regulation

    • mcloide

      You would need to adapt to construct a component or behavior to use on the ZF, therefore the basic code is there that you can use as reference.

      You can also check if there is already a library done for the ZF

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: