for any APIs related to money, should the currency be in strings as opposed to in floats? This will prevent accidental float arithmetic in the code. I always find it tricky to work with currency in javascript.
No Abstractions: our API design principle
21–30 of 141 posts
Re: No Abstractions: our API design principle
#22for any APIs related to money, should the currency be in strings as opposed to in floats? This will prevent accidental float arithmetic in the code. I always find it tricky to work with currency in javascript.
Re: No Abstractions: our API design principle
#23for any APIs related to money, should the currency be in strings as opposed to in floats? This will prevent accidental float arithmetic in the code. I always find it tricky to work with currency in javascript.
I've always seen currencies multiplied by 100 to remove the need for floating point.
Re: No Abstractions: our API design principle
#24for any APIs related to money, should the currency be in strings as opposed to in floats? This will prevent accidental float arithmetic in the code. I always find it tricky to work with currency in javascript.
Re: No Abstractions: our API design principle
#25Earlier quoted context omitted.
Yes, exactly, the important thing to us is that our users don't need to build an additional mental model between us and the networks we sit atop. If you know the network, we want you to be able to intuit how our API works. There's a very real difference (arguably the fundamental value-add of our company) in the transport layer, though. The actual mechanics of integrating with, say, FedACH, are a bit long to get into…
That's an excellent point too. Some payment systems have abysmal technology. The product I worked on was focused on international payments and in a couple cases, the "API" was literally, "Upload a CSV file via FTP, and at some later point, another CSV file might appear on the FTP server with some of the payment results, but if it doesn't, call us because we probably just forgot to upload it."
Re: No Abstractions: our API design principle
#26for any APIs related to money, should the currency be in strings as opposed to in floats? This will prevent accidental float arithmetic in the code. I always find it tricky to work with currency in javascript.
Re: No Abstractions: our API design principle
#27Earlier quoted context omitted.
I've always seen currencies multiplied by 100 to remove the need for floating point.
Yeah, this seems like a common pattern. Not sure about currency with arbitrary place values though (like Bitcoin)
¹(where you need to; otherwise, I'd use some fixed point type if my language supports it)
Re: No Abstractions: our API design principle
#28Earlier quoted context omitted.
In this case, a HTTP API is the abstraction. Integrating with ACH and other payment rails requires a lengthy integration process. Sometime you have to send binary files using FTP!
The article says “no abstractions”, but HTTP is often exactly that: an abstraction over lower-level protocols.
Re: No Abstractions: our API design principle
#29for any APIs related to money, should the currency be in strings as opposed to in floats? This will prevent accidental float arithmetic in the code. I always find it tricky to work with currency in javascript.
Re: No Abstractions: our API design principle
#30for any APIs related to money, should the currency be in strings as opposed to in floats? This will prevent accidental float arithmetic in the code. I always find it tricky to work with currency in javascript.
You should never use floats for dinero. And it has nothing to do with JS, though i find it funny that you mention JS.