Easy Aim Integration

Posted on

Enabling credit card payments on your website is easy with When you enable payments or a shopping cart, it takes your website to a whole new level. You can sell things and make money online and anywhere, which is alway a good thing, right!? Anyways, today im going to show you how to integrate into your website. It makes accepting credit card payments safe, easy and affordable.

The method I am going to teach you today will show you how to use the api to control all phases of the customers experience. They don’t need to leave your website once, and they will never know that you use a third party service.

First, Signup for a Test Account

You will want to head over to and fill out the form.

Once you Create your account, you will receive an email with your API login information. These credentials are important, and you will use them in your application to allow you to connect to the aim api. If you somehow forget or lose your api login information, you can always log into the website and generate a new api login information.

Code For Advanced Integration Method

In order to send the request to the api, we will be using cURL. The way works, is it accepts a large array of values such as the credit card number, expiration date, your api login credentials, your api transaction method and other various items to function correctly. Here is the code to enable payments on your website.

$test_url = '';
$live_url = '';
$post_data = array
	'x_amount'		   => '15.00',
	'x_login'          => '*********', // Unique - replace with your credentials
	'x_tran_key'       => '****************', // Unique - replace with your credentials
	'x_version'        => '3.1',
	'x_delim_char'     => '|',
	'x_delim_data'	   => 'true', // Required to work
	'x_type'           => 'AUTH_CAPTURE', // Optional - default is AUTH_CAPTURE
	'x_method'         => 'CC', // Optional - default is CC
	'x_card_num'	   => '370000000000002', // Required
	'x_exp_date' 	   => '05/2014', // Required MMYY, MM/YY, MM-YY, MMYYYY, MM/YYYY, MM-YYYY
	'x_test_request'   => 'false',
	'x_duplicate_window' => '1', 
$post_data = http_build_query($post_data);
$request = curl_init($test_url);
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($request, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($request);
	echo 'There was an error while connecting to';
$response = explode('|', $response);
echo $response[3];
if($response[0] === '1')
	// Handle Response
	echo 'response was successful';

Explanation of the Parameters

EVERY parameter is a string. Even the dollar amount, and boolean values need to be inside parentheses. Look above in the code for real examples.
‘x_amount’ => ‘15.00’,

  • x_amount the dollar amount that will be charge to the credit card
  • x_login this is your login id that you got when you created your account. NOTE! this is not your account login.
  • x_tran_key this is your transaction key, you also go this when you created your account. Keep your login id and your transaction key secret!
  • x_version either 3.0, or 3.1. I suggest you use 3.1 because it allows for a more robust integration.
  • x_delim_char This is the character that splits your return values up, it can be anything, but its best to use a vertical bar because it is used very little in other areas of your code.
  • x_delim_data this needs to be set to ‘true’ or else the transaction wont work and you will get an error.
  • x_type Type of transaction, whether you are preauthorizing the card or actually charging the card or even a refund.
  • x_method Default is CC, it just means you are going to run a Credit Card
  • x_card_num This is the credit card number that will be charged.
  • x_exp_date The expiration date for the card being billed.
  • x_test_request This is only used in test mode. It specifies that the request is just a test and not actually charging the card.
  • x_duplicate_window The amount of time in seconds that must pass for a request with the same parameters to not be counted as a duplicate transaction and therefore rejected. I used a 1 for testing purposes. You should use something like 120 seconds (2 minutes).

Test Credit Card Numbers

When you specify the expiration date for a test transaction, you must use an expiration date that is the current date or any date in the future.
American Express Test Card 370000000000002
Discover Test Card 6011000000000012
Visa Test Card 4007000000027
Second Visa Test Card 4012888818888
JCB 3088000000000017
Diners Club/ Carte Blanche 38000000000006

Sending the Transactions Parameters to

Since we are just testing right now, we will be using as the url to send the parameters to. Once we are ready to actually charge real credit card numbers, you can use In order to send the transaction details to we need to format the request in a ‘GET’ fashion like using form action=”get”. Use http_build_query to format it correctly.

Testing Different Response Codes & Errors

If you would like to deliberately test your code with different error response codes, you can use the test credit card number 4222222222222 and use the error code you would like to receive in place of x_amount. You can see a list of the Response Reason Codes and Response Reason Text here.

Using the response

If the first index of the response array is equal to ‘1’ then the request was successful. You can then store the transaction id in the database for later use if you need. Its really up to you what you do with the data you receive from A good suggestion would be to send a receipt or a confirmation of their order. If you would like to study the Advanced integration method more thoroughly you can read the aim integration developer guide in pdf format here.