Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Currency Not Reflecting Correctly #13845 (#13847)

Pritam1463f97f1442
diff --git a/packages/app-store/stripepayment/lib/currencyConversions.ts b/packages/app-store/stripepayment/lib/currencyConversions.ts
index 75c528c75fc..72fe54ff867 100644
--- a/packages/app-store/stripepayment/lib/currencyConversions.ts
+++ b/packages/app-store/stripepayment/lib/currencyConversions.ts
@@ -22,7 +22,7 @@ const zeroDecimalCurrencies = [
export const convertToSmallestCurrencyUnit = (amount: number, currency: string) => {
// Special cases
- if (zeroDecimalCurrencies.includes(currency)) {
+ if (zeroDecimalCurrencies.includes(currency.toUpperCase())) {
return amount;
}
return Math.round(amount * 100);
@@ -30,7 +30,7 @@ export const convertToSmallestCurrencyUnit = (amount: number, currency: string)
export const convertFromSmallestToPresentableCurrencyUnit = (amount: number, currency: string) => {
// Special cases
- if (zeroDecimalCurrencies.includes(currency)) {
+ if (zeroDecimalCurrencies.includes(currency.toUpperCase())) {
return amount;
}
return amount / 100;
diff --git a/packages/lib/price.ts b/packages/lib/price.ts
index 54a3f8423e9..3fcc184924e 100644
--- a/packages/lib/price.ts
+++ b/packages/lib/price.ts
@@ -1,11 +1,14 @@
+import { convertFromSmallestToPresentableCurrencyUnit } from "@calcom/app-store/stripepayment/lib/currencyConversions";
+
export const formatPrice = (price: number, currency: string | undefined, locale = "en") => {
switch (currency) {
case "BTC":
return `${price} sats`;
default:
+ currency = currency?.toUpperCase() || "USD";
return `${Intl.NumberFormat(locale, {
style: "currency",
- currency: currency?.toUpperCase() || "USD",
- }).format(price / 100.0)}`;
+ currency: currency,
+ }).format(convertFromSmallestToPresentableCurrencyUnit(price, currency))}`;
}
};