functions-samples icon indicating copy to clipboard operation
functions-samples copied to clipboard

Stripe functions example: incorrect type handling

Open garyo opened this issue 5 years ago • 0 comments

https://github.com/firebase/functions-samples/blob/5614dd71cddbe27512b41d662cc51d8d25f2a562/stripe/public/javascript/app.js#L275

In formatAmount it converts amount to a string using .toFixed(2), and then tries to pass that string to Intl.NumberFormat().format(), but that function only accepts numbers. I just convert it back to a number, assuming the intent is just to round to two decimal places. (Although if that's the case, you'd expect a similar rounding in the zeroDecimalCurrency case so I'm not sure what's really intended there.)

garyo avatar Oct 02 '20 16:10 garyo