recurly-client-go
recurly-client-go copied to clipboard
Library uses float which causes rounding errors
Describe the bug
The Go library uses float for monetary values. Float is widely discouraged as it does not contain the necessary precision to handle currency values.
To Reproduce
Fetch a credit invoice of $-79.99. Multiply by 100.0 and convert to an `int:
// invoice.Subtotal = -79.99
x = int(invoice.Subtotal * 100.0)
assert.equal(-7999, x)
Error: Not equal:
expected: -7999
actual : -7998
Expected behavior
Library should use a Decimal or other fixed-point
Your Environment
- Which version of this library are you using? v3.8.0 f4d23f429fa01778f037d3b88c04c380f8fd745d
- Which version of golang are you using? 1.14.9
Thank you for reporting this @Talljoe. We are aware of this limitation and are investigating solutions that we can employ in our upcoming 4.x client release. Updating the 3.x client would introduce a breaking change to existing implementations, unfortunately. We will leave this issue open and will provide updates when they become available.
Have there been any updates on this @douglasmiller?
This was 4 years ago and it's still not fixed in the product? I just submitted a support ticket. This issue results in incorrect billing calculations.