@zuplo/zudoku-plugin-monetization 0.0.29 → 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 +31 -10
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -156,6 +156,21 @@ const formatPrice = (amount, currency) => new Intl.NumberFormat("en-US", {
|
|
|
156
156
|
maximumFractionDigits: 6,
|
|
157
157
|
trailingZeroDisplay: "stripIfInteger"
|
|
158
158
|
}).format(amount);
|
|
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
|
+
};
|
|
159
174
|
|
|
160
175
|
//#endregion
|
|
161
176
|
//#region src/utils/categorizeRateCards.ts
|
|
@@ -232,7 +247,7 @@ const getPlanFromPurchaseDetails = (response) => {
|
|
|
232
247
|
return response;
|
|
233
248
|
};
|
|
234
249
|
const getTaxAmountFromPurchaseDetails = (response) => {
|
|
235
|
-
const taxAmount = response?.tax?.taxAmount;
|
|
250
|
+
const taxAmount = response?.tax?.items[0]?.taxAmount;
|
|
236
251
|
const numericAmount = typeof taxAmount === "number" ? taxAmount : Number.parseFloat(taxAmount ?? "");
|
|
237
252
|
if (!Number.isFinite(numericAmount)) return;
|
|
238
253
|
return numericAmount;
|
|
@@ -411,13 +426,13 @@ const CheckoutConfirmPage = () => {
|
|
|
411
426
|
className: "text-2xl font-bold",
|
|
412
427
|
children: formatPrice(price.monthly, selectedPlan?.currency)
|
|
413
428
|
}),
|
|
429
|
+
taxAmount != null && /* @__PURE__ */ jsx("div", {
|
|
430
|
+
className: "text-sm font-normal mt-1",
|
|
431
|
+
children: taxInclusive ? `${formatMinorCurrencyAmount(taxAmount, selectedPlan?.currency)} ${taxLabel} included` : `+ ${formatMinorCurrencyAmount(taxAmount, selectedPlan?.currency)} ${taxLabel}`
|
|
432
|
+
}),
|
|
414
433
|
billingCycle && /* @__PURE__ */ jsxs("div", {
|
|
415
434
|
className: "text-sm text-muted-foreground font-normal",
|
|
416
435
|
children: ["Billed ", formatBillingCycle(billingCycle)]
|
|
417
|
-
}),
|
|
418
|
-
taxAmount != null && /* @__PURE__ */ jsx("div", {
|
|
419
|
-
className: "text-xs text-muted-foreground font-normal mt-1",
|
|
420
|
-
children: taxInclusive ? `${formatPrice(taxAmount, selectedPlan?.currency)} ${taxLabel} included` : `+ ${formatPrice(taxAmount, selectedPlan?.currency)} ${taxLabel}`
|
|
421
436
|
})
|
|
422
437
|
]
|
|
423
438
|
}),
|
|
@@ -783,7 +798,13 @@ const PricingPage = () => {
|
|
|
783
798
|
children: pricing?.subtitle ?? "See our pricing options and choose the one that best suits your needs."
|
|
784
799
|
})]
|
|
785
800
|
}),
|
|
786
|
-
/* @__PURE__ */
|
|
801
|
+
pricingTable.items.length === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
802
|
+
className: "text-center py-12 text-muted-foreground",
|
|
803
|
+
children: [/* @__PURE__ */ jsx("p", { children: "No plans are currently available." }), /* @__PURE__ */ jsx("p", {
|
|
804
|
+
className: "text-sm mt-2",
|
|
805
|
+
children: "Make sure your plans are set up and published."
|
|
806
|
+
})]
|
|
807
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
787
808
|
className: "w-full grid grid-cols-1 sm:grid-cols-[repeat(auto-fit,minmax(300px,max-content))] justify-center gap-6",
|
|
788
809
|
children: pricingTable.items.map((plan) => /* @__PURE__ */ jsx(PricingCard, {
|
|
789
810
|
plan,
|
|
@@ -931,13 +952,13 @@ const SubscriptionChangeConfirmPage = () => {
|
|
|
931
952
|
className: "text-2xl font-bold",
|
|
932
953
|
children: formatPrice(price.monthly, selectedPlan?.currency)
|
|
933
954
|
}),
|
|
955
|
+
taxAmount != null && /* @__PURE__ */ jsx("div", {
|
|
956
|
+
className: "text-sm font-normal mt-1",
|
|
957
|
+
children: taxInclusive ? `${formatMinorCurrencyAmount(taxAmount, selectedPlan?.currency)} ${taxLabel} included` : `+ ${formatMinorCurrencyAmount(taxAmount, selectedPlan?.currency)} ${taxLabel}`
|
|
958
|
+
}),
|
|
934
959
|
billingCycle && /* @__PURE__ */ jsxs("div", {
|
|
935
960
|
className: "text-sm text-muted-foreground font-normal",
|
|
936
961
|
children: ["Billed ", formatBillingCycle(billingCycle)]
|
|
937
|
-
}),
|
|
938
|
-
taxAmount != null && /* @__PURE__ */ jsx("div", {
|
|
939
|
-
className: "text-xs text-muted-foreground font-normal mt-1",
|
|
940
|
-
children: taxInclusive ? `${formatPrice(taxAmount, selectedPlan?.currency)} ${taxLabel} included` : `+ ${formatPrice(taxAmount, selectedPlan?.currency)} ${taxLabel}`
|
|
941
962
|
})
|
|
942
963
|
]
|
|
943
964
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/zudoku-plugin-monetization",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zuplo/zudoku",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"react": "19.2.4",
|
|
32
32
|
"react-dom": "19.2.4",
|
|
33
33
|
"tsdown": "0.20.3",
|
|
34
|
-
"zudoku": "0.
|
|
34
|
+
"zudoku": "0.75.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": ">=19.2.0",
|