cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Help! Format of Sample Sim looks wonky, no idea how to fix

I've inhereted a website with my new job and I'm trying to integrate Authorize.net PHP SIM into a nopcommerce site being hosted on our old web developer's computers. The website isn't live yet so anything I'm adding has had to be done through an FTP. A lot of this is new to me, so the learning curve is high.

 

I signed up for a test account, installed the API onto the server in a folder called anet_php_skdAuthorizeNet.php. I installed it into the top level of the server, alongside traditional folders like App_Data, Bin, Content, ect.

 

I altered the sample PHP to read 

 

<!--
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		= "IPUTMYLOGINHERE";
$transactionKey = "IPUTAFRESHTRANSACTIONKEYHERE";
$amount 		= "19.99";
$description 	= "Sample Transaction";
$label 			= "Submit Payment"; // The is the label on the 'submit' button
$testMode		= "false";
// 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>

 I made no other changes to the php file other than adding the login and transaction key.

 

I added the sim.php into the top level of the aformentioned folder, and then copied the http via right click in my ftp. I got an error message, Access Denied, so I instead tried using the ip url, and logging into the server. It took me to a page that looks like it could be the API if it was formatted correctly. The screencap is below

 

WTF

 

 

As far as I can figure, this is (possible) a result of one of three things, and I hope y'all can clarify which one for me.

 

1. The API isn't working properly bcause I installed it into the wrong directory/failed to grant permissions to it

2. The API is working properly but I failed to change enough code in the sample php file/named the php file wrong

3. The API is working correctly but the fact that it's not a live site, but rather a test site means that there's a breakdown in communication between the computer the site is hosted on and test.authorize.net

4. There's an error I don't even know about.

5 A combination of the above?

 

I looked through the Authorize.net tools and didn't find anything I could really use. I do know that I'm producing a fingerprint, through the fingerprint tool. I have no idea what that means, however. 

 

I will bake cookies for anyone who can help!!

hurwitm
Member
1 REPLY 1

on the screenshot, the url is ftp and not http://

RaynorC1emen7
Expert