Search code examples
phpjavascriptpayment-processing

Is it bad to implement a payment system using JavaScript?


I am wondering here is that is it a bad idea to implement a legal payment system using JavaScript on the client-side and PHP on the server-side? I am mainly worried about IEEE floating point and overly loose languages.


Solution

  • The main problem is Javascript, which doesn't even have a real integer type, let alone an (official) proper decimal library (PHP has BC Math). There is an old third-party port of Java's BigDecimal to Javascript you could use on the client side. Alternatively, calculate everything in cents, since an IEEE double can accurately represent integers up to 53 bits in length, which is enough to hold even the entire US sovereign debt for at least another 10 years (probably).