cancel
Showing results for 
Search instead for 
Did you mean: 

aim php •The merchant login ID or password is invalid or the account is inactive.

when I run aim in php using the aim sample code (where I changed my loginid and transactionkey)

 

 

 

 

  • 13
  • The merchant login ID or password is invalid or the account is inactive. 
  •  
  •  
  •  
  • 19.99 
  •  
  • auth_capture 
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  • F5FB0412546E713FCEC05FA033DCD235 
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

 

 

 

<!-- This sample code is designed to connect to Authorize.net using the AIM method. For API documentation or additional sample code, please visit: http://developer.authorize.net -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd"> <HTML lang='en'> <HEAD>  <TITLE> Sample AIM Implementation </TITLE> </HEAD> <BODY> <P> This sample code is designed to generate a post using Authorize.net's Advanced Integration Method (AIM) and display the results of this post to the screen. </P> <P> For details on how this is accomplished, please review the readme file, the comments in the sample code, and the Authorize.net AIM API documentation found at http://developer.authorize.net </P> <HR />

<?PHP

// By default, this sample code is designed to post to our test server for // developer accounts: https://test.authorize.net/gateway/transact.dll // for real accounts (even in test mode), please make sure that you are // posting to: https://secure.authorize.net/gateway/transact.dll $post_url = "https://test.authorize.net/gateway/transact.dll";

$post_values

