1.0.10 • Published 2 years ago
stripe-money-format v1.0.10
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