-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amount in price should be int and in paise for INR #39
Comments
Cryptocurrencies have decimals beyond the traditional two. Floats should be fine. |
@batramanuj - your comments? |
Hi @batramanuj pls share your comments on this |
Along with the problem mentioned above, arithmetic operations on two float/Double values can result in loss of precision which is certainly how we don't want to handle money.Using a long data type we can represent amount as integers in their lowest currency denominations without having to ever worry about precision. Same approach gets followed in UPI. |
@pramodkvarma @core-wg-admin - for your comments |
I generally prefer the amount to be represented as two separate integer values. At base protocol level we can support both integer and decimal representations. We should also ensure we explicitly capture currency. @core-wg-admin |
The problem is float comparison.
1.0 != 1.000000001 but with floats passing around without bounded with decimal points, we will run into these problems.
The 2 most popular payment gateway (Strip and Razorpay) use paise/cents instead thus forcing these to be integers. That works wonderfully well.
Another alternative solution if to fix the maximum possible decimal points to 2 (Cashfree does this).
Current unbonded decimal space amount though will lead to trouble in future.
Links below for reference --
https://stripe.com/docs/api/orders_v2/object
https://docs.cashfree.com/reference/createorder
https://razorpay.com/docs/api/orders/
@BLR-0118 @core-wg-admin
The text was updated successfully, but these errors were encountered: