I'm having loads of trouble understanding the process here for using SIM integration payment option, as well as creating a form to do so. I have no experience in online payments and have never created a form to do so. If i'm doing SIM integration, can I just use the hosted payment form on authorize.net's website? If so how to I go about accomplishing this? All I want is a "Click here to pay your bill online" button on my clients website where the customers can go to the payment form(something that looks like the virtual terminal form), and enter their account #, credit card #, address, contact info, and payment amount of their bill. Under "Transaction Format Settings" you can go edit the payment form. How do you get to that payment form? B/c I see where there is a place to customize the form, i.e. header and footer. I want to add my clients logo in the header and go w/ it that way. For now, they just want a simple answer for an online payment option. Struggling to grasp this concept. Thanks for any help.
Solved! Go to Solution.
01-31-2010 11:24 AM
Delete the line that says include(simlib.php) (line 76).
Then go down to the bottom of the file and replace:
$ret = getFP($loginid, $x_tran_key, $amount, $sequence);
$fields = array(
'x_fp_sequence'=>$sequence,
'x_fp_timestamp'=>$ret[1],
'x_fp_hash'=>$ret[0],
with this:
$timestamp = time();
$fingerprint = hash_hmac("md5", $loginid."^".$sequence."^".$timestamp."^".$amount."^", $x_tran_key);
$fields = array(
'x_fp_sequence'=>$sequence,
'x_fp_timestamp'=>$timestamp,
'x_fp_hash'=>$fingerprint,
Also make sure you change the form action to be the name of the file you are working with. The sample code you are using has it set to donate.php.
<form method="POST" action="donate.php">
02-01-2010 12:59 PM - edited 02-01-2010 01:01 PM
I made the changes and the errors went away, thanks again for that. And I went to change this
<form method="POST" action="donate.php">
to exform.php, which is the name of my file and when I click the button the page just reloads. Is that correct of do I need to change it to something else?
02-01-2010 03:09 PM
That shouldn't happen. If you can, post the code you have so far. That will make it easier for me to troubleshoot it for you.
02-01-2010 03:24 PM
I couldn't put it all in one post, here is one part....
<?php//// How to use this page...// // NOTE: You can search for [Fixup #] (with the square brackets), where #// is the step number from below, to find where in the code to make// the changes.//// 1. Fill in the appropriate information under the "Site Identity// Constants" section below.//// 2. Fill in the appropriate information under the "Authorize.net// Credentials" below.//// 3. (Optional) Select to use the Live or Test server/account.// Default=Test.//// 4. Find the "How to apply your donation" section in the HTML and fix// up according to your needs (different options, checkboxes for// multi-select, etc.)//// 5. Find the comment "Make Description Here" below and modify the// following line to match the control(s) set up in step 3.//// 6. Test/Fix/Test/Deploy
//// [Fixup 1] Site Identity Constants//$SiteOwnerName = "Dixie Gas & Oil Corp.";$PageTitle = "Dixie Gas & Oil";$ReturnHomePage = "www.dixiegas.com";
//// [Fixup 2] Authorize.net Credentials//// Note: The Test account credentials are for my own test account, but you// can replace them with your own if you have one.//$LiveLoginId = "6qSD82eFL";$LiveTransactionKey = "6367y2hfmYy8LEfe";
$TestLoginId = "6qSD82eFL";$TestTransactionKey = "6367y2hfmYy8LEfe";
//// [Fixup 3] Choose live or test server/account//$UseTestAccount = true;
//// Now set the global vars used to process the request//$LiveGatewayUrl = "https://secure.authorize.net/gateway/transact.dll";$TestGatewayUrl = "https://test.authorize.net/gateway/transact.dll";
if ($UseTestAccount) { $loginid = $TestLoginId; $x_tran_key = $TestTransactionKey; $gateway_url = $TestGatewayUrl;} else { $loginid = $LiveLoginId; $x_tran_key = $TestTransactionKey; $gateway_url = $LiveGatewayUrl;}
//// Other Global Vars//$doredirect = false;
//// Includes//
//// did form submit??//if (isset($HTTP_POST_VARS["formSubmitted"])){ $strFirstName = $HTTP_POST_VARS["x_first_name"]; $strLastName = $HTTP_POST_VARS["x_last_name"]; // // [Fixup 5] Make Description Here // $strDescription = "[ApplyTo:". trim($HTTP_POST_VARS["ApplyTo"])."] + [Country:" . trim($HTTP_POST_VARS["ForCountry"])."]"; $amount = $HTTP_POST_VARS["x_amount"]; if (substr($amount, 0,1) == "$") { $amount = substr($amount,1); } if (is_numeric($amount)) { $doredirect=true; } else { $msg = "Please enter only a numeric amount."; }}?>
<?if ($doredirect == false){?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Online Payment</title> <meta name="description" content="<? echo $SiteOwnerName ?>"> <meta name="resource-type" content="document"> <meta name="revisit-after" content="14 days"> <meta name="classification" content="consumer"> <meta name="keywords" content="<? echo $SiteOwnerName ?>"> <meta name="robots" content="All"> <meta name="distribution" content="global"> <meta name="rating" content="general"> <meta name="copyright" content="2008"> <meta name="web author" content="Interdimensional Designs: wwww.interdimensionaldesigns.com"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
02-01-2010 04:19 PM
<style type="text/css">
<!--
fieldset
{
float: left;
clear: left;
width: 400px;
margin: 0 0 0 0;
padding: 0em 1em 1em 0;
border: none;
}
fieldset legend
{
font-size: 1em;
margin-right: 0;
padding: 0;
font-family: Corbel, Geneva, Arial, Helvetica, sans-serif;
font-size: 1.5em;
font-weight: 600;
}
fieldset ol
{
padding: 0;
border-top: solid 1px black;
list-style: none;
margin-left: 10px;
margin-top: 2px;
}
fieldset li
{
padding: 0 0 0 0;
float: left;
clear: left;
margin: 4px 10px 0 0;
width: 100%;
vertical-align: top;
}
fieldset label
{
float: left;
font-size: 1em;
width: 60%;
margin-top: 3px;
text-align: left;
}
fieldset input
{
width: 95%;
}
fieldset select
{
width: 38%;
}
fieldset input.btn-submit
{
margin-top: 10px;
text-align: center;
width:250px;
}
-->
</style>
<script language="JavaScript">
<!--
function IsNumeric(sText)
{
var ValidChars = "0123456789.";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++) {
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1) {
IsNumber = false;
}
}
if (IsNumber==false) {
alert('Please enter only a number.');
document.getElementById("formsub").innerHTML = "";
}
else {
document.getElementById("formsub").innerHTML =
"<input type=\"submit\" class=\"btn-submit\" value=\"Click " +
"here for secure payment form\" /><input type=\"hidden\" " +
"name=\"formSubmitted\" value=\"1\"/>";
}
}
// -->
</script>
</head>
<html>
<body>
<p style="font-weight: bold; font-family:Arial, Helvetica, Sans-Serif; font-size: 14px;">
<? echo "$SiteOwnerName - $PageTitle" ?>
</p>
<? if ($msg<>"") {echo "<p color=red>$msg</p>";} ?>
<form method="POST" action="http://www.interdimensionaldesigns.com/exform.php">
<div style="text-align:left; font-family: Verdana; font-size:.8em;">
<fieldset>
<legend>
Enter the amount you wish to pay on your bill.
</legend>
02-01-2010 04:20 PM
<ol> <li> <label for="x_first_name"> *First name: </label> <input type="text" name="x_first_name" size="30"/> </li> <li> <label for="x_last_name"> *Last name:</label> <input type="text" name="x_last_name"/> </li> <li> <label for="x_amount" > *Amount: $ </label> <input type="text" name="x_amount" onblur="IsNumeric(this.value);"/> </li> <li id="formsub"> <input type="submit" class="btn-submit" value="Click here for secure payment form" /> <input type="hidden" name="formSubmitted" value="1"/> </li> </ol> </fieldset> </div></form><? } else {// DO REDIRECT srand(time()); $sequence = rand(1, 1000); // Insert the form elements required for SIM by calling InsertFP $timestamp = time(); $fingerprint = hash_hmac("md5", $loginid."^".$sequence."^".$timestamp."^".$amount."^", $x_tran_key); $fields = array( 'x_fp_sequence'=>$sequence, 'x_fp_timestamp'=>$timestamp, 'x_fp_hash'=>$fingerprint, 'x_description'=>$strDescription, 'x_login'=>$loginid,
'x_show_form'=>"PAYMENT_FORM", 'x_first_name'=>$strFirstName, 'x_last_name'=>$strLastName, 'x_amount'=>$amount, 'x_header_html_payment_form'=>"<div style='font-family: Verdana; font-size: 18px; font-weight: bold;'><i>Thank You</i> from $SiteOwnerName.</div>", 'x_footer_html_payment_form'=>"<span style='font-style:italic; font-size:.8em;'>God Bless</span>", 'x_receipt_link_method'=>"LINK", 'x_receipt_link_text'=>"Return to $SiteOwnerName site", 'x_receipt_link_url'=>"http://$ReturnHomePage" ); echo "<html><head></head><body>"; echo "<form name='myform' action='$gateway_url' method='post'>"; foreach ($fields as $key => $value) { print "<input type='hidden' name='".$key."' value=\"".$value."\">"; $fields_string .= "$key=$value"; } echo "</form>";?><script language="javascript" type="text/javascript">document.myform.submit();</script><?}?></body></html>
02-01-2010 04:20 PM
So that's the code in 3 parts. I tried to put it in w/ insercode but it wouldn't let me.
02-01-2010 04:21 PM
Looks like your code got borked somewhere along the line. I pieced it back together and I think found your problem. Your server may not like $HTTP_POST_VARS. I replaced them with $_POST. Try it out and let me know how it goes. (FYI, I took out your login info so you'll need to replace it. It's generally not a good idea to make that public. I;d replace the transaction key when you go live.)
<?php
//
// How to use this page...
//
// NOTE: You can search for [Fixup #] (with the square brackets), where #
// is the step number from below, to find where in the code to make
// the changes.
//
// 1. Fill in the appropriate information under the "Site Identity
// Constants" section below.
//
// 2. Fill in the appropriate information under the "Authorize.net
// Credentials" below.
//
// 3. (Optional) Select to use the Live or Test server/account.
// Default=Test.
//
// 4. Find the "How to apply your donation" section in the HTML and fix
// up according to your needs (different options, checkboxes for
// multi-select, etc.)
//
// 5. Find the comment "Make Description Here" below and modify the
// following line to match the control(s) set up in step 3.
//
// 6. Test/Fix/Test/Deploy
//
// [Fixup 1] Site Identity Constants
//
$SiteOwnerName = "Dixie Gas & Oil Corp.";
$PageTitle = "Dixie Gas & Oil";
$ReturnHomePage = "www.dixiegas.com";
//
// [Fixup 2] Authorize.net Credentials
//
// Note: The Test account credentials are for my own test account, but you
// can replace them with your own if you have one.
//
$LiveLoginId = "";
$LiveTransactionKey = "";
$TestLoginId = "";
$TestTransactionKey = "";
//
// [Fixup 3] Choose live or test server/account
//
$UseTestAccount = true;
//
// Now set the global vars used to process the request
//
$LiveGatewayUrl = "https://secure.authorize.net/gateway/transact.dll";
$TestGatewayUrl = "https://test.authorize.net/gateway/transact.dll";
if ($UseTestAccount) {
$loginid = $TestLoginId;
$x_tran_key = $TestTransactionKey;
$gateway_url = $TestGatewayUrl;
} else {
$loginid = $LiveLoginId;
$x_tran_key = $TestTransactionKey;
$gateway_url = $LiveGatewayUrl;
}
//
// Other Global Vars
//
$doredirect = false;
//
// Includes
//
//
// did form submit??
//
if (isset($_POST["formSubmitted"])){
$strFirstName = $_POST["x_first_name"];
$strLastName = $_POST["x_last_name"];
//
// [Fixup 5] Make Description Here
//
$strDescription = "[ApplyTo:". trim($_POST["ApplyTo"])."] + [Country:" . trim($_POST["ForCountry"])."]";
$amount = $_POST["x_amount"];
if (substr($amount, 0,1) == "$") {
$amount = substr($amount,1);
}
if (is_numeric($amount))
{
$doredirect=true;
} else {
$msg = "Please enter only a numeric amount.";
}
}
if ($doredirect == false)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Online Payment</title>
<meta name="description" content="<? echo $SiteOwnerName ?>">
<meta name="resource-type" content="document">
<meta name="revisit-after" content="14 days">
<meta name="classification" content="consumer">
<meta name="keywords" content="<? echo $SiteOwnerName ?>">
<meta name="robots" content="All">
<meta name="distribution" content="global">
<meta name="rating" content="general">
<meta name="copyright" content="2008">
<meta name="web author" content="Interdimensional Designs: wwww.interdimensionaldesigns.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
fieldset
{
float: left;
clear: left;
width: 400px;
margin: 0 0 0 0;
padding: 0em 1em 1em 0;
border: none;
}
fieldset legend
{
font-size: 1em;
margin-right: 0;
padding: 0;
font-family: Corbel, Geneva, Arial, Helvetica, sans-serif;
font-size: 1.5em;
font-weight: 600;
}
fieldset ol
{
padding: 0;
border-top: solid 1px black;
list-style: none;
margin-left: 10px;
margin-top: 2px;
}
fieldset li
{
padding: 0 0 0 0;
float: left;
clear: left;
margin: 4px 10px 0 0;
width: 100%;
vertical-align: top;
}
fieldset label
{
float: left;
font-size: 1em;
width: 60%;
margin-top: 3px;
text-align: left;
}
fieldset input
{
width: 95%;
}
fieldset select
{
width: 38%;
}
fieldset input.btn-submit
{
margin-top: 10px;
text-align: center;
width:250px;
}
-->
</style>
<script type="text/javascript">
<!--
function IsNumeric(sText)
{
var ValidChars = "0123456789.";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++) {
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1) {
IsNumber = false;
}
}
if (IsNumber==false) {
alert('Please enter only a number.');
document.getElementById("formsub").innerHTML = "";
}
else {
document.getElementById("formsub").innerHTML =
"<input type=\"submit\" class=\"btn-submit\" value=\"Click " +
"here for secure payment form\" /><input type=\"hidden\" " +
"name=\"formSubmitted\" value=\"1\"/>";
}
}
// -->
</script>
</head>
<body>
<p style="font-weight: bold; font-family:Arial, Helvetica, Sans-Serif; font-size: 14px;">
<?php echo SITE_NAME . " - Donations" ?>
</p>
<?php if ($msg<>"") {echo "<p color=red>$msg</p>";} ?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div style="text-align:left; font-family: Verdana; font-size:.8em;">
<fieldset>
<legend>
Enter the amount you wish to pay on your bill.
</legend>
<ol>
<li>
<label for="x_first_name">
*First name: </label>
<input type="text" name="x_first_name" size="30"/>
</li>
<li>
<label for="x_last_name">
*Last name:</label>
<input type="text" name="x_last_name"/>
</li>
<li>
<label for="x_amount" >
*Amount: $ </label>
<input type="text" name="x_amount"
onblur="IsNumeric(this.value);"/>
</li>
<li id="formsub">
<input type="submit" class="btn-submit"
value="Click here for secure payment form" />
<input type="hidden" name="formSubmitted" value="1"/>
</li>
</ol>
</fieldset>
</div>
</form>
<?
} else {// DO REDIRECT
srand(time());
$sequence = rand(1, 1000);
// Insert the form elements required for SIM by calling InsertFP
$timestamp = time();
$fingerprint = hash_hmac("md5", $loginid."^".$sequence."^".$timestamp."^".$amount."^", $x_tran_key);
$fields = array(
'x_fp_sequence'=>$sequence,
'x_fp_timestamp'=>$timestamp,
'x_fp_hash'=>$fingerprint,
'x_description'=>$strDescription,
'x_login'=>$loginid,
'x_show_form'=>"PAYMENT_FORM",
'x_first_name'=>$strFirstName,
'x_last_name'=>$strLastName,
'x_amount'=>$amount,
'x_header_html_payment_form'=>"<div style='font-family: Verdana; font-size: 18px; font-weight: bold;'><i>Thank You</i> from $SiteOwnerName.</div>",
'x_footer_html_payment_form'=>"<span style='font-style:italic; font-size:.8em;'>God Bless</span>",
'x_receipt_link_method'=>"LINK",
'x_receipt_link_text'=>"Return to $SiteOwnerName site",
'x_receipt_link_url'=>"http://$ReturnHomePage"
);
echo "<html><head></head><body>";
echo "<form name='myform' action='$gateway_url' method='post'>";
foreach ($fields as $key => $value) {
print "<input type='hidden' name='".$key."' value=\"".$value."\">";
$fields_string .= "$key=$value";
}
echo "</form>";
?>
<script language="javascript" type="text/javascript">
document.myform.submit();
</script>
<?
}
?>
</body>
</html>
02-01-2010 04:51 PM - edited 02-01-2010 04:52 PM
Let's troubleshoot this. Change:
if (isset($_POST["formSubmitted"])){ $strFirstName = $_POST["x_first_name"]; $strLastName = $_POST["x_last_name"];
to:
if (isset($_POST["formSubmitted"])){ echo "made it here!"; exit; $strFirstName = $_POST["x_first_name"]; $strLastName = $_POST["x_last_name"];
If that prints then we're making to the code that handles the form submission. If it doesn't then that's the isue we need to resolve.
02-01-2010 05:12 PM
ok that worked
02-01-2010 05:22 PM