cancel
Showing results for 
Search instead for 
Did you mean: 

Online payment form for SIM with customer's ability to put in invoice # and payment amount

We have a page on our website where customers can pay their invoices online.  Until a few weeks ago, this page was working. We’ve had this page for over a year and have not had any problems with it.  I've tried everything from uploading my old backups to going through the code line by line. I see no reason why it stopped working...

 

The page is supposed to behave as follows:

1)       Customers go to www.xtreme-exhibits.com/sim_gateway.php

2)       They are presented with a box where they can enter their invoice number and amount they want to pay.

3)       Then they select the “Verify Payment Amount” button

4)       they are given one final screen – a summary page – where they see the amount they entered and a button to “confirm payment”

5)       Then all this information that has been collected is forwarded to our secure Authorize.net merchant account – the payment gateway -- where the credit card is entered, etc…

 

This script which has been working for over a year, has ceased to function between steps 3 and 4.  I’ve checked with multiple programmers and no one can identify why the script has stopped working.  Now, when a customer completes step 3, they are returned to the same page and the boxes are cleared.  I welcome you to try it out yourself.

 

Since its stopping between steps 3 and 4 it seems like the information is not being temporarily stored anymore. It seems like the information is being dumped and the process is restarting rather than summarizing the invoice number and the payment amount and passing the data to Authorize.net.  I've gone round and round with our hosting provider (hostgator.com) and they have no reason on their end why it would stop working.  They ran a strace for me and suggested I post the problem to this board.  Here's a link to the strace:  http://xtreme-exhibits.com/strace.txt

Any ideas as to what could have happened in the last month?

Thanks so much for your suggestions!

 

1 ACCEPTED SOLUTION

Accepted Solutions

I think this confirms that register globals have been turned off on your server. Put this line of code at the top of your page and your problems should be solved:

 

<?php extract($_POST); ?>

 


-------------------------------------------------------------------------------------------------------------------------------------------
John Conde :: Certified Authorize.Net Developer (Brainyminds) :: Official Authorize.Net Blogger

NEW! Handling Authorize.Net's Webhooks with PHP

Integrate Every Authorize.Net JSON API with One PHP Class (Sample code included)

Tutorials for integrating Authorize.Net with PHP: AIM, ARB, CIM, Silent Post
All About Authorize.Net's Silent Post

View solution in original post

11 REPLIES 11

This is a PHP issue since the script never quite makes it to Authorize.Net. I'd be happy to take a peek at the code for you. If you can post it here please do and I'll review it. If not send me a private message with the code and I'll take a peek at it for you.

 

 

FYI, that web page isn't even close to being valid HTML. For starters I'd clean it up (i.e. add HTML, HEAD, BODY tags, etc). Although I doubt this is causing the issue it's always easier to troubleshoot things when you're working with proper code.


-------------------------------------------------------------------------------------------------------------------------------------------
John Conde :: Certified Authorize.Net Developer (Brainyminds) :: Official Authorize.Net Blogger

NEW! Handling Authorize.Net's Webhooks with PHP

Integrate Every Authorize.Net JSON API with One PHP Class (Sample code included)

Tutorials for integrating Authorize.Net with PHP: AIM, ARB, CIM, Silent Post
All About Authorize.Net's Silent Post
stymiee
Expert
Expert

Thank you so much for taking a look at this for me! Here's the code from the payment form on our server that's used to collect informaiton. If there's a simpler way to collect a one time payment where the customer can imput the invoice # and the payment amount, i'd love to implement it.  My knowledge is limited and the documentation doesn't address this sort of need... at least not that i can find :)

<?php

