var iMinorUnit = 0;
function Decimals(x, dec_sep) {
var tmp=new String(); tmp=x; if (tmp.indexOf(dec_sep)>-1) return tmp.length-tmp.indexOf(dec_sep)-1; else return 0; }
function startPayment() { var objForm = document.getElementById("ePayForm"); var objAmount = objForm.useramount;
if (objForm.orderid.value.length == 0) { alert("Please enter a invoice number correctly."); objForm.orderid.focus(); return false; }
if (objAmount.value.length < 1 || objAmount.value == "") { alert("You need to enter the amount!"); objAmount.focus(); return false; } else if (objAmount.value.indexOf(".") > -1 || Decimals(objAmount.value, ",") > 2) { alert("The amount may not contain the character . (Period). Decimals must be indicated by ,. Eg. 199,95"); objAmount.focus(); return false; }
var amount = trimString(objAmount.value);
if (iMinorUnit == "-1") { alert("You entered an invalid amount: The amount can contain only numbers."); objAmount.focus(); return false; } else if (iMinorUnit == "0") amount = parseInt(amount) * 100;
if(objForm.name){ if(objForm.name.value.length < 2){ alert("Please enter your name"); return false; } } var epayOrderID = objForm.orderid.value; var epayAmount = amount; var epayCurrency = objForm.currency.value; var epayMerchantnumber = "8883903"; var epayAccepturl = "http://kolding.magdev.dk/faktura-betaling/&accept=1"; var epayCallbackurl = "http://kolding.magdev.dk/wp-content/plugins/epay/epay.php?epay_callback=1"; var epayDeclineurl = "http://kolding.magdev.dk/faktura-betaling/"; var epayDescription= ""; var epayOwnreceipt = "1"; var epayCms = "wordpress_invoice"; var epayGroup = ""; var epayInstantcapture = "0"; var epayAuthsms = ""; var epayAuthmail = ""; var epayWindowstate = "1"; epayAccepturl = epayAccepturl + "&cemail=" + objForm.email.value + "&cname=" + objForm.name.value + "&caddress=" + objForm.address.value + "&ccountry=" + objForm.country.value + "&cphone=" + objForm.phone.value + "&ccomment=" + objForm.comment.value; epayCallbackurl = epayCallbackurl + "&cemail=" + objForm.email.value + "&cname=" + objForm.name.value + "&caddress=" + objForm.address.value + "&ccountry=" + objForm.country.value + "&cphone=" + objForm.phone.value + "&ccomment=" + objForm.comment.value; var hashstring = epayOrderID + epayAmount + epayCurrency + epayMerchantnumber + epayAccepturl + epayCallbackurl + epayDeclineurl + epayDescription + epayOwnreceipt + epayCms + epayGroup + epayInstantcapture + epayAuthsms + epayAuthmail + epayWindowstate; paymentwindow = new PaymentWindow({ 'orderid': epayOrderID, 'amount': epayAmount, 'currency': epayCurrency, 'merchantnumber': epayMerchantnumber, 'accepturl': epayAccepturl, 'callbackurl': epayCallbackurl, 'cancelurl': epayDeclineurl, 'description': epayDescription, 'ownreceipt': epayOwnreceipt, 'cms': epayCms, 'group': epayGroup, 'instantcapture': epayInstantcapture, 'smsreceipt': epayAuthsms, 'mailreceipt': epayAuthmail, 'windowstate': epayWindowstate }); var objPoll = document.createElement("script"); objPoll.type = "text/javascript"; objPoll.src = "http://kolding.magdev.dk/wp-content/plugins/epay//epay.php?epay_md5=1&md5string=" + escape(hashstring); document.body.appendChild(objPoll); } function setMD5(str){ paymentwindow.options['hash'] = str; paymentwindow.open(); } function trimString(str) { iMinorUnit = 0; var tmp = String(str); var returnVal = ""; var cVal = ""; if (tmp != "") { for (var i = 0; i < tmp.length; i++) { cVal = tmp.substr(i, 1); if(!isNaN(cVal)) returnVal = returnVal + cVal; else { if(cVal != ",") { iMinorUnit = -1; break; } else iMinorUnit = 1; } } } return returnVal; }