Quantity

Adding quantity

This code is for adding a quantity field to your payment form. The form takes the quantity and multiplies it by a base amount you set in the form. The below example assumes you are using the default payment form without any changes.

Log into your Newtek Gateway merchant gateway. Go to "Settings", then "Source Keys". Select the source key you are using and click "Edit". Click "Edit Customization to Epay Form". In the header of the document, add the following code: Follow the above instructions for adding a quality field to your form, but use the following Javascript:

<script>
      function addCharge() 
      {
      var baseamount = document.epayform.baseamount.value ; 
      var quantity = document.epayform.UMquantity.value ;
      var total = (baseamount*1)*quantity;
      document.epayform.UMamount.value = total ;
      document.getElementById('totalamount').innerHTML = CurrencyFormatted(total) ;
      }
</script>
<script>
function CurrencyFormatted(amount)
{
    var i = parseFloat(amount);
    if(isNaN(i)) { i = 0.00; }
    var minus = '';
    if(i < 0) { minus = '-'; }
    i = Math.abs(i);
    i = parseInt((i + .005) * 100);
    i = i / 100;
    s = new String(i);
    if(s.indexOf('.') < 0) { s += '.00'; }
    if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
    s = minus + s;
    return s;
}
// end of function CurrencyFormatted()


</script>
  • Find and delete the following code in your form:

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

  • 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>

Replace it with the following:

<tr>
      <td bgcolor="#F0F0F0" width="234" align="right"><font size="2" face="Verdana">Payment Amount:</font></td>
      <td bgcolor="#F0F0F0" width="450"><input type="hidden" name="baseamount" value="10.00" size=10>10.00
      </td>
      </tr>
      <tr>
      <td bgcolor="#F0F0F0" width="234" align="right"><font size="2" face="Verdana">Quantity:</font></td>
      <td bgcolor="#F0F0F0" width="234"><input name="UMquantity" type="text" size=2   onChange="addCharge()"></input></td>
      </tr>
      <tr>
      <td bgcolor="#F0F0F0" width="234" align="right"><font size="2" face="Verdana">Total Charge:</font></td>
      <td bgcolor="#F0F0F0" width="450"><input type="hidden" name="UMamount" value="[UMamount]"><div id="totalamount"></div>
      </td>
</tr>