if ($action == "pay") {

$global_date = date("l F j, Y");



// Currency Code //

$x_currency = "USD";



// Parse Invoice //

$x_invoice = htmlspecialchars($x_invoice);

// Parsing of currency amount. //

$amount_owing = floatval($amount_owing);

$amount_owing = round($amount_owing,2);

$amount_owing = number_format($amount_owing, 2);

$amount_owing = str_replace(",", "", $amount_owing);

$amount_owing = str_replace("$", "", $amount_owing);

?>
<body bgcolor="#202020" text="#FFFFFF">
<table width=70% align="left">
  <tr><td valign=top>

<form method=post action=https://secure.authorize.net/gateway/transact.dll target=_parent>





<?

  // Authorize.net Username and Transaction Code //

  $loginid = "xxxxxxxx";

  $x_tran_key = "xxxxxxxxx";

  include ("simlib.php");



  // 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, $x_tran_key, $amount_owing, $sequence);

?>





<table width="100%" border="0" cellspacing="1" cellpadding="3">

  <tr valign="top">

          <td width="52%" align="left"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Invoice 
            Number:</font> <? echo $x_invoice; ?><br />
            </b></td>

          <td width="48%" align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Payment will be processed 
            on: <? echo $global_date; ?></b></font></td>

   </tr>

   <tr>

    <td width=100% colspan=2 height=15></td>

   </tr>

   <tr>

    <td width=55%>

<h3><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Total Invoiced Amount: 
              <? echo "\$$amount_owing"; ?></font></h3></td>

     <td width=45% align=right></td>

   </tr>

   <tr>

     <td width=

</table>

<input type=hidden name=x_invoice_num value="<? echo $x_invoice; ?>">

<input type=hidden name=x_amount value="<? echo $amount_owing; ?>">

<input type=hidden name=x_login value="<? echo $loginid; ?>">

<input type=hidden name=x_currency value="USD">

<input type=hidden name=data_currency value="<? echo $x_currency; ?>">

<input type=hidden name=data_converted value="<? echo "$cur_symbol$conversion_total"; ?>">

<INPUT type="hidden" name="x_show_form" value="PAYMENT_FORM">

<INPUT type="hidden" name="x_test_request" value="FALSE">

<center>

              <input name="submit" type=submit value="Confirm Payment">

            </center>

</form>

</td></tr></table>

<?php

}

else {

?>
<table width="70%" border="0" align="left" cellpadding="0" bordercolor="#202020" bgcolor="#202020">
  <tr>
    <td valign="top"> 
      <form method=post action=sim_gateway.php>
        <input type=hidden name=action value=pay><body bgcolor="#202020" text="#FFFFFF">
        <font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Thank 
        you for choosing to pay your invoice online. To insure your payment is 
        properly applied to your account, we ask that you first enter your invoice 
        number and the amount due. </font><font face="Verdana, Arial, Helvetica, sans-serif">
<p><font color="#FFFFFF" size="2">You will then be asked to confirm this information before 
          proceeding to our secure online payment form where you will enter your 
          credit card. </font></p>
        </font> 
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr valign="top"> 
            <td width="52%" align="left"><table>
                <tr> 
                  <td><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Invoice 
                    Number:</b></font></td>
                  <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
                    <input type=text name=x_invoice size=6>
                    </font></td>
                </tr>
              </table></td>
            <td width="48%" align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><? echo $global_date; ?></b></font></td>
          </tr>
          <tr> 
            <td width=100% colspan=2 height=7></td>
          </tr>
          <tr> 
            <td width=55%><table>
                <tr> 
                  <td><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Total 
                    Amount Due:</b></font></td>
                  <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
                    <input type=text name=amount_owing size=6 value="0.00">
                    </font></td>
                </tr>
              </table></td>
            <td width=45% align=right></td>
          </tr>
        </table>
        <center>
          <input name="submit2" type=submit value="Verify Payment Amount">
        </center>
      </form>
      <?php

}

?>
    </td>
  </tr>
</table>
<p>&nbsp;</p>

 

This code works on my local test server so I suspect your problems have to do with the settings on your server possibly having changed. Are you using shared hosting?

 

In the mean time try changing the first line of code from:

 

