@blocklet/payment-react 1.18.12 → 1.18.14

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 (42) hide show
  1. package/es/components/link.js +1 -0
  2. package/es/components/over-due-invoice-payment.d.ts +3 -1
  3. package/es/components/over-due-invoice-payment.js +14 -3
  4. package/es/history/invoice/list.js +42 -32
  5. package/es/libs/navigation.d.ts +33 -0
  6. package/es/libs/navigation.js +45 -0
  7. package/es/libs/util.d.ts +4 -0
  8. package/es/libs/util.js +20 -0
  9. package/es/locales/en.js +2 -2
  10. package/es/locales/zh.js +2 -2
  11. package/es/payment/form/index.js +5 -0
  12. package/es/payment/form/stripe/form.js +41 -11
  13. package/es/payment/form/stripe/index.d.ts +1 -0
  14. package/es/payment/form/stripe/index.js +2 -1
  15. package/es/theme/index.js +5 -0
  16. package/lib/components/link.js +1 -0
  17. package/lib/components/over-due-invoice-payment.d.ts +3 -1
  18. package/lib/components/over-due-invoice-payment.js +18 -3
  19. package/lib/history/invoice/list.js +53 -42
  20. package/lib/libs/navigation.d.ts +33 -0
  21. package/lib/libs/navigation.js +59 -0
  22. package/lib/libs/util.d.ts +4 -0
  23. package/lib/libs/util.js +25 -0
  24. package/lib/locales/en.js +2 -2
  25. package/lib/locales/zh.js +2 -2
  26. package/lib/payment/form/index.js +5 -0
  27. package/lib/payment/form/stripe/form.js +16 -3
  28. package/lib/payment/form/stripe/index.d.ts +1 -0
  29. package/lib/payment/form/stripe/index.js +2 -1
  30. package/lib/theme/index.js +5 -0
  31. package/package.json +8 -8
  32. package/src/components/link.tsx +1 -0
  33. package/src/components/over-due-invoice-payment.tsx +14 -1
  34. package/src/history/invoice/list.tsx +46 -35
  35. package/src/libs/navigation.ts +89 -0
  36. package/src/libs/util.ts +25 -0
  37. package/src/locales/en.tsx +2 -2
  38. package/src/locales/zh.tsx +2 -2
  39. package/src/payment/form/index.tsx +5 -0
  40. package/src/payment/form/stripe/form.tsx +26 -3
  41. package/src/payment/form/stripe/index.tsx +2 -0
  42. package/src/theme/index.tsx +5 -0
@@ -11,6 +11,7 @@ export default function Link({ to, children, onClick, replace, target, outLink =
11
11
  e.preventDefault();
12
12
  window.location.href = to;
13
13
  }
14
+ e.preventDefault();
14
15
  onClick?.(e);
15
16
  };
16
17
  return /* @__PURE__ */ jsx("a", { href: to, onClick: handleClick, target, rel: "noreferrer", ...props, children });
