hello i was wondering if someone can help i'm using the sim-php is their away where i can have the customer add the amount instead of being hard coded as people are calling it here if so can someone tell me how to change it thanks
$loginID = "API_LOGIN_ID";
$transactionKey = "TRANSACTION_KEY";
$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>
06-11-2011 07:44 PM
06-12-2011 07:43 PM
Thanks already figured that part out but now i need help with making so i have more text fields on the first part and have them post to my payment form i just cann't get the first and last name to do it i would also like to figure out have to put the sumit to them all on one page this is my first time ever playing with code so any help would be great.
<head>
<title>Sample SIM Implementation</title>
</head>
<body><?php
if (isset($_POST) && is_array($_POST) && count($_POST))
{
$loginID = "xxxxxxxxxxxxxxxxxx";
$transactionKey = "xxxxxxxxxxxxxxx";
$description = "Please put Defendants name Here";
$testMode = "false";
$amount = (float) trim($_REQUEST["x_amount"]);
$FirstName = (float) trim($_REQUEST["x_firstname"]);
$LastName = (float) trim($_REQUEST["x_lastname"]);
$Address = (float) trim($_REQUEST["x_address"]);
$city = (float) trim($_REQUEST["x_city"]);
$state = (float) trim($_REQUEST["x_state"]);
$zip = (float) trim($_REQUEST["x_zip"]);
$invoice = date(YmdHis);
$sequence = rand(1, 1000);
$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));
}
?>
<form method="post" action="https://test.authorize.net/gateway/transact.dll"><input value="<?php echo $loginID; ?>" type="hidden" name="x_login" /> <input value="<?php echo $amount; ?>" type="hidden" name="x_amount" /> <input value="<?php echo $FirstName; ?>" type="hidden" name="x_firstname" /> <input value="<?php echo $LastName; ?>" type="hidden" name="x_lastname" /> <input value="<?php echo $Address; ?>" type="hidden" name="x_address" /> <input value="<?php echo $city; ?>" type="hidden" name="x_city" /> <input value="<?php echo $state; ?>" type="hidden" name="x_state" /> <input value="<?php echo $zip; ?>" type="hidden" name="x_zip" /> <input value="<?php echo $description; ?>" type="hidden" name="x_description" /> <input value="<?php echo $invoice; ?>" type="hidden" name="x_invoice_num" /> <input value="<?php echo $sequence; ?>" type="hidden" name="x_fp_sequence" /> <input value="<?php echo $timeStamp; ?>" type="hidden" name="x_fp_timestamp" /> <input value="<?php echo $fingerprint; ?>" type="hidden" name="x_fp_hash" /> <input value="<?php echo $testMode; ?>" type="hidden" name="x_test_request" /> <input value="PAYMENT_FORM" type="hidden" name="x_show_form" /> <input value="Submit Payment" type="submit" /> </form><?php
}
else
{
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">Amount: <input type="text" name="x_amount" /> First Name: <input value="<?php echo $FirstName; ?>" type="text" name="x_FirstName" /> Last Name: <input value="<?php echo $LastName; ?>" type="text" name="x_LastName" /> Address: <input value="<?php echo $address; ?>" type="text" name="x_address" /> city: <input value="<?php echo $city; ?>" type="text" name="x_city" /> state: <input value="<?php echo $state; ?>" type="text" name="x_state" /> zip: <input value="<?php echo $zip; ?>" type="text" name="x_zip" /> <input value="AMOUNT" type="submit" /> </form><?php
}
?>
</body>
</html>
06-12-2011 09:35 PM
$amount = (float) trim($_REQUEST["x_amount"]);
$FirstName = (float) trim($_REQUEST["x_firstname"]);
$LastName = (float) trim($_REQUEST["x_lastname"]);
$Address = (float) trim($_REQUEST["x_address"]);
$city = (float) trim($_REQUEST["x_city"]);
$state = (float) trim($_REQUEST["x_state"]);
$zip = (float) trim($_REQUEST["x_zip"]);
Um... why are you casting string values to a float? It makes sense for certain values that are numeric (such as x_amount), but it shouldn't be done for string values like x_firstname.
06-13-2011 07:24 AM
Sorry i now nothing about coding i get part of this from here and changed the rest what do i need to do
06-13-2011 09:29 AM