Showing results for 
Search instead for 
Did you mean: 

Migration from AIM to the Authorize.Net API

We have a PHP-based ecom system in which our client wants to implement accept.js.  We're currently using the AIM method and my understanding is that we will first need to migrate to the Authorize.Net API.  I've read through the API Reference, but looking for something that boils down the steps for migrating.  Can somebody here help?  Should I post my current code?  Sorry for newbie questions, this is my first time posting here.




Hi @danjo,


You've got a few options here. Since your application is PHP-based, you may want to look at our PHP SDK, which can handle the heavy lifting of processing through our API. If that's not going to work for whatever reason, you could change the message format of your requests and then go step by step through your application replacing each point of communication with the AIM system with its equivalent in the API.


Communication with our API is done using HTTP POST, but instead of a bunch of key/value pairs like with AIM, you'll format a message body in XML or JSON format, then post that. Click the "API Endpoints" tab at the top of our API Reference to see the endpoint URLs and the Content-type to send.


Whether you're choosing XML or JSON formatting, samples of the correct formatting for each type of request are on the "Try it" tab in the API Reference.


Hopefully that gives you a rough idea of how to proceed, but if you have more specific questions, please feel free to post them here!



All Star

Thanks for getting me started in the right direction Aaron!  I've got the SDK installed and have begun looking at the sample code from the API reference section under Payment Transactions / Charge a Credit Card.  Just a few questions before I give it a whirl...



define("AUTHORIZENET_LOG_FILE", "phplog");

- I'm assuming this will result in a log file named "phplog" eventually being created somewhere... in the current directory where the script runs or elsewhere?




- I'm not finding where these constants are defined for me to update.  Are they actually defined somewhere (in a separate file maybe) where I can just update them or is it up to me to set them up?



echo "Code : " . $tresponse->getMessages()[0]->getCode() . "\n";

- Lines like this one (and others) generate a syntax error in Dreamweaver, unless I remove the "[0]" part.  I'm sure this is a bit out of the realm of this forum (and I'm showing my inexperience here), but hoping you might be able to hed some light on it for me.


Thank you!

Update: I went ahead and gave it a whirl... partial success!  I set up a sample app running through our server and processing transactions through to a sandbox account I created (sandbox mode on the SDK points to  However, when I switch it to production mode ( with the id and transaction key that we’re currently using in our production (AIM-based) system, I get response code 35… “An error occured during processing. Call Merchant Service Provider.”.  Should I be able to use our current AIM-based production credentials with the API?



Well, that's not good...


The same credentials that you use for AIM should absolutely work with the new API. I wonder if there's some account misconfiguration that's not causing any problems with your AIM setup, but somehow bubbles up in this new scenario?


The only suggestion I can give off the top of my head is to double check and make sure it's really the right api login id and transaction key. Check the phplog file to see the request, and make sure that they right key was going out with the request.

I contacted Client Services to see if they could find any additional details on why it's being rejected, but no luck.  They did say that they're seeing the rejected transaction coming through on their end as well, which indicates that the login credentials are good, but no additional info on what's causing the error.  I'm wondering if it might be that the production account requires more details on the transaction than the sandbox account (cardholder's bill-to info... name, address, etc.).  I'm looking through the sample code for the API/SDK, but not finding how to include that info.  Can you point me in the right direction for how to do that?



It would be really good to find out exactly why the transactions are being rejected, which could save you a bunch of work down the road. However, if you just want to send more information with the transactions and see if that changes anything, I can hopefully get you started.


Generally in the PHP SDK, you're creating objects and then calling methods on those objects to add information. All of the information you're sending with the transaction is ultimately included in a TransactionRequestType object, and that object has a "setBillTo" method you can use for setting the address (the address information having previously been added to a CustomerAddressType).

I noticed that our sample PHP code doesn't show adding the address in the charge a card and authorize a card samples. I just sent a request to fix that, but in the mean time, here's the updated code from the charge-credit-card.php sample. Adding other things besides address is done the same way, where you create an object of the right type you want, call the methods to add the information you want to the object, then add the object to your transaction request.


  require 'vendor/autoload.php';

  use net\authorize\api\contract\v1 as AnetAPI;
  use net\authorize\api\controller as AnetController;

  define("AUTHORIZENET_LOG_FILE", "phplog");

  function chargeCreditCard($amount){
    // Common setup for API credentials
    $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
    $refId = 'ref' . time();

    // Create the payment data for a credit card
    $creditCard = new AnetAPI\CreditCardType();
    $paymentOne = new AnetAPI\PaymentType();

    $order = new AnetAPI\OrderType();
    $order->setDescription("New Item");

    // Set the customer's Bill To address
    $customerAddress = new AnetAPI\CustomerAddressType();
    $customerAddress->setAddress("14 Main Street");
    $customerAddress->setCity("Pecan Springs");

    // Create a TransactionRequestType object
    $transactionRequestType = new AnetAPI\TransactionRequestType();
    $transactionRequestType->setTransactionType( "authCaptureTransaction"); 

    $request = new AnetAPI\CreateTransactionRequest();
    $request->setRefId( $refId);
    $request->setTransactionRequest( $transactionRequestType);

    $controller = new AnetController\CreateTransactionController($request);
    $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);

    if ($response != null)
      if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK)
        $tresponse = $response->getTransactionResponse();
        if ($tresponse != null && $tresponse->getMessages() != null)   
          echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n";
          echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n";
          echo "Charge Credit Card TRANS ID  : " . $tresponse->getTransId() . "\n";
          echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n"; 
          echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n";
          echo "Transaction Failed \n";
          if($tresponse->getErrors() != null)
            echo " Error code  : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
            echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";            
        echo "Transaction Failed \n";
        $tresponse = $response->getTransactionResponse();
        if($tresponse != null && $tresponse->getErrors() != null)
          echo " Error code  : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
          echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";                      
          echo " Error code  : " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
          echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n";
      echo  "No response returned \n";

    return $response;

Thanks a bunch for that!  I'm still getting the same generic error after adding the address info, but I would have eventually needed it anyway.  I've sent an email to the Developer Support.  Client Services thought that they might have some other thoughts and/or might be able to elevate the issue to get more eyes on it.  I will let you know how that pans out, but if you come up with anything else I might want to try from a code perspective, certainly let me know.


Thanks again!