= array(    // the API Login ID and Transaction Key must be replaced with valid values  "x_login"   => "API_LOGIN_ID",  "x_tran_key"  => "TRANSACTION_KEY",

 "x_version"   => "3.1",  "x_delim_data"  => "TRUE",  "x_delim_char"  => "|",  "x_relay_response" => "FALSE",

 "x_type"   => "AUTH_CAPTURE",  "x_method"   => "CC",  "x_card_num"  => "4111111111111111",  "x_exp_date"  => "0115",

 "x_amount"   => "19.99",  "x_description"  => "Sample Transaction",

 "x_first_name"  => "John",  "x_last_name"  => "Doe",  "x_address"   => "1234 Street",  "x_state"   => "WA",  "x_zip"    => "98004"  // Additional fields can be added here as outlined in the AIM integration  // guide at: http://developer.authorize.net );

// This section takes the input fields and converts them to the proper format // for an http post.  For example: "x_login=username&x_tran_key=a1B2c3D4" $post_string = ""; foreach( $post_values as $key => $value )  { $post_string .= "$key=" . urlencode( $value ) . "&"; } $post_string = rtrim( $post_string, "& " );

// The following section provides an example of how to add line item details to // the post string.  Because line items may consist of multiple values with the // same key/name, they cannot be simply added into the above array. // // This section is commented out by default. /* $line_items = array(  "item1<|>golf balls<|><|>2<|>18.95<|>Y",  "item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y",  "item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y");   foreach( $line_items as $value )  { $post_string .= "&x_line_item=" . urlencode( $value ); } */

// This sample code uses the CURL library for php to establish a connection, // submit the post, and record the response. // If you receive an error, you may want to ensure that you have the curl // library enabled in your php configuration $request = curl_init($post_url); // initiate curl object  curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response  curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)  curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.  $post_response = curl_exec($request); // execute curl post and store results in $post_response  // additional options may be required depending upon your server configuration  // you can find documentation on curl options at http://www.php.net/curl_setopt curl_close ($request); // close curl object

// This line takes the response and breaks it into an array using the specified delimiting character $response_array = explode($post_values["x_delim_char"],$post_response);

// The results are output to the screen in the form of an html numbered list. echo "<OL>\n"; foreach ($response_array as $value) {  echo "<LI>" . $value . "&nbsp;</LI>\n";  $i++; } echo "</OL>\n"; // individual elements of the array could be accessed to read certain response // fields.  For example, response_array[0] would return the Response Code, // response_array[2] would return the Response Reason Code. // for a list of response fields, please review the AIM Implementation Guide ?> </BODY> </HTML>

forthis
Contributor
17 REPLIES 17
I got a card not present test account the code works on the test account but I want the code to work on my account could there be something wrong with my authorize.net account and who do I ask

Go back and read my previous posts. You're almost certainly running in sandbox mode still but trying to log in with your production account.

The merchant login ID or password is invalid or the account is inactive. 

I can toggle on/off test/development sandbox true/false

 

<!-- This sample code is designed to connect to Authorize.net using the AIM method. For API documentation or additional sample code, please visit: http://developer.authorize.net -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd"> <HTML lang='en'> <HEAD>   <TITLE> Sample AIM Implementation </TITLE> </HEAD> <BODY> <P> This sample code is designed to generate a post using Authorize.net's Advanced Integration Method (AIM) and display the results of this post to the screen. </P> <P> For details on how this is accomplished, please review the readme file, the comments in the sample code, and the Authorize.net AIM API documentation found at http://developer.authorize.net </P> <HR />

<?PHP //real $apiLoginID="xxx"; $transactionKey="xxx"; //test //$apiLoginID="xxx"; //$transactionKey="xxx";

 

// By default, this sample code is designed to post to our test server for // developer accounts: https://test.authorize.net/gateway/transact.dll // for real accounts (even in test mode), please make sure that you are // posting to: https://secure.authorize.net/gateway/transact.dll $post_url = "https://test.authorize.net/gateway/transact.dll";

//$transaction

= new AuthorizeNetAIM('YOUR_API_LOGIN_ID', 'YOUR_TRANSACTION_KEY'); //$transaction->setSandbox(false); require_once 'anet_php_sdk/AuthorizeNet.php'; $transaction = new AuthorizeNetAIM("$apiLoginID", "$transactionKey"); //$transaction->setSandbox(true); $transaction->setSandbox(false);

$post_values = array(     // the API Login ID and Transaction Key must be replaced with valid values   "x_login"      => "$apiLoginID",   "x_tran_key"    => "$transactionKey",

  "x_version"      => "3.1",   "x_delim_data"    => "TRUE",   "x_delim_char"    => "|",   "x_relay_response"  => "FALSE",

  "x_type"      => "AUTH_CAPTURE",   "x_method"      => "CC",   "x_card_num"    => "4111111111111111",   "x_exp_date"    => "0115",

  "x_amount"      => "19.99",   "x_description"    => "Sample Transaction",

  "x_first_name"    => "John",   "x_last_name"    => "Doe",   "x_address"      => "1234 Street",   "x_state"      => "WA",   "x_zip"        => "98004"   // Additional fields can be added here as outlined in the AIM integration   // guide at: http://developer.authorize.net );

// This section takes the input fields and converts them to the proper format // for an http post.  For example: "x_login=username&x_tran_key=a1B2c3D4" $post_string = ""; foreach( $post_values as $key => $value )   { $post_string .= "$key=" . urlencode( $value ) . "&"; } $post_string = rtrim( $post_string, "& " );

// The following section provides an example of how to add line item details to // the post string.  Because line items may consist of multiple values with the // same key/name, they cannot be simply added into the above array. // // This section is commented out by default. /* $line_items = array(   "item1<|>golf balls<|><|>2<|>18.95<|>Y",   "item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y",   "item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y");   foreach( $line_items as $value )   { $post_string .= "&x_line_item=" . urlencode( $value ); } */

// This sample code uses the CURL library for php to establish a connection, // submit the post, and record the response. // If you receive an error, you may want to ensure that you have the curl // library enabled in your php configuration $request = curl_init($post_url); // initiate curl object   curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response   curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)   curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data   curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.   $post_response = curl_exec($request); // execute curl post and store results in $post_response   // additional options may be required depending upon your server configuration   // you can find documentation on curl options at http://www.php.net/curl_setopt curl_close ($request); // close curl object

// This line takes the response and breaks it into an array using the specified delimiting character $response_array = explode($post_values["x_delim_char"],$post_response);

// The results are output to the screen in the form of an html numbered list. echo "<OL>\n"; foreach ($response_array as $value) {   echo "<LI>" . $value . "&nbsp;</LI>\n";   $i++; } echo "</OL>\n"; // individual elements of the array could be accessed to read certain response // fields.  For example, response_array[0] would return the Response Code, // response_array[2] would return the Response Reason Code. // for a list of response fields, please review the AIM Implementation Guide ?> </BODY> </HTML>

You are using the sample code

Please read this, it right in the code.

// By default, this sample code is designed to post to our test server for 
// developer accounts: https://test.authorize.net/gateway/transact.dll
// for real accounts (even in test mode), please make sure that you are
// posting to: https://secure.authorize.net/gateway/transact.dll
$post_url = "https://test.authorize.net/gateway/transact.dll";

 

https://secure.authorize.net/gateway/transact.dll

This transaction has been declined. 

 

Now, how can I add a credit card field to the post form  (even though it is unsafe)

It declined because you can't use a test cc# on a production account.

 

With my limited understanding of PHP is that, add the x_card_num field input field and any other input fields on another form(Let said formINPUT) and post to this AIM form and change

$post_values = array(
	// the API Login ID and Transaction Key must be replaced with valid values
	"x_login"			=> "API_LOGIN_ID",
	"x_tran_key"		=> "TRANSACTION_KEY",
	"x_version"			=> "3.1",
	"x_delim_data"		=> "TRUE",
	"x_delim_char"		=> "|",
	"x_relay_response"	=> "FALSE",
	"x_type"			=> "AUTH_CAPTURE",
	"x_method"		=> "CC",
	"x_card_num"		=> $_POST['x_card_num'],
	"x_exp_date"		=> "0115",
	"x_amount"		=> "19.99",
	"x_description"		=> "Sample Transaction",
	"x_first_name"		=> "John",
	"x_last_name"		=> "Doe",
	"x_address"		=> "1234 Street",
	"x_state"			=> "WA",
	"x_zip"			=> "98004"
	// Additional fields can be added here as outlined in the AIM integration
	// guide at: http://developer.authorize.net
);

 to use the post value $_POST["x_card_num"] from the previous from  formINPUT.

Just keep in mind that you really don't want to be sending your credit card over an unsecured connection. Better to get a developer account and set just this page to use it, that way you can use the test credit cards to test your form. You only need to go live and run your own credit card through once when everything's working in developer.

I can't believe we are still talking about this two years later! I see this answer being given over and over again --

"If you are integrating your website with Advanced Integration Method (AIM) using PHP, please be aware that
---the gateway URL is listed twice--once in the cURL configuration, and once again in the main body of the code." SO WHAT DO WE DO ABOUT IT?  DOESN'T THE URL IN THE MAIN BODY OF THE CODE OVER-WRITE THE cURL URL?
Then it says: 'USING THE TEST GATEWAY URL in the cURL section of the code will create an Error 13, as cURL would connect to the incorrect server."  SO DOES THAT MEAN WE SHOULDN'T EVER USE THE TEST GATEWAY IF WE'RE DEVELOPING IN AIM?  WE CAN ONLY USE THE PRODUCTION GATEWAY? AND IN TEST MODE?

Would somebody please make this clear?

Thanks.