Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 426
Tower Avatar asked Apr 07 '26 03:04

Tower


1 Answers

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).

like image 74
Michael Borgwardt Avatar answered Apr 09 '26 17:04

Michael Borgwardt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!