@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.
Files changed (160) hide show
  1. package/es/checkout-v2/checkout-v2.d.ts +2 -0
  2. package/es/checkout-v2/checkout-v2.js +121 -0
  3. package/es/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
  4. package/es/checkout-v2/components/dialogs/checkout-dialogs.js +106 -0
  5. package/es/checkout-v2/components/left/billing-toggle.d.ts +6 -0
  6. package/es/checkout-v2/components/left/billing-toggle.js +118 -0
  7. package/es/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
  8. package/es/checkout-v2/components/left/cross-sell-card.js +167 -0
  9. package/es/checkout-v2/components/left/product-item-card.d.ts +26 -0
  10. package/es/checkout-v2/components/left/product-item-card.js +571 -0
  11. package/es/checkout-v2/components/left/promotion-input.d.ts +19 -0
  12. package/es/checkout-v2/components/left/promotion-input.js +178 -0
  13. package/es/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
  14. package/es/checkout-v2/components/left/staking-breakdown.js +48 -0
  15. package/es/checkout-v2/components/left/trial-info.d.ts +13 -0
  16. package/es/checkout-v2/components/left/trial-info.js +48 -0
  17. package/es/checkout-v2/components/right/currency-grid.d.ts +8 -0
  18. package/es/checkout-v2/components/right/currency-grid.js +48 -0
  19. package/es/checkout-v2/components/right/customer-info-card.d.ts +17 -0
  20. package/es/checkout-v2/components/right/customer-info-card.js +156 -0
  21. package/es/checkout-v2/components/right/status-feedback.d.ts +7 -0
  22. package/es/checkout-v2/components/right/status-feedback.js +17 -0
  23. package/es/checkout-v2/components/right/submit-button.d.ts +10 -0
  24. package/es/checkout-v2/components/right/submit-button.js +29 -0
  25. package/es/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
  26. package/es/checkout-v2/components/right/subscription-disclaimer.js +8 -0
  27. package/es/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
  28. package/es/checkout-v2/components/shared/exchange-rate-footer.js +182 -0
  29. package/es/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
  30. package/es/checkout-v2/components/shared/scenario-badge.js +47 -0
  31. package/es/checkout-v2/components/shared/total-display.d.ts +7 -0
  32. package/es/checkout-v2/components/shared/total-display.js +84 -0
  33. package/es/checkout-v2/index.d.ts +2 -0
  34. package/es/checkout-v2/index.js +1 -0
  35. package/es/checkout-v2/layouts/checkout-layout.d.ts +7 -0
  36. package/es/checkout-v2/layouts/checkout-layout.js +226 -0
  37. package/es/checkout-v2/panels/left/composite-panel.d.ts +1 -0
  38. package/es/checkout-v2/panels/left/composite-panel.js +423 -0
  39. package/es/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
  40. package/es/checkout-v2/panels/left/credit-topup-panel.js +615 -0
  41. package/es/checkout-v2/panels/left/scenario-router.d.ts +1 -0
  42. package/es/checkout-v2/panels/left/scenario-router.js +19 -0
  43. package/es/checkout-v2/panels/right/payment-panel.d.ts +1 -0
  44. package/es/checkout-v2/panels/right/payment-panel.js +644 -0
  45. package/es/checkout-v2/types.d.ts +15 -0
  46. package/es/checkout-v2/types.js +0 -0
  47. package/es/checkout-v2/utils/format.d.ts +59 -0
  48. package/es/checkout-v2/utils/format.js +125 -0
  49. package/es/checkout-v2/utils/scenario-detector.d.ts +3 -0
  50. package/es/checkout-v2/utils/scenario-detector.js +17 -0
  51. package/es/checkout-v2/views/error-view.d.ts +7 -0
  52. package/es/checkout-v2/views/error-view.js +269 -0
  53. package/es/checkout-v2/views/loading-view.d.ts +5 -0
  54. package/es/checkout-v2/views/loading-view.js +158 -0
  55. package/es/checkout-v2/views/success-view.d.ts +29 -0
  56. package/es/checkout-v2/views/success-view.js +614 -0
  57. package/es/components/phone-field.d.ts +14 -0
  58. package/es/components/phone-field.js +96 -0
  59. package/es/index.d.ts +3 -1
  60. package/es/index.js +3 -1
  61. package/es/locales/en.js +45 -6
  62. package/es/locales/zh.js +45 -6
  63. package/es/payment/form/index.js +10 -1
  64. package/lib/checkout-v2/checkout-v2.d.ts +2 -0
  65. package/lib/checkout-v2/checkout-v2.js +151 -0
  66. package/lib/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
  67. package/lib/checkout-v2/components/dialogs/checkout-dialogs.js +131 -0
  68. package/lib/checkout-v2/components/left/billing-toggle.d.ts +6 -0
  69. package/lib/checkout-v2/components/left/billing-toggle.js +126 -0
  70. package/lib/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
  71. package/lib/checkout-v2/components/left/cross-sell-card.js +257 -0
  72. package/lib/checkout-v2/components/left/product-item-card.d.ts +26 -0
  73. package/lib/checkout-v2/components/left/product-item-card.js +738 -0
  74. package/lib/checkout-v2/components/left/promotion-input.d.ts +19 -0
  75. package/lib/checkout-v2/components/left/promotion-input.js +220 -0
  76. package/lib/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
  77. package/lib/checkout-v2/components/left/staking-breakdown.js +96 -0
  78. package/lib/checkout-v2/components/left/trial-info.d.ts +13 -0
  79. package/lib/checkout-v2/components/left/trial-info.js +82 -0
  80. package/lib/checkout-v2/components/right/currency-grid.d.ts +8 -0
  81. package/lib/checkout-v2/components/right/currency-grid.js +96 -0
  82. package/lib/checkout-v2/components/right/customer-info-card.d.ts +17 -0
  83. package/lib/checkout-v2/components/right/customer-info-card.js +246 -0
  84. package/lib/checkout-v2/components/right/status-feedback.d.ts +7 -0
  85. package/lib/checkout-v2/components/right/status-feedback.js +30 -0
  86. package/lib/checkout-v2/components/right/submit-button.d.ts +10 -0
  87. package/lib/checkout-v2/components/right/submit-button.js +35 -0
  88. package/lib/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
  89. package/lib/checkout-v2/components/right/subscription-disclaimer.js +33 -0
  90. package/lib/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
  91. package/lib/checkout-v2/components/shared/exchange-rate-footer.js +282 -0
  92. package/lib/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
  93. package/lib/checkout-v2/components/shared/scenario-badge.js +57 -0
  94. package/lib/checkout-v2/components/shared/total-display.d.ts +7 -0
  95. package/lib/checkout-v2/components/shared/total-display.js +154 -0
  96. package/lib/checkout-v2/index.d.ts +2 -0
  97. package/lib/checkout-v2/index.js +13 -0
  98. package/lib/checkout-v2/layouts/checkout-layout.d.ts +7 -0
  99. package/lib/checkout-v2/layouts/checkout-layout.js +308 -0
  100. package/lib/checkout-v2/panels/left/composite-panel.d.ts +1 -0
  101. package/lib/checkout-v2/panels/left/composite-panel.js +515 -0
  102. package/lib/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
  103. package/lib/checkout-v2/panels/left/credit-topup-panel.js +799 -0
  104. package/lib/checkout-v2/panels/left/scenario-router.d.ts +1 -0
  105. package/lib/checkout-v2/panels/left/scenario-router.js +29 -0
  106. package/lib/checkout-v2/panels/right/payment-panel.d.ts +1 -0
  107. package/lib/checkout-v2/panels/right/payment-panel.js +906 -0
  108. package/lib/checkout-v2/types.d.ts +15 -0
  109. package/lib/checkout-v2/types.js +1 -0
  110. package/lib/checkout-v2/utils/format.d.ts +59 -0
  111. package/lib/checkout-v2/utils/format.js +158 -0
  112. package/lib/checkout-v2/utils/scenario-detector.d.ts +3 -0
  113. package/lib/checkout-v2/utils/scenario-detector.js +23 -0
  114. package/lib/checkout-v2/views/error-view.d.ts +7 -0
  115. package/lib/checkout-v2/views/error-view.js +321 -0
  116. package/lib/checkout-v2/views/loading-view.d.ts +5 -0
  117. package/lib/checkout-v2/views/loading-view.js +168 -0
  118. package/lib/checkout-v2/views/success-view.d.ts +29 -0
  119. package/lib/checkout-v2/views/success-view.js +735 -0
  120. package/lib/components/phone-field.d.ts +14 -0
  121. package/lib/components/phone-field.js +130 -0
  122. package/lib/index.d.ts +3 -1
  123. package/lib/index.js +8 -0
  124. package/lib/locales/en.js +45 -6
  125. package/lib/locales/zh.js +45 -6
  126. package/lib/payment/form/index.js +10 -1
  127. package/package.json +4 -3
  128. package/src/checkout-v2/checkout-v2.tsx +155 -0
  129. package/src/checkout-v2/components/dialogs/checkout-dialogs.tsx +134 -0
  130. package/src/checkout-v2/components/left/billing-toggle.tsx +122 -0
  131. package/src/checkout-v2/components/left/cross-sell-card.tsx +170 -0
  132. package/src/checkout-v2/components/left/product-item-card.tsx +634 -0
  133. package/src/checkout-v2/components/left/promotion-input.tsx +207 -0
  134. package/src/checkout-v2/components/left/staking-breakdown.tsx +57 -0
  135. package/src/checkout-v2/components/left/trial-info.tsx +63 -0
  136. package/src/checkout-v2/components/right/currency-grid.tsx +59 -0
  137. package/src/checkout-v2/components/right/customer-info-card.tsx +214 -0
  138. package/src/checkout-v2/components/right/status-feedback.tsx +35 -0
  139. package/src/checkout-v2/components/right/submit-button.tsx +37 -0
  140. package/src/checkout-v2/components/right/subscription-disclaimer.tsx +27 -0
  141. package/src/checkout-v2/components/shared/exchange-rate-footer.tsx +221 -0
  142. package/src/checkout-v2/components/shared/scenario-badge.tsx +51 -0
  143. package/src/checkout-v2/components/shared/total-display.tsx +112 -0
  144. package/src/checkout-v2/index.ts +2 -0
  145. package/src/checkout-v2/layouts/checkout-layout.tsx +232 -0
  146. package/src/checkout-v2/panels/left/composite-panel.tsx +465 -0
  147. package/src/checkout-v2/panels/left/credit-topup-panel.tsx +681 -0
  148. package/src/checkout-v2/panels/left/scenario-router.tsx +22 -0
  149. package/src/checkout-v2/panels/right/payment-panel.tsx +703 -0
  150. package/src/checkout-v2/types.ts +18 -0
  151. package/src/checkout-v2/utils/format.ts +204 -0
  152. package/src/checkout-v2/utils/scenario-detector.ts +30 -0
  153. package/src/checkout-v2/views/error-view.tsx +293 -0
  154. package/src/checkout-v2/views/loading-view.tsx +162 -0
  155. package/src/checkout-v2/views/success-view.tsx +770 -0
  156. package/src/components/phone-field.tsx +119 -0
  157. package/src/index.ts +3 -0
  158. package/src/locales/en.tsx +45 -4
  159. package/src/locales/zh.tsx +43 -4
  160. package/src/payment/form/index.tsx +16 -1
