pikaju / flutter-braintree

Flutter plugin that wraps the native Braintree SDKs. Enables payments with credit cards, PayPal, Google Pay and more.
https://pub.dev/packages/flutter_braintree
MIT License
64 stars 116 forks source link

Why is the amount a String? #67

Closed felixjaehn closed 1 year ago

felixjaehn commented 3 years ago

This is just something I would like to know. When using this package, I was wondering why we handle the amount as a String. In this case, will PayPal carry out the internalization and adapt the format of the amount to the local conditions (3.00 vs. 3.00) or do I have to format the transferred string myself? I was just wondering if this could lead to any problems when doing so.

Thank you!

pikaju commented 1 year ago

It's a string to avoid rounding errors caused by floating point math. See https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency

You should format your string as follows: 1234567.89