@solvapay/react 1.2.1 → 1.3.0-preview-cb8ad16e16ce8f8f357bd7f2e7068d85159df587
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/CHANGELOG.md +11 -0
- package/dist/adapters/auth0.cjs +60 -0
- package/dist/adapters/auth0.d.cts +16 -0
- package/dist/adapters/auth0.d.ts +16 -0
- package/dist/adapters/auth0.js +15 -0
- package/dist/adapters/session-auth.cjs +49 -0
- package/dist/adapters/session-auth.d.cts +20 -0
- package/dist/adapters/session-auth.d.ts +20 -0
- package/dist/adapters/session-auth.js +6 -0
- package/dist/{chunk-XRNCDI2T.js → chunk-3UR4QQ5P.js} +1 -1
- package/dist/chunk-JTW665JR.js +25 -0
- package/dist/{chunk-Y2UAJG67.js → chunk-ORMHGGOU.js} +244 -73
- package/dist/{chunk-MYD6KTR2.js → chunk-WGDHMTDO.js} +1 -1
- package/dist/{index-DPoqku6R.d.cts → index-BwwdMBdt.d.ts} +20 -5
- package/dist/{index-Cs-QqpkJ.d.ts → index-kXLvp7EU.d.cts} +20 -5
- package/dist/index.cjs +294 -106
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +8 -3
- package/dist/mcp/index.cjs +328 -70
- package/dist/mcp/index.d.cts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +131 -34
- package/dist/mcp/styles.css +39 -0
- package/dist/primitives/index.cjs +207 -38
- package/dist/primitives/index.d.cts +22 -5
- package/dist/primitives/index.d.ts +22 -5
- package/dist/primitives/index.js +6 -2
- package/dist/{shared-DpS2yEah.d.cts → shared-BNZAIWkU.d.cts} +196 -7
- package/dist/{shared-CXRbrNFw.d.ts → shared-lIhc8DS3.d.ts} +196 -7
- package/dist/styles.css +25 -0
- package/package.json +12 -7
|
@@ -110,9 +110,11 @@ __export(primitives_exports, {
|
|
|
110
110
|
PlanSelector: () => PlanSelector,
|
|
111
111
|
PlanSelectorCard: () => PlanSelectorCard2,
|
|
112
112
|
PlanSelectorCardBadge: () => PlanSelectorCardBadge2,
|
|
113
|
+
PlanSelectorCardCurrency: () => PlanSelectorCardCurrency2,
|
|
113
114
|
PlanSelectorCardInterval: () => PlanSelectorCardInterval2,
|
|
114
115
|
PlanSelectorCardName: () => PlanSelectorCardName2,
|
|
115
116
|
PlanSelectorCardPrice: () => PlanSelectorCardPrice2,
|
|
117
|
+
PlanSelectorCurrencySwitcher: () => PlanSelectorCurrencySwitcher2,
|
|
116
118
|
PlanSelectorError: () => PlanSelectorError2,
|
|
117
119
|
PlanSelectorGrid: () => PlanSelectorGrid2,
|
|
118
120
|
PlanSelectorHeading: () => PlanSelectorHeading2,
|
|
@@ -371,6 +373,17 @@ async function buildRequestHeaders(config) {
|
|
|
371
373
|
return { headers, userId };
|
|
372
374
|
}
|
|
373
375
|
|
|
376
|
+
// src/utils/readErrorMessage.ts
|
|
377
|
+
async function readErrorMessage(res, fallbackPrefix) {
|
|
378
|
+
let serverMessage;
|
|
379
|
+
try {
|
|
380
|
+
const data = await res.clone().json();
|
|
381
|
+
serverMessage = data?.error;
|
|
382
|
+
} catch {
|
|
383
|
+
}
|
|
384
|
+
return serverMessage || `${fallbackPrefix}: ${res.statusText || res.status}`;
|
|
385
|
+
}
|
|
386
|
+
|
|
374
387
|
// src/transport/http.ts
|
|
375
388
|
async function request(config, url, opts) {
|
|
376
389
|
const { headers } = await buildRequestHeaders(config);
|
|
@@ -381,13 +394,8 @@ async function request(config, url, opts) {
|
|
|
381
394
|
}
|
|
382
395
|
const res = await fetchFn(url, init);
|
|
383
396
|
if (!res.ok) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const data = await res.clone().json();
|
|
387
|
-
serverMessage = data?.error;
|
|
388
|
-
} catch {
|
|
389
|
-
}
|
|
390
|
-
const error = new Error(serverMessage || `${opts.errorPrefix}: ${res.statusText || res.status}`);
|
|
397
|
+
const message = await readErrorMessage(res, opts.errorPrefix);
|
|
398
|
+
const error = new Error(message);
|
|
391
399
|
config?.onError?.(error, opts.onErrorContext);
|
|
392
400
|
throw error;
|
|
393
401
|
}
|
|
@@ -427,6 +435,7 @@ function createHttpTransport(config) {
|
|
|
427
435
|
const body = {};
|
|
428
436
|
if (params.planRef) body.planRef = params.planRef;
|
|
429
437
|
if (params.productRef) body.productRef = params.productRef;
|
|
438
|
+
if (params.currency) body.currency = params.currency;
|
|
430
439
|
if (params.customer && (params.customer.name || params.customer.email)) {
|
|
431
440
|
body.customer = params.customer;
|
|
432
441
|
}
|
|
@@ -659,6 +668,7 @@ var enCopy = {
|
|
|
659
668
|
currentBadge: "Current",
|
|
660
669
|
popularBadge: "Popular",
|
|
661
670
|
freeBadge: "Free",
|
|
671
|
+
usageRateLabel: "Usage-based",
|
|
662
672
|
perIntervalShort: "/{interval}",
|
|
663
673
|
continueButton: "Continue",
|
|
664
674
|
backButton: "\u2190 Back to plans",
|
|
@@ -1043,7 +1053,8 @@ async function defaultListPlans(productRef, config) {
|
|
|
1043
1053
|
const { headers } = await buildRequestHeaders(config);
|
|
1044
1054
|
const res = await fetchFn(url, { method: "GET", headers });
|
|
1045
1055
|
if (!res.ok) {
|
|
1046
|
-
const
|
|
1056
|
+
const message = await readErrorMessage(res, "Failed to fetch plans");
|
|
1057
|
+
const error = new Error(message);
|
|
1047
1058
|
config?.onError?.(error, "listPlans");
|
|
1048
1059
|
throw error;
|
|
1049
1060
|
}
|
|
@@ -1304,7 +1315,7 @@ function toMajorUnits(amountMinor, currency) {
|
|
|
1304
1315
|
return fractionDigits === 0 ? amountMinor : amountMinor / 100;
|
|
1305
1316
|
}
|
|
1306
1317
|
function formatPrice(amountMinor, currency, opts = {}) {
|
|
1307
|
-
const { locale, interval, intervalCount = 1, free = "Free" } = opts;
|
|
1318
|
+
const { locale, interval, intervalCount = 1, free = "Free", currencyDisplay } = opts;
|
|
1308
1319
|
if (amountMinor === 0 && free !== "") {
|
|
1309
1320
|
return free;
|
|
1310
1321
|
}
|
|
@@ -1313,12 +1324,16 @@ function formatPrice(amountMinor, currency, opts = {}) {
|
|
|
1313
1324
|
const isWhole = amountMinor % minorPerMajor === 0;
|
|
1314
1325
|
const fractionDigits = isWhole ? 0 : naturalFractionDigits;
|
|
1315
1326
|
const major = toMajorUnits(amountMinor, currency);
|
|
1316
|
-
const
|
|
1327
|
+
const formatterOptions = {
|
|
1317
1328
|
style: "currency",
|
|
1318
1329
|
currency: currency.toUpperCase(),
|
|
1319
1330
|
minimumFractionDigits: fractionDigits,
|
|
1320
1331
|
maximumFractionDigits: fractionDigits
|
|
1321
|
-
}
|
|
1332
|
+
};
|
|
1333
|
+
if (currencyDisplay) {
|
|
1334
|
+
formatterOptions.currencyDisplay = currencyDisplay;
|
|
1335
|
+
}
|
|
1336
|
+
const formatter = new Intl.NumberFormat(locale, formatterOptions);
|
|
1322
1337
|
const formatted = formatter.format(major);
|
|
1323
1338
|
if (!interval) return formatted;
|
|
1324
1339
|
const suffix = intervalCount > 1 ? `${intervalCount} ${interval}s` : interval;
|
|
@@ -1496,6 +1511,28 @@ function isPaygPlan(plan) {
|
|
|
1496
1511
|
return type === "usage-based" || type === "hybrid";
|
|
1497
1512
|
}
|
|
1498
1513
|
|
|
1514
|
+
// src/utils/planPricing.ts
|
|
1515
|
+
function getPlanPricingOptions(plan) {
|
|
1516
|
+
if (plan.pricingOptions && plan.pricingOptions.length > 0) {
|
|
1517
|
+
return plan.pricingOptions;
|
|
1518
|
+
}
|
|
1519
|
+
return [
|
|
1520
|
+
{
|
|
1521
|
+
currency: plan.currency ?? "USD",
|
|
1522
|
+
price: plan.price ?? 0,
|
|
1523
|
+
default: true
|
|
1524
|
+
}
|
|
1525
|
+
];
|
|
1526
|
+
}
|
|
1527
|
+
function resolvePlanPricingOption(plan, currency) {
|
|
1528
|
+
const options = getPlanPricingOptions(plan);
|
|
1529
|
+
if (currency) {
|
|
1530
|
+
const match = options.find((option) => option.currency.toUpperCase() === currency.toUpperCase());
|
|
1531
|
+
if (match) return match;
|
|
1532
|
+
}
|
|
1533
|
+
return options.find((option) => option.default) ?? options[0];
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1499
1536
|
// src/primitives/PlanSelector.tsx
|
|
1500
1537
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1501
1538
|
var PlanSelectorContext = (0, import_react10.createContext)(null);
|
|
@@ -1576,6 +1613,23 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
1576
1613
|
setSelectedPlanIndex(-1);
|
|
1577
1614
|
}, [setSelectedPlanIndex]);
|
|
1578
1615
|
const selectedPlanRef = selectedPlan?.reference ?? null;
|
|
1616
|
+
const [preferredCurrency, setPreferredCurrencyState] = (0, import_react10.useState)(null);
|
|
1617
|
+
const [selectedCurrencies, setSelectedCurrencies] = (0, import_react10.useState)({});
|
|
1618
|
+
const getSelectedOption = (0, import_react10.useCallback)(
|
|
1619
|
+
(plan) => resolvePlanPricingOption(
|
|
1620
|
+
plan,
|
|
1621
|
+
selectedCurrencies[plan.reference] ?? preferredCurrency ?? null
|
|
1622
|
+
),
|
|
1623
|
+
[selectedCurrencies, preferredCurrency]
|
|
1624
|
+
);
|
|
1625
|
+
const setPreferredCurrency = (0, import_react10.useCallback)((currency) => {
|
|
1626
|
+
setPreferredCurrencyState(currency.toUpperCase());
|
|
1627
|
+
setSelectedCurrencies({});
|
|
1628
|
+
}, []);
|
|
1629
|
+
const setPlanCurrency = (0, import_react10.useCallback)((planRef, currency) => {
|
|
1630
|
+
setSelectedCurrencies((current) => ({ ...current, [planRef]: currency }));
|
|
1631
|
+
}, []);
|
|
1632
|
+
const selectedCurrency = selectedPlan ? getSelectedOption(selectedPlan).currency : null;
|
|
1579
1633
|
const autoCurrentAppliedKeyRef = (0, import_react10.useRef)(null);
|
|
1580
1634
|
(0, import_react10.useEffect)(() => {
|
|
1581
1635
|
if (autoCurrentAppliedKeyRef.current === productRef) return;
|
|
@@ -1605,7 +1659,12 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
1605
1659
|
isFree,
|
|
1606
1660
|
isPopular,
|
|
1607
1661
|
select,
|
|
1608
|
-
clearSelection
|
|
1662
|
+
clearSelection,
|
|
1663
|
+
preferredCurrency,
|
|
1664
|
+
setPreferredCurrency,
|
|
1665
|
+
selectedCurrencies,
|
|
1666
|
+
setPlanCurrency,
|
|
1667
|
+
getSelectedOption
|
|
1609
1668
|
}),
|
|
1610
1669
|
[
|
|
1611
1670
|
plans,
|
|
@@ -1619,7 +1678,12 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
1619
1678
|
isFree,
|
|
1620
1679
|
isPopular,
|
|
1621
1680
|
select,
|
|
1622
|
-
clearSelection
|
|
1681
|
+
clearSelection,
|
|
1682
|
+
preferredCurrency,
|
|
1683
|
+
setPreferredCurrency,
|
|
1684
|
+
selectedCurrencies,
|
|
1685
|
+
setPlanCurrency,
|
|
1686
|
+
getSelectedOption
|
|
1623
1687
|
]
|
|
1624
1688
|
);
|
|
1625
1689
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -1631,6 +1695,12 @@ var Root2 = (0, import_react10.forwardRef)(function PlanSelectorRoot(props, forw
|
|
|
1631
1695
|
setSelectedPlanRef: (ref) => {
|
|
1632
1696
|
if (ref) select(ref);
|
|
1633
1697
|
},
|
|
1698
|
+
selectedCurrency,
|
|
1699
|
+
setSelectedCurrency: (currency) => {
|
|
1700
|
+
if (currency) {
|
|
1701
|
+
setPreferredCurrency(currency);
|
|
1702
|
+
}
|
|
1703
|
+
},
|
|
1634
1704
|
plans,
|
|
1635
1705
|
loading,
|
|
1636
1706
|
error
|
|
@@ -1655,14 +1725,19 @@ var Grid = (0, import_react10.forwardRef)(function PlanSelectorGrid({ children,
|
|
|
1655
1725
|
const isPaygCurrent = isCurrent && isPaygPlan(plan);
|
|
1656
1726
|
const disabled = isFree || isCurrent && !isPaygCurrent;
|
|
1657
1727
|
const state = isCurrent && !isPaygCurrent ? "current" : selected ? "selected" : isCurrent ? "current" : isFree ? "disabled" : "idle";
|
|
1728
|
+
const pricingOptions = getPlanPricingOptions(plan);
|
|
1729
|
+
const selectedOption = ctx.getSelectedOption(plan);
|
|
1658
1730
|
const cardCtx = {
|
|
1659
1731
|
plan,
|
|
1732
|
+
selectedOption,
|
|
1733
|
+
pricingOptions,
|
|
1660
1734
|
state,
|
|
1661
1735
|
isCurrent,
|
|
1662
1736
|
isFree,
|
|
1663
1737
|
isPopular,
|
|
1664
1738
|
disabled,
|
|
1665
|
-
select: () => ctx.select(plan.reference)
|
|
1739
|
+
select: () => ctx.select(plan.reference),
|
|
1740
|
+
setCurrency: (currency) => ctx.setPlanCurrency(plan.reference, currency)
|
|
1666
1741
|
};
|
|
1667
1742
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardContext.Provider, { value: cardCtx, children }, plan.reference);
|
|
1668
1743
|
}) });
|
|
@@ -1714,26 +1789,20 @@ var CardPrice = (0, import_react10.forwardRef)(function PlanSelectorCardPrice({
|
|
|
1714
1789
|
const formatted = (0, import_react10.useMemo)(() => {
|
|
1715
1790
|
if (card.isFree) return copy.planSelector.freeBadge;
|
|
1716
1791
|
if (card.plan.type === "usage-based") {
|
|
1717
|
-
|
|
1718
|
-
const perCallMinor = Math.max(1, Math.round(1 / creditsPerUnit));
|
|
1719
|
-
const rate = formatPrice(perCallMinor, card.plan.currency ?? "usd", {
|
|
1720
|
-
locale,
|
|
1721
|
-
free: ""
|
|
1722
|
-
});
|
|
1723
|
-
return `${rate} / call`;
|
|
1792
|
+
return copy.planSelector.usageRateLabel;
|
|
1724
1793
|
}
|
|
1725
|
-
return formatPrice(card.
|
|
1794
|
+
return formatPrice(card.selectedOption.price ?? 0, card.selectedOption.currency ?? "usd", {
|
|
1726
1795
|
locale,
|
|
1727
1796
|
free: copy.interval.free
|
|
1728
1797
|
});
|
|
1729
1798
|
}, [
|
|
1730
1799
|
card.isFree,
|
|
1731
1800
|
card.plan.type,
|
|
1732
|
-
card.
|
|
1733
|
-
card.
|
|
1734
|
-
card.plan.creditsPerUnit,
|
|
1801
|
+
card.selectedOption.price,
|
|
1802
|
+
card.selectedOption.currency,
|
|
1735
1803
|
locale,
|
|
1736
1804
|
copy.planSelector.freeBadge,
|
|
1805
|
+
copy.planSelector.usageRateLabel,
|
|
1737
1806
|
copy.interval.free
|
|
1738
1807
|
]);
|
|
1739
1808
|
const Comp = asChild ? Slot : "span";
|
|
@@ -1758,6 +1827,57 @@ function normalizeBillingCycle(cycle) {
|
|
|
1758
1827
|
if (lc === "daily" || lc === "day") return "day";
|
|
1759
1828
|
return cycle;
|
|
1760
1829
|
}
|
|
1830
|
+
var CurrencySwitcher = (0, import_react10.forwardRef)(function PlanSelectorCurrencySwitcher({ children, onChange, className, ...rest }, forwardedRef) {
|
|
1831
|
+
const ctx = usePlanSelectorContext("CurrencySwitcher");
|
|
1832
|
+
const availableCurrencies = (0, import_react10.useMemo)(() => {
|
|
1833
|
+
const currencies = /* @__PURE__ */ new Set();
|
|
1834
|
+
for (const plan of ctx.plans) {
|
|
1835
|
+
const options = getPlanPricingOptions(plan);
|
|
1836
|
+
if (options.length <= 1) continue;
|
|
1837
|
+
for (const option of options) {
|
|
1838
|
+
currencies.add(option.currency.toUpperCase());
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
return [...currencies].sort();
|
|
1842
|
+
}, [ctx.plans]);
|
|
1843
|
+
if (availableCurrencies.length < 2) return null;
|
|
1844
|
+
const effectiveCurrency = ctx.preferredCurrency ?? (ctx.selectedPlan ? ctx.getSelectedOption(ctx.selectedPlan).currency.toUpperCase() : null) ?? availableCurrencies[0];
|
|
1845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1846
|
+
"select",
|
|
1847
|
+
{
|
|
1848
|
+
ref: forwardedRef,
|
|
1849
|
+
"data-solvapay-plan-selector-currency-switcher": "",
|
|
1850
|
+
className,
|
|
1851
|
+
value: effectiveCurrency,
|
|
1852
|
+
onChange: (event) => {
|
|
1853
|
+
ctx.setPreferredCurrency(event.target.value);
|
|
1854
|
+
onChange?.(event);
|
|
1855
|
+
},
|
|
1856
|
+
...rest,
|
|
1857
|
+
children: children ?? availableCurrencies.map((currency) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: currency, children: currency }, currency))
|
|
1858
|
+
}
|
|
1859
|
+
);
|
|
1860
|
+
});
|
|
1861
|
+
var CardCurrency = (0, import_react10.forwardRef)(
|
|
1862
|
+
function PlanSelectorCardCurrency({ children, onChange, ...rest }, forwardedRef) {
|
|
1863
|
+
const card = useCardContext("CardCurrency");
|
|
1864
|
+
if (card.pricingOptions.length <= 1) return null;
|
|
1865
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1866
|
+
"select",
|
|
1867
|
+
{
|
|
1868
|
+
ref: forwardedRef,
|
|
1869
|
+
"data-solvapay-plan-selector-card-currency": "",
|
|
1870
|
+
value: card.selectedOption.currency,
|
|
1871
|
+
onChange: (event) => {
|
|
1872
|
+
card.setCurrency(event.target.value);
|
|
1873
|
+
onChange?.(event);
|
|
1874
|
+
},
|
|
1875
|
+
...rest,
|
|
1876
|
+
children: children ?? card.pricingOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: option.currency, children: option.currency }, option.currency))
|
|
1877
|
+
}
|
|
1878
|
+
);
|
|
1879
|
+
}
|
|
1880
|
+
);
|
|
1761
1881
|
var CardBadge = (0, import_react10.forwardRef)(function PlanSelectorCardBadge({ asChild, children, ...rest }, forwardedRef) {
|
|
1762
1882
|
const card = useCardContext("CardBadge");
|
|
1763
1883
|
const copy = useCopy();
|
|
@@ -1802,6 +1922,8 @@ var PlanSelectorCard2 = Card;
|
|
|
1802
1922
|
var PlanSelectorCardName2 = CardName;
|
|
1803
1923
|
var PlanSelectorCardPrice2 = CardPrice;
|
|
1804
1924
|
var PlanSelectorCardInterval2 = CardInterval;
|
|
1925
|
+
var PlanSelectorCurrencySwitcher2 = CurrencySwitcher;
|
|
1926
|
+
var PlanSelectorCardCurrency2 = CardCurrency;
|
|
1805
1927
|
var PlanSelectorCardBadge2 = CardBadge;
|
|
1806
1928
|
var PlanSelectorLoading2 = Loading;
|
|
1807
1929
|
var PlanSelectorError2 = ErrorSlot;
|
|
@@ -1813,6 +1935,8 @@ var PlanSelector = {
|
|
|
1813
1935
|
CardName,
|
|
1814
1936
|
CardPrice,
|
|
1815
1937
|
CardInterval,
|
|
1938
|
+
CurrencySwitcher,
|
|
1939
|
+
CardCurrency,
|
|
1816
1940
|
CardBadge,
|
|
1817
1941
|
Loading,
|
|
1818
1942
|
Error: ErrorSlot
|
|
@@ -1913,7 +2037,11 @@ async function resolvePlanRef(productRef, config) {
|
|
|
1913
2037
|
const { headers } = await buildRequestHeaders(config);
|
|
1914
2038
|
const res = await fetchFn(url, { method: "GET", headers });
|
|
1915
2039
|
if (!res.ok) {
|
|
1916
|
-
|
|
2040
|
+
const message = await readErrorMessage(
|
|
2041
|
+
res,
|
|
2042
|
+
`Failed to fetch plans for product "${productRef}"`
|
|
2043
|
+
);
|
|
2044
|
+
throw new Error(message);
|
|
1917
2045
|
}
|
|
1918
2046
|
const data = await res.json();
|
|
1919
2047
|
const allPlans = data.plans ?? [];
|
|
@@ -1935,7 +2063,8 @@ async function resolvePlanRef(productRef, config) {
|
|
|
1935
2063
|
);
|
|
1936
2064
|
}
|
|
1937
2065
|
function useCheckout(options) {
|
|
1938
|
-
const { planRef, productRef, customer } = options;
|
|
2066
|
+
const { planRef, productRef, currency: currencyOverride, customer } = options;
|
|
2067
|
+
const planSelection = usePlanSelection();
|
|
1939
2068
|
const { createPayment, customerRef, updateCustomerRef, _config } = useSolvaPay();
|
|
1940
2069
|
const [loading, setLoading] = (0, import_react12.useState)(false);
|
|
1941
2070
|
const [error, setError] = (0, import_react12.useState)(null);
|
|
@@ -1967,9 +2096,11 @@ function useCheckout(options) {
|
|
|
1967
2096
|
if (!effectivePlanRef) {
|
|
1968
2097
|
throw new Error("Could not determine plan reference for checkout");
|
|
1969
2098
|
}
|
|
2099
|
+
const selectedCurrency = currencyOverride ?? planSelection?.selectedCurrency ?? void 0;
|
|
1970
2100
|
const result = await createPayment({
|
|
1971
2101
|
planRef: effectivePlanRef,
|
|
1972
2102
|
productRef,
|
|
2103
|
+
...selectedCurrency && { currency: selectedCurrency },
|
|
1973
2104
|
customer
|
|
1974
2105
|
});
|
|
1975
2106
|
if (!result || typeof result !== "object") {
|
|
@@ -2003,7 +2134,17 @@ function useCheckout(options) {
|
|
|
2003
2134
|
setLoading(false);
|
|
2004
2135
|
isStartingRef.current = false;
|
|
2005
2136
|
}
|
|
2006
|
-
}, [
|
|
2137
|
+
}, [
|
|
2138
|
+
planRef,
|
|
2139
|
+
productRef,
|
|
2140
|
+
currencyOverride,
|
|
2141
|
+
planSelection?.selectedCurrency,
|
|
2142
|
+
customer,
|
|
2143
|
+
createPayment,
|
|
2144
|
+
updateCustomerRef,
|
|
2145
|
+
loading,
|
|
2146
|
+
_config
|
|
2147
|
+
]);
|
|
2007
2148
|
const reset = (0, import_react12.useCallback)(() => {
|
|
2008
2149
|
isStartingRef.current = false;
|
|
2009
2150
|
setLoading(false);
|
|
@@ -4830,21 +4971,21 @@ function buildDefaultCheckoutPlanFilter(allPlans) {
|
|
|
4830
4971
|
return true;
|
|
4831
4972
|
};
|
|
4832
4973
|
}
|
|
4833
|
-
function formatContinueLabel(plan, locale) {
|
|
4974
|
+
function formatContinueLabel(plan, locale, pricingOption) {
|
|
4834
4975
|
if (!plan) return "Continue";
|
|
4835
4976
|
if (isPayg(plan)) {
|
|
4836
4977
|
return `Continue with ${plan.name ?? "Pay as you go"}`;
|
|
4837
4978
|
}
|
|
4838
|
-
const
|
|
4839
|
-
const
|
|
4979
|
+
const option = pricingOption ?? resolvePlanPricingOption(plan, null);
|
|
4980
|
+
const currency = option.currency.toUpperCase();
|
|
4981
|
+
const priceLabel = formatPrice(option.price ?? 0, currency, { locale });
|
|
4840
4982
|
const cycle = plan.billingCycle ? `/${shortCycle(plan.billingCycle)}` : "";
|
|
4841
4983
|
return `Continue with ${plan.name ?? "Plan"} \u2014 ${priceLabel}${cycle}`;
|
|
4842
4984
|
}
|
|
4843
4985
|
function formatPaygRate(plan, locale) {
|
|
4844
|
-
const currency = (plan.currency ?? "USD").toUpperCase();
|
|
4845
4986
|
const creditsPerUnit = plan.creditsPerUnit ?? 1;
|
|
4846
|
-
const
|
|
4847
|
-
return `${
|
|
4987
|
+
const creditLabel = creditsPerUnit === 1 ? "credit" : "credits";
|
|
4988
|
+
return `${creditsPerUnit.toLocaleString(locale)} ${creditLabel} / call`;
|
|
4848
4989
|
}
|
|
4849
4990
|
function inferIncludedCredits(plan) {
|
|
4850
4991
|
const price = plan.price ?? 0;
|
|
@@ -4879,14 +5020,31 @@ function useCheckoutFlow(opts) {
|
|
|
4879
5020
|
onPurchaseSuccessRef.current = opts.onPurchaseSuccess;
|
|
4880
5021
|
onErrorRef.current = opts.onError;
|
|
4881
5022
|
const planCtx = usePlanSelector();
|
|
5023
|
+
const planSelection = usePlanSelection();
|
|
4882
5024
|
const transport = useTransport();
|
|
4883
5025
|
const locale = useLocale();
|
|
4884
5026
|
const balance = useBalance();
|
|
4885
5027
|
const { creditsPerMinorUnit, displayExchangeRate, adjustBalance } = balance;
|
|
4886
5028
|
const { refetchPurchase } = useSolvaPay();
|
|
4887
5029
|
const { merchant } = useMerchant();
|
|
4888
|
-
const
|
|
5030
|
+
const [topupCurrencyOverride, setTopupCurrencyOverride] = (0, import_react33.useState)(null);
|
|
5031
|
+
const topupCurrencies = (0, import_react33.useMemo)(() => {
|
|
5032
|
+
const fromMerchant = (merchant?.supportedTopupCurrencies ?? []).map((code) => code.toUpperCase()).filter(Boolean);
|
|
5033
|
+
const fallback = opts.topupCurrency?.toUpperCase() ?? merchant?.defaultCurrency?.toUpperCase() ?? null;
|
|
5034
|
+
const list = fromMerchant.length > 0 ? fromMerchant : fallback ? [fallback] : [];
|
|
5035
|
+
return Array.from(new Set(list));
|
|
5036
|
+
}, [merchant?.supportedTopupCurrencies, merchant?.defaultCurrency, opts.topupCurrency]);
|
|
5037
|
+
const resolvedDefaultTopupCurrency = opts.topupCurrency?.toUpperCase() ?? merchant?.defaultCurrency?.toUpperCase() ?? null;
|
|
5038
|
+
const planPickerCurrency = planCtx.preferredCurrency?.toUpperCase() ?? null;
|
|
5039
|
+
const topupCurrency = (topupCurrencyOverride && topupCurrencies.includes(topupCurrencyOverride) ? topupCurrencyOverride : null) ?? (planPickerCurrency && topupCurrencies.includes(planPickerCurrency) ? planPickerCurrency : null) ?? resolvedDefaultTopupCurrency;
|
|
4889
5040
|
const topupCurrencyReady = topupCurrency != null;
|
|
5041
|
+
const setTopupCurrency = (0, import_react33.useCallback)(
|
|
5042
|
+
(code) => {
|
|
5043
|
+
const normalized = code.toUpperCase();
|
|
5044
|
+
setTopupCurrencyOverride(normalized);
|
|
5045
|
+
},
|
|
5046
|
+
[]
|
|
5047
|
+
);
|
|
4890
5048
|
const [step, setStep] = (0, import_react33.useState)(initialStep);
|
|
4891
5049
|
const [status, setStatus] = (0, import_react33.useState)("idle");
|
|
4892
5050
|
const [selectedAmountMinor, setSelectedAmountMinor] = (0, import_react33.useState)(initialAmountMinor);
|
|
@@ -4984,19 +5142,23 @@ function useCheckoutFlow(opts) {
|
|
|
4984
5142
|
);
|
|
4985
5143
|
const recordRecurringSuccess = (0, import_react33.useCallback)(() => {
|
|
4986
5144
|
if (!selectedPlanShape) return;
|
|
4987
|
-
const
|
|
5145
|
+
const pricingOption = selectedPlan ? resolvePlanPricingOption(selectedPlan, planSelection?.selectedCurrency) : {
|
|
5146
|
+
currency: selectedPlanShape.currency ?? "USD",
|
|
5147
|
+
price: selectedPlanShape.price ?? 0
|
|
5148
|
+
};
|
|
5149
|
+
const currency = pricingOption.currency.toUpperCase();
|
|
4988
5150
|
const meta = {
|
|
4989
5151
|
branch: "recurring",
|
|
4990
5152
|
plan: selectedPlanShape,
|
|
4991
5153
|
creditsIncluded: inferIncludedCredits(selectedPlanShape),
|
|
4992
|
-
chargedTodayMinor:
|
|
5154
|
+
chargedTodayMinor: pricingOption.price ?? 0,
|
|
4993
5155
|
currency,
|
|
4994
5156
|
nextRenewalLabel: null
|
|
4995
5157
|
};
|
|
4996
5158
|
setSuccessMeta(meta);
|
|
4997
5159
|
setStep("success");
|
|
4998
5160
|
onPurchaseSuccessRef.current?.(meta);
|
|
4999
|
-
}, [selectedPlanShape]);
|
|
5161
|
+
}, [selectedPlanShape, selectedPlan, planSelection?.selectedCurrency]);
|
|
5000
5162
|
const advance = (0, import_react33.useCallback)(async () => {
|
|
5001
5163
|
if (step === "plan") {
|
|
5002
5164
|
await advanceFromPlan();
|
|
@@ -5042,6 +5204,7 @@ function useCheckoutFlow(opts) {
|
|
|
5042
5204
|
setSuccessMeta(null);
|
|
5043
5205
|
setError(null);
|
|
5044
5206
|
setStatus("idle");
|
|
5207
|
+
setTopupCurrencyOverride(null);
|
|
5045
5208
|
}, []);
|
|
5046
5209
|
const retry = (0, import_react33.useCallback)(async () => {
|
|
5047
5210
|
if (status !== "error") return;
|
|
@@ -5071,6 +5234,8 @@ function useCheckoutFlow(opts) {
|
|
|
5071
5234
|
branch,
|
|
5072
5235
|
topupCurrency,
|
|
5073
5236
|
topupCurrencyReady,
|
|
5237
|
+
topupCurrencies,
|
|
5238
|
+
setTopupCurrency,
|
|
5074
5239
|
canGoBack,
|
|
5075
5240
|
selectPlan,
|
|
5076
5241
|
selectAmount,
|
|
@@ -5091,6 +5256,8 @@ function useCheckoutFlow(opts) {
|
|
|
5091
5256
|
branch,
|
|
5092
5257
|
topupCurrency,
|
|
5093
5258
|
topupCurrencyReady,
|
|
5259
|
+
topupCurrencies,
|
|
5260
|
+
setTopupCurrency,
|
|
5094
5261
|
canGoBack,
|
|
5095
5262
|
selectPlan,
|
|
5096
5263
|
selectAmount,
|
|
@@ -6345,9 +6512,11 @@ function useUsageMeter() {
|
|
|
6345
6512
|
PlanSelector,
|
|
6346
6513
|
PlanSelectorCard,
|
|
6347
6514
|
PlanSelectorCardBadge,
|
|
6515
|
+
PlanSelectorCardCurrency,
|
|
6348
6516
|
PlanSelectorCardInterval,
|
|
6349
6517
|
PlanSelectorCardName,
|
|
6350
6518
|
PlanSelectorCardPrice,
|
|
6519
|
+
PlanSelectorCurrencySwitcher,
|
|
6351
6520
|
PlanSelectorError,
|
|
6352
6521
|
PlanSelectorGrid,
|
|
6353
6522
|
PlanSelectorHeading,
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { Ref } from 'react';
|
|
3
|
-
import { b as Plan, v as Product, q as UseTopupAmountSelectorReturn, u as PurchaseInfo, T as TopupFormProps } from '../shared-
|
|
4
|
-
export { x as BootstrapPlanLike, y as CheckoutStep, K as SuccessMeta } from '../shared-
|
|
5
|
-
import { j as PaywallStructuredContent, U as UsageSnapshot } from '../index-
|
|
6
|
-
export { E as ActivationFlow, F as ActivationFlowActivateButton, G as ActivationFlowActivated, H as ActivationFlowAmountPicker, I as ActivationFlowContinueButton, J as ActivationFlowError, K as ActivationFlowLoading, L as ActivationFlowRetrying, N as ActivationFlowRoot, A as ActivationFlowStep, O as ActivationFlowSummary, B as BalanceBadge, k as CancelPlanButton, m as CheckoutStatus, n as CheckoutSteps, Q as CheckoutStepsAmountContinueButton, R as CheckoutStepsAmountPicker, S as CheckoutStepsBackLink, T as CheckoutStepsIfStep, V as CheckoutStepsPayment, W as CheckoutStepsPlanContinueButton, X as CheckoutStepsPlanGrid, Y as CheckoutStepsRoot, Z as CheckoutStepsStepHeading, _ as CheckoutStepsStepMessage, $ as CheckoutStepsSuccess, M as MandateText, q as MandateTextProps, a0 as PaymentForm, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, i as PaymentFormLegalFooter, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, a1 as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, e as PaymentFormTermsCheckbox, r as PlanBadge, s as ProductBadge, t as PurchaseGate, a2 as PurchaseGateAllowed, a3 as PurchaseGateBlocked, a4 as PurchaseGateError, a5 as PurchaseGateLoading, a6 as PurchaseGateRoot, a7 as useActivationFlow, z as useCheckoutStepsContext, a8 as usePurchaseGate } from '../index-
|
|
3
|
+
import { b as Plan, v as Product, q as UseTopupAmountSelectorReturn, u as PurchaseInfo, T as TopupFormProps } from '../shared-BNZAIWkU.cjs';
|
|
4
|
+
export { x as BootstrapPlanLike, y as CheckoutStep, K as SuccessMeta } from '../shared-BNZAIWkU.cjs';
|
|
5
|
+
import { j as PaywallStructuredContent, U as UsageSnapshot } from '../index-kXLvp7EU.cjs';
|
|
6
|
+
export { E as ActivationFlow, F as ActivationFlowActivateButton, G as ActivationFlowActivated, H as ActivationFlowAmountPicker, I as ActivationFlowContinueButton, J as ActivationFlowError, K as ActivationFlowLoading, L as ActivationFlowRetrying, N as ActivationFlowRoot, A as ActivationFlowStep, O as ActivationFlowSummary, B as BalanceBadge, k as CancelPlanButton, m as CheckoutStatus, n as CheckoutSteps, Q as CheckoutStepsAmountContinueButton, R as CheckoutStepsAmountPicker, S as CheckoutStepsBackLink, T as CheckoutStepsIfStep, V as CheckoutStepsPayment, W as CheckoutStepsPlanContinueButton, X as CheckoutStepsPlanGrid, Y as CheckoutStepsRoot, Z as CheckoutStepsStepHeading, _ as CheckoutStepsStepMessage, $ as CheckoutStepsSuccess, M as MandateText, q as MandateTextProps, a0 as PaymentForm, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, i as PaymentFormLegalFooter, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, a1 as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, e as PaymentFormTermsCheckbox, r as PlanBadge, s as ProductBadge, t as PurchaseGate, a2 as PurchaseGateAllowed, a3 as PurchaseGateBlocked, a4 as PurchaseGateError, a5 as PurchaseGateLoading, a6 as PurchaseGateRoot, a7 as useActivationFlow, z as useCheckoutStepsContext, a8 as usePurchaseGate } from '../index-kXLvp7EU.cjs';
|
|
7
7
|
import { PaymentElement } from '@stripe/react-stripe-js';
|
|
8
8
|
import { Stripe, StripeElements } from '@stripe/stripe-js';
|
|
9
9
|
import '../adapters/auth.cjs';
|
|
10
10
|
|
|
11
|
+
type PlanPricingOption = {
|
|
12
|
+
currency: string;
|
|
13
|
+
price: number;
|
|
14
|
+
basePrice?: number;
|
|
15
|
+
setupFee?: number;
|
|
16
|
+
default?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
11
19
|
interface SlotProps extends React.HTMLAttributes<HTMLElement> {
|
|
12
20
|
children?: React.ReactNode;
|
|
13
21
|
}
|
|
@@ -147,6 +155,11 @@ type PlanSelectorContextValue = {
|
|
|
147
155
|
* `userHasSelected` true so auto-selection doesn't reassert.
|
|
148
156
|
*/
|
|
149
157
|
clearSelection: () => void;
|
|
158
|
+
preferredCurrency: string | null;
|
|
159
|
+
setPreferredCurrency: (currency: string) => void;
|
|
160
|
+
selectedCurrencies: Record<string, string>;
|
|
161
|
+
setPlanCurrency: (planRef: string, currency: string) => void;
|
|
162
|
+
getSelectedOption: (plan: Plan) => PlanPricingOption;
|
|
150
163
|
};
|
|
151
164
|
declare const PlanSelectorRoot: React.ForwardRefExoticComponent<{
|
|
152
165
|
productRef?: string;
|
|
@@ -178,6 +191,8 @@ declare const PlanSelectorCardPrice: React.ForwardRefExoticComponent<React.HTMLA
|
|
|
178
191
|
declare const PlanSelectorCardInterval: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
179
192
|
asChild?: boolean;
|
|
180
193
|
} & React.RefAttributes<HTMLSpanElement>>;
|
|
194
|
+
declare const PlanSelectorCurrencySwitcher: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
|
|
195
|
+
declare const PlanSelectorCardCurrency: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
|
|
181
196
|
declare const PlanSelectorCardBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
182
197
|
asChild?: boolean;
|
|
183
198
|
} & {
|
|
@@ -220,6 +235,8 @@ declare const PlanSelector: {
|
|
|
220
235
|
readonly CardInterval: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
221
236
|
asChild?: boolean;
|
|
222
237
|
} & React.RefAttributes<HTMLSpanElement>>;
|
|
238
|
+
readonly CurrencySwitcher: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
|
|
239
|
+
readonly CardCurrency: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
|
|
223
240
|
readonly CardBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
224
241
|
asChild?: boolean;
|
|
225
242
|
} & {
|
|
@@ -794,4 +811,4 @@ declare const UsageMeter: React.ForwardRefExoticComponent<UsageMeterRootProps &
|
|
|
794
811
|
|
|
795
812
|
declare function useUsageMeter(): UsageMeterContextValue;
|
|
796
813
|
|
|
797
|
-
export { AmountPicker, AmountPickerConfirm, AmountPickerCustom, AmountPickerOption, AmountPickerRoot, CancelledPlanNotice, CancelledPlanNoticeAccessUntil, CancelledPlanNoticeCancelledOn, CancelledPlanNoticeDaysRemaining, CancelledPlanNoticeExpires, CancelledPlanNoticeHeading, CancelledPlanNoticeReactivateButton, CancelledPlanNoticeReason, CancelledPlanNoticeRoot, CheckoutSummary, CheckoutSummaryPlan, CheckoutSummaryPrice, CheckoutSummaryProduct, CheckoutSummaryRoot, CheckoutSummaryTaxNote, CheckoutSummaryTrial, CreditGate, CreditGateError, CreditGateHeading, CreditGateLoading, CreditGateRoot, CreditGateSubheading, CreditGateTopup, LegalFooter, type LegalFooterProps, PaywallNotice, Balance as PaywallNoticeBalance, type PaywallNoticeClassNames, EmbeddedCheckout as PaywallNoticeEmbeddedCheckout, Heading as PaywallNoticeHeading, HostedCheckoutLink as PaywallNoticeHostedCheckoutLink, Message as PaywallNoticeMessage, Plans as PaywallNoticePlans, ProductContext as PaywallNoticeProductContext, Retry as PaywallNoticeRetry, Root$1 as PaywallNoticeRoot, type PaywallNoticeRootProps, PlanSelector, PlanSelectorCard, PlanSelectorCardBadge, PlanSelectorCardInterval, PlanSelectorCardName, PlanSelectorCardPrice, PlanSelectorError, PlanSelectorGrid, PlanSelectorHeading, PlanSelectorLoading, PlanSelectorRoot, Slot, Slottable, TopupForm, TopupFormError, TopupFormLegalFooter, TopupFormLoading, TopupFormPaymentElement, TopupFormRoot, TopupFormSubmitButton, UsageMeter, Bar as UsageMeterBar, type UsageMeterClassNames, Empty as UsageMeterEmpty, Label as UsageMeterLabel, Loading as UsageMeterLoading, Percentage as UsageMeterPercentage, ResetsIn as UsageMeterResetsIn, Root as UsageMeterRoot, type UsageMeterRootProps, composeEventHandlers, composeRefs, setRef, useAmountPicker, useAmountPickerCopy, useCancelledPlanNotice, useCheckoutSummary, useCreditGate, usePaywallNotice, usePlanSelector, useTopupForm, useUsageMeter };
|
|
814
|
+
export { AmountPicker, AmountPickerConfirm, AmountPickerCustom, AmountPickerOption, AmountPickerRoot, CancelledPlanNotice, CancelledPlanNoticeAccessUntil, CancelledPlanNoticeCancelledOn, CancelledPlanNoticeDaysRemaining, CancelledPlanNoticeExpires, CancelledPlanNoticeHeading, CancelledPlanNoticeReactivateButton, CancelledPlanNoticeReason, CancelledPlanNoticeRoot, CheckoutSummary, CheckoutSummaryPlan, CheckoutSummaryPrice, CheckoutSummaryProduct, CheckoutSummaryRoot, CheckoutSummaryTaxNote, CheckoutSummaryTrial, CreditGate, CreditGateError, CreditGateHeading, CreditGateLoading, CreditGateRoot, CreditGateSubheading, CreditGateTopup, LegalFooter, type LegalFooterProps, PaywallNotice, Balance as PaywallNoticeBalance, type PaywallNoticeClassNames, EmbeddedCheckout as PaywallNoticeEmbeddedCheckout, Heading as PaywallNoticeHeading, HostedCheckoutLink as PaywallNoticeHostedCheckoutLink, Message as PaywallNoticeMessage, Plans as PaywallNoticePlans, ProductContext as PaywallNoticeProductContext, Retry as PaywallNoticeRetry, Root$1 as PaywallNoticeRoot, type PaywallNoticeRootProps, PlanSelector, PlanSelectorCard, PlanSelectorCardBadge, PlanSelectorCardCurrency, PlanSelectorCardInterval, PlanSelectorCardName, PlanSelectorCardPrice, PlanSelectorCurrencySwitcher, PlanSelectorError, PlanSelectorGrid, PlanSelectorHeading, PlanSelectorLoading, PlanSelectorRoot, Slot, Slottable, TopupForm, TopupFormError, TopupFormLegalFooter, TopupFormLoading, TopupFormPaymentElement, TopupFormRoot, TopupFormSubmitButton, UsageMeter, Bar as UsageMeterBar, type UsageMeterClassNames, Empty as UsageMeterEmpty, Label as UsageMeterLabel, Loading as UsageMeterLoading, Percentage as UsageMeterPercentage, ResetsIn as UsageMeterResetsIn, Root as UsageMeterRoot, type UsageMeterRootProps, composeEventHandlers, composeRefs, setRef, useAmountPicker, useAmountPickerCopy, useCancelledPlanNotice, useCheckoutSummary, useCreditGate, usePaywallNotice, usePlanSelector, useTopupForm, useUsageMeter };
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { Ref } from 'react';
|
|
3
|
-
import { b as Plan, v as Product, q as UseTopupAmountSelectorReturn, u as PurchaseInfo, T as TopupFormProps } from '../shared-
|
|
4
|
-
export { x as BootstrapPlanLike, y as CheckoutStep, K as SuccessMeta } from '../shared-
|
|
5
|
-
import { j as PaywallStructuredContent, U as UsageSnapshot } from '../index-
|
|
6
|
-
export { E as ActivationFlow, F as ActivationFlowActivateButton, G as ActivationFlowActivated, H as ActivationFlowAmountPicker, I as ActivationFlowContinueButton, J as ActivationFlowError, K as ActivationFlowLoading, L as ActivationFlowRetrying, N as ActivationFlowRoot, A as ActivationFlowStep, O as ActivationFlowSummary, B as BalanceBadge, k as CancelPlanButton, m as CheckoutStatus, n as CheckoutSteps, Q as CheckoutStepsAmountContinueButton, R as CheckoutStepsAmountPicker, S as CheckoutStepsBackLink, T as CheckoutStepsIfStep, V as CheckoutStepsPayment, W as CheckoutStepsPlanContinueButton, X as CheckoutStepsPlanGrid, Y as CheckoutStepsRoot, Z as CheckoutStepsStepHeading, _ as CheckoutStepsStepMessage, $ as CheckoutStepsSuccess, M as MandateText, q as MandateTextProps, a0 as PaymentForm, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, i as PaymentFormLegalFooter, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, a1 as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, e as PaymentFormTermsCheckbox, r as PlanBadge, s as ProductBadge, t as PurchaseGate, a2 as PurchaseGateAllowed, a3 as PurchaseGateBlocked, a4 as PurchaseGateError, a5 as PurchaseGateLoading, a6 as PurchaseGateRoot, a7 as useActivationFlow, z as useCheckoutStepsContext, a8 as usePurchaseGate } from '../index-
|
|
3
|
+
import { b as Plan, v as Product, q as UseTopupAmountSelectorReturn, u as PurchaseInfo, T as TopupFormProps } from '../shared-lIhc8DS3.js';
|
|
4
|
+
export { x as BootstrapPlanLike, y as CheckoutStep, K as SuccessMeta } from '../shared-lIhc8DS3.js';
|
|
5
|
+
import { j as PaywallStructuredContent, U as UsageSnapshot } from '../index-BwwdMBdt.js';
|
|
6
|
+
export { E as ActivationFlow, F as ActivationFlowActivateButton, G as ActivationFlowActivated, H as ActivationFlowAmountPicker, I as ActivationFlowContinueButton, J as ActivationFlowError, K as ActivationFlowLoading, L as ActivationFlowRetrying, N as ActivationFlowRoot, A as ActivationFlowStep, O as ActivationFlowSummary, B as BalanceBadge, k as CancelPlanButton, m as CheckoutStatus, n as CheckoutSteps, Q as CheckoutStepsAmountContinueButton, R as CheckoutStepsAmountPicker, S as CheckoutStepsBackLink, T as CheckoutStepsIfStep, V as CheckoutStepsPayment, W as CheckoutStepsPlanContinueButton, X as CheckoutStepsPlanGrid, Y as CheckoutStepsRoot, Z as CheckoutStepsStepHeading, _ as CheckoutStepsStepMessage, $ as CheckoutStepsSuccess, M as MandateText, q as MandateTextProps, a0 as PaymentForm, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, i as PaymentFormLegalFooter, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, a1 as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, e as PaymentFormTermsCheckbox, r as PlanBadge, s as ProductBadge, t as PurchaseGate, a2 as PurchaseGateAllowed, a3 as PurchaseGateBlocked, a4 as PurchaseGateError, a5 as PurchaseGateLoading, a6 as PurchaseGateRoot, a7 as useActivationFlow, z as useCheckoutStepsContext, a8 as usePurchaseGate } from '../index-BwwdMBdt.js';
|
|
7
7
|
import { PaymentElement } from '@stripe/react-stripe-js';
|
|
8
8
|
import { Stripe, StripeElements } from '@stripe/stripe-js';
|
|
9
9
|
import '../adapters/auth.js';
|
|
10
10
|
|
|
11
|
+
type PlanPricingOption = {
|
|
12
|
+
currency: string;
|
|
13
|
+
price: number;
|
|
14
|
+
basePrice?: number;
|
|
15
|
+
setupFee?: number;
|
|
16
|
+
default?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
11
19
|
interface SlotProps extends React.HTMLAttributes<HTMLElement> {
|
|
12
20
|
children?: React.ReactNode;
|
|
13
21
|
}
|
|
@@ -147,6 +155,11 @@ type PlanSelectorContextValue = {
|
|
|
147
155
|
* `userHasSelected` true so auto-selection doesn't reassert.
|
|
148
156
|
*/
|
|
149
157
|
clearSelection: () => void;
|
|
158
|
+
preferredCurrency: string | null;
|
|
159
|
+
setPreferredCurrency: (currency: string) => void;
|
|
160
|
+
selectedCurrencies: Record<string, string>;
|
|
161
|
+
setPlanCurrency: (planRef: string, currency: string) => void;
|
|
162
|
+
getSelectedOption: (plan: Plan) => PlanPricingOption;
|
|
150
163
|
};
|
|
151
164
|
declare const PlanSelectorRoot: React.ForwardRefExoticComponent<{
|
|
152
165
|
productRef?: string;
|
|
@@ -178,6 +191,8 @@ declare const PlanSelectorCardPrice: React.ForwardRefExoticComponent<React.HTMLA
|
|
|
178
191
|
declare const PlanSelectorCardInterval: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
179
192
|
asChild?: boolean;
|
|
180
193
|
} & React.RefAttributes<HTMLSpanElement>>;
|
|
194
|
+
declare const PlanSelectorCurrencySwitcher: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
|
|
195
|
+
declare const PlanSelectorCardCurrency: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
|
|
181
196
|
declare const PlanSelectorCardBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
182
197
|
asChild?: boolean;
|
|
183
198
|
} & {
|
|
@@ -220,6 +235,8 @@ declare const PlanSelector: {
|
|
|
220
235
|
readonly CardInterval: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
221
236
|
asChild?: boolean;
|
|
222
237
|
} & React.RefAttributes<HTMLSpanElement>>;
|
|
238
|
+
readonly CurrencySwitcher: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
|
|
239
|
+
readonly CardCurrency: React.ForwardRefExoticComponent<React.SelectHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
|
|
223
240
|
readonly CardBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
224
241
|
asChild?: boolean;
|
|
225
242
|
} & {
|
|
@@ -794,4 +811,4 @@ declare const UsageMeter: React.ForwardRefExoticComponent<UsageMeterRootProps &
|
|
|
794
811
|
|
|
795
812
|
declare function useUsageMeter(): UsageMeterContextValue;
|
|
796
813
|
|
|
797
|
-
export { AmountPicker, AmountPickerConfirm, AmountPickerCustom, AmountPickerOption, AmountPickerRoot, CancelledPlanNotice, CancelledPlanNoticeAccessUntil, CancelledPlanNoticeCancelledOn, CancelledPlanNoticeDaysRemaining, CancelledPlanNoticeExpires, CancelledPlanNoticeHeading, CancelledPlanNoticeReactivateButton, CancelledPlanNoticeReason, CancelledPlanNoticeRoot, CheckoutSummary, CheckoutSummaryPlan, CheckoutSummaryPrice, CheckoutSummaryProduct, CheckoutSummaryRoot, CheckoutSummaryTaxNote, CheckoutSummaryTrial, CreditGate, CreditGateError, CreditGateHeading, CreditGateLoading, CreditGateRoot, CreditGateSubheading, CreditGateTopup, LegalFooter, type LegalFooterProps, PaywallNotice, Balance as PaywallNoticeBalance, type PaywallNoticeClassNames, EmbeddedCheckout as PaywallNoticeEmbeddedCheckout, Heading as PaywallNoticeHeading, HostedCheckoutLink as PaywallNoticeHostedCheckoutLink, Message as PaywallNoticeMessage, Plans as PaywallNoticePlans, ProductContext as PaywallNoticeProductContext, Retry as PaywallNoticeRetry, Root$1 as PaywallNoticeRoot, type PaywallNoticeRootProps, PlanSelector, PlanSelectorCard, PlanSelectorCardBadge, PlanSelectorCardInterval, PlanSelectorCardName, PlanSelectorCardPrice, PlanSelectorError, PlanSelectorGrid, PlanSelectorHeading, PlanSelectorLoading, PlanSelectorRoot, Slot, Slottable, TopupForm, TopupFormError, TopupFormLegalFooter, TopupFormLoading, TopupFormPaymentElement, TopupFormRoot, TopupFormSubmitButton, UsageMeter, Bar as UsageMeterBar, type UsageMeterClassNames, Empty as UsageMeterEmpty, Label as UsageMeterLabel, Loading as UsageMeterLoading, Percentage as UsageMeterPercentage, ResetsIn as UsageMeterResetsIn, Root as UsageMeterRoot, type UsageMeterRootProps, composeEventHandlers, composeRefs, setRef, useAmountPicker, useAmountPickerCopy, useCancelledPlanNotice, useCheckoutSummary, useCreditGate, usePaywallNotice, usePlanSelector, useTopupForm, useUsageMeter };
|
|
814
|
+
export { AmountPicker, AmountPickerConfirm, AmountPickerCustom, AmountPickerOption, AmountPickerRoot, CancelledPlanNotice, CancelledPlanNoticeAccessUntil, CancelledPlanNoticeCancelledOn, CancelledPlanNoticeDaysRemaining, CancelledPlanNoticeExpires, CancelledPlanNoticeHeading, CancelledPlanNoticeReactivateButton, CancelledPlanNoticeReason, CancelledPlanNoticeRoot, CheckoutSummary, CheckoutSummaryPlan, CheckoutSummaryPrice, CheckoutSummaryProduct, CheckoutSummaryRoot, CheckoutSummaryTaxNote, CheckoutSummaryTrial, CreditGate, CreditGateError, CreditGateHeading, CreditGateLoading, CreditGateRoot, CreditGateSubheading, CreditGateTopup, LegalFooter, type LegalFooterProps, PaywallNotice, Balance as PaywallNoticeBalance, type PaywallNoticeClassNames, EmbeddedCheckout as PaywallNoticeEmbeddedCheckout, Heading as PaywallNoticeHeading, HostedCheckoutLink as PaywallNoticeHostedCheckoutLink, Message as PaywallNoticeMessage, Plans as PaywallNoticePlans, ProductContext as PaywallNoticeProductContext, Retry as PaywallNoticeRetry, Root$1 as PaywallNoticeRoot, type PaywallNoticeRootProps, PlanSelector, PlanSelectorCard, PlanSelectorCardBadge, PlanSelectorCardCurrency, PlanSelectorCardInterval, PlanSelectorCardName, PlanSelectorCardPrice, PlanSelectorCurrencySwitcher, PlanSelectorError, PlanSelectorGrid, PlanSelectorHeading, PlanSelectorLoading, PlanSelectorRoot, Slot, Slottable, TopupForm, TopupFormError, TopupFormLegalFooter, TopupFormLoading, TopupFormPaymentElement, TopupFormRoot, TopupFormSubmitButton, UsageMeter, Bar as UsageMeterBar, type UsageMeterClassNames, Empty as UsageMeterEmpty, Label as UsageMeterLabel, Loading as UsageMeterLoading, Percentage as UsageMeterPercentage, ResetsIn as UsageMeterResetsIn, Root as UsageMeterRoot, type UsageMeterRootProps, composeEventHandlers, composeRefs, setRef, useAmountPicker, useAmountPickerCopy, useCancelledPlanNotice, useCheckoutSummary, useCreditGate, usePaywallNotice, usePlanSelector, useTopupForm, useUsageMeter };
|