@@ -0,0 +1,614 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import {
4
+ Box,
5
+ Typography,
6
+ Stack,
7
+ Alert,
8
+ Button,
9
+ Link,
10
+ Divider,
11
+ LinearProgress,
12
+ Skeleton,
13
+ keyframes
14
+ } from "@mui/material";
15
+ import CheckIcon from "@mui/icons-material/Check";
16
+ import CheckCircleIcon from "@mui/icons-material/CheckCircle";
17
+ import VerifiedUserIcon from "@mui/icons-material/VerifiedUser";
18
+ import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
19
+ import OpenInNewIcon from "@mui/icons-material/OpenInNew";
20
+ import ArrowBackIcon from "@mui/icons-material/ArrowBack";
21
+ import { joinURL } from "ufo";
22
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
23
+ import { usePaymentMethodContext } from "@blocklet/payment-react-headless";
24
+ import { getPrefix } from "../../libs/util.js";
25
+ import { formatTokenAmount } from "../utils/format.js";
26
+ const scaleIn = keyframes`
27
+ from { transform: scale(0); opacity: 0; }
28
+ 60% { transform: scale(1.15); }
29
+ to { transform: scale(1); opacity: 1; }
30
+ `;
31
+ const fadeUp = keyframes`
32
+ from { opacity: 0; transform: translateY(16px); }
33
+ to { opacity: 1; transform: translateY(0); }
34
+ `;
35
+ function useConfetti(containerRef, enabled) {
36
+ const firedRef = useRef(false);
37
+ useEffect(() => {
38
+ if (!enabled || firedRef.current || !containerRef.current) return void 0;
39
+ firedRef.current = true;
40
+ const container = containerRef.current;
41
+ const canvas = document.createElement("canvas");
42
+ canvas.style.cssText = "position:absolute;inset:0;pointer-events:none;z-index:10;";
43
+ canvas.width = container.offsetWidth;
44
+ canvas.height = container.offsetHeight;
45
+ container.appendChild(canvas);
46
+ const ctx = canvas.getContext("2d");
47
+ if (!ctx) return void 0;
48
+ const colors = ["#3b82f6", "#60a5fa", "#34d399", "#fbbf24", "#f472b6", "#a78bfa", "#f97316"];
49
+ const pieces = [];
50
+ for (let i = 0; i < 80; i++) {
51
+ pieces.push({
52
+ x: canvas.width / 2 + (Math.random() - 0.5) * 60,
53
+ y: canvas.height * 0.35,
54
+ vx: (Math.random() - 0.5) * 12,
55
+ vy: -Math.random() * 14 - 4,
56
+ w: Math.random() * 8 + 4,
57
+ h: Math.random() * 6 + 2,
58
+ color: colors[Math.floor(Math.random() * colors.length)],
59
+ rot: Math.random() * Math.PI * 2,
60
+ rv: (Math.random() - 0.5) * 0.3,
61
+ opacity: 1
62
+ });
63
+ }
64
+ let frame;
65
+ const gravity = 0.25;
66
+ const friction = 0.99;
67
+ const animate = () => {
68
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
69
+ let alive = false;
70
+ for (const p of pieces) {
71
+ p.vy += gravity;
72
+ p.vx *= friction;
73
+ p.x += p.vx;
74
+ p.y += p.vy;
75
+ p.rot += p.rv;
76
+ if (p.y > canvas.height * 0.6) {
77
+ p.opacity -= 0.02;
78
+ }
79
+ if (p.opacity > 0) {
80
+ alive = true;
81
+ ctx.save();
82
+ ctx.globalAlpha = p.opacity;
83
+ ctx.translate(p.x, p.y);
84
+ ctx.rotate(p.rot);
85
+ ctx.fillStyle = p.color;
86
+ ctx.fillRect(-p.w / 2, -p.h / 2, p.w, p.h);
87
+ ctx.restore();
88
+ }
89
+ }
90
+ if (alive) {
91
+ frame = requestAnimationFrame(animate);
92
+ } else {
93
+ canvas.remove();
94
+ }
95
+ };
96
+ const timer = setTimeout(() => {
97
+ frame = requestAnimationFrame(animate);
98
+ }, 400);
99
+ return () => {
100
+ clearTimeout(timer);
101
+ cancelAnimationFrame(frame);
102
+ canvas.remove();
103
+ };
104
+ }, [enabled, containerRef]);
105
+ }
106
+ function getCustomMessage(session) {
107
+ return session?.payment_link?.after_completion?.hosted_confirmation?.custom_message;
108
+ }
109
+ function getPayee(session) {
110
+ const items = session?.line_items || [];
111
+ for (const item of items) {
112
+ if (item?.price?.product?.statement_descriptor) {
113
+ return item.price.product.statement_descriptor;
114
+ }
115
+ }
116
+ return session?.app_name || session?.payment_link?.app_name || "";
117
+ }
118
+ function getVendorLabel(vendor, isFailed, t) {
119
+ const name = vendor.name || vendor.title;
120
+ const isCompleted = vendor.status === "delivered";
121
+ if (vendor.vendorType === "didnames") {
122
+ if (isFailed) return t("payment.checkout.vendor.didnames.failed", { name });
123
+ if (isCompleted) return t("payment.checkout.vendor.didnames.completed", { name });
124
+ return t("payment.checkout.vendor.didnames.processing", { name });
125
+ }
126
+ if (isFailed) return t("payment.checkout.vendor.launcher.failed", { name });
127
+ if (isCompleted) return t("payment.checkout.vendor.launcher.completed", { name });
128
+ return t("payment.checkout.vendor.launcher.processing", { name });
129
+ }
130
+ function HeroSuccessIcon() {
131
+ return /* @__PURE__ */ jsxs(
132
+ Box,
133
+ {
134
+ sx: {
135
+ position: "relative",
136
+ mb: 1,
137
+ animation: `${scaleIn} 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both`
138
+ },
139
+ children: [
140
+ /* @__PURE__ */ jsx(
141
+ Box,
142
+ {
143
+ sx: {
144
+ position: "absolute",
145
+ inset: -24,
146
+ background: (theme) => theme.palette.mode === "dark" ? "radial-gradient(circle, rgba(59,130,246,0.12) 0%, transparent 70%)" : "radial-gradient(circle, rgba(59,130,246,0.08) 0%, transparent 70%)",
147
+ borderRadius: "50%",
148
+ pointerEvents: "none"
149
+ }
150
+ }
151
+ ),
152
+ /* @__PURE__ */ jsxs(
153
+ Box,
154
+ {
155
+ sx: {
156
+ position: "relative",
157
+ width: { xs: 100, md: 120 },
158
+ height: { xs: 100, md: 120 },
159
+ borderRadius: { xs: "28px", md: "32px" },
160
+ background: (theme) => theme.palette.mode === "dark" ? "linear-gradient(135deg, rgba(59,130,246,0.15) 0%, rgba(255,255,255,0.04) 100%)" : "linear-gradient(135deg, #eff6ff 0%, #ffffff 100%)",
161
+ border: "1px solid",
162
+ borderColor: (theme) => theme.palette.mode === "dark" ? "rgba(59,130,246,0.2)" : "rgba(59,130,246,0.12)",
163
+ boxShadow: (theme) => theme.palette.mode === "dark" ? "0 10px 30px -5px rgba(0,0,0,0.3)" : "0 10px 30px -5px rgba(59,130,246,0.1)",
164
+ display: "flex",
165
+ alignItems: "center",
166
+ justifyContent: "center"
167
+ },
168
+ children: [
169
+ /* @__PURE__ */ jsx(
170
+ Box,
171
+ {
172
+ sx: {
173
+ position: "absolute",
174
+ inset: 0,
175
+ borderRadius: "inherit",
176
+ background: (theme) => theme.palette.mode === "dark" ? "linear-gradient(to top-right, rgba(59,130,246,0.1), transparent)" : "linear-gradient(to top-right, rgba(59,130,246,0.06), transparent)",
177
+ pointerEvents: "none"
178
+ }
179
+ }
180
+ ),
181
+ /* @__PURE__ */ jsx(
182
+ VerifiedUserIcon,
183
+ {
184
+ sx: {
185
+ fontSize: { xs: 52, md: 64 },
186
+ color: "primary.main",
187
+ filter: (theme) => theme.palette.mode === "dark" ? "drop-shadow(0 0 12px rgba(59,130,246,0.4))" : "drop-shadow(0 0 12px rgba(59,130,246,0.2))"
188
+ }
189
+ }
190
+ )
191
+ ]
192
+ }
193
+ ),
194
+ /* @__PURE__ */ jsx(
195
+ Box,
196
+ {
197
+ sx: {
198
+ position: "absolute",
199
+ bottom: { xs: -6, md: -8 },
200
+ right: { xs: -6, md: -8 },
201
+ width: { xs: 32, md: 38 },
202
+ height: { xs: 32, md: 38 },
203
+ borderRadius: { xs: "12px", md: "14px" },
204
+ bgcolor: "background.paper",
205
+ boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
206
+ border: "1px solid",
207
+ borderColor: (theme) => theme.palette.mode === "dark" ? "rgba(255,255,255,0.1)" : "rgba(59,130,246,0.08)",
208
+ display: "flex",
209
+ alignItems: "center",
210
+ justifyContent: "center"
211
+ },
212
+ children: /* @__PURE__ */ jsx(CheckCircleIcon, { sx: { fontSize: { xs: 20, md: 24 }, color: "success.main" } })
213
+ }
214
+ )
215
+ ]
216
+ }
217
+ );
218
+ }
219
+ function PaymentReceipt({
220
+ session,
221
+ t
222
+ }) {
223
+ const { currencies } = usePaymentMethodContext();
224
+ const amountTotal = session?.amount_total;
225
+ const currencyId = session?.currency_id;
226
+ const subData = session?.subscription_data;
227
+ if (Number(subData?.trial_period_days || 0) > 0) return null;
228
+ if (!amountTotal || amountTotal === "0") return null;
229
+ const currency = currencies.find((c) => c.id === currencyId) || null;
230
+ if (!currency) return null;
231
+ const formatted = formatTokenAmount(amountTotal, currency);
232
+ if (!formatted || formatted === "0") return null;
233
+ const amountStr = `${formatted} ${currency.symbol || ""}`.trim();
234
+ const fullText = t("payment.checkout.completed.summary.paid", { amount: amountStr });
235
+ const idx = fullText.indexOf(amountStr);
236
+ return /* @__PURE__ */ jsx(
237
+ Typography,
238
+ {
239
+ sx: {
240
+ fontSize: { xs: 15, md: 16 },
241
+ color: "text.secondary",
242
+ fontWeight: 500,
243
+ lineHeight: 1.6,
244
+ textAlign: "center",
245
+ maxWidth: 440,
246
+ animation: `${fadeUp} 0.5s ease 0.3s both`
247
+ },
248
+ children: idx >= 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
249
+ fullText.slice(0, idx),
250
+ /* @__PURE__ */ jsx(Box, { component: "span", sx: { fontWeight: 700, color: "text.primary" }, children: amountStr }),
251
+ fullText.slice(idx + amountStr.length)
252
+ ] }) : fullText
253
+ }
254
+ );
255
+ }
256
+ function VendorProgressItemV2({ vendor, t }) {
257
+ const [displayProgress, setDisplayProgress] = useState(0);
258
+ const animationRef = useRef();
259
+ const startAnimation = useCallback(() => {
260
+ const realProgress = vendor.progress || 0;
261
+ let startTime;
262
+ let startProgress;
263
+ const animate = (currentTime) => {
264
+ if (!startTime) {
265
+ startTime = currentTime;
266
+ startProgress = displayProgress;
267
+ }
268
+ const elapsed = currentTime - startTime;
269
+ let newProgress;
270
+ if (realProgress === 100) {
271
+ newProgress = 100;
272
+ } else if (realProgress === 0) {
273
+ newProgress = Math.min(startProgress + elapsed / 1e3, 99);
274
+ } else if (realProgress > startProgress) {
275
+ const progress = Math.min(elapsed / 1e3, 1);
276
+ newProgress = startProgress + (realProgress - startProgress) * progress;
277
+ } else {
278
+ newProgress = Math.min(startProgress + elapsed / 1e3, 99);
279
+ }
280
+ newProgress = Math.round(newProgress);
281
+ setDisplayProgress((pre) => Math.min(pre > newProgress ? pre : newProgress, 100));
282
+ if (realProgress === 100) return;
283
+ if (newProgress < 99 && realProgress < 100) {
284
+ animationRef.current = requestAnimationFrame(animate);
285
+ }
286
+ };
287
+ if (animationRef.current) cancelAnimationFrame(animationRef.current);
288
+ animationRef.current = requestAnimationFrame(animate);
289
+ }, [vendor.progress, displayProgress]);
290
+ useEffect(() => {
291
+ startAnimation();
292
+ return () => {
293
+ if (animationRef.current) cancelAnimationFrame(animationRef.current);
294
+ };
295
+ }, [startAnimation]);
296
+ const isCompleted = displayProgress >= 100;
297
+ const isFailed = vendor.status === "failed";
298
+ const nameText = getVendorLabel(vendor, isFailed, t);
299
+ if (!vendor.name && !vendor.title) {
300
+ return /* @__PURE__ */ jsxs(Box, { sx: { mb: 1.5 }, children: [
301
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 0.75 }, children: [
302
+ /* @__PURE__ */ jsx(Skeleton, { variant: "rounded", height: 14, width: 150 }),
303
+ /* @__PURE__ */ jsx(Skeleton, { variant: "rounded", height: 14, width: 50 })
304
+ ] }),
305
+ /* @__PURE__ */ jsx(Skeleton, { variant: "rounded", height: 6, width: "100%" })
306
+ ] });
307
+ }
308
+ return /* @__PURE__ */ jsxs(Box, { sx: { mb: 1.5 }, children: [
309
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 0.75 }, children: [
310
+ /* @__PURE__ */ jsxs(
311
+ Typography,
312
+ {
313
+ sx: {
314
+ fontSize: 13,
315
+ fontWeight: 600,
316
+ color: isFailed ? "error.main" : "text.secondary",
317
+ display: "flex",
318
+ alignItems: "center"
319
+ },
320
+ children: [
321
+ nameText,
322
+ isCompleted && !isFailed && /* @__PURE__ */ jsx(CheckIcon, { sx: { color: "success.main", ml: 0.5, fontSize: 16 } })
323
+ ]
324
+ }
325
+ ),
326
+ !isCompleted && /* @__PURE__ */ jsx(Typography, { sx: { fontSize: 12, fontWeight: 600, color: isFailed ? "error.main" : "text.secondary" }, children: t("payment.checkout.vendor.progress", { progress: isFailed ? 0 : displayProgress }) })
327
+ ] }),
328
+ /* @__PURE__ */ jsx(
329
+ LinearProgress,
330
+ {
331
+ variant: "determinate",
332
+ value: isFailed ? 100 : displayProgress || 0,
333
+ sx: {
334
+ height: 6,
335
+ borderRadius: 3,
336
+ bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(255,255,255,0.08)" : "grey.200",
337
+ "& .MuiLinearProgress-bar": {
338
+ borderRadius: 3,
339
+ // eslint-disable-next-line no-nested-ternary
340
+ bgcolor: isFailed ? "error.main" : isCompleted ? "success.main" : "primary.main",
341
+ transition: "background-color 0.3s linear"
342
+ }
343
+ }
344
+ }
345
+ )
346
+ ] });
347
+ }
348
+ function VendorProgressPanel({
349
+ vendorStatus,
350
+ pageInfo = void 0,
351
+ locale,
352
+ t
353
+ }) {
354
+ return /* @__PURE__ */ jsxs(
355
+ Box,
356
+ {
357
+ sx: {
358
+ width: "100%",
359
+ maxWidth: 420,
360
+ p: 2.5,
361
+ borderRadius: 3,
362
+ bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(255,255,255,0.04)" : "grey.50",
363
+ border: "1px solid",
364
+ borderColor: "divider",
365
+ animation: `${fadeUp} 0.5s ease 0.3s both`
366
+ },
367
+ children: [
368
+ vendorStatus.vendors.map((vendor, idx) => /* @__PURE__ */ jsx(VendorProgressItemV2, { vendor, t }, vendor.title || `vendor-${idx}`)),
369
+ vendorStatus.hasFailed && /* @__PURE__ */ jsx(Typography, { sx: { fontSize: 13, fontWeight: 600, color: "warning.main", mt: 1 }, children: t("payment.checkout.vendor.failedMsg") }),
370
+ vendorStatus.isAllCompleted && pageInfo?.success_message?.[locale] && /* @__PURE__ */ jsx(Typography, { sx: { fontSize: 14, fontWeight: 600, color: "text.primary", mt: 1 }, children: pageInfo.success_message[locale] })
371
+ ]
372
+ }
373
+ );
374
+ }
375
+ function SubscriptionLinks({
376
+ mode,
377
+ subscriptions,
378
+ subscriptionId = void 0,
379
+ payee,
380
+ prefix,
381
+ t
382
+ }) {
383
+ if (!["subscription", "setup"].includes(mode)) return null;
384
+ if (subscriptions.length > 1) {
385
+ return /* @__PURE__ */ jsx(
386
+ Box,
387
+ {
388
+ sx: {
389
+ width: "100%",
390
+ maxWidth: 420,
391
+ borderRadius: 3,
392
+ bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(255,255,255,0.04)" : "grey.50",
393
+ border: "1px solid",
394
+ borderColor: "divider",
395
+ overflow: "hidden",
396
+ animation: `${fadeUp} 0.5s ease 0.35s both`
397
+ },
398
+ children: subscriptions.map((sub, idx) => /* @__PURE__ */ jsxs(Box, { children: [
399
+ idx > 0 && /* @__PURE__ */ jsx(Divider, {}),
400
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", sx: { px: 2.5, py: 1.5 }, children: [
401
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: 13, fontWeight: 500, color: "text.secondary", flex: 1, minWidth: 0 }, noWrap: true, children: sub.description || sub.id }),
402
+ /* @__PURE__ */ jsx(
403
+ Box,
404
+ {
405
+ sx: {
406
+ flex: 1,
407
+ borderBottom: "1px dashed",
408
+ borderColor: "grey.300",
409
+ mx: 2,
410
+ minWidth: 20
411
+ }
412
+ }
413
+ ),
414
+ /* @__PURE__ */ jsxs(
415
+ Link,
416
+ {
417
+ href: joinURL(prefix, `/customer/subscription/${sub.id}`),
418
+ underline: "none",
419
+ sx: {
420
+ display: "flex",
421
+ alignItems: "center",
422
+ gap: 0.5,
423
+ fontSize: 13,
424
+ fontWeight: 600,
425
+ color: "primary.main",
426
+ flexShrink: 0
427
+ },
428
+ children: [
429
+ t("payment.checkout.next.view"),
430
+ /* @__PURE__ */ jsx(OpenInNewIcon, { sx: { fontSize: 14 } })
431
+ ]
432
+ }
433
+ )
434
+ ] })
435
+ ] }, sub.id))
436
+ }
437
+ );
438
+ }
439
+ if (subscriptionId) {
440
+ return /* @__PURE__ */ jsx(
441
+ Button,
442
+ {
443
+ variant: "contained",
444
+ href: joinURL(prefix, `/customer/subscription/${subscriptionId}`),
445
+ endIcon: /* @__PURE__ */ jsx(OpenInNewIcon, { sx: { fontSize: 16 } }),
446
+ sx: {
447
+ width: "100%",
448
+ maxWidth: 320,
449
+ height: 52,
450
+ borderRadius: "16px",
451
+ textTransform: "none",
452
+ fontWeight: 700,
453
+ fontSize: { xs: 16, md: 17 },
454
+ letterSpacing: "0.02em",
455
+ boxShadow: "0 8px 24px -4px rgba(59,130,246,0.25)",
456
+ "&:hover": {
457
+ boxShadow: "0 12px 28px -4px rgba(59,130,246,0.35)"
458
+ },
459
+ animation: `${fadeUp} 0.5s ease 0.35s both`
460
+ },
461
+ children: t("payment.checkout.next.subscription", { payee })
462
+ }
463
+ );
464
+ }
465
+ return null;
466
+ }
467
+ function InvoiceLink({
468
+ mode,
469
+ invoiceId = void 0,
470
+ prefix,
471
+ t
472
+ }) {
473
+ if (mode !== "payment" || !invoiceId) return null;
474
+ return /* @__PURE__ */ jsx(
475
+ Button,
476
+ {
477
+ variant: "contained",
478
+ href: joinURL(prefix, `/customer/invoice/${invoiceId}`),
479
+ endIcon: /* @__PURE__ */ jsx(OpenInNewIcon, { sx: { fontSize: 16 } }),
480
+ sx: {
481
+ width: "100%",
482
+ maxWidth: 320,
483
+ height: 52,
484
+ borderRadius: "16px",
485
+ textTransform: "none",
486
+ fontWeight: 700,
487
+ fontSize: { xs: 16, md: 17 },
488
+ letterSpacing: "0.02em",
489
+ boxShadow: "0 8px 24px -4px rgba(59,130,246,0.25)",
490
+ "&:hover": {
491
+ boxShadow: "0 12px 28px -4px rgba(59,130,246,0.35)"
492
+ },
493
+ animation: `${fadeUp} 0.5s ease 0.35s both`
494
+ },
495
+ children: t("payment.checkout.next.invoice")
496
+ }
497
+ );
498
+ }
499
+ export default function SuccessView({ submit, session }) {
500
+ const { t, locale } = useLocaleContext();
501
+ const { vendorStatus } = submit;
502
+ const payee = getPayee(session);
503
+ const prefix = getPrefix();
504
+ const mode = session?.mode || "payment";
505
+ const resultSession = submit.result?.checkoutSession;
506
+ const subscriptions = session?.subscriptions || [];
507
+ const subscriptionId = session?.subscription_id || resultSession?.subscription_id;
508
+ const invoiceId = session?.invoice_id || submit.result?.checkoutSession?.invoice_id || submit.result?.checkoutSession?.payment_intent?.invoice_id;
509
+ const pageInfo = session?.metadata?.page_info;
510
+ const customMessage = getCustomMessage(session);
511
+ const submitType = session?.submit_type;
512
+ const messageKey = submitType === "donate" ? "payment.checkout.completed.donate" : `payment.checkout.completed.${mode}`;
513
+ const headline = customMessage || t(messageKey);
514
+ const isVendorProcessing = vendorStatus && !vendorStatus.isAllCompleted && !vendorStatus.hasFailed;
515
+ const containerRef = useRef(null);
516
+ const showConfetti = !vendorStatus?.hasFailed;
517
+ useConfetti(containerRef, showConfetti);
518
+ return /* @__PURE__ */ jsx(
519
+ Box,
520
+ {
521
+ ref: containerRef,
522
+ sx: {
523
+ position: "relative",
524
+ display: "flex",
525
+ flexDirection: "column",
526
+ justifyContent: "center",
527
+ alignItems: "center",
528
+ flex: 1,
529
+ minHeight: 400,
530
+ p: { xs: 3, md: 4 },
531
+ textAlign: "center",
532
+ overflow: "hidden"
533
+ },
534
+ children: /* @__PURE__ */ jsxs(Stack, { spacing: 3, alignItems: "center", sx: { width: "100%", maxWidth: 440 }, children: [
535
+ vendorStatus?.hasFailed ? /* @__PURE__ */ jsx(
536
+ ErrorOutlineIcon,
537
+ {
538
+ sx: {
539
+ fontSize: 64,
540
+ color: "warning.main",
541
+ animation: `${scaleIn} 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both`
542
+ }
543
+ }
544
+ ) : /* @__PURE__ */ jsx(HeroSuccessIcon, {}),
545
+ /* @__PURE__ */ jsxs(Stack, { spacing: 1, alignItems: "center", sx: { animation: `${fadeUp} 0.5s ease 0.2s both` }, children: [
546
+ /* @__PURE__ */ jsx(
547
+ Typography,
548
+ {
549
+ sx: {
550
+ fontSize: { xs: 28, md: 36 },
551
+ fontWeight: 800,
552
+ color: "text.primary",
553
+ lineHeight: 1.2,
554
+ letterSpacing: "-0.02em"
555
+ },
556
+ children: headline
557
+ }
558
+ ),
559
+ payee && /* @__PURE__ */ jsx(
560
+ Typography,
561
+ {
562
+ sx: {
563
+ fontSize: { xs: 14, md: 16 },
564
+ color: "text.secondary",
565
+ fontWeight: 500,
566
+ lineHeight: 1.6,
567
+ maxWidth: 360
568
+ },
569
+ children: t("payment.checkout.completed.tip", { payee })
570
+ }
571
+ )
572
+ ] }),
573
+ /* @__PURE__ */ jsx(PaymentReceipt, { session: resultSession || session, t }),
574
+ vendorStatus && /* @__PURE__ */ jsx(VendorProgressPanel, { vendorStatus, pageInfo, locale, t }),
575
+ vendorStatus?.hasFailed && vendorStatus.error && /* @__PURE__ */ jsx(Alert, { severity: "warning", sx: { maxWidth: 420, borderRadius: 3, width: "100%" }, children: vendorStatus.error }),
576
+ !isVendorProcessing && /* @__PURE__ */ jsx(
577
+ SubscriptionLinks,
578
+ {
579
+ mode,
580
+ subscriptions,
581
+ subscriptionId,
582
+ payee,
583
+ prefix,
584
+ t
585
+ }
586
+ ),
587
+ !isVendorProcessing && /* @__PURE__ */ jsx(InvoiceLink, { mode, invoiceId, prefix, t }),
588
+ !isVendorProcessing && /* @__PURE__ */ jsx(
589
+ Button,
590
+ {
591
+ variant: "text",
592
+ startIcon: /* @__PURE__ */ jsx(ArrowBackIcon, { sx: { fontSize: 16 } }),
593
+ onClick: () => {
594
+ if (window.history.length > 1) {
595
+ window.history.back();
596
+ } else {
597
+ window.location.href = "/";
598
+ }
599
+ },
600
+ sx: {
601
+ textTransform: "none",
602
+ fontWeight: 600,
603
+ fontSize: 14,
604
+ color: "text.secondary",
605
+ "&:hover": { bgcolor: "action.hover" },
606
+ animation: `${fadeUp} 0.5s ease 0.45s both`
607
+ },
608
+ children: t("common.back")
609
+ }
610
+ )
611
+ ] })
612
+ }
613
+ );
614
+ }
@@ -0,0 +1,14 @@
1
+ export interface PhoneFieldProps {
2
+ value: string;
3
+ country: string;
4
+ onChange: (phone: string) => void;
5
+ onCountryChange: (country: string) => void;
6
+ label: string;
7
+ error?: string;
8
+ onBlur?: () => void;
9
+ }
10
+ /**
11
+ * Phone input with country flag + dial code selector.
12
+ * Standalone version of V1 PhoneInput — no react-hook-form dependency.
13
+ */
14
+ export default function PhoneField({ value, country: externalCountry, onChange, onCountryChange, label, error, onBlur, }: PhoneFieldProps): import("react").JSX.Element;