diff --git a/lib/format-stripe-price.ts b/lib/format-stripe-price.ts index 4d74363..4ff4e60 100644 --- a/lib/format-stripe-price.ts +++ b/lib/format-stripe-price.ts @@ -17,10 +17,15 @@ export function formatStripePrice( const decimals = zeroDecimalCurrencies.has(normalized) ? 0 : 2; const major = unitAmount / 10 ** decimals; + // Drop the fraction digits for whole amounts (9.00 -> 9), keep them when + // there are real cents (9.99 stays 9.99). + const isWholeAmount = unitAmount % 10 ** decimals === 0; + try { return new Intl.NumberFormat(undefined, { style: "currency", currency: normalized.toUpperCase(), + minimumFractionDigits: isWholeAmount ? 0 : decimals, maximumFractionDigits: decimals, }).format(major); } catch {