if ($action == "pay") {

 

to:

 

if ($_POST['action'] == "pay") {

 

My guess is that register globals has been turned off on your server causing the $action variable to have no value. If this is true the rest of your script will need to be changed as well since it relies heavily of register globals being turned on.

 

Let me know if this works.


-------------------------------------------------------------------------------------------------------------------------------------------
John Conde :: Certified Authorize.Net Developer (Brainyminds) :: Official Authorize.Net Blogger

NEW! Handling Authorize.Net's Webhooks with PHP

Integrate Every Authorize.Net JSON API with One PHP Class (Sample code included)

Tutorials for integrating Authorize.Net with PHP: AIM, ARB, CIM, Silent Post
All About Authorize.Net's Silent Post

Thanks for the suggestion! It definately did something...

 

now when i put in a value for the amount and the invoice number it DOES go to the confirmation page.  But it does not show the invoice # or the payment amount i put in on the first screen.  I tried clicking the submit button anyway just to see if it will go through to the web payment form.  But instead i get the following error:

 

The following errors have occurred.

(5) A valid amount is required. 

 

I think this confirms that register globals have been turned off on your server. Put this line of code at the top of your page and your problems should be solved:

 

<?php extract($_POST); ?>

 


-------------------------------------------------------------------------------------------------------------------------------------------
John Conde :: Certified Authorize.Net Developer (Brainyminds) :: Official Authorize.Net Blogger

NEW! Handling Authorize.Net's Webhooks with PHP

Integrate Every Authorize.Net JSON API with One PHP Class (Sample code included)

Tutorials for integrating Authorize.Net with PHP: AIM, ARB, CIM, Silent Post
All About Authorize.Net's Silent Post

Thank you so so much! It worked!!

Is there anyway you could post your final code? I can't get it to work and I'm thinking I missed something. Are there multiple PHP pages of code or just this one named sim_gateway.php? There appears to be another php page reference in your code

include ("simlib.php");

 

 

Thanks for any help you can give to a strugling Web designer who's client purchased Authorize.net without consulting with me first.

Hi,

 

Can you put your code for simlib.php and sim-gateway.php ?

 

thanks in advanced

I do not understand where I am going wrong. This form simply will not submit. Could you help me with my code? After i fill in the fields and click on the appropriate radio button I hit submit and it essentially refreshs. I just want our members to be able to imput the amount of their choosing. Thank you so much.

 

<?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 = "Christ Covenant Church";
$PageTitle = "Donate";
$ReturnHomePage = "www.christcovenant.org";


//
// [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.
//

$TestLoginId = "************";
$TestTransactionKey = "****************";

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

//
// Now set the global vars used to process the request
//
$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 = "[x_description:". trim($HTTP_POST_VARS["x_description"])."] + [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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <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>

<? if ($msg<>"") {echo "<p color=red>$msg</p>";} ?>                         
<form method="POST" action="sim-donate.php">
                <label for="x_amount" >
                *Donation Amount: $
                </label>
                <input type="text" name="x_amount"
                    onblur="IsNumeric(this.value);"/>

<?
                //
                // [Fixup 4]. Change these controls as per your requirements
                // 
?>
                
                <table width="809">
  <tr>
    <td><input type="radio" value="Tithe" name="x_description" />
      <strong>Tithe</strong> </td>
    <td><input type="radio" value="Faith Promise" name="x_description" />
      <strong>Faith Promise</strong></td>
    <td><strong>Kingdom Advancement Giving</strong></td>
    <td width="239"><strong>Special Projects &amp; Needs</strong></td>
    <td width="118"><input type="radio" value="Endowments" name="x_description" />
      <strong>Endowments</strong></td>
  </tr>
  <tr>
    <td width="74">&nbsp;</td>
    <td width="128">&nbsp;</td>
    <td width="226"><label>
      <input type="radio" name="x_description" value="Pastoral Interns" id="x_description_0" />
      Pastoral Interns</label></td>
    <td><label>
      <input type="radio" name="x_description" value="Mercy" id="x_description_5" />
      Mercy</label></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><label>
      <input type="radio" name="x_description" value="Covenant Day School" id="x_description_1" />
      Covenant Day School</label></td>
    <td><label>
      <input type="radio" name="x_description" value="Buildings/Debt/Capital Campaigns" id="x_description_6" />
      Buildings/Debt/Capital Campaigns</label></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><label>
      <input type="radio" name="x_description" value="Reformed Theological Seminary" id="x_description_2" />
      Reformed Theological Seminary</label></td>
    <td><label>
      <input type="radio" name="x_description" value="Campus Outreach" id="x_description_7" />
      Campus Outreach</label></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><label>
      <input type="radio" name="x_description" value="PCA Askings" id="x_description_3" />
      PCA Askings</label></td>
    <td><label>
      <input type="radio" name="x_description" value="SOAR" id="x_description_8" />
      SOAR</label></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><label>
      <input type="radio" name="x_description" value="Church Planting" id="x_description_4" />
      Church Planting</label></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<input type="submit" class="btn-submit"
                    value="Click here for secure payment form" />
                <input type="hidden" name="formSubmitted" value="1"/>

</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_amount'=>$amount,  
        'x_header_html_payment_form'=>"<div style='font-family: Verdana; font-size: 18px; font-weight: bold;'><i>Thank You</i> from Christ Covenant Church.</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>