Skip to content

A simple js function to format numbers to stripe's smallest common currency unit format

License

Notifications You must be signed in to change notification settings

wmelton/stripe-money-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stripe Money format

A simple js utility to format numbers to Stripe's smallest common currency unit format

Supports most International Curriences.

Usage

ES6

import StripeMoneyFormat from "stripe-money-format";

const number = 86753.09;
console.log(StripeMoneyFormat.toStripeFormat(number)); // 8675309

CommonJS

const {toStripeFormat} = require("stripe-money-format");

const number = 86753.09;
console.log(toStripeFormat(number)); // 8675309

International Currency Support

Should support any currency available to the node Intl package: Intl.NumberFormat

ES6 Example

import StripeMoneyFormat from "stripe-money-format";

const number = 123456.789;
const currency = "EUR";
const language = "de-DE";

console.log(toStripeFormatCustomCurrency(currency, language, number)); // 12345679

Common JS Example

const {toStripeCustomCurrency} = require("stripe-money-format");

const number = 123456.789;
const currency = "EUR";
const language = "de-DE";

console.log(toStripeCustomCurrency(currency, language, number)); // 12345679

About

A simple js function to format numbers to stripe's smallest common currency unit format

Resources

License

Stars

Watchers

Forks

Packages

No packages published