@@ -9,6 +9,7 @@ type Props = {
9
9
  mode?: 'default' | 'custom';
10
10
  onPaid?: (subscriptionId: string, currencyId: string) => void;
11
11
  dialogProps?: DialogProps;
12
+ inSubscriptionDetail?: boolean;
12
13
  children?: (handlePay: (item: SummaryItem) => void, data: {
13
14
  subscription: Subscription;
14
15
  summary: {
@@ -23,7 +24,7 @@ type SummaryItem = {
23
24
  currency: PaymentCurrency;
24
25
  method: PaymentMethod;
25
26
  };
26
- declare function OverdueInvoicePayment({ subscriptionId, mode, dialogProps, children, onPaid, }: Props): import("react").JSX.Element;
27
+ declare function OverdueInvoicePayment({ subscriptionId, mode, dialogProps, children, onPaid, inSubscriptionDetail, }: Props): import("react").JSX.Element | null;
27
28
  declare namespace OverdueInvoicePayment {
28
29
  var defaultProps: {
29
30
  mode: string;
@@ -32,6 +33,7 @@ declare namespace OverdueInvoicePayment {
32
33
  open: boolean;
33
34
  };
34
35
  children: null;
36
+ inSubscriptionDetail: boolean;
35
37
  };
36
38
  }
37
39
  export default OverdueInvoicePayment;
@@ -20,7 +20,8 @@ function OverdueInvoicePayment({
20
20
  dialogProps = {},
21
21
  children,
22
22
  onPaid = () => {
23
- }
23
+ },
24
+ inSubscriptionDetail = false
24
25
  }) {
25
26
  const { t } = useLocaleContext();
26
27
  const { connect } = usePaymentContext();
@@ -100,8 +101,14 @@ function OverdueInvoicePayment({
100
101
  setDialogOpen(false);
101
102
  dialogProps.onClose?.();
102
103
  };
104
+ const handleViewDetailClick = (e) => {
105
+ if (inSubscriptionDetail) {
106
+ e.preventDefault();
107
+ handleClose();
108
+ }
109
+ };
103
110
  if (loading) {
104
- return /* @__PURE__ */ jsx(CircularProgress, {});
111
+ return null;
105
112
  }
106
113
  const renderPayButton = (item, props) => {
107
114
  const isPayLoading = payLoading && item.currency.id === selectCurrencyId;
@@ -130,6 +137,7 @@ function OverdueInvoicePayment({
130
137
  ...dialogProps || {},
131
138
  open: dialogOpen,
132
139
  title: dialogProps?.title || t("payment.subscription.overdue.pastDue"),
140
+ sx: { "& .MuiDialogContent-root": { pt: 0 } },
133
141
  onClose: handleClose,
134
142
  children: error ? /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message }) : /* @__PURE__ */ jsxs(Stack, { gap: 1, children: [
135
143
  summaryList.length === 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -155,6 +163,7 @@ function OverdueInvoicePayment({
155
163
  {
156
164
  href: subscriptionUrl,
157
165
  target: "_blank",
166
+ onClick: handleViewDetailClick,
158
167
  rel: "noreferrer",
159
168
  style: { color: "var(--foregrounds-fg-interactive, 0086FF)" },
160
169
  children: t("payment.subscription.overdue.view")
@@ -181,6 +190,7 @@ function OverdueInvoicePayment({
181
190
  href: subscriptionUrl,
182
191
  target: "_blank",
183
192
  rel: "noreferrer",
193
+ onClick: handleViewDetailClick,
184
194
  style: { color: "var(--foregrounds-fg-interactive, 0086FF)" },
185
195
  children: t("payment.subscription.overdue.view")
186
196
  }
@@ -229,6 +239,7 @@ OverdueInvoicePayment.defaultProps = {
229
239
  dialogProps: {
230
240
  open: true
231
241
  },
232
- children: null
242
+ children: null,
243
+ inSubscriptionDetail: false
233
244
  };
234
245
  export default OverdueInvoicePayment;
@@ -6,7 +6,7 @@ import { Box, Button, CircularProgress, Hidden, Stack, Typography } from "@mui/m
6
6
  import { styled } from "@mui/system";
7
7
  import { useInfiniteScroll, useRequest, useSetState } from "ahooks";
8
8
  import React, { useEffect, useRef, useState } from "react";
9
- import { joinURL } from "ufo";
9
+ import { useNavigate } from "react-router-dom";
10
10
  import debounce from "lodash/debounce";
11
11
  import Status from "../../components/status.js";
12
12
  import { usePaymentContext } from "../../contexts/payment.js";
@@ -19,10 +19,10 @@ import {
19
19
  formatToDatetime,
20
20
  getInvoiceDescriptionAndReason,
21
21
  getInvoiceStatusColor,
22
- getPrefix,
23
22
  getTxLink
24
23
  } from "../../libs/util.js";
25
24
  import Table from "../../components/table.js";
25
+ import { createLink, handleNavigation } from "../../libs/navigation.js";
26
26
  const groupByDate = (items) => {
27
27
  const grouped = {};
28
28
  items.forEach((item) => {
@@ -45,21 +45,20 @@ const fetchData = (params = {}) => {
45
45
  };
46
46
  const getInvoiceLink = (invoice, action) => {
47
47
  if (invoice.id.startsWith("in_")) {
48
+ const path = `/customer/invoice/${invoice.id}${invoice.status === "uncollectible" && action ? `?action=${action}` : ""}`;
48
49
  return {
49
- external: false,
50
50
  connect: invoice.status === "uncollectible",
51
- url: joinURL(
52
- getPrefix(),
53
- `/customer/invoice/${invoice.id}?action=${invoice.status === "uncollectible" ? action : ""}`
54
- )
51
+ link: createLink(path)
55
52
  };
56
53
  }
57
54
  return {
58
- external: true,
59
55
  connect: false,
60
- url: getTxLink(invoice.paymentMethod, invoice.metadata?.payment_details).link
56
+ link: createLink(getTxLink(invoice.paymentMethod, invoice.metadata?.payment_details).link, true)
61
57
  };
62
58
  };
59
+ const linkStyle = {
60
+ cursor: "pointer"
61
+ };
63
62
  const InvoiceTable = React.memo((props) => {
64
63
  const {
65
64
  pageSize,
@@ -77,6 +76,7 @@ const InvoiceTable = React.memo((props) => {
77
76
  } = props;
78
77
  const listKey = "invoice-table";
79
78
  const { t, locale } = useLocaleContext();
79
+ const navigate = useNavigate();
80
80
  const [search, setSearch] = useState({
81
81
  pageSize: pageSize || 10,
82
82
  page: 1
@@ -131,6 +131,10 @@ const InvoiceTable = React.memo((props) => {
131
131
  });
132
132
  }
133
133
  }, [subscription]);
134
+ const handleLinkClick = (e, invoice) => {
135
+ const { link } = getInvoiceLink(invoice, action);
136
+ handleNavigation(e, link, navigate, { target: link.external ? "_blank" : target });
137
+ };
134
138
  const columns = [
135
139
  {
136
140
  label: t("common.amount"),
@@ -140,8 +144,7 @@ const InvoiceTable = React.memo((props) => {
140
144
  options: {
141
145
  customBodyRenderLite: (_, index) => {
142
146
  const invoice = data?.list[index];
143
- const link = getInvoiceLink(invoice, action);
144
- return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: /* @__PURE__ */ jsxs(Typography, { children: [
147
+ return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: /* @__PURE__ */ jsxs(Typography, { children: [
145
148
  formatBNStr(invoice.total, invoice.paymentCurrency.decimal),
146
149
  "\xA0",
147
150
  invoice.paymentCurrency.symbol
@@ -155,8 +158,7 @@ const InvoiceTable = React.memo((props) => {
155
158
  options: {
156
159
  customBodyRenderLite: (_, index) => {
157
160
  const invoice = data.list[index];
158
- const link = getInvoiceLink(invoice, action);
159
- return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: /* @__PURE__ */ jsx(Status, { label: getInvoiceDescriptionAndReason(invoice, locale)?.type }) });
161
+ return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: /* @__PURE__ */ jsx(Status, { label: getInvoiceDescriptionAndReason(invoice, locale)?.type }) });
160
162
  }
161
163
  }
162
164
  },
@@ -166,8 +168,7 @@ const InvoiceTable = React.memo((props) => {
166
168
  options: {
167
169
  customBodyRenderLite: (_, index) => {
168
170
  const invoice = data?.list[index];
169
- const link = getInvoiceLink(invoice, action);
170
- return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: invoice?.number });
171
+ return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: invoice?.number });
171
172
  }
172
173
  }
173
174
  },
@@ -177,8 +178,7 @@ const InvoiceTable = React.memo((props) => {
177
178
  options: {
178
179
  customBodyRenderLite: (val, index) => {
179
180
  const invoice = data?.list[index];
180
- const link = getInvoiceLink(invoice, action);
181
- return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: formatToDate(invoice.created_at, locale, "YYYY-MM-DD HH:mm:ss") });
181
+ return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: formatToDate(invoice.created_at, locale, "YYYY-MM-DD HH:mm:ss") });
182
182
  }
183
183
  }
184
184
  },
@@ -189,8 +189,7 @@ const InvoiceTable = React.memo((props) => {
189
189
  sort: false,
190
190
  customBodyRenderLite: (val, index) => {
191
191
  const invoice = data?.list[index];
192
- const link = getInvoiceLink(invoice, action);
193
- return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: getInvoiceDescriptionAndReason(invoice, locale)?.description || invoice.id });
192
+ return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: getInvoiceDescriptionAndReason(invoice, locale)?.description || invoice.id });
194
193
  }
195
194
  }
196
195
  },
@@ -200,24 +199,23 @@ const InvoiceTable = React.memo((props) => {
200
199
  options: {
201
200
  customBodyRenderLite: (val, index) => {
202
201
  const invoice = data?.list[index];
203
- const link = getInvoiceLink(invoice, action);
204
202
  const hidePay = invoice.billing_reason === "overdraft-protection";
203
+ const { connect } = getInvoiceLink(invoice, action);
205
204
  if (action && !hidePay) {
206
- return link.connect ? /* @__PURE__ */ jsx(Button, { variant: "text", size: "small", onClick: () => onPay(invoice.id), sx: { color: "text.link" }, children: t("payment.customer.invoice.pay") }) : /* @__PURE__ */ jsx(
205
+ return connect ? /* @__PURE__ */ jsx(Button, { variant: "text", size: "small", onClick: () => onPay(invoice.id), sx: { color: "text.link" }, children: t("payment.customer.invoice.pay") }) : /* @__PURE__ */ jsx(
207
206
  Button,
208
207
  {
209
208
  component: "a",
210
209
  variant: "text",
211
210
  size: "small",
212
- href: link.url,
213
- target: link.external ? "_blank" : target,
211
+ onClick: (e) => handleLinkClick(e, invoice),
214
212
  sx: { color: "var(--foregrounds-fg-interactive, #0086FF) !important" },
215
213
  rel: "noreferrer",
216
214
  children: t("payment.customer.invoice.pay")
217
215
  }
218
216
  );
219
217
  }
220
- return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) });
218
+ return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) });
221
219
  }
222
220
  }
223
221
  }
@@ -283,6 +281,7 @@ const InvoiceList = React.memo((props) => {
283
281
  const size = pageSize || 10;
284
282
  const subscription = useSubscription("events");
285
283
  const { t, locale } = useLocaleContext();
284
+ const navigate = useNavigate();
286
285
  const { data, loadMore, loadingMore, loading, reloadAsync } = useInfiniteScroll(
287
286
  (d) => {
288
287
  const page = d ? Math.ceil(d.list.length / size) + 1 : 1;
@@ -342,11 +341,14 @@ const InvoiceList = React.memo((props) => {
342
341
  }
343
342
  const hasMore = data && data.list.length < data.count;
344
343
  const grouped = groupByDate(data.list);
344
+ const handleLinkClick = (e, link) => {
345
+ handleNavigation(e, link, navigate, { target: link.external ? "_blank" : target });
346
+ };
345
347
  return /* @__PURE__ */ jsxs(Root, { direction: "column", gap: 1, sx: { mt: 1 }, children: [
346
348
  Object.entries(grouped).map(([date, invoices]) => /* @__PURE__ */ jsxs(Box, { children: [
347
349
  /* @__PURE__ */ jsx(Typography, { sx: { fontWeight: "bold", color: "text.secondary", mt: 2, mb: 1 }, children: date }),
348
350
  invoices.map((invoice) => {
349
- const link = getInvoiceLink(invoice, action);
351
+ const { link, connect } = getInvoiceLink(invoice, action);
350
352
  return /* @__PURE__ */ jsxs(
351
353
  Stack,
352
354
  {
@@ -360,10 +362,19 @@ const InvoiceList = React.memo((props) => {
360
362
  alignItems: "center",
361
363
  flexWrap: "nowrap",
362
364
  children: [
363
- /* @__PURE__ */ jsx(Box, { flex: 2, children: /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
364
- /* @__PURE__ */ jsx(Typography, { component: "span", children: invoice.number }),
365
- link.external && /* @__PURE__ */ jsx(Hidden, { mdDown: true, children: /* @__PURE__ */ jsx(OpenInNewOutlined, { fontSize: "small", sx: { color: "text.secondary" } }) })
366
- ] }) }) }),
365
+ /* @__PURE__ */ jsx(Box, { flex: 2, children: /* @__PURE__ */ jsx(
366
+ "a",
367
+ {
368
+ href: link.url,
369
+ target: link.external ? "_blank" : target,
370
+ rel: "noreferrer",
371
+ onClick: (e) => handleLinkClick(e, link),
372
+ children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
373
+ /* @__PURE__ */ jsx(Typography, { component: "span", children: invoice.number }),
374
+ link.external && /* @__PURE__ */ jsx(Hidden, { mdDown: true, children: /* @__PURE__ */ jsx(OpenInNewOutlined, { fontSize: "small", sx: { color: "text.secondary" } }) })
375
+ ] })
376
+ }
377
+ ) }),
367
378
  /* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsxs(Typography, { children: [
368
379
  formatBNStr(invoice.total, invoice.paymentCurrency.decimal),
369
380
  "\xA0",
@@ -371,7 +382,7 @@ const InvoiceList = React.memo((props) => {
371
382
  ] }) }),
372
383
  /* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsx(Typography, { children: formatToDate(invoice.created_at, locale, "HH:mm:ss") }) }),
373
384
  !action && /* @__PURE__ */ jsx(Hidden, { mdDown: true, children: /* @__PURE__ */ jsx(Box, { flex: 2, className: "invoice-description", textAlign: "right", children: /* @__PURE__ */ jsx(Typography, { children: invoice.description || invoice.id }) }) }),
374
- /* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: action ? link.connect ? /* @__PURE__ */ jsx(
385
+ /* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: action ? connect ? /* @__PURE__ */ jsx(
375
386
  Button,
376
387
  {
377
388
  variant: "contained",
@@ -387,8 +398,7 @@ const InvoiceList = React.memo((props) => {
387
398
  component: "a",
388
399
  variant: "contained",
389
400
  size: "small",
390
- href: link.url,
391
- target: link.external ? "_blank" : target,
401
+ onClick: (e) => handleLinkClick(e, link),
392
402
  sx: { whiteSpace: "nowrap" },
393
403
  rel: "noreferrer",
394
404
  children: t("payment.customer.invoice.pay")
@@ -0,0 +1,33 @@
1
+ import { NavigateFunction } from 'react-router-dom';
2
+ export interface LinkInfo {
3
+ url: string;
4
+ external: boolean;
5
+ path: string;
6
+ }
7
+ /**
8
+ * Check if currently running inside Payment Kit
9
+ */
10
+ export declare function isInPaymentKit(): boolean;
11
+ /**
12
+ * Create link information object
13
+ * @param path Path or URL
14
+ * @param external Force external link behavior
15
+ */
16
+ export declare function createLink(path: string, external?: boolean): LinkInfo;
17
+ /**
18
+ * Get HTML attributes for a link
19
+ * @param link Link information
20
+ * @param target Link target (default: _self)
21
+ */
22
+ export declare function getLinkProps(link: LinkInfo, target?: string): Record<string, any>;
23
+ /**
24
+ * Handle link navigation
25
+ * @param e Click event
26
+ * @param link Link information
27
+ * @param navigate React Router navigate function
28
+ * @param options Navigation options
29
+ */
30
+ export declare function handleNavigation(e: React.MouseEvent, link: LinkInfo, navigate?: NavigateFunction, options?: {
31
+ replace?: boolean;
32
+ target?: string;
33
+ }): void;
@@ -0,0 +1,45 @@
1
+ import { joinURL } from "ufo";
2
+ import { getPrefix, PAYMENT_KIT_DID } from "./util.js";
3
+ export function isInPaymentKit() {
4
+ const componentId = (window.blocklet?.componentId || "").split("/").pop();
5
+ return componentId === PAYMENT_KIT_DID;
6
+ }
7
+ export function createLink(path, external = false) {
8
+ const isAbsoluteUrl = /^https?:\/\//.test(path);
9
+ const isExternal = external || isAbsoluteUrl;
10
+ const url = isExternal ? path : joinURL(getPrefix(), path);
11
+ return {
12
+ url,
13
+ external: isExternal,
14
+ path
15
+ };
16
+ }
17
+ export function getLinkProps(link, target = "_self") {
18
+ const props = {
19
+ href: link.url
20
+ };
21
+ if (link.external) {
22
+ props.target = target;
23
+ props.rel = target === "_blank" ? "noopener noreferrer" : void 0;
24
+ }
25
+ return props;
26
+ }
27
+ export function handleNavigation(e, link, navigate, options = {}) {
28
+ if (e) {
29
+ e.preventDefault();
30
+ }
31
+ const { replace = false, target = "_self" } = options;
32
+ if (link.external || target === "_blank") {
33
+ window.open(link.url, target);
34
+ return;
35
+ }
36
+ if (isInPaymentKit() && navigate) {
37
+ navigate(link.path, { replace });
38
+ return;
39
+ }
40
+ if (replace) {
41
+ window.location.replace(link.url);
42
+ } else {
43
+ window.location.href = link.url;
44
+ }
45
+ }
package/es/libs/util.d.ts CHANGED
@@ -114,3 +114,7 @@ export declare function getInvoiceDescriptionAndReason(invoice: TInvoiceExpanded
114
114
  export declare function getPaymentKitComponent(): any;
115
115
  export declare function openDonationSettings(openInNewTab?: boolean): void;
116
116
  export declare function getUserProfileLink(userDid: string, locale?: string): string;
117
+ export declare function parseMarkedText(text: string): Array<{
118
+ type: 'text' | 'marked';
119
+ content: string;
120
+ }>;
package/es/libs/util.js CHANGED
@@ -933,3 +933,23 @@ export function getUserProfileLink(userDid, locale = "en") {
933
933
  })
934
934
  );
935
935
  }
936
+ export function parseMarkedText(text) {
937
+ if (!text)
938
+ return [];
939
+ const parts = text.split(/(#([^#]*)#)/);
940
+ const result = [];
941
+ for (let i = 0; i < parts.length; i++) {
942
+ const part = parts[i];
943
+ if (!part)
944
+ continue;
945
+ if (i % 3 === 0) {
946
+ result.push({ type: "text", content: part });
947
+ } else if (i % 3 === 1 && part.startsWith("#") && part.endsWith("#")) {
948
+ const content = part.slice(1, -1);
949
+ if (content.length >= 0) {
950
+ result.push({ type: "marked", content });
951
+ }
952
+ }
953
+ }
954
+ return result.filter((p) => p.content !== "");
955
+ }
package/es/locales/en.js CHANGED
@@ -245,8 +245,8 @@ export default flat({
245
245
  }
246
246
  },
247
247
  recover: {
248
- button: "Renew",
249
- title: "Renew your subscription",
248
+ button: "Resume Subscription",
249
+ title: "Resume Your Subscription",
250
250
  description: "Your subscription will not be canceled and will be automatically renewed on {date}, please confirm to continue"
251
251
  },
252
252
  changePlan: {
package/es/locales/zh.js CHANGED
@@ -245,8 +245,8 @@ export default flat({
245
245
  }
246
246
  },
247
247
  recover: {
248
- button: "\u7EED\u8BA2",
249
- title: "\u7EED\u8BA2\u60A8\u7684\u8BA2\u9605",
248
+ button: "\u6062\u590D\u8BA2\u9605",
249
+ title: "\u6062\u590D\u60A8\u7684\u8BA2\u9605",
250
250
  description: "\u60A8\u7684\u8BA2\u9605\u5C06\u4E0D\u4F1A\u88AB\u53D6\u6D88\uFF0C\u5E76\u5C06\u5728{date}\u81EA\u52A8\u7EED\u8BA2\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u7EE7\u7EED"
251
251
  },
252
252
  changePlan: {
@@ -137,6 +137,11 @@ export default function PaymentForm({
137
137
  setValue("customer_phone", session.user.phone);
138
138
  }
139
139
  }
140
+ if (!session?.user) {
141
+ setValue("customer_name", "");
142
+ setValue("customer_email", "");
143
+ setValue("customer_phone", "");
144
+ }
140
145
  }, [session?.user, getValues, setValue]);
141
146
  useEffect(() => {
142
147
  setValue("payment_method", currencies[paymentCurrencyIndex]?.method?.id);
@@ -8,7 +8,7 @@ import { useSetState } from "ahooks";
8
8
  import { useEffect, useCallback } from "react";
9
9
  import { useMobile } from "../../../hooks/mobile.js";
10
10
  import LoadingButton from "../../../components/loading-button.js";
11
- const { Elements, PaymentElement, useElements, useStripe, loadStripe } = globalThis.__STRIPE_COMPONENTS__;
11
+ const { Elements, PaymentElement, useElements, useStripe, loadStripe, LinkAuthenticationElement } = globalThis.__STRIPE_COMPONENTS__;
12
12
  function StripeCheckoutForm({
13
13
  clientSecret,
14
14
  intentType,
@@ -90,10 +90,30 @@ function StripeCheckoutForm({
90
90
  // eslint-disable-line
91
91
  );
92
92
  return /* @__PURE__ */ jsxs(Content, { onSubmit: handleSubmit, children: [
93
+ /* @__PURE__ */ jsx(
94
+ LinkAuthenticationElement,
95
+ {
96
+ options: {
97
+ defaultEmail: customer.email
98
+ }
99
+ }
100
+ ),
93
101
  /* @__PURE__ */ jsx(
94
102
  PaymentElement,
95
103
  {
96
- options: { layout: "auto", fields: { billingDetails: "never" }, readOnly: state.confirming },
104
+ options: {
105
+ layout: "auto",
106
+ fields: { billingDetails: "never" },
107
+ readOnly: state.confirming,
108
+ defaultValues: {
109
+ billingDetails: {
110
+ name: customer.name,
111
+ phone: customer.phone,
112
+ email: customer.email,
113
+ address: customer.address
114
+ }
115
+ }
116
+ },
97
117
  onReady: () => setState({ loaded: true })
98
118
  }
99
119
  ),
@@ -170,17 +190,27 @@ export default function StripeCheckout({
170
190
  minWidth: isMobile ? "100%" : "500px"
171
191
  }
172
192
  },
173
- children: /* @__PURE__ */ jsx(Elements, { options: { clientSecret, locale: locale === "zh" ? "zh-CN" : "en" }, stripe: stripePromise, children: /* @__PURE__ */ jsx(
174
- StripeCheckoutForm,
193
+ children: /* @__PURE__ */ jsx(
194
+ Elements,
175
195
  {
176
- clientSecret,
177
- intentType,
178
- mode,
179
- customer,
180
- onConfirm,
181
- returnUrl
196
+ options: {
197
+ clientSecret,
198
+ locale: locale === "zh" ? "zh-CN" : "en"
199
+ },
200
+ stripe: stripePromise,
201
+ children: /* @__PURE__ */ jsx(
202
+ StripeCheckoutForm,
203
+ {
204
+ clientSecret,
205
+ intentType,
206
+ mode,
207
+ customer,
208
+ onConfirm,
209
+ returnUrl
210
+ }
211
+ )
182
212
  }
183
- ) })
213
+ )
184
214
  }
185
215
  );
186
216
  }
@@ -4,6 +4,7 @@ declare global {
4
4
  __STRIPE_COMPONENTS__?: {
5
5
  Elements: any;
6
6
  PaymentElement: any;
7
+ LinkAuthenticationElement: any;
7
8
  useElements: () => any;
8
9
  useStripe: () => any;
9
10
  loadStripe: (key: string) => Promise<any>;
@@ -6,7 +6,8 @@ export default createLazyComponent(async () => {
6
6
  PaymentElement: stripeReact.PaymentElement,
7
7
  useElements: stripeReact.useElements,
8
8
  useStripe: stripeReact.useStripe,
9
- loadStripe: stripe.loadStripe
9
+ loadStripe: stripe.loadStripe,
10
+ LinkAuthenticationElement: stripeReact.LinkAuthenticationElement
10
11
  };
11
12
  const { default: Component } = await import("./form.js");
12
13
  return Component;
package/es/theme/index.js CHANGED
@@ -139,6 +139,11 @@ export function PaymentThemeProvider({
139
139
  fontWeight: "500",
140
140
  lineHeight: "24px"
141
141
  },
142
+ ".base-dialog": {
143
+ ".MuiPaper-root>.MuiDialogContent-root": {
144
+ paddingTop: "0"
145
+ }
146
+ },
142
147
  a: {
143
148
  textDecoration: "none !important"
144
149
  }
@@ -27,6 +27,7 @@ function Link({
27
27
  e.preventDefault();
28
28
  window.location.href = to;
29
29
  }
30
+ e.preventDefault();
30
31
  onClick?.(e);
31
32
  };
32
33
  return /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
@@ -9,6 +9,7 @@ type Props = {
9
9
  mode?: 'default' | 'custom';
10
10
  onPaid?: (subscriptionId: string, currencyId: string) => void;
11
11
  dialogProps?: DialogProps;
12
+ inSubscriptionDetail?: boolean;
12
13
  children?: (handlePay: (item: SummaryItem) => void, data: {
13
14
  subscription: Subscription;
14
15
  summary: {
@@ -23,7 +24,7 @@ type SummaryItem = {
23
24
  currency: PaymentCurrency;
24
25
  method: PaymentMethod;
25
26
  };
26
- declare function OverdueInvoicePayment({ subscriptionId, mode, dialogProps, children, onPaid, }: Props): import("react").JSX.Element;
27
+ declare function OverdueInvoicePayment({ subscriptionId, mode, dialogProps, children, onPaid, inSubscriptionDetail, }: Props): import("react").JSX.Element | null;
27
28
  declare namespace OverdueInvoicePayment {
28
29
  var defaultProps: {
29
30
  mode: string;
@@ -32,6 +33,7 @@ declare namespace OverdueInvoicePayment {
32
33
  open: boolean;
33
34
  };
34
35
  children: null;
36
+ inSubscriptionDetail: boolean;
35
37
  };
36
38
  }
37
39
  export default OverdueInvoicePayment;
@@ -26,7 +26,8 @@ function OverdueInvoicePayment({
26
26
  mode = "default",
27
27
  dialogProps = {},
28
28
  children,
29
- onPaid = () => {}
29
+ onPaid = () => {},
30
+ inSubscriptionDetail = false
30
31
  }) {
31
32
  const {
32
33
  t
@@ -121,8 +122,14 @@ function OverdueInvoicePayment({
121
122
  setDialogOpen(false);
122
123
  dialogProps.onClose?.();
123
124
  };
125
+ const handleViewDetailClick = e => {
126
+ if (inSubscriptionDetail) {
127
+ e.preventDefault();
128
+ handleClose();
129
+ }
130
+ };
124
131
  if (loading) {
125
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {});
132
+ return null;
126
133
  }
127
134
  const renderPayButton = (item, props) => {
128
135
  const isPayLoading = payLoading && item.currency.id === selectCurrencyId;
@@ -169,6 +176,11 @@ function OverdueInvoicePayment({
169
176
  ...(dialogProps || {}),
170
177
  open: dialogOpen,
171
178
  title: dialogProps?.title || t("payment.subscription.overdue.pastDue"),
179
+ sx: {
180
+ "& .MuiDialogContent-root": {
181
+ pt: 0
182
+ }
183
+ },
172
184
  onClose: handleClose,
173
185
  children: error ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Alert, {
174
186
  severity: "error",
@@ -209,6 +221,7 @@ function OverdueInvoicePayment({
209
221
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)("br", {}), t("payment.subscription.overdue.description"), /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
210
222
  href: subscriptionUrl,
211
223
  target: "_blank",
224
+ onClick: handleViewDetailClick,
212
225
  rel: "noreferrer",
213
226
  style: {
214
227
  color: "var(--foregrounds-fg-interactive, 0086FF)"
@@ -239,6 +252,7 @@ function OverdueInvoicePayment({
239
252
  href: subscriptionUrl,
240
253
  target: "_blank",
241
254
  rel: "noreferrer",
255
+ onClick: handleViewDetailClick,
242
256
  style: {
243
257
  color: "var(--foregrounds-fg-interactive, 0086FF)"
244
258
  },
@@ -285,6 +299,7 @@ OverdueInvoicePayment.defaultProps = {
285
299
  dialogProps: {
286
300
  open: true
287
301
  },
288
- children: null
302
+ children: null,
303
+ inSubscriptionDetail: false
289
304
  };
290
305
  module.exports = OverdueInvoicePayment;