@zuplo/zudoku-plugin-monetization 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +19 -10
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -156,12 +156,21 @@ const formatPrice = (amount, currency) => new Intl.NumberFormat("en-US", {
|
|
|
156
156
|
maximumFractionDigits: 6,
|
|
157
157
|
trailingZeroDisplay: "stripIfInteger"
|
|
158
158
|
}).format(amount);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
/** Amount is in the smallest currency unit (e.g. Stripe); divisor from `Intl` / ISO 4217. */
|
|
160
|
+
const formatMinorCurrencyAmount = (amountInMinorUnits, currency) => {
|
|
161
|
+
const code = (currency ?? "USD").toUpperCase();
|
|
162
|
+
const fractionDigits = new Intl.NumberFormat("en-US", {
|
|
163
|
+
style: "currency",
|
|
164
|
+
currency: code
|
|
165
|
+
}).resolvedOptions().maximumFractionDigits ?? 2;
|
|
166
|
+
const divisor = 10 ** fractionDigits;
|
|
167
|
+
return new Intl.NumberFormat("en-US", {
|
|
168
|
+
style: "currency",
|
|
169
|
+
currency: code,
|
|
170
|
+
minimumFractionDigits: fractionDigits,
|
|
171
|
+
maximumFractionDigits: fractionDigits
|
|
172
|
+
}).format(amountInMinorUnits / divisor);
|
|
173
|
+
};
|
|
165
174
|
|
|
166
175
|
//#endregion
|
|
167
176
|
//#region src/utils/categorizeRateCards.ts
|
|
@@ -418,8 +427,8 @@ const CheckoutConfirmPage = () => {
|
|
|
418
427
|
children: formatPrice(price.monthly, selectedPlan?.currency)
|
|
419
428
|
}),
|
|
420
429
|
taxAmount != null && /* @__PURE__ */ jsx("div", {
|
|
421
|
-
className: "text-
|
|
422
|
-
children: taxInclusive ? `${
|
|
430
|
+
className: "text-sm font-normal mt-1",
|
|
431
|
+
children: taxInclusive ? `${formatMinorCurrencyAmount(taxAmount, selectedPlan?.currency)} ${taxLabel} included` : `+ ${formatMinorCurrencyAmount(taxAmount, selectedPlan?.currency)} ${taxLabel}`
|
|
423
432
|
}),
|
|
424
433
|
billingCycle && /* @__PURE__ */ jsxs("div", {
|
|
425
434
|
className: "text-sm text-muted-foreground font-normal",
|
|
@@ -944,8 +953,8 @@ const SubscriptionChangeConfirmPage = () => {
|
|
|
944
953
|
children: formatPrice(price.monthly, selectedPlan?.currency)
|
|
945
954
|
}),
|
|
946
955
|
taxAmount != null && /* @__PURE__ */ jsx("div", {
|
|
947
|
-
className: "text-
|
|
948
|
-
children: taxInclusive ? `${
|
|
956
|
+
className: "text-sm font-normal mt-1",
|
|
957
|
+
children: taxInclusive ? `${formatMinorCurrencyAmount(taxAmount, selectedPlan?.currency)} ${taxLabel} included` : `+ ${formatMinorCurrencyAmount(taxAmount, selectedPlan?.currency)} ${taxLabel}`
|
|
949
958
|
}),
|
|
950
959
|
billingCycle && /* @__PURE__ */ jsxs("div", {
|
|
951
960
|
className: "text-sm text-muted-foreground font-normal",
|