@lukoweb/apitogo-plugin-dev-portal-billing 0.2.80 → 0.2.82
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/{AccountPlansPage-BDfagKTr.mjs → AccountPlansPage-B4gb0WvB.mjs} +4 -4
- package/dist/{CheckoutPage-4tCFiL7W.mjs → CheckoutPage-Bom6gjGC.mjs} +2 -2
- package/dist/{ContactSalesPage-BqxdJ4wl.mjs → ContactSalesPage-DvqVqsuC.mjs} +2 -2
- package/dist/{CredentialsPage-DMVMiDdL.mjs → CredentialsPage-BH8xLVnt.mjs} +3 -3
- package/dist/{PricingCard-CrN4GIZ7.mjs → PricingCard-CRH9rxT3.mjs} +27 -3
- package/dist/{PricingPage-DPIF_DOP.mjs → PricingPage-DJwl2XAp.mjs} +57 -137
- package/dist/{SubscriptionsPage-C8hRY5Sr.mjs → SubscriptionsPage-d5gWSBMr.mjs} +129 -7
- package/dist/{UsagePage-Cwqnusaz.mjs → UsagePage-lPOEWUOG.mjs} +4 -4
- package/dist/{account-links-DGL7nKSZ.mjs → account-links-QGu5q_vP.mjs} +1 -1
- package/dist/billing-period-C2PIOhfT.mjs +141 -0
- package/dist/{billing-state-CIqyRwkD.mjs → billing-state-Dal_UzOQ.mjs} +1 -1
- package/dist/index.d.mts +23 -3
- package/dist/index.mjs +15 -15
- package/dist/{useApiKeys-BE2aLp-q.mjs → useApiKeys-CS2SmfJc.mjs} +1 -1
- package/dist/{useDevPortalApiBaseUrl-TaJ7GhG5.mjs → useDevPortalApiBaseUrl-DwObxX8r.mjs} +10 -4
- package/dist/{useMySubscriptions-DnjIFrcQ.mjs → useMySubscriptions-CfZPpul6.mjs} +1 -1
- package/dist/{usePlans-BfvrukjB.mjs → usePlans-CRFHBOqz.mjs} +1 -1
- package/dist/{useUsage-DQty3tDN.mjs → useUsage-DqizlLwt.mjs} +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as PricingCard } from "./PricingCard-
|
|
2
|
+
import { l as isActiveSubscription, m as parseManifestPlans, n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl, x as withPlanFeatures } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
3
|
+
import { t as PricingCard } from "./PricingCard-CRH9rxT3.mjs";
|
|
4
4
|
import { n as readProblemDetail } from "./problem-details-n20-dy3w.mjs";
|
|
5
|
-
import { t as useMySubscriptions } from "./useMySubscriptions-
|
|
6
|
-
import { t as usePlans } from "./usePlans-
|
|
5
|
+
import { t as useMySubscriptions } from "./useMySubscriptions-CfZPpul6.mjs";
|
|
6
|
+
import { t as usePlans } from "./usePlans-CRFHBOqz.mjs";
|
|
7
7
|
import { n as readPendingCheckout, t as clearPendingCheckout } from "./pending-checkout-DpVaNnTu.mjs";
|
|
8
8
|
import { Head } from "@lukoweb/apitogo/components";
|
|
9
9
|
import { CreditCardIcon } from "@lukoweb/apitogo/icons";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as ALREADY_SUBSCRIBED_PARAM, s as PRICING_PATH, t as ACCOUNT_PLANS_PATH } from "./paths-DBr3Dj_q.mjs";
|
|
2
|
-
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-
|
|
2
|
+
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
3
3
|
import { n as readProblemDetail, t as isAlreadySubscribedMessage } from "./problem-details-n20-dy3w.mjs";
|
|
4
4
|
import { r as rememberPendingCheckout } from "./pending-checkout-DpVaNnTu.mjs";
|
|
5
|
-
import { t as FREE_CHECKOUT_MARKER } from "./billing-state-
|
|
5
|
+
import { t as FREE_CHECKOUT_MARKER } from "./billing-state-Dal_UzOQ.mjs";
|
|
6
6
|
import { ShieldIcon } from "@lukoweb/apitogo/icons";
|
|
7
7
|
import { Link, useNavigate, useSearchParams } from "@lukoweb/apitogo/router";
|
|
8
8
|
import { useEffect } from "react";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
2
|
import { s as PRICING_PATH } from "./paths-DBr3Dj_q.mjs";
|
|
3
|
-
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl
|
|
3
|
+
import { d as isPlanCustomPriced, n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
4
4
|
import { n as readProblemDetail } from "./problem-details-n20-dy3w.mjs";
|
|
5
|
-
import { t as usePlans } from "./usePlans-
|
|
5
|
+
import { t as usePlans } from "./usePlans-CRFHBOqz.mjs";
|
|
6
6
|
import { Link, useSearchParams } from "@lukoweb/apitogo/router";
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
2
|
import { t as ACCOUNT_PLANS_PATH } from "./paths-DBr3Dj_q.mjs";
|
|
3
|
-
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-
|
|
3
|
+
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
4
4
|
import { r as createDemoCredentials, t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-yK9qEqV-.mjs";
|
|
5
|
-
import { n as useApiKeys } from "./useApiKeys-
|
|
6
|
-
import { n as apiReferencePath, r as ApiKeysPanel } from "./account-links-
|
|
5
|
+
import { n as useApiKeys } from "./useApiKeys-CS2SmfJc.mjs";
|
|
6
|
+
import { n as apiReferencePath, r as ApiKeysPanel } from "./account-links-QGu5q_vP.mjs";
|
|
7
7
|
import { i as ChoosePlanNotice, r as keyPlanNote, t as apiKeysPageState } from "./page-state-Cmo0FPLl.mjs";
|
|
8
8
|
import { Head } from "@lukoweb/apitogo/components";
|
|
9
9
|
import { KeyRoundIcon } from "@lukoweb/apitogo/icons";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
2
|
import { i as CONTACT_SALES_PATH, r as CHECKOUT_PATH } from "./paths-DBr3Dj_q.mjs";
|
|
3
|
-
import { a as
|
|
3
|
+
import { a as formatMoney, c as formatPlanPriceUnit, d as isPlanCustomPriced, f as isPlanFree, i as formatBillingPeriod, l as isActiveSubscription, o as formatPlanDisplayPrice, p as listPlanFeatureLines } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
4
4
|
import { Button } from "@lukoweb/apitogo/components";
|
|
5
5
|
import { Link as Link$1 } from "@lukoweb/apitogo/router";
|
|
6
6
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@lukoweb/apitogo/ui/AlertDialog.js";
|
|
@@ -8,14 +8,17 @@ import { cn } from "@lukoweb/apitogo/ui/util.js";
|
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
//#region src/components/PricingCard.tsx
|
|
11
|
+
/** The free days a paid plan gives a new subscriber, or 0. */
|
|
12
|
+
const planTrialDays = (plan) => !isPlanCustomPriced(plan) && !isPlanFree(plan) && (plan.trialDays ?? 0) > 0 ? plan.trialDays ?? 0 : 0;
|
|
11
13
|
const publicCtaLabel = (plan) => {
|
|
12
14
|
if (isPlanCustomPriced(plan)) return "Contact sales";
|
|
13
15
|
if (isPlanFree(plan)) return "Get started for free";
|
|
14
|
-
return "Subscribe now";
|
|
16
|
+
return planTrialDays(plan) ? "Start free trial" : "Subscribe now";
|
|
15
17
|
};
|
|
16
18
|
const accountCtaLabel = (plan) => {
|
|
17
19
|
if (isPlanCustomPriced(plan)) return "Contact sales";
|
|
18
|
-
|
|
20
|
+
if (isPlanFree(plan)) return "Get started";
|
|
21
|
+
return planTrialDays(plan) ? "Start free trial" : "Subscribe";
|
|
19
22
|
};
|
|
20
23
|
/**
|
|
21
24
|
* Custom-priced plans skip checkout and open the contact-sales form. A plan sold at several prices also says which one
|
|
@@ -74,6 +77,27 @@ const PricingCard = ({ plan, mode = "public", subscriptionStatus, isSubscribed =
|
|
|
74
77
|
className: "mt-0.5 text-[0.78125rem] text-muted-foreground",
|
|
75
78
|
children: formatPlanPriceUnit(plan)
|
|
76
79
|
}),
|
|
80
|
+
plan.overage && !isPlanFree(plan) && !isPlanCustomPriced(plan) ? /* @__PURE__ */ jsxs("p", {
|
|
81
|
+
className: "mt-1.5 text-[0.8125rem] text-muted-foreground",
|
|
82
|
+
"data-testid": `overage-${plan.sku}`,
|
|
83
|
+
children: [
|
|
84
|
+
"Then ",
|
|
85
|
+
formatMoney(plan.overage.amount, plan.priceCurrency),
|
|
86
|
+
" per",
|
|
87
|
+
" ",
|
|
88
|
+
plan.overage.per.toLocaleString("en-US"),
|
|
89
|
+
" calls past the quota, up to",
|
|
90
|
+
" ",
|
|
91
|
+
formatMoney(plan.overage.cap, plan.priceCurrency),
|
|
92
|
+
" ",
|
|
93
|
+
formatBillingPeriod(plan.billingPeriod)
|
|
94
|
+
]
|
|
95
|
+
}) : null,
|
|
96
|
+
planTrialDays(plan) ? /* @__PURE__ */ jsxs("p", {
|
|
97
|
+
className: "mt-1.5 text-[0.8125rem] font-semibold text-primary",
|
|
98
|
+
"data-testid": `trial-${plan.sku}`,
|
|
99
|
+
children: [planTrialDays(plan), "-day free trial"]
|
|
100
|
+
}) : null,
|
|
77
101
|
discount ? /* @__PURE__ */ jsxs("p", {
|
|
78
102
|
className: "mt-1.5 text-[0.8125rem] font-semibold text-emerald-600",
|
|
79
103
|
"data-testid": `saving-${plan.sku}`,
|
|
@@ -1,147 +1,16 @@
|
|
|
1
1
|
import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as PricingCard } from "./PricingCard-
|
|
4
|
-
import { t as usePlans } from "./usePlans-
|
|
2
|
+
import { _ as pickFeaturedPlanSku, a as formatMoney, f as isPlanFree, i as formatBillingPeriod, m as parseManifestPlans, n as useDevPortalPreviewMode, x as withPlanFeatures } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
3
|
+
import { t as PricingCard } from "./PricingCard-CRH9rxT3.mjs";
|
|
4
|
+
import { t as usePlans } from "./usePlans-CRFHBOqz.mjs";
|
|
5
5
|
import { t as isPreviewPricingEnabled } from "./pricing-config-Bc6eWFUO.mjs";
|
|
6
|
-
import { a as isPricingLoading, n as buildCompareRows } from "./billing-state-
|
|
6
|
+
import { a as isPricingLoading, n as buildCompareRows } from "./billing-state-Dal_UzOQ.mjs";
|
|
7
|
+
import { a as featuredSkuForPeriod, i as discountFor, n as addOnPriceFor, o as plansForPeriod, r as availablePeriods, s as savingsLabel, t as PERIOD_LABELS } from "./billing-period-C2PIOhfT.mjs";
|
|
7
8
|
import { Head, Heading } from "@lukoweb/apitogo/components";
|
|
8
9
|
import { Navigate } from "@lukoweb/apitogo/router";
|
|
9
10
|
import { useState } from "react";
|
|
10
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import { useAuth } from "@lukoweb/apitogo/hooks";
|
|
12
13
|
|
|
13
|
-
//#region src/utils/billing-period.ts
|
|
14
|
-
const PRICING_PERIODS = [
|
|
15
|
-
"monthly",
|
|
16
|
-
"quarterly",
|
|
17
|
-
"yearly"
|
|
18
|
-
];
|
|
19
|
-
const PERIOD_LABELS = {
|
|
20
|
-
monthly: "Monthly",
|
|
21
|
-
quarterly: "Quarterly",
|
|
22
|
-
yearly: "Yearly"
|
|
23
|
-
};
|
|
24
|
-
const MONTHS = {
|
|
25
|
-
monthly: 1,
|
|
26
|
-
quarterly: 3,
|
|
27
|
-
yearly: 12
|
|
28
|
-
};
|
|
29
|
-
/** The view a billing period (`monthly`, `quarterly`, `annual`, `month`, `year`, …) belongs to. */
|
|
30
|
-
function periodOf(billingPeriod) {
|
|
31
|
-
const normalized = billingPeriod?.trim().toLowerCase();
|
|
32
|
-
if (normalized === "annual" || normalized === "year" || normalized === "yearly") return "yearly";
|
|
33
|
-
if (normalized === "quarterly" || normalized === "quarter") return "quarterly";
|
|
34
|
-
return "monthly";
|
|
35
|
-
}
|
|
36
|
-
/** A paid plan with a fixed price: the only kind that belongs to a period. Free and contact-us plans show in every view. */
|
|
37
|
-
const isPaidFixed = (plan) => !isPlanFree(plan) && !isPlanCustomPriced(plan);
|
|
38
|
-
/** The periods a plan is sold at, or `all` for a free or contact-us plan. */
|
|
39
|
-
function planPeriods(plan) {
|
|
40
|
-
if (!isPaidFixed(plan)) return "all";
|
|
41
|
-
if (plan.prices?.length) return new Set(plan.prices.map((price) => periodOf(price.billingPeriod)));
|
|
42
|
-
return new Set([periodOf(plan.billingPeriod)]);
|
|
43
|
-
}
|
|
44
|
-
/** The periods the page offers: every period some paid plan is sold at, shortest first. */
|
|
45
|
-
function availablePeriods(plans) {
|
|
46
|
-
const offered = /* @__PURE__ */ new Set();
|
|
47
|
-
for (const plan of plans) {
|
|
48
|
-
const periods = planPeriods(plan);
|
|
49
|
-
if (periods !== "all") for (const period of periods) offered.add(period);
|
|
50
|
-
}
|
|
51
|
-
return PRICING_PERIODS.filter((period) => offered.has(period));
|
|
52
|
-
}
|
|
53
|
-
/** The switch is offered only when paid plans come in more than one period; otherwise every plan shows as before. */
|
|
54
|
-
function hasPeriodChoice(plans) {
|
|
55
|
-
return availablePeriods(plans).length > 1;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The plan as it is sold in one period: a plan with several prices shows that period's price (in the plan's own
|
|
59
|
-
* currency when it has one there). A plan with no price in that period keeps its default price.
|
|
60
|
-
*/
|
|
61
|
-
function planAtPeriod(plan, period) {
|
|
62
|
-
const inPeriod = (plan.prices ?? []).filter((price) => periodOf(price.billingPeriod) === period);
|
|
63
|
-
const price = inPeriod.find((p) => p.currency.toLowerCase() === plan.priceCurrency.toLowerCase()) ?? inPeriod.at(0);
|
|
64
|
-
return price ? {
|
|
65
|
-
...plan,
|
|
66
|
-
priceAmount: price.amount,
|
|
67
|
-
priceCurrency: price.currency,
|
|
68
|
-
billingPeriod: price.billingPeriod
|
|
69
|
-
} : plan;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* The plans of one view, in their own order: plans sold in that period (at that period's price), plans with several
|
|
73
|
-
* prices (at their default price when they have none in that period), and the free and contact-us plans.
|
|
74
|
-
*/
|
|
75
|
-
function plansForPeriod(plans, period) {
|
|
76
|
-
if (!hasPeriodChoice(plans)) return plans;
|
|
77
|
-
return plans.filter((plan) => {
|
|
78
|
-
const periods = planPeriods(plan);
|
|
79
|
-
return periods === "all" || periods.has(period) || Boolean(plan.prices?.length);
|
|
80
|
-
}).map((plan) => planAtPeriod(plan, period));
|
|
81
|
-
}
|
|
82
|
-
const nameKey = (plan) => `${plan.displayName.trim().toLowerCase()}|${plan.priceCurrency.trim().toLowerCase()}`;
|
|
83
|
-
/** The monthly price to compare a plan with: its own monthly price, or the monthly plan with the same name. */
|
|
84
|
-
function monthlyPriceFor(plan, plans) {
|
|
85
|
-
const own = plan.prices?.find((price) => periodOf(price.billingPeriod) === "monthly" && price.currency.toLowerCase() === plan.priceCurrency.toLowerCase());
|
|
86
|
-
if (own) return own.amount;
|
|
87
|
-
return plans.map((other) => planAtPeriod(other, "monthly")).find((other) => isPaidFixed(other) && periodOf(other.billingPeriod) === "monthly" && nameKey(other) === nameKey(plan))?.priceAmount;
|
|
88
|
-
}
|
|
89
|
-
const cents = (amount) => Math.round(amount * 100) / 100;
|
|
90
|
-
/**
|
|
91
|
-
* The saving of a plan as shown (already at its period's price) against paying monthly for as long: its own monthly
|
|
92
|
-
* price, or the monthly plan with the same name and currency. Null for a monthly price, nothing to compare with, or no
|
|
93
|
-
* saving.
|
|
94
|
-
*/
|
|
95
|
-
function discountFor(plan, plans) {
|
|
96
|
-
if (!isPaidFixed(plan)) return null;
|
|
97
|
-
const period = periodOf(plan.billingPeriod);
|
|
98
|
-
if (period === "monthly") return null;
|
|
99
|
-
const monthly = monthlyPriceFor(plan, plans);
|
|
100
|
-
if (!monthly) return null;
|
|
101
|
-
const originalAmount = cents(monthly * MONTHS[period]);
|
|
102
|
-
const savedAmount = cents(originalAmount - plan.priceAmount);
|
|
103
|
-
if (savedAmount <= 0) return null;
|
|
104
|
-
const percent = Math.round(savedAmount / originalAmount * 100);
|
|
105
|
-
return percent > 0 ? {
|
|
106
|
-
originalAmount,
|
|
107
|
-
savedAmount,
|
|
108
|
-
percent
|
|
109
|
-
} : null;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* What a plan saves in a longer period against paying monthly for as long, in whole percent. Null when there is
|
|
113
|
-
* nothing to compare with or no saving.
|
|
114
|
-
*/
|
|
115
|
-
function savingsPercent(plan, period, plans) {
|
|
116
|
-
if (period === "monthly" || !isPaidFixed(plan)) return null;
|
|
117
|
-
const atPeriod = planAtPeriod(plan, period);
|
|
118
|
-
if (periodOf(atPeriod.billingPeriod) !== period) return null;
|
|
119
|
-
return discountFor(atPeriod, plans)?.percent ?? null;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* A period button's badge: "Save 20%" when every plan saves the same, "Save up to 25%" when they differ, null when
|
|
123
|
-
* none saves anything.
|
|
124
|
-
*/
|
|
125
|
-
function savingsLabel(plans, period) {
|
|
126
|
-
const savings = plans.map((plan) => savingsPercent(plan, period, plans)).filter((percent) => percent !== null);
|
|
127
|
-
if (savings.length === 0) return null;
|
|
128
|
-
const best = Math.max(...savings);
|
|
129
|
-
return savings.every((percent) => percent === best) ? `Save ${best}%` : `Save up to ${best}%`;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* The plan shown as "Popular" in a view: the marked plan, or, when it belongs to another period, the plan of this view
|
|
133
|
-
* with the same name (the yearly Pro when the monthly Pro is marked).
|
|
134
|
-
*/
|
|
135
|
-
function featuredSkuForPeriod(visible, all, featuredSku) {
|
|
136
|
-
if (!featuredSku) return void 0;
|
|
137
|
-
if (visible.some((plan) => plan.sku === featuredSku)) return featuredSku;
|
|
138
|
-
const marked = all.find((plan) => plan.sku === featuredSku);
|
|
139
|
-
if (!marked) return void 0;
|
|
140
|
-
const name = marked.displayName.trim().toLowerCase();
|
|
141
|
-
return visible.find((plan) => plan.displayName.trim().toLowerCase() === name)?.sku;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
//#endregion
|
|
145
14
|
//#region src/pages/PricingPage.tsx
|
|
146
15
|
const DEFAULT_COMPARE_ROWS = [
|
|
147
16
|
{
|
|
@@ -208,7 +77,7 @@ const DEFAULT_FAQS = [{
|
|
|
208
77
|
answer: "Yes. Each plan has its own API keys and limits: create a key for a plan on the API keys page and use it in your app."
|
|
209
78
|
}];
|
|
210
79
|
const PricingPage = () => {
|
|
211
|
-
const { pricing, previewPlans, featuredPlanSku, planFeatures } = useDevPortalBillingConfig();
|
|
80
|
+
const { pricing, previewPlans, previewAddOns, featuredPlanSku, planFeatures } = useDevPortalBillingConfig();
|
|
212
81
|
const isPreview = useDevPortalPreviewMode();
|
|
213
82
|
const pricingEnabled = isPreviewPricingEnabled() || isPreview;
|
|
214
83
|
const livePlans = usePlans();
|
|
@@ -234,6 +103,9 @@ const PricingPage = () => {
|
|
|
234
103
|
const periodChoice = periods.length > 1;
|
|
235
104
|
const period = periods.includes(chosenPeriod) ? chosenPeriod : periods.at(0) ?? "monthly";
|
|
236
105
|
const plans = plansForPeriod(allPlans, period);
|
|
106
|
+
const addOns = (isPreview ? previewAddOns : catalog?.addOns) ?? [];
|
|
107
|
+
const viewCurrency = plans.find((plan) => !isPlanFree(plan))?.priceCurrency ?? "usd";
|
|
108
|
+
const viewPeriod = period === "yearly" ? "annual" : period;
|
|
237
109
|
const featuredSku = featuredSkuForPeriod(plans, allPlans, pickFeaturedPlanSku(allPlans, featuredPlanSku));
|
|
238
110
|
const compareRows = buildCompareRows({
|
|
239
111
|
plans,
|
|
@@ -338,6 +210,54 @@ const PricingPage = () => {
|
|
|
338
210
|
}) : null
|
|
339
211
|
]
|
|
340
212
|
}),
|
|
213
|
+
addOns.length > 0 && !isLoading ? /* @__PURE__ */ jsx("section", {
|
|
214
|
+
className: "px-6 pb-16",
|
|
215
|
+
"data-testid": "pricing-add-ons",
|
|
216
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
217
|
+
className: "mx-auto max-w-[1200px]",
|
|
218
|
+
children: [
|
|
219
|
+
/* @__PURE__ */ jsx("h2", {
|
|
220
|
+
className: "mb-2 text-[clamp(1.5rem,2.5vw,2.25rem)] font-extrabold tracking-[-0.02em]",
|
|
221
|
+
children: "Add-ons"
|
|
222
|
+
}),
|
|
223
|
+
/* @__PURE__ */ jsx("p", {
|
|
224
|
+
className: "mb-6 text-muted-foreground",
|
|
225
|
+
children: "Add them to a paid plan from your account, at any time."
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ jsx("div", {
|
|
228
|
+
className: "grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3",
|
|
229
|
+
children: addOns.map((addOn) => {
|
|
230
|
+
const price = addOnPriceFor(addOn, viewPeriod, viewCurrency);
|
|
231
|
+
return /* @__PURE__ */ jsxs("article", {
|
|
232
|
+
className: "rounded-xl border border-border bg-card p-6",
|
|
233
|
+
"data-testid": `add-on-${addOn.sku}`,
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ jsx("h3", {
|
|
236
|
+
className: "text-base font-bold",
|
|
237
|
+
children: addOn.displayName
|
|
238
|
+
}),
|
|
239
|
+
addOn.description ? /* @__PURE__ */ jsx("p", {
|
|
240
|
+
className: "mt-1.5 text-sm text-muted-foreground",
|
|
241
|
+
children: addOn.description
|
|
242
|
+
}) : null,
|
|
243
|
+
price ? /* @__PURE__ */ jsxs("p", {
|
|
244
|
+
className: "mt-3 text-sm font-semibold",
|
|
245
|
+
children: [
|
|
246
|
+
formatMoney(price.amount, price.currency),
|
|
247
|
+
" ",
|
|
248
|
+
/* @__PURE__ */ jsx("span", {
|
|
249
|
+
className: "font-normal text-muted-foreground",
|
|
250
|
+
children: formatBillingPeriod(price.billingPeriod)
|
|
251
|
+
})
|
|
252
|
+
]
|
|
253
|
+
}) : null
|
|
254
|
+
]
|
|
255
|
+
}, addOn.sku);
|
|
256
|
+
})
|
|
257
|
+
})
|
|
258
|
+
]
|
|
259
|
+
})
|
|
260
|
+
}) : null,
|
|
341
261
|
isLoading || compareRows.length === 0 ? null : /* @__PURE__ */ jsx("section", {
|
|
342
262
|
className: "border-t border-border bg-muted/40 px-6 py-16",
|
|
343
263
|
"data-testid": "pricing-compare",
|
|
@@ -1,21 +1,139 @@
|
|
|
1
1
|
import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
2
|
import { a as CREDENTIALS_PATH, n as ALREADY_SUBSCRIBED_PARAM, t as ACCOUNT_PLANS_PATH } from "./paths-DBr3Dj_q.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
3
|
+
import { a as formatMoney, f as isPlanFree, h as parseMonthlyQuotaCalls, i as formatBillingPeriod, l as isActiveSubscription, n as useDevPortalPreviewMode, r as useIsDemoSession, s as formatPlanPrice, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
4
|
+
import { n as readProblemDetail } from "./problem-details-n20-dy3w.mjs";
|
|
5
|
+
import { t as useMySubscriptions } from "./useMySubscriptions-CfZPpul6.mjs";
|
|
6
|
+
import { t as usePlans } from "./usePlans-CRFHBOqz.mjs";
|
|
6
7
|
import { n as readPendingCheckout, t as clearPendingCheckout } from "./pending-checkout-DpVaNnTu.mjs";
|
|
7
|
-
import { n as useApiKeys } from "./useApiKeys-
|
|
8
|
-
import { t as useUsage } from "./useUsage-
|
|
9
|
-
import { i as hasPaymentProvider, r as checkoutConfirmingText } from "./billing-state-
|
|
8
|
+
import { n as useApiKeys } from "./useApiKeys-CS2SmfJc.mjs";
|
|
9
|
+
import { t as useUsage } from "./useUsage-DqizlLwt.mjs";
|
|
10
|
+
import { i as hasPaymentProvider, r as checkoutConfirmingText } from "./billing-state-Dal_UzOQ.mjs";
|
|
10
11
|
import { i as ChoosePlanNotice, n as billingPageState, r as keyPlanNote } from "./page-state-Cmo0FPLl.mjs";
|
|
12
|
+
import { n as addOnPriceFor } from "./billing-period-C2PIOhfT.mjs";
|
|
11
13
|
import { Head, Spinner } from "@lukoweb/apitogo/components";
|
|
12
14
|
import { Link as Link$1, useSearchParams } from "@lukoweb/apitogo/router";
|
|
13
15
|
import { useEffect } from "react";
|
|
14
16
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import { useMutation } from "@lukoweb/apitogo/react-query";
|
|
17
|
+
import { useMutation, useQuery, useQueryClient } from "@lukoweb/apitogo/react-query";
|
|
16
18
|
import { useAuth } from "@lukoweb/apitogo/hooks";
|
|
17
19
|
import { Button as Button$1 } from "@lukoweb/apitogo/ui/Button.js";
|
|
18
20
|
|
|
21
|
+
//#region src/hooks/useAddOns.ts
|
|
22
|
+
/** The add-ons on the signed-in customer's plans, and adding or removing one. Nothing in a preview or demo. */
|
|
23
|
+
function useSubscriptionAddOns() {
|
|
24
|
+
const apiBaseUrl = useDevPortalApiBaseUrl();
|
|
25
|
+
const isPreview = useDevPortalPreviewMode();
|
|
26
|
+
const isDemoSession = useIsDemoSession();
|
|
27
|
+
const live = Boolean(apiBaseUrl) && !isPreview && !isDemoSession;
|
|
28
|
+
const queryClient = useQueryClient();
|
|
29
|
+
const queryKey = ["dev-portal-subscription-add-ons", apiBaseUrl];
|
|
30
|
+
return {
|
|
31
|
+
live,
|
|
32
|
+
list: useQuery({
|
|
33
|
+
queryKey,
|
|
34
|
+
enabled: live,
|
|
35
|
+
queryFn: async () => {
|
|
36
|
+
const response = await fetch(`${apiBaseUrl}/api/v1/subscriptions/add-ons`, {
|
|
37
|
+
headers: { Accept: "application/json" },
|
|
38
|
+
credentials: "include"
|
|
39
|
+
});
|
|
40
|
+
if (!response.ok) throw new Error("Unable to load your add-ons.");
|
|
41
|
+
return await response.json();
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
change: useMutation({
|
|
45
|
+
mutationFn: async (input) => {
|
|
46
|
+
const url = `${apiBaseUrl}/api/v1/subscriptions/add-ons`;
|
|
47
|
+
const response = input.action === "add" ? await fetch(url, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
Accept: "application/json",
|
|
51
|
+
"Content-Type": "application/json"
|
|
52
|
+
},
|
|
53
|
+
credentials: "include",
|
|
54
|
+
body: JSON.stringify({
|
|
55
|
+
planSku: input.planSku,
|
|
56
|
+
addOnSku: input.addOnSku
|
|
57
|
+
})
|
|
58
|
+
}) : await fetch(`${url}?planSku=${encodeURIComponent(input.planSku)}&addOnSku=${encodeURIComponent(input.addOnSku)}`, {
|
|
59
|
+
method: "DELETE",
|
|
60
|
+
credentials: "include"
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) throw new Error(await readProblemDetail(response) ?? (input.action === "add" ? "The add-on could not be added." : "The add-on could not be removed."));
|
|
63
|
+
},
|
|
64
|
+
onSettled: () => queryClient.invalidateQueries({ queryKey })
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/components/AddOnsPanel.tsx
|
|
71
|
+
/**
|
|
72
|
+
* The add-ons a customer can put on one paid plan: what each costs for the plan's period, and Add or Remove. Stripe
|
|
73
|
+
* prorates: adding charges the rest of the period now, removing credits it on the next invoice.
|
|
74
|
+
*/
|
|
75
|
+
const AddOnsPanel = ({ plan, addOns }) => {
|
|
76
|
+
const { live, list, change } = useSubscriptionAddOns();
|
|
77
|
+
const offered = addOns.filter((addOn) => !addOn.plans?.length || addOn.plans.includes(plan.sku));
|
|
78
|
+
if (!live || offered.length === 0) return null;
|
|
79
|
+
const held = new Set((list.data ?? []).filter((item) => item.planSku === plan.sku).map((item) => item.addOnSku));
|
|
80
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
81
|
+
className: "mt-5 border-t border-border pt-4",
|
|
82
|
+
"data-testid": `add-ons-${plan.sku}`,
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ jsx("p", {
|
|
85
|
+
className: "mb-2 text-xs font-medium uppercase tracking-[0.05em] text-muted-foreground",
|
|
86
|
+
children: "Add-ons"
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ jsx("ul", {
|
|
89
|
+
className: "space-y-3",
|
|
90
|
+
children: offered.map((addOn) => {
|
|
91
|
+
const price = addOnPriceFor(addOn, plan.billingPeriod, plan.priceCurrency);
|
|
92
|
+
const has = held.has(addOn.sku);
|
|
93
|
+
const busy = change.isPending && change.variables?.addOnSku === addOn.sku;
|
|
94
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
95
|
+
className: "flex items-start justify-between gap-4",
|
|
96
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [
|
|
97
|
+
/* @__PURE__ */ jsx("p", {
|
|
98
|
+
className: "text-sm font-semibold",
|
|
99
|
+
children: addOn.displayName
|
|
100
|
+
}),
|
|
101
|
+
addOn.description ? /* @__PURE__ */ jsx("p", {
|
|
102
|
+
className: "text-sm text-muted-foreground",
|
|
103
|
+
children: addOn.description
|
|
104
|
+
}) : null,
|
|
105
|
+
price ? /* @__PURE__ */ jsxs("p", {
|
|
106
|
+
className: "text-sm text-muted-foreground",
|
|
107
|
+
children: [
|
|
108
|
+
formatMoney(price.amount, price.currency),
|
|
109
|
+
" ",
|
|
110
|
+
formatBillingPeriod(price.billingPeriod)
|
|
111
|
+
]
|
|
112
|
+
}) : null
|
|
113
|
+
] }), /* @__PURE__ */ jsx(Button$1, {
|
|
114
|
+
variant: has ? "outline" : "default",
|
|
115
|
+
size: "sm",
|
|
116
|
+
disabled: busy || !price,
|
|
117
|
+
onClick: () => change.mutate({
|
|
118
|
+
planSku: plan.sku,
|
|
119
|
+
addOnSku: addOn.sku,
|
|
120
|
+
action: has ? "remove" : "add"
|
|
121
|
+
}),
|
|
122
|
+
"data-testid": `add-on-${plan.sku}-${addOn.sku}`,
|
|
123
|
+
children: has ? "Remove" : "Add"
|
|
124
|
+
})]
|
|
125
|
+
}, addOn.sku);
|
|
126
|
+
})
|
|
127
|
+
}),
|
|
128
|
+
change.isError ? /* @__PURE__ */ jsx("p", {
|
|
129
|
+
className: "mt-2 text-sm text-destructive",
|
|
130
|
+
children: change.error.message
|
|
131
|
+
}) : null
|
|
132
|
+
]
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
19
137
|
//#region src/hooks/useBillingPortal.ts
|
|
20
138
|
function useBillingPortal() {
|
|
21
139
|
const apiBaseUrl = useDevPortalApiBaseUrl();
|
|
@@ -206,6 +324,10 @@ const SubscriptionsPage = () => {
|
|
|
206
324
|
style: { width: `${quotaPct}%` }
|
|
207
325
|
})
|
|
208
326
|
})]
|
|
327
|
+
}) : null,
|
|
328
|
+
plan && !isPlanFree(plan) && catalog?.addOns?.length ? /* @__PURE__ */ jsx(AddOnsPanel, {
|
|
329
|
+
plan,
|
|
330
|
+
addOns: catalog.addOns
|
|
209
331
|
}) : null
|
|
210
332
|
]
|
|
211
333
|
}, subscription.planSku);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as useMySubscriptions } from "./useMySubscriptions-
|
|
4
|
-
import { t as usePlans } from "./usePlans-
|
|
5
|
-
import { n as useUsageRecent, t as useUsage } from "./useUsage-
|
|
2
|
+
import { g as parseQuotaPeriodDays, h as parseMonthlyQuotaCalls, l as isActiveSubscription } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
3
|
+
import { t as useMySubscriptions } from "./useMySubscriptions-CfZPpul6.mjs";
|
|
4
|
+
import { t as usePlans } from "./usePlans-CRFHBOqz.mjs";
|
|
5
|
+
import { n as useUsageRecent, t as useUsage } from "./useUsage-DqizlLwt.mjs";
|
|
6
6
|
import { Head } from "@lukoweb/apitogo/components";
|
|
7
7
|
import { Link as Link$1 } from "@lukoweb/apitogo/router";
|
|
8
8
|
import { useState } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as useRevokeApiKey, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-
|
|
1
|
+
import { i as useRevokeApiKey, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-CS2SmfJc.mjs";
|
|
2
2
|
import { Spinner } from "@lukoweb/apitogo/components";
|
|
3
3
|
import { KeyRoundIcon, TrashIcon } from "@lukoweb/apitogo/icons";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { d as isPlanCustomPriced, f as isPlanFree } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/billing-period.ts
|
|
4
|
+
const PRICING_PERIODS = [
|
|
5
|
+
"monthly",
|
|
6
|
+
"quarterly",
|
|
7
|
+
"yearly"
|
|
8
|
+
];
|
|
9
|
+
const PERIOD_LABELS = {
|
|
10
|
+
monthly: "Monthly",
|
|
11
|
+
quarterly: "Quarterly",
|
|
12
|
+
yearly: "Yearly"
|
|
13
|
+
};
|
|
14
|
+
const MONTHS = {
|
|
15
|
+
monthly: 1,
|
|
16
|
+
quarterly: 3,
|
|
17
|
+
yearly: 12
|
|
18
|
+
};
|
|
19
|
+
/** The view a billing period (`monthly`, `quarterly`, `annual`, `month`, `year`, …) belongs to. */
|
|
20
|
+
function periodOf(billingPeriod) {
|
|
21
|
+
const normalized = billingPeriod?.trim().toLowerCase();
|
|
22
|
+
if (normalized === "annual" || normalized === "year" || normalized === "yearly") return "yearly";
|
|
23
|
+
if (normalized === "quarterly" || normalized === "quarter") return "quarterly";
|
|
24
|
+
return "monthly";
|
|
25
|
+
}
|
|
26
|
+
/** A paid plan with a fixed price: the only kind that belongs to a period. Free and contact-us plans show in every view. */
|
|
27
|
+
const isPaidFixed = (plan) => !isPlanFree(plan) && !isPlanCustomPriced(plan);
|
|
28
|
+
/** The periods a plan is sold at, or `all` for a free or contact-us plan. */
|
|
29
|
+
function planPeriods(plan) {
|
|
30
|
+
if (!isPaidFixed(plan)) return "all";
|
|
31
|
+
if (plan.prices?.length) return new Set(plan.prices.map((price) => periodOf(price.billingPeriod)));
|
|
32
|
+
return new Set([periodOf(plan.billingPeriod)]);
|
|
33
|
+
}
|
|
34
|
+
/** The periods the page offers: every period some paid plan is sold at, shortest first. */
|
|
35
|
+
function availablePeriods(plans) {
|
|
36
|
+
const offered = /* @__PURE__ */ new Set();
|
|
37
|
+
for (const plan of plans) {
|
|
38
|
+
const periods = planPeriods(plan);
|
|
39
|
+
if (periods !== "all") for (const period of periods) offered.add(period);
|
|
40
|
+
}
|
|
41
|
+
return PRICING_PERIODS.filter((period) => offered.has(period));
|
|
42
|
+
}
|
|
43
|
+
/** The switch is offered only when paid plans come in more than one period; otherwise every plan shows as before. */
|
|
44
|
+
function hasPeriodChoice(plans) {
|
|
45
|
+
return availablePeriods(plans).length > 1;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The plan as it is sold in one period: a plan with several prices shows that period's price (in the plan's own
|
|
49
|
+
* currency when it has one there). A plan with no price in that period keeps its default price.
|
|
50
|
+
*/
|
|
51
|
+
function planAtPeriod(plan, period) {
|
|
52
|
+
const inPeriod = (plan.prices ?? []).filter((price) => periodOf(price.billingPeriod) === period);
|
|
53
|
+
const price = inPeriod.find((p) => p.currency.toLowerCase() === plan.priceCurrency.toLowerCase()) ?? inPeriod.at(0);
|
|
54
|
+
return price ? {
|
|
55
|
+
...plan,
|
|
56
|
+
priceAmount: price.amount,
|
|
57
|
+
priceCurrency: price.currency,
|
|
58
|
+
billingPeriod: price.billingPeriod
|
|
59
|
+
} : plan;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The plans of one view, in their own order: plans sold in that period (at that period's price), plans with several
|
|
63
|
+
* prices (at their default price when they have none in that period), and the free and contact-us plans.
|
|
64
|
+
*/
|
|
65
|
+
function plansForPeriod(plans, period) {
|
|
66
|
+
if (!hasPeriodChoice(plans)) return plans;
|
|
67
|
+
return plans.filter((plan) => {
|
|
68
|
+
const periods = planPeriods(plan);
|
|
69
|
+
return periods === "all" || periods.has(period) || Boolean(plan.prices?.length);
|
|
70
|
+
}).map((plan) => planAtPeriod(plan, period));
|
|
71
|
+
}
|
|
72
|
+
const nameKey = (plan) => `${plan.displayName.trim().toLowerCase()}|${plan.priceCurrency.trim().toLowerCase()}`;
|
|
73
|
+
/** The monthly price to compare a plan with: its own monthly price, or the monthly plan with the same name. */
|
|
74
|
+
function monthlyPriceFor(plan, plans) {
|
|
75
|
+
const own = plan.prices?.find((price) => periodOf(price.billingPeriod) === "monthly" && price.currency.toLowerCase() === plan.priceCurrency.toLowerCase());
|
|
76
|
+
if (own) return own.amount;
|
|
77
|
+
return plans.map((other) => planAtPeriod(other, "monthly")).find((other) => isPaidFixed(other) && periodOf(other.billingPeriod) === "monthly" && nameKey(other) === nameKey(plan))?.priceAmount;
|
|
78
|
+
}
|
|
79
|
+
const cents = (amount) => Math.round(amount * 100) / 100;
|
|
80
|
+
/**
|
|
81
|
+
* The saving of a plan as shown (already at its period's price) against paying monthly for as long: its own monthly
|
|
82
|
+
* price, or the monthly plan with the same name and currency. Null for a monthly price, nothing to compare with, or no
|
|
83
|
+
* saving.
|
|
84
|
+
*/
|
|
85
|
+
function discountFor(plan, plans) {
|
|
86
|
+
if (!isPaidFixed(plan)) return null;
|
|
87
|
+
const period = periodOf(plan.billingPeriod);
|
|
88
|
+
if (period === "monthly") return null;
|
|
89
|
+
const monthly = monthlyPriceFor(plan, plans);
|
|
90
|
+
if (!monthly) return null;
|
|
91
|
+
const originalAmount = cents(monthly * MONTHS[period]);
|
|
92
|
+
const savedAmount = cents(originalAmount - plan.priceAmount);
|
|
93
|
+
if (savedAmount <= 0) return null;
|
|
94
|
+
const percent = Math.round(savedAmount / originalAmount * 100);
|
|
95
|
+
return percent > 0 ? {
|
|
96
|
+
originalAmount,
|
|
97
|
+
savedAmount,
|
|
98
|
+
percent
|
|
99
|
+
} : null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* What a plan saves in a longer period against paying monthly for as long, in whole percent. Null when there is
|
|
103
|
+
* nothing to compare with or no saving.
|
|
104
|
+
*/
|
|
105
|
+
function savingsPercent(plan, period, plans) {
|
|
106
|
+
if (period === "monthly" || !isPaidFixed(plan)) return null;
|
|
107
|
+
const atPeriod = planAtPeriod(plan, period);
|
|
108
|
+
if (periodOf(atPeriod.billingPeriod) !== period) return null;
|
|
109
|
+
return discountFor(atPeriod, plans)?.percent ?? null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A period button's badge: "Save 20%" when every plan saves the same, "Save up to 25%" when they differ, null when
|
|
113
|
+
* none saves anything.
|
|
114
|
+
*/
|
|
115
|
+
function savingsLabel(plans, period) {
|
|
116
|
+
const savings = plans.map((plan) => savingsPercent(plan, period, plans)).filter((percent) => percent !== null);
|
|
117
|
+
if (savings.length === 0) return null;
|
|
118
|
+
const best = Math.max(...savings);
|
|
119
|
+
return savings.every((percent) => percent === best) ? `Save ${best}%` : `Save up to ${best}%`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The plan shown as "Popular" in a view: the marked plan, or, when it belongs to another period, the plan of this view
|
|
123
|
+
* with the same name (the yearly Pro when the monthly Pro is marked).
|
|
124
|
+
*/
|
|
125
|
+
function featuredSkuForPeriod(visible, all, featuredSku) {
|
|
126
|
+
if (!featuredSku) return void 0;
|
|
127
|
+
if (visible.some((plan) => plan.sku === featuredSku)) return featuredSku;
|
|
128
|
+
const marked = all.find((plan) => plan.sku === featuredSku);
|
|
129
|
+
if (!marked) return void 0;
|
|
130
|
+
const name = marked.displayName.trim().toLowerCase();
|
|
131
|
+
return visible.find((plan) => plan.displayName.trim().toLowerCase() === name)?.sku;
|
|
132
|
+
}
|
|
133
|
+
/** An add-on's price for a plan's period and currency: that one, else its price in that period, else its first. */
|
|
134
|
+
function addOnPriceFor(addOn, billingPeriod, currency) {
|
|
135
|
+
const period = periodOf(billingPeriod);
|
|
136
|
+
const inPeriod = addOn.prices.filter((price) => periodOf(price.billingPeriod) === period);
|
|
137
|
+
return inPeriod.find((price) => price.currency.toLowerCase() === currency.toLowerCase()) ?? inPeriod.at(0) ?? addOn.prices.at(0);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { featuredSkuForPeriod as a, discountFor as i, addOnPriceFor as n, plansForPeriod as o, availablePeriods as r, savingsLabel as s, PERIOD_LABELS as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as quotaCell, y as rateLimitCell } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/billing-state.ts
|
|
4
4
|
/** Whether the pricing page has no plans to show yet because the answer is still on its way. */
|
package/dist/index.d.mts
CHANGED
|
@@ -22,7 +22,9 @@ type DevPortalPlan = {
|
|
|
22
22
|
syncedAtUtc?: string;
|
|
23
23
|
includedActionKeys?: string[]; /** Optional marketing bullets for pricing cards (preview / local catalog). */
|
|
24
24
|
features?: string[]; /** Every price of a plan sold at several (periods, currencies); the first is the default. Absent: one price. */
|
|
25
|
-
prices?: DevPortalPlanPrice[];
|
|
25
|
+
prices?: DevPortalPlanPrice[]; /** Free days before a new subscriber's first charge; absent or null for no trial. */
|
|
26
|
+
trialDays?: number | null; /** Billed usage past the quota; absent or null when calls past it are refused. */
|
|
27
|
+
overage?: DevPortalPlanOverage | null;
|
|
26
28
|
};
|
|
27
29
|
/** One price of a plan: `monthly`, `quarterly` or `annual`, a lowercase currency, an amount for one period. */
|
|
28
30
|
type DevPortalPlanPrice = {
|
|
@@ -32,7 +34,22 @@ type DevPortalPlanPrice = {
|
|
|
32
34
|
};
|
|
33
35
|
type DevPortalPlanCatalog = {
|
|
34
36
|
plans: DevPortalPlan[];
|
|
35
|
-
lastSyncedAtUtc?: string | null;
|
|
37
|
+
lastSyncedAtUtc?: string | null; /** Billed extras a subscriber adds to a paid plan. */
|
|
38
|
+
addOns?: DevPortalAddOn[];
|
|
39
|
+
};
|
|
40
|
+
/** Calls past the quota billed instead of refused: `amount` per `per` calls, at most `cap` a billing period. */
|
|
41
|
+
type DevPortalPlanOverage = {
|
|
42
|
+
per: number;
|
|
43
|
+
amount: number;
|
|
44
|
+
cap: number;
|
|
45
|
+
};
|
|
46
|
+
/** An add-on: a billed extra, priced per period and currency; `plans` empty or absent means every paid plan. */
|
|
47
|
+
type DevPortalAddOn = {
|
|
48
|
+
sku: string;
|
|
49
|
+
displayName: string;
|
|
50
|
+
description?: string | null;
|
|
51
|
+
prices: DevPortalPlanPrice[];
|
|
52
|
+
plans?: string[] | null;
|
|
36
53
|
};
|
|
37
54
|
type DevPortalPricingCompareRow = {
|
|
38
55
|
label: string;
|
|
@@ -87,7 +104,10 @@ type DevPortalBillingConfig = {
|
|
|
87
104
|
includedActionKeys?: string[];
|
|
88
105
|
features?: string[];
|
|
89
106
|
prices?: DevPortalPlanPrice[];
|
|
90
|
-
|
|
107
|
+
trialDays?: number;
|
|
108
|
+
overage?: DevPortalPlanOverage;
|
|
109
|
+
}>; /** Add-ons for a preview, from plans.json (a deployed portal reads them from the plans backend). */
|
|
110
|
+
previewAddOns?: DevPortalAddOn[];
|
|
91
111
|
};
|
|
92
112
|
type DevPortalApiKey = {
|
|
93
113
|
id: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { t as AccountPlansPage } from "./AccountPlansPage-
|
|
1
|
+
import { t as AccountPlansPage } from "./AccountPlansPage-B4gb0WvB.mjs";
|
|
2
2
|
import { n as registerDevPortalBillingOptions, r as useDevPortalBillingConfig, t as DevPortalBillingProvider } from "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
3
3
|
import { a as CREDENTIALS_PATH, c as SUBSCRIPTIONS_PATH, i as CONTACT_SALES_PATH, l as USAGE_PATH, o as LOGIN_NAV_PATH, r as CHECKOUT_PATH, s as PRICING_PATH, t as ACCOUNT_PLANS_PATH } from "./paths-DBr3Dj_q.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import "./PricingCard-
|
|
4
|
+
import { _ as pickFeaturedPlanSku, b as resolveDevPortalApiBaseUrl, c as formatPlanPriceUnit, l as isActiveSubscription, m as parseManifestPlans, o as formatPlanDisplayPrice, p as listPlanFeatureLines } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
5
|
+
import "./PricingCard-CRH9rxT3.mjs";
|
|
6
6
|
import { t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-yK9qEqV-.mjs";
|
|
7
|
-
import { t as useMySubscriptions } from "./useMySubscriptions-
|
|
8
|
-
import { n as startPlansPrefetch, t as usePlans } from "./usePlans-
|
|
7
|
+
import { t as useMySubscriptions } from "./useMySubscriptions-CfZPpul6.mjs";
|
|
8
|
+
import { n as startPlansPrefetch, t as usePlans } from "./usePlans-CRFHBOqz.mjs";
|
|
9
9
|
import "./pending-checkout-DpVaNnTu.mjs";
|
|
10
|
-
import { a as playgroundKeyIdentities, i as useRevokeApiKey, n as useApiKeys, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-
|
|
11
|
-
import { n as useUsageRecent, t as useUsage } from "./useUsage-
|
|
12
|
-
import { r as ApiKeysPanel, t as accountLayoutProps } from "./account-links-
|
|
10
|
+
import { a as playgroundKeyIdentities, i as useRevokeApiKey, n as useApiKeys, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-CS2SmfJc.mjs";
|
|
11
|
+
import { n as useUsageRecent, t as useUsage } from "./useUsage-DqizlLwt.mjs";
|
|
12
|
+
import { r as ApiKeysPanel, t as accountLayoutProps } from "./account-links-QGu5q_vP.mjs";
|
|
13
13
|
import { t as isPreviewPricingEnabled } from "./pricing-config-Bc6eWFUO.mjs";
|
|
14
14
|
import { Head, Link } from "@lukoweb/apitogo/components";
|
|
15
15
|
import { ArrowRightIcon, KeyRoundIcon, StarsIcon } from "@lukoweb/apitogo/icons";
|
|
@@ -367,13 +367,13 @@ async function getSignedInIdentities(apiBaseUrl, fetchImpl = fetch) {
|
|
|
367
367
|
|
|
368
368
|
//#endregion
|
|
369
369
|
//#region src/DevPortalBillingPlugin.tsx
|
|
370
|
-
const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-
|
|
371
|
-
const CheckoutPage = lazy(() => import("./CheckoutPage-
|
|
372
|
-
const ContactSalesPage = lazy(() => import("./ContactSalesPage-
|
|
373
|
-
const CredentialsPage = lazy(() => import("./CredentialsPage-
|
|
374
|
-
const PricingPage = lazy(() => import("./PricingPage-
|
|
375
|
-
const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-
|
|
376
|
-
const UsagePage = lazy(() => import("./UsagePage-
|
|
370
|
+
const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-B4gb0WvB.mjs").then((n) => n.n));
|
|
371
|
+
const CheckoutPage = lazy(() => import("./CheckoutPage-Bom6gjGC.mjs"));
|
|
372
|
+
const ContactSalesPage = lazy(() => import("./ContactSalesPage-DvqVqsuC.mjs"));
|
|
373
|
+
const CredentialsPage = lazy(() => import("./CredentialsPage-BH8xLVnt.mjs"));
|
|
374
|
+
const PricingPage = lazy(() => import("./PricingPage-DJwl2XAp.mjs"));
|
|
375
|
+
const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-d5gWSBMr.mjs"));
|
|
376
|
+
const UsagePage = lazy(() => import("./UsagePage-lPOEWUOG.mjs"));
|
|
377
377
|
function resolvePricingEnabled(config) {
|
|
378
378
|
if (config.__meta?.pricingEnabled !== void 0) return config.__meta.pricingEnabled;
|
|
379
379
|
return isPreviewPricingEnabled();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
|
-
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-
|
|
2
|
+
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
3
3
|
import { n as readProblemDetail } from "./problem-details-n20-dy3w.mjs";
|
|
4
4
|
import { n as createDemoApiKeys, t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-yK9qEqV-.mjs";
|
|
5
5
|
import { useMutation, useQuery, useQueryClient } from "@lukoweb/apitogo/react-query";
|
|
@@ -30,7 +30,9 @@ function mapPreviewPlans(plans) {
|
|
|
30
30
|
limitsJson: resolveLimitsJson(plan),
|
|
31
31
|
includedActionKeys: plan.includedActionKeys,
|
|
32
32
|
features: plan.features,
|
|
33
|
-
...plan.prices?.length ? { prices: plan.prices } : {}
|
|
33
|
+
...plan.prices?.length ? { prices: plan.prices } : {},
|
|
34
|
+
...plan.trialDays ? { trialDays: plan.trialDays } : {},
|
|
35
|
+
...plan.overage ? { overage: plan.overage } : {}
|
|
34
36
|
}));
|
|
35
37
|
}
|
|
36
38
|
function readModulePlanItems() {
|
|
@@ -50,7 +52,9 @@ function parseManifestPlans(configPlans) {
|
|
|
50
52
|
limitsJson: plan.limitsJson ?? null,
|
|
51
53
|
includedActionKeys: plan.includedActionKeys ?? [],
|
|
52
54
|
features: plan.features,
|
|
53
|
-
prices: plan.prices
|
|
55
|
+
prices: plan.prices,
|
|
56
|
+
trialDays: plan.trialDays,
|
|
57
|
+
overage: plan.overage
|
|
54
58
|
}))) };
|
|
55
59
|
if (manifestCatalog?.plans?.length) return { plans: mapPreviewPlans(manifestCatalog.plans) };
|
|
56
60
|
const metaPlans = zudokuConfig?.__meta?.previewPlans;
|
|
@@ -68,7 +72,9 @@ function parseManifestPlans(configPlans) {
|
|
|
68
72
|
limitsJson: plan.limitsJson ?? null,
|
|
69
73
|
includedActionKeys: plan.includedActionKeys ?? [],
|
|
70
74
|
features: plan.features,
|
|
71
|
-
prices: plan.prices
|
|
75
|
+
prices: plan.prices,
|
|
76
|
+
trialDays: plan.trialDays,
|
|
77
|
+
overage: plan.overage
|
|
72
78
|
}))) };
|
|
73
79
|
return { plans: [] };
|
|
74
80
|
}
|
|
@@ -281,4 +287,4 @@ function useDevPortalPreviewMode() {
|
|
|
281
287
|
}
|
|
282
288
|
|
|
283
289
|
//#endregion
|
|
284
|
-
export {
|
|
290
|
+
export { pickFeaturedPlanSku as _, formatMoney as a, resolveDevPortalApiBaseUrl as b, formatPlanPriceUnit as c, isPlanCustomPriced as d, isPlanFree as f, parseQuotaPeriodDays as g, parseMonthlyQuotaCalls as h, formatBillingPeriod as i, isActiveSubscription as l, parseManifestPlans as m, useDevPortalPreviewMode as n, formatPlanDisplayPrice as o, listPlanFeatureLines as p, useIsDemoSession as r, formatPlanPrice as s, useDevPortalApiBaseUrl as t, isPlaceholderDevPortalApiUrl as u, quotaCell as v, withPlanFeatures as x, rateLimitCell as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
|
-
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-
|
|
2
|
+
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
3
3
|
import { i as createDemoMeResponse } from "./demo-session-yK9qEqV-.mjs";
|
|
4
4
|
import { useQuery } from "@lukoweb/apitogo/react-query";
|
|
5
5
|
import { useAuth } from "@lukoweb/apitogo/hooks";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { m as parseManifestPlans, n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl, u as isPlaceholderDevPortalApiUrl, x as withPlanFeatures } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
3
3
|
import { useQuery } from "@lukoweb/apitogo/react-query";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/plans-prefetch.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-
|
|
1
|
+
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DwObxX8r.mjs";
|
|
2
2
|
import { useQuery } from "@lukoweb/apitogo/react-query";
|
|
3
3
|
import { useAuth } from "@lukoweb/apitogo/hooks";
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukoweb/apitogo-plugin-dev-portal-billing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.82",
|
|
4
4
|
"homepage": "https://docs.apitogo.com",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"react": "19.2.4",
|
|
43
43
|
"react-dom": "19.2.4",
|
|
44
44
|
"tsdown": "0.20.3",
|
|
45
|
-
"@lukoweb/apitogo": "0.2.
|
|
46
|
-
"@lukoweb/apitogo-module-user-panel": "0.2.
|
|
45
|
+
"@lukoweb/apitogo": "0.2.82",
|
|
46
|
+
"@lukoweb/apitogo-module-user-panel": "0.2.82"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": ">=19.2.0",
|