Created
August 5, 2021 18:40
-
-
Save drmzio/8032709490fa70413a0a50cf54d69d48 to your computer and use it in GitHub Desktop.
Stripe convert amount to float
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts Stripe amounts like 25000 to the currency amount like "250.00" in string format. | |
* @param amount - A stripe whole number amount. | |
* @return string | |
*/ | |
export const toFloatString = (amount) => { | |
const total = (amount / 100) | |
.toLocaleString('en-US', { style: 'currency', currency: 'usd' }) | |
.replace('$', ''); | |
return total.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment