Certain merchants may want to create a convenience fee or handling charge that is added to the transaction total. We have example code for both flat fees and percentage fees.
This code is for adding a flat fee to each transaction that occurs on your payment form. The below example assumes you are using the default payment form without any changes.
Follow the above instructions for adding a flat-rate convenience fee to your account, but use the following Javascript:
<script>
function doTotal()
{
var form = document.epayform;
var amount = form.UMcustom1.value = form.UMcustom1.value.replace(/[^0-9\.]/, "");
var fee = Math.round(amount * .02*100)/100; // Don't forget to change the percentage here
var total = Math.round(((amount*1)+fee) *100)/100;
form.UMcustom2.value=fee;
form.UMamount.value=total;
document.getElementByName('UMcustom2').innerHTML = fee;
document.getElementByName('UMamount').innerHTML = total;
}
</script>
And the following HTML:
<tr>
<td bgcolor="#F0F0F0" width="234" align="right"><font size="2" face="Verdana">Payment Amount:</font></td>
<td bgcolor="#F0F0F0" width="450"><input type="text" name="UMcustom1" value="[UMcustom1]" size=10 onChange="doTotal()"></td>
</tr>
<tr>
<td bgcolor="#F0F0F0" width="234" align="right"><font size="2" face="Verdana">Service Fee (2%):</font></td> // Change the percentage here as well!
<td bgcolor="#F0F0F0" width="450"><input type=text name="UMcustom2" value="[UMcustom2]" readonly="readonly" onChange="doTotal()"></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=text name="UMamount" value="[UMamount]" readonly="readonly" onChange="doTotal()"></td>
</tr>
<script>
var servicefee = 3 ;
function addCharge()
{
var baseamount = document.epayform.baseamount.value ;
var total = (baseamount*1) + servicefee ;
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>
Html code is the same as in the example #1