<?PHP
$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”; // 是否开启测试功能, 如果开启,则网上付款都是测试,paypal也有此功能,只是方式不一样
$url = “https://test.authorize.net/gateway/transact.dll”; // 这个是测试地址,实际付款地址为: $url = “https://secure.authorize.net/gateway/transact.dll”
// If an amount or description were posted to this page, the defaults are overidden
if ($_REQUEST[“amount”])
{ $amount = $_REQUEST[“amount”]; }
if ($_REQUEST[“description”])
{ $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 ();
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)); }
echo “Amount: $amount <br />”;
echo “Description: $description <br />”;
// 创建html 表单,里面包含了必须的SIM 内容
echo “<FORM method=’post’ action=’$url’ >”;
// Additional fields can be added here as outlined in the SIM integration guide
// at: http://developer.authorize.net
echo ” <INPUT type=’hidden’ name=’x_login’ value=’$loginID’ />”; // ID
echo ” <INPUT type=’hidden’ name=’x_amount’ value=’$amount’ />”; // 付款金额
echo ” <INPUT type=’hidden’ name=’x_description’ value=’$description’ />”; // 描述
echo ” <INPUT type=’hidden’ name=’x_invoice_num’ value=’$invoice’ />”;
echo ” <INPUT type=’hidden’ name=’x_fp_sequence’ value=’$sequence’ />”;
echo ” <INPUT type=’hidden’ name=’x_fp_timestamp’ value=’$timeStamp’ />”;
echo ” <INPUT type=’hidden’ name=’x_fp_hash’ value=’$fingerprint’ />”;
echo ” <INPUT type=’hidden’ name=’x_test_request’ value=’$testMode’ />”;
echo ” <INPUT type=’hidden’ name=’x_show_form’ value=’PAYMENT_FORM’ />”;
echo ” <input type=’submit’ value=’$label’ />”;
echo “</FORM>”;
?>
from: http://newyorkphper.javaeye.com/blog/545210