Skip to content
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

Open
mahoriR opened this issue May 19, 2022 · 6 comments
Open

Amount in price should be int and in paise for INR #39

mahoriR opened this issue May 19, 2022 · 6 comments

Comments

@mahoriR
Copy link

mahoriR commented May 19, 2022

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

@amitabhdhiwal
Copy link

Cryptocurrencies have decimals beyond the traditional two. Floats should be fine.

@BLR-0118
Copy link
Member

@batramanuj - your comments?

@BLR-0118
Copy link
Member

Hi @batramanuj pls share your comments on this

@batramanuj
Copy link

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.

@BLR-0118
Copy link
Member

@pramodkvarma @core-wg-admin - for your comments

@pramodkvarma
Copy link

pramodkvarma commented Jul 10, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants