@lukoweb/apitogo-plugin-dev-portal-billing 0.2.77 → 0.2.78

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.
@@ -1,9 +1,9 @@
1
1
  import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
- import { f as parseManifestPlans, n as useDevPortalPreviewMode, r as useIsDemoSession, s as isActiveSubscription, t as useDevPortalApiBaseUrl, y as withPlanFeatures } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
- import { t as PricingCard } from "./PricingCard-KDRcH2ny.mjs";
2
+ import { f as parseManifestPlans, n as useDevPortalPreviewMode, r as useIsDemoSession, s as isActiveSubscription, t as useDevPortalApiBaseUrl, y as withPlanFeatures } from "./useDevPortalApiBaseUrl-DoEmQpw0.mjs";
3
+ import { t as PricingCard } from "./PricingCard-CgSIIalL.mjs";
4
4
  import { n as readProblemDetail } from "./problem-details-n20-dy3w.mjs";
5
- import { t as useMySubscriptions } from "./useMySubscriptions-BHp7cjkN.mjs";
6
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
5
+ import { t as useMySubscriptions } from "./useMySubscriptions-CAvkfuhc.mjs";
6
+ import { t as usePlans } from "./usePlans-ARES9Hcn.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-B7gBA5El.mjs";
2
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DoEmQpw0.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-D0Nkuz7i.mjs";
5
+ import { t as FREE_CHECKOUT_MARKER } from "./billing-state-BKTAV0xR.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";
@@ -58,6 +58,8 @@ const RedirectPage = ({ icon: Icon, title, description, url, children }) => {
58
58
  const CheckoutPage = () => {
59
59
  const [searchParams] = useSearchParams();
60
60
  const planSku = searchParams.get("planSku") ?? "";
61
+ const billingPeriod = searchParams.get("period") ?? void 0;
62
+ const currency = searchParams.get("currency") ?? void 0;
61
63
  const navigate = useNavigate();
62
64
  const auth = useAuth();
63
65
  const apiBaseUrl = useDevPortalApiBaseUrl();
@@ -69,6 +71,8 @@ const CheckoutPage = () => {
69
71
  "dev-portal-checkout",
70
72
  apiBaseUrl,
71
73
  planSku,
74
+ billingPeriod,
75
+ currency,
72
76
  auth.profile?.sub
73
77
  ],
74
78
  enabled: Boolean(planSku) && !isPreview && !isDemoSession && auth.isAuthenticated && Boolean(apiBaseUrl),
@@ -81,7 +85,11 @@ const CheckoutPage = () => {
81
85
  "Content-Type": "application/json"
82
86
  },
83
87
  credentials: "include",
84
- body: JSON.stringify({ planSku })
88
+ body: JSON.stringify({
89
+ planSku,
90
+ billingPeriod,
91
+ currency
92
+ })
85
93
  });
86
94
  if (!response.ok) throw new Error(await readProblemDetail(response) ?? "Checkout failed.");
87
95
  return await response.json();
@@ -1,8 +1,8 @@
1
1
  import "./DevPortalBillingContext-BUQPLoyk.mjs";
2
2
  import { s as PRICING_PATH } from "./paths-DBr3Dj_q.mjs";
3
- import { l as isPlanCustomPriced, n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
+ import { l as isPlanCustomPriced, n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DoEmQpw0.mjs";
4
4
  import { n as readProblemDetail } from "./problem-details-n20-dy3w.mjs";
5
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
5
+ import { t as usePlans } from "./usePlans-ARES9Hcn.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-B7gBA5El.mjs";
3
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DoEmQpw0.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-Co1xhgcO.mjs";
6
- import { n as apiReferencePath, r as ApiKeysPanel } from "./account-links-DZ9i1WTa.mjs";
5
+ import { n as useApiKeys } from "./useApiKeys-4pgYaVZ0.mjs";
6
+ import { n as apiReferencePath, r as ApiKeysPanel } from "./account-links-Dri6HK0u.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 { d as listPlanFeatureLines, i as formatPlanDisplayPrice, l as isPlanCustomPriced, o as formatPlanPriceUnit, s as isActiveSubscription, u as isPlanFree } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
+ import { d as listPlanFeatureLines, i as formatPlanDisplayPrice, l as isPlanCustomPriced, o as formatPlanPriceUnit, s as isActiveSubscription, u as isPlanFree } from "./useDevPortalApiBaseUrl-DoEmQpw0.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";
@@ -17,8 +17,15 @@ const accountCtaLabel = (plan) => {
17
17
  if (isPlanCustomPriced(plan)) return "Contact sales";
18
18
  return isPlanFree(plan) ? "Get started" : "Subscribe";
19
19
  };
20
- /** Custom-priced plans skip checkout and open the contact-sales form. */
21
- const planCtaPath = (plan) => `${isPlanCustomPriced(plan) ? CONTACT_SALES_PATH : CHECKOUT_PATH}?planSku=${encodeURIComponent(plan.sku)}`;
20
+ /**
21
+ * Custom-priced plans skip checkout and open the contact-sales form. A plan sold at several prices also says which one
22
+ * the card shows (its period and currency), so checkout charges what the visitor saw.
23
+ */
24
+ const planCtaPath = (plan) => {
25
+ const base = `${isPlanCustomPriced(plan) ? CONTACT_SALES_PATH : CHECKOUT_PATH}?planSku=${encodeURIComponent(plan.sku)}`;
26
+ if (isPlanCustomPriced(plan) || (plan.prices?.length ?? 0) < 2) return base;
27
+ return `${base}&period=${encodeURIComponent(plan.billingPeriod)}&currency=${encodeURIComponent(plan.priceCurrency)}`;
28
+ };
22
29
  const PricingCard = ({ plan, mode = "public", subscriptionStatus, isSubscribed = false, onUnsubscribe, onSwitch, isSwitching = false, isCanceling = false, cancelDisabled = false, featured = false, isConfirming = false }) => {
23
30
  const isActive = isSubscribed || isActiveSubscription(subscriptionStatus ?? "");
24
31
  const { showEndpoints } = useDevPortalBillingConfig();
@@ -1,14 +1,128 @@
1
1
  import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
- import { f as parseManifestPlans, h as pickFeaturedPlanSku, n as useDevPortalPreviewMode, y as withPlanFeatures } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
- import { t as PricingCard } from "./PricingCard-KDRcH2ny.mjs";
4
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
2
+ import { f as parseManifestPlans, h as pickFeaturedPlanSku, l as isPlanCustomPriced, n as useDevPortalPreviewMode, u as isPlanFree, y as withPlanFeatures } from "./useDevPortalApiBaseUrl-DoEmQpw0.mjs";
3
+ import { t as PricingCard } from "./PricingCard-CgSIIalL.mjs";
4
+ import { t as usePlans } from "./usePlans-ARES9Hcn.mjs";
5
5
  import { t as isPreviewPricingEnabled } from "./pricing-config-Bc6eWFUO.mjs";
6
- import { a as isPricingLoading, n as buildCompareRows } from "./billing-state-D0Nkuz7i.mjs";
6
+ import { a as isPricingLoading, n as buildCompareRows } from "./billing-state-BKTAV0xR.mjs";
7
7
  import { Head, Heading } from "@lukoweb/apitogo/components";
8
8
  import { Navigate } from "@lukoweb/apitogo/router";
9
+ import { useState } from "react";
9
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
11
  import { useAuth } from "@lukoweb/apitogo/hooks";
11
12
 
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
+ /**
90
+ * What a plan saves in a longer period against paying monthly for as long, in whole percent: the plan's own monthly
91
+ * price, or the monthly plan with the same name and currency. Null when there is nothing to compare with or no saving.
92
+ */
93
+ function savingsPercent(plan, period, plans) {
94
+ if (period === "monthly" || !isPaidFixed(plan)) return null;
95
+ const atPeriod = planAtPeriod(plan, period);
96
+ if (periodOf(atPeriod.billingPeriod) !== period) return null;
97
+ const monthly = monthlyPriceFor(atPeriod, plans);
98
+ if (!monthly) return null;
99
+ const percent = Math.round((1 - atPeriod.priceAmount / (monthly * MONTHS[period])) * 100);
100
+ return percent > 0 ? percent : null;
101
+ }
102
+ /**
103
+ * A period button's badge: "Save 20%" when every plan saves the same, "Save up to 25%" when they differ, null when
104
+ * none saves anything.
105
+ */
106
+ function savingsLabel(plans, period) {
107
+ const savings = plans.map((plan) => savingsPercent(plan, period, plans)).filter((percent) => percent !== null);
108
+ if (savings.length === 0) return null;
109
+ const best = Math.max(...savings);
110
+ return savings.every((percent) => percent === best) ? `Save ${best}%` : `Save up to ${best}%`;
111
+ }
112
+ /**
113
+ * The plan shown as "Popular" in a view: the marked plan, or, when it belongs to another period, the plan of this view
114
+ * with the same name (the yearly Pro when the monthly Pro is marked).
115
+ */
116
+ function featuredSkuForPeriod(visible, all, featuredSku) {
117
+ if (!featuredSku) return void 0;
118
+ if (visible.some((plan) => plan.sku === featuredSku)) return featuredSku;
119
+ const marked = all.find((plan) => plan.sku === featuredSku);
120
+ if (!marked) return void 0;
121
+ const name = marked.displayName.trim().toLowerCase();
122
+ return visible.find((plan) => plan.displayName.trim().toLowerCase() === name)?.sku;
123
+ }
124
+
125
+ //#endregion
12
126
  //#region src/pages/PricingPage.tsx
13
127
  const DEFAULT_COMPARE_ROWS = [
14
128
  {
@@ -81,6 +195,7 @@ const PricingPage = () => {
81
195
  const livePlans = usePlans();
82
196
  const catalog = isPreview ? withPlanFeatures(parseManifestPlans(previewPlans), planFeatures) : livePlans.data;
83
197
  const { isPending: authPending } = useAuth();
198
+ const [chosenPeriod, setPeriod] = useState("monthly");
84
199
  const isLoading = isPricingLoading({
85
200
  isPreview,
86
201
  plansLoading: livePlans.isLoading,
@@ -95,8 +210,12 @@ const PricingPage = () => {
95
210
  });
96
211
  const title = pricing?.title ?? "Plans and pricing";
97
212
  const subtitle = pricing?.subtitle ?? "Choose the plan that fits how you use the API. Each plan lists its limits and what it includes.";
98
- const plans = catalog?.plans ?? [];
99
- const featuredSku = pickFeaturedPlanSku(plans, featuredPlanSku);
213
+ const allPlans = catalog?.plans ?? [];
214
+ const periods = availablePeriods(allPlans);
215
+ const periodChoice = periods.length > 1;
216
+ const period = periods.includes(chosenPeriod) ? chosenPeriod : periods.at(0) ?? "monthly";
217
+ const plans = plansForPeriod(allPlans, period);
218
+ const featuredSku = featuredSkuForPeriod(plans, allPlans, pickFeaturedPlanSku(allPlans, featuredPlanSku));
100
219
  const compareRows = buildCompareRows({
101
220
  plans,
102
221
  configuredRows: pricing?.compareRows,
@@ -148,6 +267,27 @@ const PricingPage = () => {
148
267
  className: "text-center text-destructive",
149
268
  children: "Unable to load plans."
150
269
  }) : null,
270
+ periodChoice ? /* @__PURE__ */ jsx("div", {
271
+ className: "mb-8 flex justify-center",
272
+ children: /* @__PURE__ */ jsx("div", {
273
+ role: "radiogroup",
274
+ "aria-label": "Billing period",
275
+ className: "inline-flex items-center gap-1 rounded-full border border-border bg-card p-1",
276
+ "data-testid": "billing-period-switch",
277
+ children: periods.map((option) => /* @__PURE__ */ jsxs("button", {
278
+ type: "button",
279
+ role: "radio",
280
+ "aria-checked": period === option,
281
+ onClick: () => setPeriod(option),
282
+ className: period === option ? "inline-flex items-center gap-2 rounded-full bg-primary px-5 py-2 text-sm font-semibold text-primary-foreground" : "inline-flex items-center gap-2 rounded-full px-5 py-2 text-sm font-semibold text-muted-foreground hover:text-foreground",
283
+ "data-testid": `billing-period-${option}`,
284
+ children: [PERIOD_LABELS[option], savingsLabel(allPlans, option) ? /* @__PURE__ */ jsx("span", {
285
+ className: period === option ? "rounded-full bg-primary-foreground/20 px-2 py-0.5 text-xs" : "rounded-full bg-primary/15 px-2 py-0.5 text-xs text-primary",
286
+ children: savingsLabel(allPlans, option)
287
+ }) : null]
288
+ }, option))
289
+ })
290
+ }) : null,
151
291
  plans.length > 0 ? /* @__PURE__ */ jsx("div", {
152
292
  className: "mx-auto grid max-w-[1200px] grid-cols-1 items-stretch gap-5 sm:grid-cols-2 lg:grid-cols-4",
153
293
  children: plans.map((plan) => /* @__PURE__ */ jsx(PricingCard, {
@@ -1,12 +1,12 @@
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 { a as formatPlanPrice, p as parseMonthlyQuotaCalls, s as isActiveSubscription, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
4
- import { t as useMySubscriptions } from "./useMySubscriptions-BHp7cjkN.mjs";
5
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
3
+ import { a as formatPlanPrice, p as parseMonthlyQuotaCalls, s as isActiveSubscription, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DoEmQpw0.mjs";
4
+ import { t as useMySubscriptions } from "./useMySubscriptions-CAvkfuhc.mjs";
5
+ import { t as usePlans } from "./usePlans-ARES9Hcn.mjs";
6
6
  import { n as readPendingCheckout, t as clearPendingCheckout } from "./pending-checkout-DpVaNnTu.mjs";
7
- import { n as useApiKeys } from "./useApiKeys-Co1xhgcO.mjs";
8
- import { t as useUsage } from "./useUsage-BKuMJS65.mjs";
9
- import { i as hasPaymentProvider, r as checkoutConfirmingText } from "./billing-state-D0Nkuz7i.mjs";
7
+ import { n as useApiKeys } from "./useApiKeys-4pgYaVZ0.mjs";
8
+ import { t as useUsage } from "./useUsage-4fYIwe5V.mjs";
9
+ import { i as hasPaymentProvider, r as checkoutConfirmingText } from "./billing-state-BKTAV0xR.mjs";
10
10
  import { i as ChoosePlanNotice, n as billingPageState, r as keyPlanNote } from "./page-state-Cmo0FPLl.mjs";
11
11
  import { Head, Spinner } from "@lukoweb/apitogo/components";
12
12
  import { Link as Link$1, useSearchParams } from "@lukoweb/apitogo/router";
@@ -1,8 +1,8 @@
1
1
  import "./DevPortalBillingContext-BUQPLoyk.mjs";
2
- import { m as parseQuotaPeriodDays, p as parseMonthlyQuotaCalls, s as isActiveSubscription } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
- import { t as useMySubscriptions } from "./useMySubscriptions-BHp7cjkN.mjs";
4
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
5
- import { n as useUsageRecent, t as useUsage } from "./useUsage-BKuMJS65.mjs";
2
+ import { m as parseQuotaPeriodDays, p as parseMonthlyQuotaCalls, s as isActiveSubscription } from "./useDevPortalApiBaseUrl-DoEmQpw0.mjs";
3
+ import { t as useMySubscriptions } from "./useMySubscriptions-CAvkfuhc.mjs";
4
+ import { t as usePlans } from "./usePlans-ARES9Hcn.mjs";
5
+ import { n as useUsageRecent, t as useUsage } from "./useUsage-4fYIwe5V.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-Co1xhgcO.mjs";
1
+ import { i as useRevokeApiKey, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-4pgYaVZ0.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";
@@ -1,4 +1,4 @@
1
- import { _ as rateLimitCell, g as quotaCell } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
1
+ import { _ as rateLimitCell, g as quotaCell } from "./useDevPortalApiBaseUrl-DoEmQpw0.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
@@ -21,7 +21,14 @@ type DevPortalPlan = {
21
21
  billingPeriod: string;
22
22
  syncedAtUtc?: string;
23
23
  includedActionKeys?: string[]; /** Optional marketing bullets for pricing cards (preview / local catalog). */
24
- features?: string[];
24
+ features?: string[]; /** Every price of a plan sold at several (periods, currencies); the first is the default. Absent: one price. */
25
+ prices?: DevPortalPlanPrice[];
26
+ };
27
+ /** One price of a plan: `monthly`, `quarterly` or `annual`, a lowercase currency, an amount for one period. */
28
+ type DevPortalPlanPrice = {
29
+ billingPeriod: string;
30
+ currency: string;
31
+ amount: number;
25
32
  };
26
33
  type DevPortalPlanCatalog = {
27
34
  plans: DevPortalPlan[];
@@ -79,6 +86,7 @@ type DevPortalBillingConfig = {
79
86
  limitsJson?: string | null;
80
87
  includedActionKeys?: string[];
81
88
  features?: string[];
89
+ prices?: DevPortalPlanPrice[];
82
90
  }>;
83
91
  };
84
92
  type DevPortalApiKey = {
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import { t as AccountPlansPage } from "./AccountPlansPage-USlRPEhN.mjs";
1
+ import { t as AccountPlansPage } from "./AccountPlansPage-CRZpmhTm.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 { d as listPlanFeatureLines, f as parseManifestPlans, h as pickFeaturedPlanSku, i as formatPlanDisplayPrice, o as formatPlanPriceUnit, s as isActiveSubscription, v as resolveDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
5
- import "./PricingCard-KDRcH2ny.mjs";
4
+ import { d as listPlanFeatureLines, f as parseManifestPlans, h as pickFeaturedPlanSku, i as formatPlanDisplayPrice, o as formatPlanPriceUnit, s as isActiveSubscription, v as resolveDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DoEmQpw0.mjs";
5
+ import "./PricingCard-CgSIIalL.mjs";
6
6
  import { t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-yK9qEqV-.mjs";
7
- import { t as useMySubscriptions } from "./useMySubscriptions-BHp7cjkN.mjs";
8
- import { n as startPlansPrefetch, t as usePlans } from "./usePlans-BKT8rIgl.mjs";
7
+ import { t as useMySubscriptions } from "./useMySubscriptions-CAvkfuhc.mjs";
8
+ import { n as startPlansPrefetch, t as usePlans } from "./usePlans-ARES9Hcn.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-Co1xhgcO.mjs";
11
- import { n as useUsageRecent, t as useUsage } from "./useUsage-BKuMJS65.mjs";
12
- import { r as ApiKeysPanel, t as accountLayoutProps } from "./account-links-DZ9i1WTa.mjs";
10
+ import { a as playgroundKeyIdentities, i as useRevokeApiKey, n as useApiKeys, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-4pgYaVZ0.mjs";
11
+ import { n as useUsageRecent, t as useUsage } from "./useUsage-4fYIwe5V.mjs";
12
+ import { r as ApiKeysPanel, t as accountLayoutProps } from "./account-links-Dri6HK0u.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-USlRPEhN.mjs").then((n) => n.n));
371
- const CheckoutPage = lazy(() => import("./CheckoutPage-CED9AYw0.mjs"));
372
- const ContactSalesPage = lazy(() => import("./ContactSalesPage-B1qWs7UW.mjs"));
373
- const CredentialsPage = lazy(() => import("./CredentialsPage-DpV3JBPM.mjs"));
374
- const PricingPage = lazy(() => import("./PricingPage-CiejO1vQ.mjs"));
375
- const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-LvYhFxv1.mjs"));
376
- const UsagePage = lazy(() => import("./UsagePage-CeUcC33p.mjs"));
370
+ const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-CRZpmhTm.mjs").then((n) => n.n));
371
+ const CheckoutPage = lazy(() => import("./CheckoutPage-B56e5vLI.mjs"));
372
+ const ContactSalesPage = lazy(() => import("./ContactSalesPage-Ca-LTZbN.mjs"));
373
+ const CredentialsPage = lazy(() => import("./CredentialsPage-JtIVqKF4.mjs"));
374
+ const PricingPage = lazy(() => import("./PricingPage-DD6m9wtN.mjs"));
375
+ const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-CMcTjfb-.mjs"));
376
+ const UsagePage = lazy(() => import("./UsagePage--DVUA6rr.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-B7gBA5El.mjs";
2
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DoEmQpw0.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";
@@ -29,7 +29,8 @@ function mapPreviewPlans(plans) {
29
29
  billingPeriod: plan.billingPeriod,
30
30
  limitsJson: resolveLimitsJson(plan),
31
31
  includedActionKeys: plan.includedActionKeys,
32
- features: plan.features
32
+ features: plan.features,
33
+ ...plan.prices?.length ? { prices: plan.prices } : {}
33
34
  }));
34
35
  }
35
36
  function readModulePlanItems() {
@@ -48,7 +49,8 @@ function parseManifestPlans(configPlans) {
48
49
  limits: plan.limits,
49
50
  limitsJson: plan.limitsJson ?? null,
50
51
  includedActionKeys: plan.includedActionKeys ?? [],
51
- features: plan.features
52
+ features: plan.features,
53
+ prices: plan.prices
52
54
  }))) };
53
55
  if (manifestCatalog?.plans?.length) return { plans: mapPreviewPlans(manifestCatalog.plans) };
54
56
  const metaPlans = zudokuConfig?.__meta?.previewPlans;
@@ -65,7 +67,8 @@ function parseManifestPlans(configPlans) {
65
67
  limits: plan.limits,
66
68
  limitsJson: plan.limitsJson ?? null,
67
69
  includedActionKeys: plan.includedActionKeys ?? [],
68
- features: plan.features
70
+ features: plan.features,
71
+ prices: plan.prices
69
72
  }))) };
70
73
  return { plans: [] };
71
74
  }
@@ -91,6 +94,7 @@ function formatPlanPrice(plan) {
91
94
  }).format(plan.priceAmount);
92
95
  const period = plan.billingPeriod.toLowerCase();
93
96
  if (period === "monthly" || period === "month") return `${amount}/mo`;
97
+ if (period === "quarterly" || period === "quarter") return `${amount}/qtr`;
94
98
  if (period === "annual" || period === "year") return `${amount}/yr`;
95
99
  return amount;
96
100
  }
@@ -100,6 +104,7 @@ function isPlanFree(plan) {
100
104
  function formatBillingPeriod(period) {
101
105
  const normalized = period.toLowerCase();
102
106
  if (normalized === "month" || normalized === "monthly") return "per month";
107
+ if (normalized === "quarter" || normalized === "quarterly") return "per quarter";
103
108
  if (normalized === "year" || normalized === "annual") return "per year";
104
109
  if (normalized === "custom") return "talk to us";
105
110
  return period;
@@ -109,7 +114,7 @@ function formatPlanDisplayPrice(plan) {
109
114
  if (isPlanCustomPriced(plan)) return formatCustomPriceLabel(plan);
110
115
  if (isPlanFree(plan)) return "$0";
111
116
  const priceLabel = formatPlanPrice(plan);
112
- return priceLabel.replace(/\/mo$/, "").replace(/\/yr$/, "") || priceLabel;
117
+ return priceLabel.replace(/\/mo$/, "").replace(/\/qtr$/, "").replace(/\/yr$/, "") || priceLabel;
113
118
  }
114
119
  /** Caption shown under the plan price (e.g. `per month`, `talk to us`). */
115
120
  function formatPlanPriceUnit(plan) {
@@ -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-B7gBA5El.mjs";
2
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DoEmQpw0.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 { c as isPlaceholderDevPortalApiUrl, f as parseManifestPlans, n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl, y as withPlanFeatures } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
2
+ import { c as isPlaceholderDevPortalApiUrl, f as parseManifestPlans, n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl, y as withPlanFeatures } from "./useDevPortalApiBaseUrl-DoEmQpw0.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-B7gBA5El.mjs";
1
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-DoEmQpw0.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.77",
3
+ "version": "0.2.78",
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.77",
46
- "@lukoweb/apitogo-module-user-panel": "0.2.77"
45
+ "@lukoweb/apitogo": "0.2.78",
46
+ "@lukoweb/apitogo-module-user-panel": "0.2.78"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "react": ">=19.2.0",