Reply
Highlighted
Contributor
Posts: 18
Registered: ‎11-30-2011

the sample sim php code is generating error 13

the sample sim php code is generating error 13


The following errors have occurred.

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

 

 

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

Most of this page can be modified using any standard html. The parts of the
page that cannot be modified are noted in the comments. This file can be
renamed as long as the file extension remains .php
-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang='en'>
<head>
<title> Sample SIM Implementation </title>
</head>
<body>

<!-- This section generates the "Submit Payment" button using PHP -->
<?php
// This sample code requires the mhash library for PHP versions older than
// 5.1.2 - http://hmhash.sourceforge.net/

// the parameters for the payment can be configured here
// the API Login ID and Transaction Key must be replaced with valid values
$loginID = "I entered my login id";
$transactionKey = "I entered my transaction key";
$amount = "19.99";
$description = "Sample Transaction";
$label = "Submit Payment"; // The is the label on the 'submit' button
$testMode = "true";
// 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
$url = "https://test.authorize.net/gateway/transact.dll";

// If an amount or description were posted to this page, the defaults are overidden
if (array_key_exists("amount",$_REQUEST))
{ $amount = $_REQUEST["amount"]; }
if (array_key_exists("amount",$_REQUEST))
{ $description = $_REQUEST["description"]; }

// an invoice is generated using the date and time
$invoice = date(YmdHis);
// a sequence number is randomly generated
$sequence = rand(1, 1000);
// a timestamp is generated
$timeStamp = time();

// The following lines generate the SIM fingerprint. PHP versions 5.1.2 and
// newer have the necessary hmac function built in. For older versions, it
// will try to use the mhash library.
if( phpversion() >= '5.1.2' )
{ $fingerprint = hash_hmac("md5", $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey); }
else
{ $fingerprint = bin2hex(mhash(MHASH_MD5, $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey)); }
?>

<!-- Print the Amount and Description to the screen. -->
Amount: <?php echo $amount; ?> <br />
Description: <?php echo $description; ?> <br />

<!-- Create the HTML form containing necessary SIM post values -->
<form method='post' action='<?php echo $url; ?>' >
<!-- Additional fields can be added here as outlined in the SIM integration
guide at: http://developer.authorize.net -->
<input type='hidden' name='x_login' value='<?php echo $loginID; ?>' />
<input type='hidden' name='x_amount' value='<?php echo $amount; ?>' />
<input type='hidden' name='x_description' value='<?php echo $description; ?>' />
<input type='hidden' name='x_invoice_num' value='<?php echo $invoice; ?>' />
<input type='hidden' name='x_fp_sequence' value='<?php echo $sequence; ?>' />
<input type='hidden' name='x_fp_timestamp' value='<?php echo $timeStamp; ?>' />
<input type='hidden' name='x_fp_hash' value='<?php echo $fingerprint; ?>' />
<input type='hidden' name='x_test_request' value='<?php echo $testMode; ?>' />
<input type='hidden' name='x_show_form' value='PAYMENT_FORM' />
<input type='submit' value='<?php echo $label; ?>' />
</form>

</body>
</html>

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: the sample sim php code is generating error 13

This submits to the sandbox (developer / test) server. Are you using a sandbox account, or a production account in test mode?

Highlighted
Contributor
Posts: 18
Registered: ‎11-30-2011

Re: the sample sim php code is generating error 13

I did it with testmode true and testmode false

 

I am using my developer account

 

 

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: the sample sim php code is generating error 13

Add this:

 

$transaction->setSandbox(true);

 

Highlighted
Contributor
Posts: 18
Registered: ‎11-30-2011

Re: the sample sim php code is generating error 13

I put this at the top of the php

$transaction->setSandbox(true);

 

and got this error

Fatal error: Call to a member function setSandbox() on a non-object

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: the sample sim php code is generating error 13

[ Edited ]

Are you just using the sample code(NOT the SDKs)?

If so

// posting to: https://secure.authorize.net/gateway/transact.dll
$url = "https://test.authorize.net/gateway/transact.dll";

If your ID and Key is for production, change the url to the secure.authoirze.net

If it from test account, change it to test.authorize.net

 

P.S. If your ID and Key is for production, make sure you running on testmode for testing. Better yet, get a test account for testing.

 

http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/Authorize-Net-Test-Acco...

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: the sample sim php code is generating error 13

You obviously have to use $transaction = new [insert Authorize.net class call here] before you can call the setSandbox method on it. See your sample code.

Highlighted
Contributor
Posts: 18
Registered: ‎11-30-2011

Re: the sample sim php code is generating error 13

I added this code to the top of the php: require_once 'anet_php_sdk/AuthorizeNet.php'; $transaction = new AuthorizeNetSIM("$apiLoginID", "$transactionKey"); $transaction->setSandbox(true); Fatal error: Call to undefined method AuthorizeNetSIM::setSandbox()
Highlighted
Contributor
Posts: 18
Registered: ‎11-30-2011

Re: the sample sim php code is generating error 13

I added this code to the top of the php:

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

 

 

Fatal error: Call to undefined method AuthorizeNetSIM::setSandbox()              

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: the sample sim php code is generating error 13

Ok , try this instead:

 

FOR DEVELOPER ACCOUNT:

define("AUTHORIZENET_SANDBOX", true);

 FOR PRODUCTION ACCOUNT:

define("AUTHORIZENET_SANDBOX", false);