@blocklet/payment-react 1.25.10 → 1.26.0
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/es/checkout-v2/checkout-v2.d.ts +2 -0
- package/es/checkout-v2/checkout-v2.js +121 -0
- package/es/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
- package/es/checkout-v2/components/dialogs/checkout-dialogs.js +106 -0
- package/es/checkout-v2/components/left/billing-toggle.d.ts +6 -0
- package/es/checkout-v2/components/left/billing-toggle.js +118 -0
- package/es/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
- package/es/checkout-v2/components/left/cross-sell-card.js +167 -0
- package/es/checkout-v2/components/left/product-item-card.d.ts +26 -0
- package/es/checkout-v2/components/left/product-item-card.js +571 -0
- package/es/checkout-v2/components/left/promotion-input.d.ts +19 -0
- package/es/checkout-v2/components/left/promotion-input.js +178 -0
- package/es/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
- package/es/checkout-v2/components/left/staking-breakdown.js +48 -0
- package/es/checkout-v2/components/left/trial-info.d.ts +13 -0
- package/es/checkout-v2/components/left/trial-info.js +48 -0
- package/es/checkout-v2/components/right/currency-grid.d.ts +8 -0
- package/es/checkout-v2/components/right/currency-grid.js +48 -0
- package/es/checkout-v2/components/right/customer-info-card.d.ts +17 -0
- package/es/checkout-v2/components/right/customer-info-card.js +156 -0
- package/es/checkout-v2/components/right/status-feedback.d.ts +7 -0
- package/es/checkout-v2/components/right/status-feedback.js +17 -0
- package/es/checkout-v2/components/right/submit-button.d.ts +10 -0
- package/es/checkout-v2/components/right/submit-button.js +29 -0
- package/es/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
- package/es/checkout-v2/components/right/subscription-disclaimer.js +8 -0
- package/es/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
- package/es/checkout-v2/components/shared/exchange-rate-footer.js +182 -0
- package/es/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
- package/es/checkout-v2/components/shared/scenario-badge.js +47 -0
- package/es/checkout-v2/components/shared/total-display.d.ts +7 -0
- package/es/checkout-v2/components/shared/total-display.js +84 -0
- package/es/checkout-v2/index.d.ts +2 -0
- package/es/checkout-v2/index.js +1 -0
- package/es/checkout-v2/layouts/checkout-layout.d.ts +7 -0
- package/es/checkout-v2/layouts/checkout-layout.js +226 -0
- package/es/checkout-v2/panels/left/composite-panel.d.ts +1 -0
- package/es/checkout-v2/panels/left/composite-panel.js +423 -0
- package/es/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
- package/es/checkout-v2/panels/left/credit-topup-panel.js +615 -0
- package/es/checkout-v2/panels/left/scenario-router.d.ts +1 -0
- package/es/checkout-v2/panels/left/scenario-router.js +19 -0
- package/es/checkout-v2/panels/right/payment-panel.d.ts +1 -0
- package/es/checkout-v2/panels/right/payment-panel.js +644 -0
- package/es/checkout-v2/types.d.ts +15 -0
- package/es/checkout-v2/types.js +0 -0
- package/es/checkout-v2/utils/format.d.ts +59 -0
- package/es/checkout-v2/utils/format.js +125 -0
- package/es/checkout-v2/utils/scenario-detector.d.ts +3 -0
- package/es/checkout-v2/utils/scenario-detector.js +17 -0
- package/es/checkout-v2/views/error-view.d.ts +7 -0
- package/es/checkout-v2/views/error-view.js +269 -0
- package/es/checkout-v2/views/loading-view.d.ts +5 -0
- package/es/checkout-v2/views/loading-view.js +158 -0
- package/es/checkout-v2/views/success-view.d.ts +29 -0
- package/es/checkout-v2/views/success-view.js +614 -0
- package/es/components/phone-field.d.ts +14 -0
- package/es/components/phone-field.js +96 -0
- package/es/index.d.ts +3 -1
- package/es/index.js +3 -1
- package/es/locales/en.js +45 -6
- package/es/locales/zh.js +45 -6
- package/es/payment/form/index.js +10 -1
- package/lib/checkout-v2/checkout-v2.d.ts +2 -0
- package/lib/checkout-v2/checkout-v2.js +151 -0
- package/lib/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
- package/lib/checkout-v2/components/dialogs/checkout-dialogs.js +131 -0
- package/lib/checkout-v2/components/left/billing-toggle.d.ts +6 -0
- package/lib/checkout-v2/components/left/billing-toggle.js +126 -0
- package/lib/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
- package/lib/checkout-v2/components/left/cross-sell-card.js +257 -0
- package/lib/checkout-v2/components/left/product-item-card.d.ts +26 -0
- package/lib/checkout-v2/components/left/product-item-card.js +738 -0
- package/lib/checkout-v2/components/left/promotion-input.d.ts +19 -0
- package/lib/checkout-v2/components/left/promotion-input.js +220 -0
- package/lib/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
- package/lib/checkout-v2/components/left/staking-breakdown.js +96 -0
- package/lib/checkout-v2/components/left/trial-info.d.ts +13 -0
- package/lib/checkout-v2/components/left/trial-info.js +82 -0
- package/lib/checkout-v2/components/right/currency-grid.d.ts +8 -0
- package/lib/checkout-v2/components/right/currency-grid.js +96 -0
- package/lib/checkout-v2/components/right/customer-info-card.d.ts +17 -0
- package/lib/checkout-v2/components/right/customer-info-card.js +246 -0
- package/lib/checkout-v2/components/right/status-feedback.d.ts +7 -0
- package/lib/checkout-v2/components/right/status-feedback.js +30 -0
- package/lib/checkout-v2/components/right/submit-button.d.ts +10 -0
- package/lib/checkout-v2/components/right/submit-button.js +35 -0
- package/lib/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
- package/lib/checkout-v2/components/right/subscription-disclaimer.js +33 -0
- package/lib/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
- package/lib/checkout-v2/components/shared/exchange-rate-footer.js +282 -0
- package/lib/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
- package/lib/checkout-v2/components/shared/scenario-badge.js +57 -0
- package/lib/checkout-v2/components/shared/total-display.d.ts +7 -0
- package/lib/checkout-v2/components/shared/total-display.js +154 -0
- package/lib/checkout-v2/index.d.ts +2 -0
- package/lib/checkout-v2/index.js +13 -0
- package/lib/checkout-v2/layouts/checkout-layout.d.ts +7 -0
- package/lib/checkout-v2/layouts/checkout-layout.js +308 -0
- package/lib/checkout-v2/panels/left/composite-panel.d.ts +1 -0
- package/lib/checkout-v2/panels/left/composite-panel.js +515 -0
- package/lib/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
- package/lib/checkout-v2/panels/left/credit-topup-panel.js +799 -0
- package/lib/checkout-v2/panels/left/scenario-router.d.ts +1 -0
- package/lib/checkout-v2/panels/left/scenario-router.js +29 -0
- package/lib/checkout-v2/panels/right/payment-panel.d.ts +1 -0
- package/lib/checkout-v2/panels/right/payment-panel.js +906 -0
- package/lib/checkout-v2/types.d.ts +15 -0
- package/lib/checkout-v2/types.js +1 -0
- package/lib/checkout-v2/utils/format.d.ts +59 -0
- package/lib/checkout-v2/utils/format.js +158 -0
- package/lib/checkout-v2/utils/scenario-detector.d.ts +3 -0
- package/lib/checkout-v2/utils/scenario-detector.js +23 -0
- package/lib/checkout-v2/views/error-view.d.ts +7 -0
- package/lib/checkout-v2/views/error-view.js +321 -0
- package/lib/checkout-v2/views/loading-view.d.ts +5 -0
- package/lib/checkout-v2/views/loading-view.js +168 -0
- package/lib/checkout-v2/views/success-view.d.ts +29 -0
- package/lib/checkout-v2/views/success-view.js +735 -0
- package/lib/components/phone-field.d.ts +14 -0
- package/lib/components/phone-field.js +130 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +8 -0
- package/lib/locales/en.js +45 -6
- package/lib/locales/zh.js +45 -6
- package/lib/payment/form/index.js +10 -1
- package/package.json +4 -3
- package/src/checkout-v2/checkout-v2.tsx +155 -0
- package/src/checkout-v2/components/dialogs/checkout-dialogs.tsx +134 -0
- package/src/checkout-v2/components/left/billing-toggle.tsx +122 -0
- package/src/checkout-v2/components/left/cross-sell-card.tsx +170 -0
- package/src/checkout-v2/components/left/product-item-card.tsx +634 -0
- package/src/checkout-v2/components/left/promotion-input.tsx +207 -0
- package/src/checkout-v2/components/left/staking-breakdown.tsx +57 -0
- package/src/checkout-v2/components/left/trial-info.tsx +63 -0
- package/src/checkout-v2/components/right/currency-grid.tsx +59 -0
- package/src/checkout-v2/components/right/customer-info-card.tsx +214 -0
- package/src/checkout-v2/components/right/status-feedback.tsx +35 -0
- package/src/checkout-v2/components/right/submit-button.tsx +37 -0
- package/src/checkout-v2/components/right/subscription-disclaimer.tsx +27 -0
- package/src/checkout-v2/components/shared/exchange-rate-footer.tsx +221 -0
- package/src/checkout-v2/components/shared/scenario-badge.tsx +51 -0
- package/src/checkout-v2/components/shared/total-display.tsx +112 -0
- package/src/checkout-v2/index.ts +2 -0
- package/src/checkout-v2/layouts/checkout-layout.tsx +232 -0
- package/src/checkout-v2/panels/left/composite-panel.tsx +465 -0
- package/src/checkout-v2/panels/left/credit-topup-panel.tsx +681 -0
- package/src/checkout-v2/panels/left/scenario-router.tsx +22 -0
- package/src/checkout-v2/panels/right/payment-panel.tsx +703 -0
- package/src/checkout-v2/types.ts +18 -0
- package/src/checkout-v2/utils/format.ts +204 -0
- package/src/checkout-v2/utils/scenario-detector.ts +30 -0
- package/src/checkout-v2/views/error-view.tsx +293 -0
- package/src/checkout-v2/views/loading-view.tsx +162 -0
- package/src/checkout-v2/views/success-view.tsx +770 -0
- package/src/components/phone-field.tsx +119 -0
- package/src/index.ts +3 -0
- package/src/locales/en.tsx +45 -4
- package/src/locales/zh.tsx +43 -4
- package/src/payment/form/index.tsx +16 -1
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
4
|
+
import TrendingDownIcon from "@mui/icons-material/TrendingDown";
|
|
5
|
+
import { Avatar, Box, Button, Collapse, Stack, Typography } from "@mui/material";
|
|
6
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import Toast from "@arcblock/ux/lib/Toast";
|
|
8
|
+
import {
|
|
9
|
+
useCheckoutStatus,
|
|
10
|
+
useLineItems,
|
|
11
|
+
useBillingInterval,
|
|
12
|
+
usePricingFeature,
|
|
13
|
+
useExchangeRate,
|
|
14
|
+
useSlippage,
|
|
15
|
+
useSessionContext,
|
|
16
|
+
usePaymentMethodContext,
|
|
17
|
+
useProduct
|
|
18
|
+
} from "@blocklet/payment-react-headless";
|
|
19
|
+
import { useMobile } from "../../../hooks/mobile.js";
|
|
20
|
+
import { INTERVAL_LOCALE_KEY, formatTrialText, getSessionHeaderMeta, tSafe } from "../../utils/format.js";
|
|
21
|
+
import ProductItemCard from "../../components/left/product-item-card.js";
|
|
22
|
+
import BillingToggle from "../../components/left/billing-toggle.js";
|
|
23
|
+
import CrossSellCard from "../../components/left/cross-sell-card.js";
|
|
24
|
+
import ExchangeRateFooter from "../../components/shared/exchange-rate-footer.js";
|
|
25
|
+
import TrialInfo from "../../components/left/trial-info.js";
|
|
26
|
+
export default function CompositePanel() {
|
|
27
|
+
const { t } = useLocaleContext();
|
|
28
|
+
const { session } = useSessionContext();
|
|
29
|
+
const { currency, isStripe, switching: currencySwitching } = usePaymentMethodContext();
|
|
30
|
+
const { livemode } = useCheckoutStatus();
|
|
31
|
+
const { product, pageInfo } = useProduct();
|
|
32
|
+
const lineItems = useLineItems();
|
|
33
|
+
const billingInterval = useBillingInterval();
|
|
34
|
+
const pricing = usePricingFeature();
|
|
35
|
+
const rate = useExchangeRate();
|
|
36
|
+
const slippage = useSlippage();
|
|
37
|
+
const { isMobile } = useMobile();
|
|
38
|
+
const mode = session?.mode || "payment";
|
|
39
|
+
const discounts = session?.discounts || [];
|
|
40
|
+
const appName = session?.app_name || session?.payment_link?.app_name || "";
|
|
41
|
+
const appLogo = session?.app_logo || session?.payment_link?.app_logo || "";
|
|
42
|
+
const showItemsCollapse = isMobile || lineItems.items.length >= 4;
|
|
43
|
+
const [itemsExpanded, setItemsExpanded] = useState(
|
|
44
|
+
isMobile ? lineItems.items.length <= 1 : lineItems.items.length < 4
|
|
45
|
+
);
|
|
46
|
+
const crossSellNotAdded = lineItems.crossSellItem && !lineItems.items.some((i) => i.price_id === lineItems.crossSellItem?.id);
|
|
47
|
+
const nonCrossSellItems = lineItems.items.filter((i) => !i.cross_sell);
|
|
48
|
+
const itemsWithUpsell = lineItems.items.filter((i) => i.price?.upsell?.upsells_to);
|
|
49
|
+
const upsellPrimaryItem = itemsWithUpsell.length === 1 ? itemsWithUpsell[0] : null;
|
|
50
|
+
const upsellTarget = upsellPrimaryItem ? upsellPrimaryItem.price?.upsell?.upsells_to : null;
|
|
51
|
+
const canUpsell = nonCrossSellItems.length <= 1;
|
|
52
|
+
const hasTopUpsell = canUpsell && !!upsellPrimaryItem && ["subscription", "setup"].includes(mode);
|
|
53
|
+
const isUpselled = !!upsellPrimaryItem?.upsell_price;
|
|
54
|
+
const currentInterval = hasTopUpsell ? upsellPrimaryItem.price?.recurring?.interval : null;
|
|
55
|
+
const upsellInterval = hasTopUpsell ? upsellTarget?.recurring?.interval : null;
|
|
56
|
+
let upsellSavings = 0;
|
|
57
|
+
if (hasTopUpsell && currentInterval && upsellInterval) {
|
|
58
|
+
const fromAmt = parseFloat(
|
|
59
|
+
upsellPrimaryItem.price?.base_amount || upsellPrimaryItem.price?.unit_amount || "0"
|
|
60
|
+
);
|
|
61
|
+
const toAmt = parseFloat(upsellTarget?.base_amount || upsellTarget?.unit_amount || "0");
|
|
62
|
+
const yearMap = { day: 365, week: 52, month: 12, year: 1 };
|
|
63
|
+
const fromY = fromAmt * (yearMap[currentInterval] || 1);
|
|
64
|
+
const toY = toAmt * (yearMap[upsellInterval] || 1);
|
|
65
|
+
if (fromY > toY && fromY > 0) upsellSavings = Math.round((fromY - toY) / fromY * 100);
|
|
66
|
+
}
|
|
67
|
+
const prevRateStatusRef = useRef(rate.status);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (prevRateStatusRef.current !== "unavailable" && rate.status === "unavailable" && !isStripe) {
|
|
70
|
+
Toast.error(t("payment.dynamicPricing.unavailable.message"));
|
|
71
|
+
}
|
|
72
|
+
prevRateStatusRef.current = rate.status;
|
|
73
|
+
}, [rate.status, isStripe, t]);
|
|
74
|
+
const headerMeta = getSessionHeaderMeta(t, session, product, lineItems.items);
|
|
75
|
+
const isMultiItem = lineItems.items.length > 1;
|
|
76
|
+
const activeSx = {
|
|
77
|
+
bgcolor: "primary.main",
|
|
78
|
+
color: "#fff",
|
|
79
|
+
boxShadow: "0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)"
|
|
80
|
+
};
|
|
81
|
+
const inactiveSx = {
|
|
82
|
+
color: "text.secondary",
|
|
83
|
+
"&:hover": { color: "text.primary" }
|
|
84
|
+
};
|
|
85
|
+
const capsuleBtnSx = (active) => ({
|
|
86
|
+
px: 3.5,
|
|
87
|
+
py: 1,
|
|
88
|
+
borderRadius: "9999px",
|
|
89
|
+
cursor: "pointer",
|
|
90
|
+
transition: "all 0.3s ease",
|
|
91
|
+
userSelect: "none",
|
|
92
|
+
...active ? activeSx : inactiveSx
|
|
93
|
+
});
|
|
94
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1 }, children: [
|
|
95
|
+
!isMobile && (appName || appLogo) && /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 5 }, children: [
|
|
96
|
+
appLogo && /* @__PURE__ */ jsx(
|
|
97
|
+
Avatar,
|
|
98
|
+
{
|
|
99
|
+
src: appLogo,
|
|
100
|
+
alt: appName,
|
|
101
|
+
sx: {
|
|
102
|
+
width: 48,
|
|
103
|
+
height: 48,
|
|
104
|
+
borderRadius: "16px",
|
|
105
|
+
bgcolor: "background.paper",
|
|
106
|
+
boxShadow: 1,
|
|
107
|
+
border: "1px solid",
|
|
108
|
+
borderColor: "divider"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
appName && /* @__PURE__ */ jsx(Typography, { sx: { fontWeight: 600, fontSize: 15, color: "text.primary" }, children: appName })
|
|
113
|
+
] }),
|
|
114
|
+
!isMobile && /* @__PURE__ */ jsx(Box, { sx: { flexGrow: 1, flexShrink: 1, flexBasis: 0 } }),
|
|
115
|
+
/* @__PURE__ */ jsxs(Box, { sx: { flexShrink: 0 }, children: [
|
|
116
|
+
/* @__PURE__ */ jsxs(Box, { sx: { mb: { xs: 3, md: 4 } }, children: [
|
|
117
|
+
isMobile && (appName || appLogo) && /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 1 }, children: [
|
|
118
|
+
appLogo && /* @__PURE__ */ jsx(Avatar, { src: appLogo, alt: appName, sx: { width: 24, height: 24, borderRadius: "6px" } }),
|
|
119
|
+
appName && /* @__PURE__ */ jsx(Typography, { sx: { fontWeight: 600, fontSize: 13, color: "text.secondary" }, children: appName })
|
|
120
|
+
] }),
|
|
121
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, sx: { mb: 1.5 }, children: [
|
|
122
|
+
/* @__PURE__ */ jsx(
|
|
123
|
+
Typography,
|
|
124
|
+
{
|
|
125
|
+
component: "span",
|
|
126
|
+
sx: {
|
|
127
|
+
fontSize: 10,
|
|
128
|
+
fontWeight: 700,
|
|
129
|
+
letterSpacing: "0.1em",
|
|
130
|
+
lineHeight: 1,
|
|
131
|
+
textTransform: "uppercase",
|
|
132
|
+
color: "primary.main",
|
|
133
|
+
bgcolor: (theme) => theme.palette.mode === "dark" ? `${theme.palette.primary.main}1A` : `${theme.palette.primary.main}0D`,
|
|
134
|
+
px: 1,
|
|
135
|
+
py: 0.5,
|
|
136
|
+
borderRadius: "4px"
|
|
137
|
+
},
|
|
138
|
+
children: headerMeta.badgeLabel
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
pricing.trial.active && pricing.trial.days > 0 && /* @__PURE__ */ jsx(
|
|
142
|
+
Typography,
|
|
143
|
+
{
|
|
144
|
+
component: "span",
|
|
145
|
+
sx: {
|
|
146
|
+
fontSize: 10,
|
|
147
|
+
fontWeight: 700,
|
|
148
|
+
letterSpacing: "0.1em",
|
|
149
|
+
lineHeight: 1,
|
|
150
|
+
textTransform: "uppercase",
|
|
151
|
+
color: "primary.main",
|
|
152
|
+
bgcolor: (theme) => theme.palette.mode === "dark" ? `${theme.palette.primary.main}1A` : `${theme.palette.primary.main}0D`,
|
|
153
|
+
px: 1,
|
|
154
|
+
py: 0.5,
|
|
155
|
+
borderRadius: "4px"
|
|
156
|
+
},
|
|
157
|
+
children: formatTrialText(t, pricing.trial.days, pricing.trial.afterTrialInterval || "day")
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
!livemode && /* @__PURE__ */ jsx(
|
|
161
|
+
Typography,
|
|
162
|
+
{
|
|
163
|
+
component: "span",
|
|
164
|
+
sx: {
|
|
165
|
+
fontSize: 10,
|
|
166
|
+
fontWeight: 700,
|
|
167
|
+
letterSpacing: "0.1em",
|
|
168
|
+
lineHeight: 1,
|
|
169
|
+
textTransform: "uppercase",
|
|
170
|
+
color: (theme) => theme.palette.mode === "dark" ? theme.palette.grey[500] : theme.palette.grey[400],
|
|
171
|
+
bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(255,255,255,0.06)" : theme.palette.grey[100],
|
|
172
|
+
px: 1,
|
|
173
|
+
py: 0.5,
|
|
174
|
+
borderRadius: "4px"
|
|
175
|
+
},
|
|
176
|
+
children: t("common.livemode")
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
] }),
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
Typography,
|
|
182
|
+
{
|
|
183
|
+
sx: {
|
|
184
|
+
fontWeight: 800,
|
|
185
|
+
fontSize: { xs: 24, md: 36 },
|
|
186
|
+
lineHeight: 1.1,
|
|
187
|
+
letterSpacing: "-0.03em",
|
|
188
|
+
color: "text.primary",
|
|
189
|
+
mb: 0.75
|
|
190
|
+
},
|
|
191
|
+
children: isMultiItem ? tSafe(t, "payment.checkout.orderSummary", "Order Summary") : headerMeta.title
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
(isMultiItem || headerMeta.subtitle) && /* @__PURE__ */ jsx(
|
|
195
|
+
Typography,
|
|
196
|
+
{
|
|
197
|
+
sx: {
|
|
198
|
+
color: "text.secondary",
|
|
199
|
+
fontSize: { xs: 14, md: 16 },
|
|
200
|
+
fontWeight: 500,
|
|
201
|
+
lineHeight: 1.5
|
|
202
|
+
},
|
|
203
|
+
children: isMultiItem ? tSafe(t, "payment.checkout.orderSummarySubtitle", "Items included in this purchase") : headerMeta.subtitle
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
hasTopUpsell && /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 2, sx: { mt: 2.5 }, children: [
|
|
207
|
+
/* @__PURE__ */ jsxs(
|
|
208
|
+
Stack,
|
|
209
|
+
{
|
|
210
|
+
direction: "row",
|
|
211
|
+
alignItems: "center",
|
|
212
|
+
sx: {
|
|
213
|
+
bgcolor: "background.paper",
|
|
214
|
+
borderRadius: "9999px",
|
|
215
|
+
border: "1px solid",
|
|
216
|
+
borderColor: "divider",
|
|
217
|
+
p: "4px",
|
|
218
|
+
display: "inline-flex",
|
|
219
|
+
boxShadow: (theme) => theme.palette.mode === "dark" ? "0 1px 2px 0 rgba(0,0,0,0.3)" : "0 1px 2px 0 rgba(0,0,0,0.05)"
|
|
220
|
+
},
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ jsx(
|
|
223
|
+
Box,
|
|
224
|
+
{
|
|
225
|
+
onClick: async () => {
|
|
226
|
+
if (isUpselled) {
|
|
227
|
+
try {
|
|
228
|
+
await lineItems.downsell(
|
|
229
|
+
upsellPrimaryItem.upsell_price?.id || upsellPrimaryItem.price_id
|
|
230
|
+
);
|
|
231
|
+
} catch (err) {
|
|
232
|
+
Toast.error(err?.response?.data?.error || err?.message || "Failed");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
sx: capsuleBtnSx(!isUpselled),
|
|
237
|
+
children: /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontSize: 14, fontWeight: 700, color: "inherit", lineHeight: 1 }, children: t(INTERVAL_LOCALE_KEY[currentInterval] || "") })
|
|
238
|
+
}
|
|
239
|
+
),
|
|
240
|
+
/* @__PURE__ */ jsx(
|
|
241
|
+
Box,
|
|
242
|
+
{
|
|
243
|
+
onClick: async () => {
|
|
244
|
+
if (!isUpselled) {
|
|
245
|
+
try {
|
|
246
|
+
await lineItems.upsell(upsellPrimaryItem.price_id, upsellTarget.id);
|
|
247
|
+
} catch (err) {
|
|
248
|
+
Toast.error(err?.response?.data?.error || err?.message || "Failed");
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
sx: capsuleBtnSx(isUpselled),
|
|
253
|
+
children: /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontSize: 14, fontWeight: 700, color: "inherit", lineHeight: 1 }, children: t(INTERVAL_LOCALE_KEY[upsellInterval] || "") })
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
upsellSavings > 0 && /* @__PURE__ */ jsxs(
|
|
260
|
+
Stack,
|
|
261
|
+
{
|
|
262
|
+
direction: "row",
|
|
263
|
+
alignItems: "center",
|
|
264
|
+
spacing: 0.75,
|
|
265
|
+
sx: {
|
|
266
|
+
px: 1.5,
|
|
267
|
+
py: 0.75,
|
|
268
|
+
bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(18,184,134,0.1)" : "#ebfef5",
|
|
269
|
+
color: "#12b886",
|
|
270
|
+
fontSize: 11,
|
|
271
|
+
fontWeight: 700,
|
|
272
|
+
borderRadius: "9999px",
|
|
273
|
+
border: "1px solid",
|
|
274
|
+
borderColor: (theme) => theme.palette.mode === "dark" ? "rgba(18,184,134,0.2)" : "#d3f9e8",
|
|
275
|
+
textTransform: "uppercase",
|
|
276
|
+
letterSpacing: "0.05em"
|
|
277
|
+
},
|
|
278
|
+
children: [
|
|
279
|
+
/* @__PURE__ */ jsx(TrendingDownIcon, { sx: { fontSize: 14 } }),
|
|
280
|
+
/* @__PURE__ */ jsxs(
|
|
281
|
+
Typography,
|
|
282
|
+
{
|
|
283
|
+
component: "span",
|
|
284
|
+
sx: { fontSize: "inherit", fontWeight: "inherit", color: "inherit", lineHeight: 1 },
|
|
285
|
+
children: [
|
|
286
|
+
"SAVE ",
|
|
287
|
+
upsellSavings,
|
|
288
|
+
"%"
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
)
|
|
295
|
+
] })
|
|
296
|
+
] }),
|
|
297
|
+
/* @__PURE__ */ jsx(BillingToggle, { billingInterval })
|
|
298
|
+
] }),
|
|
299
|
+
/* @__PURE__ */ jsxs(
|
|
300
|
+
Box,
|
|
301
|
+
{
|
|
302
|
+
sx: {
|
|
303
|
+
flexGrow: 0,
|
|
304
|
+
flexShrink: 1,
|
|
305
|
+
flexBasis: "auto",
|
|
306
|
+
minHeight: { md: 0 },
|
|
307
|
+
overflowY: { md: "auto" },
|
|
308
|
+
"&::-webkit-scrollbar": { display: "none" },
|
|
309
|
+
scrollbarWidth: "none"
|
|
310
|
+
},
|
|
311
|
+
children: [
|
|
312
|
+
showItemsCollapse && /* @__PURE__ */ jsxs(
|
|
313
|
+
Stack,
|
|
314
|
+
{
|
|
315
|
+
direction: "row",
|
|
316
|
+
alignItems: "center",
|
|
317
|
+
justifyContent: "space-between",
|
|
318
|
+
onClick: () => setItemsExpanded(!itemsExpanded),
|
|
319
|
+
sx: { cursor: "pointer", mb: 1.5 },
|
|
320
|
+
children: [
|
|
321
|
+
/* @__PURE__ */ jsx(Typography, { sx: { fontSize: 14, fontWeight: 600 }, children: t("payment.checkout.productListTotal", { total: lineItems.items.length }) }),
|
|
322
|
+
/* @__PURE__ */ jsx(ExpandMoreIcon, { sx: { transform: itemsExpanded ? "rotate(180deg)" : "rotate(0deg)", transition: "0.3s" } })
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
),
|
|
326
|
+
/* @__PURE__ */ jsxs(Collapse, { in: itemsExpanded || !showItemsCollapse, children: [
|
|
327
|
+
/* @__PURE__ */ jsx(Stack, { spacing: 2, sx: { mb: 2 }, children: lineItems.items.map((item) => /* @__PURE__ */ jsx(
|
|
328
|
+
ProductItemCard,
|
|
329
|
+
{
|
|
330
|
+
item,
|
|
331
|
+
currency,
|
|
332
|
+
discounts,
|
|
333
|
+
exchangeRate: rate.value,
|
|
334
|
+
onQuantityChange: lineItems.updateQuantity,
|
|
335
|
+
onUpsell: lineItems.upsell,
|
|
336
|
+
onDownsell: lineItems.downsell,
|
|
337
|
+
trialActive: pricing.trial.active,
|
|
338
|
+
trialDays: pricing.trial.days,
|
|
339
|
+
hideUpsell: hasTopUpsell || !canUpsell,
|
|
340
|
+
isRateLoading: currencySwitching || rate.hasDynamicPricing && rate.status === "loading",
|
|
341
|
+
showFeatures: pageInfo?.showProductFeatures ?? false,
|
|
342
|
+
t,
|
|
343
|
+
children: item.cross_sell && /* @__PURE__ */ jsx(
|
|
344
|
+
Button,
|
|
345
|
+
{
|
|
346
|
+
size: "small",
|
|
347
|
+
color: "error",
|
|
348
|
+
variant: "text",
|
|
349
|
+
onClick: lineItems.removeCrossSell,
|
|
350
|
+
sx: { mt: 1, ml: -0.5, textTransform: "none", fontSize: 12 },
|
|
351
|
+
children: t("payment.checkout.cross_sell.remove")
|
|
352
|
+
}
|
|
353
|
+
)
|
|
354
|
+
},
|
|
355
|
+
item.id
|
|
356
|
+
)) }),
|
|
357
|
+
crossSellNotAdded && /* @__PURE__ */ jsx(Box, { sx: { mb: 2 }, children: /* @__PURE__ */ jsx(
|
|
358
|
+
CrossSellCard,
|
|
359
|
+
{
|
|
360
|
+
crossSellItem: lineItems.crossSellItem,
|
|
361
|
+
currency,
|
|
362
|
+
exchangeRate: rate.value,
|
|
363
|
+
crossSellRequired: lineItems.crossSellRequired,
|
|
364
|
+
onAdd: lineItems.addCrossSell
|
|
365
|
+
}
|
|
366
|
+
) })
|
|
367
|
+
] })
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
),
|
|
371
|
+
/* @__PURE__ */ jsx(Box, { sx: { flexShrink: 0 }, children: /* @__PURE__ */ jsx(
|
|
372
|
+
TrialInfo,
|
|
373
|
+
{
|
|
374
|
+
trial: {
|
|
375
|
+
active: pricing.trial.active,
|
|
376
|
+
days: pricing.trial.days,
|
|
377
|
+
afterTrialPrice: pricing.trial.afterTrialPrice,
|
|
378
|
+
afterTrialInterval: pricing.trial.afterTrialInterval
|
|
379
|
+
},
|
|
380
|
+
mode,
|
|
381
|
+
items: lineItems.items
|
|
382
|
+
}
|
|
383
|
+
) }),
|
|
384
|
+
/* @__PURE__ */ jsx(Box, { sx: { flexGrow: 1, flexShrink: 1, flexBasis: 0 } }),
|
|
385
|
+
/* @__PURE__ */ jsxs(Box, { sx: { flexShrink: 0 }, children: [
|
|
386
|
+
rate.hasDynamicPricing && rate.status === "unavailable" && !isStripe && /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.75, sx: { mb: 2 }, children: [
|
|
387
|
+
/* @__PURE__ */ jsx(Typography, { sx: { fontSize: 13, color: "text.secondary", fontWeight: 500 }, children: t("payment.dynamicPricing.unavailable.title") }),
|
|
388
|
+
/* @__PURE__ */ jsx(
|
|
389
|
+
Typography,
|
|
390
|
+
{
|
|
391
|
+
component: "span",
|
|
392
|
+
onClick: rate.refresh,
|
|
393
|
+
sx: {
|
|
394
|
+
fontSize: 13,
|
|
395
|
+
color: "primary.main",
|
|
396
|
+
fontWeight: 600,
|
|
397
|
+
cursor: "pointer",
|
|
398
|
+
"&:hover": { textDecoration: "underline" }
|
|
399
|
+
},
|
|
400
|
+
children: t("payment.dynamicPricing.unavailable.retry")
|
|
401
|
+
}
|
|
402
|
+
)
|
|
403
|
+
] }),
|
|
404
|
+
/* @__PURE__ */ jsx(
|
|
405
|
+
ExchangeRateFooter,
|
|
406
|
+
{
|
|
407
|
+
hasDynamicPricing: rate.hasDynamicPricing,
|
|
408
|
+
rate: {
|
|
409
|
+
value: rate.value,
|
|
410
|
+
display: rate.display,
|
|
411
|
+
provider: rate.provider,
|
|
412
|
+
providerDisplay: rate.providerDisplay,
|
|
413
|
+
fetchedAt: rate.fetchedAt,
|
|
414
|
+
status: rate.status
|
|
415
|
+
},
|
|
416
|
+
slippage: { percent: slippage.percent, set: slippage.set },
|
|
417
|
+
currencySymbol: currency?.symbol || "",
|
|
418
|
+
isSubscription: ["subscription", "setup"].includes(mode)
|
|
419
|
+
}
|
|
420
|
+
)
|
|
421
|
+
] })
|
|
422
|
+
] });
|
|
423
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CreditTopupPanel(): import("react").JSX.Element;
|