-
Notifications
You must be signed in to change notification settings - Fork 132
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
Some ApplePay amounts may be wrong in some locales. #84
Comments
ACK @kristoffer-zliide. Thank you for bringing it up. NSDecimalNumber(value: Double(item["amount"] as! String)!) There's the more explicit alternative to use a number formatter, though I don't think the extra overhead justifies the marginal added clarity. |
I don't really know anything about Apple's APIs, sorry. I just thought that since you're representing decimal numbers as strings, there must be bugs in there, and, lo and behold, there was. Next up are all the bugs people using this plugin will make converting their decimal amounts to strings to pass them to this plugin. How to fix those? I can't help thinking the right way to go is using Note that these bugs probably won't be caught during regular QA, as this issue also demonstrates, since all test devices use a locale where it works, so bugs that cause payment to fail sometimes for some people will be released to the public. |
This is indeed a situation where there's going to be discrepancies between platforms (Apple Pay using
Looking at it from the eyes of this plugin, choosing either of them would require converting to/from the types on one of the platforms, so another question to ask is whether it's preferable to convert from a number to a string on Android, or from a string to a number on iOS. They seem equivalent to me. All in all, it mostly comes down to dev preference on whether to work with numbers or strings when defining a price amount for an item. To me, both options are equally reasonable. For now, I'll add a PR to take localization out of the equation when converting amounts on iOS. In the meantime, it's worthwhile considering opening up a new discussion on the topic to gather general thoughts/preferences from users of the library. |
Just to be clear, the |
Your assumption is correct. |
Regarding the use of
NSDecimalNumber
in https://github.com/google-pay/flutter-plugin/blob/main/pay_ios/ios/Classes/PaymentHandler.swift#L125, please read the Discussion section in https://developer.apple.com/documentation/foundation/nsdecimalnumber/1409902-init.Should amounts really be strings? What are the odds of users of this plugin will convert their amounts to string correctly? It should always be with a
.
as decimal separator, right?The text was updated successfully, but these errors were encountered: