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>

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

newtek_randominvoice.html.zip

Javascript

Locate this section:

<script type="text/javascript">
     var submitted = false;
     function submitform()
     {
       if(submitted) {
         return false;
       }
       submitted=true;
       document.epayform.submitbutton.value='Please Wait... Processing';
       return true;
     }
</script>

Insert a new line directly below and add the following code:

<script type="text/javascript">
    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>

HTML

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:

<div class="form-group">
  <span class="col-form-label col-sm-4 col-xs-12 ">Invoice Number</span>
  <div class="col-md-8 col-xs-12 ">
    <input id="UMinvoice" name="UMinvoice" class="form-control displayonly" type="text"  readonly="readonly" placeholder="Invoice Number" value="[UMinvoice]">
  </div>
</div>

and replace with the following:

<div class="form-group">
  <span class="col-form-label col-sm-4 col-xs-12 ">Invoice Number</span>
  <div class="col-md-8 col-xs-12 ">
    <input id="UMinvoice" name="UMinvoice" class="form-control displayonly" type="text"  readonly="readonly" placeholder="Order Number" value="[UMinvoice]">
  </div>
</div>

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 the invoice number will be automatically populated.