Reply
Posts: 1,609
Topics: 15
Kudos: 209
Solutions: 121
Registered: ‎06-23-2011

Re: Changing the amount in SIM Integration

No problem!

Member
Posts: 2
Registered: ‎01-17-2012

Re: Changing the amount in SIM Integration

I'm trying to place just the form into a block on one of my pages, hoping that the submit will open the Authorize.Net payment form directly. But it keeps opening the same form on a blank page.

 

Also, when I submit that form, it says the "getFP" function is not defined...

 

Please help.

Mark

Posts: 1,609
Topics: 15
Kudos: 209
Solutions: 121
Registered: ‎06-23-2011

Re: Changing the amount in SIM Integration

The first step is to post your code (in a code box, fourth option from the left in Rich Text mode) so we have something to debug.

Member
Posts: 2
Registered: ‎01-17-2012

Re: Changing the amount in SIM Integration

The code is basically the same as Dave wrote it, with my fix-ups. I'm trying to place just the form in a block (Concrete5) and have the click go straight to the A-net payment form to complete the transaction. Do I need to insert more than just the form code? How can I do it without revealing the transaction key? Thanks.

<?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 = "Site_Owner";
$PageTitle = "Title";
$ReturnHomePage = "www.mysite.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 = "xxxxx";
$LiveTransactionKey = "xxxxx";

$TestLoginId = "xxxxx";
$TestTransactionKey = "xxxxx";

//
// [Fixup 3] Choose live or test server/account
//
$UseTestAccount = false;

//
// 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
//
include ("anet_php_sdk/AuthorizeNet.php");

//
// 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>- Donations</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="ITDevWorks, LLC: wwww.itdevworks.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 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="authsim-amount.php">
    <div style="text-align:left; font-family: Verdana; font-size:.8em;">
        <fieldset>
        <legend>
        Donation Form
        </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" >
                *Donation Amount: $
                </label>
                <input type="text" name="x_amount"
                    onblur="IsNumeric(this.value);"/>
            </li>
            <li>
<?
                //
                // [Fixup 4]. Change these controls as per your requirements
                // 
?>
                
                <label for="ApplyTo">
                *How to apply your donation:
                </label>
                <select name="ApplyTo" id="ApplyTo">
                    <option value="As needed" selected>As needed</option>
                    <option value="A good cause">A good cause</option>
                    <option value="Good cause 2">Good cause 2</option>
                    <option value="Good cause 3">Good cause 3</option>
                    <option value="And so on">And so on...</option>
                </select>
            </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
    $ret = getFP($loginid, $x_tran_key, $amount, $sequence);
    $fields = array(  
        'x_fp_sequence'=>$sequence,  
        'x_fp_timestamp'=>$ret[1],  
        'x_fp_hash'=>$ret[0],  
        '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>

 

Posts: 1,609
Topics: 15
Kudos: 209
Solutions: 121
Registered: ‎06-23-2011

Re: Changing the amount in SIM Integration

Ick, giant wall of code. I'm afraid I'm not that familiar with Dave's code, so you're better off sending Dave a PM and asking him to comment here.