Would anyone have a clue as to how to rewrite a shopping cart code to add the Authorize.Net AIM module. This shopping cart has a half dozen payment modules but they all go off site. The AIM module allows you to stay on your own site.
This is mainly due to the fact that the shopping cart script currently doesn’t have any logic to collect customer’s credit card information (for any gateway).
So in order to implement AIM with this script, the code must be modified/re arranged.
Can anyone do this? I've tried to include all the code but it's too long for this forum. I'll just include the Authorize net portion and will send a zip to anyone who wants to look at it. The cart is called CubeCart and can be downloaded free at:
// AUTHORIZE.NET
// may need attention
// data to be sent in order to make payments with Authorize.net only acceptable when hosted on secure server
if ($gateway=="Authorize")
{
$x_Description = $site_business - Order;
$x_Amount = $payable;
$x_Description = $HTTP_GET_VARS['x_Description'];
$x_Amount = $HTTP_GET_VARS['x_Amount'];
// *** IF YOU WANT TO PASS CURRENCY CODE do the following: ***
// Assign the transaction currency (from your shopping cart) to $currencycode variable
if ($x_Description == "")
$x_Description = $HTTP_POST_VARS['x_Description'];
if ($x_Amount == "")
$x_Amount = $HTTP_POST_VARS['x_Amount'];
?>
<FORM action="https://secure.authorize.net/gateway/transact.dll" name="SecureForm" target="_self" method="POST">
<?
// authdata.php contains the loginid and txnkey.
// You may use a more secure alternate method to store these (like a DB / registry).
// get account data
// Authorize.net requires the php function mhash(); to be instaled on the server
$sql_select = mysql_query( "select * from ".$prefix."store_gateways where gateway='Authorize'");
while ($row = mysql_fetch_array($sql_select))
{
$loginid = $row["cust1"];
$txnkey = $row["cust2"];
}
include ("simlib.php");
$amount = $payable;
// Trim $ sign if it exists
if (substr($amount, 0,1) == "$")
{
$amount = substr($amount,1);
}
// I would validate the Order here before generating a fingerprint
// Seed random number for security and better randomness.
srand(time());
$sequence = rand(1, 1000);
// Insert the form elements required for SIM by calling InsertFP
$ret = InsertFP ($loginid, $txnkey, $amount, $sequence);
// IF YOU ARE PASSING CURRENCY CODE uncomment and use the following instead of the InsertFP invocation above
// $ret = InsertFP ($loginid, $txnkey, $amount, $sequence, $currencycode);
// Insert rest of the form elements similiar to the legacy weblink integration
echo ("<input type=\"hidden\" name=\"x_Description\" value=\"" . $x_Description . "\">\n" );
echo ("<input type=\"hidden\" name=\"x_login\" value=\"" . $loginid . "\">\n");
echo ("<input type=\"hidden\" name=\"x_Amount\" value=\"" . $amount . "\">\n");
echo ("<input type=\"hidden\" name=\"x_Invoice\" value=\"" . $cart_order_id . "\">\n");
// IF YOU ARE PASSING CURRENCY CODE uncomment the line below **
//echo ("<input type=\"hidden\" name=\"x_currency_code\" value=\"" . $currencycode . "\">\n");
// NOTES: Authorize.net must have Reciept and relay respons set to confirmed.php and set reciept method to LINK not POST or GET
?>
<!-------begin section modified by Mr Eyecandy----->
<INPUT type='hidden' name='x_show_form' value='PAYMENT_FORM'>
<INPUT type='hidden' name='x_test_request' value='FALSE'>
<INPUT type='hidden' name='x_Method' value='CC'>
<INPUT type='hidden' name='x_Type' value='AUTH_CAPTURE'>
<INPUT type='hidden' name='cart_order_id' value='<?php echo $cart_order_id;?>'>
<INPUT type='hidden' name='total' value='<?php echo $payable;?>'>
<INPUT type='hidden' name='x_Cust_ID' value='<?php echo $email;?>'>
<INPUT type='hidden' name='x_Amount' value='<?php echo $payable;?>'>
<INPUT type='hidden' name='x_Description' value='<?php echo $site_name;?>'>
<INPUT type='hidden' name='x_Invoice_Num' value='<?php echo $cart_order_id;?>'>
<INPUT type='hidden' name='x_First_Name' value='<?php echo $name;?>'>
<INPUT type='hidden' name='x_Address' value='<?php echo $add_1;?>'>
<INPUT type='hidden' name='x_City' value='<?php echo $town;?>'>
<INPUT type='hidden' name='x_State' value='<?php echo $county;?>'>
<INPUT type='hidden' name='x_Zip' value='<?php echo $postcode;?>'>
<INPUT type='hidden' name='x_Country' value='<?php echo $country;?>'>
<INPUT type='hidden' name='x_Phone' value='<?php echo $phone;?>'>
<INPUT type='hidden' name='x_Email' value='<?php echo $email;?>'>
<INPUT type='hidden' name='session' value='<?php echo $session;?>'>
<INPUT type='hidden' name='x_Ship_To_First_Name' value='<?php echo $name_d;?>'>
<INPUT type='hidden' name='x_Ship_To_Address' value='<?php echo $add_1_d;?>'>
<INPUT type='hidden' name='x_Ship_To_City' value='<?php echo $town_d;?>'>
<INPUT type='hidden' name='x_Ship_To_State' value='<?php echo $county_d;?>'>
<INPUT type='hidden' name='x_Ship_To_Zip' value='<?php echo $postcode_D;?>'>
<INPUT type='hidden' name='x_Ship_To_Country' value='<?php echo $country_D;?>'>
<INPUT type='hidden' name='x_customer_ip' value='<?php echo $ip;?>'>
<INPUT type='hidden' name='x_Email_Customer' value='TRUE'>
<INPUT type='hidden' name='x_Email_Merchant' value='TRUE'>
<INPUT type='hidden' NAME='x_Relay_Response' VALUE='TRUE'>
<INPUT type='hidden' NAME='x_Relay_URL' VALUE='<?php echo"$site_url/confirmed.php";?>'>
<!-----end section modified by Mr Eyecandy----->
<?
}// end of Authorize.Net
Thanks,
Appmanwww.cubecart.com