Generating an Invoice Number

Overview

You can generate a unique invoice number for each transaction by adding a small script above the code you use to link to the payment form. The invoice number is not visible to your client and providing an invoice number with every transaction may also give you a better qualifying transaction rate - ask your merchant service provider for information about transaction rates and fees.

Source Code

Before you make any changes to the payment form itself, you will need to put the source code on your site. This will generate a value, that will post to the Order Number(UMinvoice) field.

<form action="https://secure.newtekgateway.com/interface/epayform/" name="form">
<input type="hidden" name="UMkey" value="SOURCE_KEY_GOES_HERE">
<input type="hidden" name="UMcommand" value="sale">
<input type="hidden" name="UMinvoice" value="">
<input type="hidden" name="UMdescription" value="Thank you for your payment">
<input type="submit" value="Continue to Payment Form">
</form>

<script language="JavaScript">
var d = new Date();
function f(n) { return n < 10 ? '0' + n : n; }

var random_num = Math.floor(Math.random() * (99999999999 -  10000000000)) + 10000000000;
random_num = d.getFullYear() + f(d.getMonth()+1) + f(d.getDate()) + random_num; 
document.form.UMinvoice.value = random_num;
</script>

Where it Goes

This code would go on your site, not on the actual payment form itself. This will generate a value that appears on your form with any other data you've posted to it.

What it looks like

The Order Number is the resulting unique invoice number for your transaction.

Random Invoice

Download Source Code

The Zip file contains an HTML page with the above code. Just plug in your source key to make it live.

newtek_randominvoice.zip

On the payment form

In the header of the document, add the following code:

<script>
function addInvoice() {
var d = new Date();
function f(n) { return n < 10 ? '0' + n : n; }  

var random_num = Math.floor(Math.random() * (99999999999 -  10000000000)) + 10000000000;
document.epayform.UMinvoice.value = random_num;
document.getElementById('invoice').innerHTML = random_num ;

}
</script> 

Locate the below command in the list of hidden values, and delete it:

<input type="hidden" name="UMinvoice" value="[UMinvoice]">

Find the following code in your form:

      <tr>
      <td bgcolor="#F0F0F0" width="234" align="right"><font size="2" face="Verdana">Order Amount:</font></td>
      <td bgcolor="#F0F0F0" width="450">[UMamount]
      </td>
      </tr>

And replace it with this:

                 <tr>
            <td bgcolor="#F0F0F0" width="234" align="right"><font face="Verdana" size="2">Order Amount:
            </font></td>
            <td bgcolor="#F0F0F0" width="450">
            <input type="text" name="UMamount" onClick="addInvoice()" size="25" value="[UMamount]"></td>
        </tr>

Find the following code in your form:

      <tr>
      <td bgcolor="#F0F0F0" width="234" align="right"><font size="2" face="Verdana">Order Number:</font></td>
      <td bgcolor="#F0F0F0" width="450">[UMinvoice]
      </td>
      </tr>

and replace with the following:

                 <tr>
            <td bgcolor="#F0F0F0" width="234" align="right"><font size="2" face="Verdana">Order Number:</font></td>
            <td bgcolor="#F0F0F0" width="450"><input type="hidden" name="UMinvoice"><div id="invoice"></div></td>
        </tr>

Save the changes to your form. Once the form is saved, the customer will be able to type in the amount they are paying and automatically have an invoice number.