@blocklet/payment-react 1.13.130 → 1.13.132

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.
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
3
+ declare function TxLink(props: {
4
+ details: PaymentDetails;
5
+ method: TPaymentMethod;
6
+ mode?: 'customer' | 'dashboard';
7
+ }): import("react").JSX.Element;
8
+ declare namespace TxLink {
9
+ var defaultProps: {
10
+ mode: string;
11
+ };
12
+ }
13
+ export default TxLink;
@@ -0,0 +1,52 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { OpenInNewOutlined } from "@mui/icons-material";
3
+ import { Link, Stack, Typography } from "@mui/material";
4
+ import { joinURL } from "ufo";
5
+ const getTxLink = (method, details) => {
6
+ if (method.type === "arcblock" && details.arcblock?.tx_hash) {
7
+ return {
8
+ link: joinURL(method.settings.arcblock?.explorer_host, "/txs", details.arcblock?.tx_hash),
9
+ text: details.arcblock?.tx_hash
10
+ };
11
+ }
12
+ if (method.type === "bitcoin" && details.bitcoin?.tx_hash) {
13
+ return {
14
+ link: joinURL(method.settings.bitcoin?.explorer_host, "/tx", details.bitcoin?.tx_hash),
15
+ text: details.bitcoin?.tx_hash
16
+ };
17
+ }
18
+ if (method.type === "ethereum" && details.ethereum?.tx_hash) {
19
+ return {
20
+ link: joinURL(method.settings.ethereum?.explorer_host, "/tx", details.ethereum?.tx_hash),
21
+ text: details.ethereum?.tx_hash
22
+ };
23
+ }
24
+ if (method.type === "stripe") {
25
+ const dashboard = method.livemode ? "https://dashboard.stripe.com" : "https://dashboard.stripe.com/test";
26
+ return {
27
+ link: joinURL(
28
+ method.settings.stripe?.dashboard || dashboard,
29
+ "payments",
30
+ details.stripe?.payment_intent_id
31
+ ),
32
+ text: details.stripe?.payment_intent_id
33
+ };
34
+ }
35
+ return { text: "N/A", link: "" };
36
+ };
37
+ TxLink.defaultProps = {
38
+ mode: "dashboard"
39
+ };
40
+ export default function TxLink(props) {
41
+ if (!props.details || props.mode === "customer" && props.method.type === "stripe") {
42
+ return /* @__PURE__ */ jsx(Typography, { component: "small", color: "text.secondary", children: "None" });
43
+ }
44
+ const { text, link } = getTxLink(props.method, props.details);
45
+ if (link) {
46
+ return /* @__PURE__ */ jsx(Link, { href: link, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ jsxs(Stack, { component: "span", direction: "row", alignItems: "center", spacing: 1, children: [
47
+ /* @__PURE__ */ jsx(Typography, { component: "span", color: "primary", children: text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join("...") : text }),
48
+ /* @__PURE__ */ jsx(OpenInNewOutlined, { fontSize: "small" })
49
+ ] }) });
50
+ }
51
+ return /* @__PURE__ */ jsx(Typography, { component: "small", color: "text.secondary", children: "None" });
52
+ }
@@ -3,9 +3,10 @@ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
3
3
  import { Box, Button, CircularProgress, Stack, Typography } from "@mui/material";
4
4
  import { fromUnitToToken } from "@ocap/util";
5
5
  import { useInfiniteScroll } from "ahooks";
6
+ import { joinURL } from "ufo";
6
7
  import api from "../../api.js";
7
8
  import Status from "../../components/status.js";
8
- import { formatToDate, getInvoiceStatusColor } from "../../util.js";
9
+ import { formatToDate, getInvoiceStatusColor, getPrefix } from "../../util.js";
9
10
  const groupByDate = (items) => {
10
11
  const grouped = {};
11
12
  items.forEach((item) => {
@@ -64,7 +65,7 @@ export default function CustomerInvoiceList({ customer_id, subscription_id }) {
64
65
  },
65
66
  flexWrap: "nowrap",
66
67
  children: [
67
- /* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx("a", { href: `/customer/invoice/${invoice.id}`, children: /* @__PURE__ */ jsx(Typography, { component: "span", children: invoice.number }) }) }),
68
+ /* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx("a", { href: joinURL(window.location.origin, getPrefix(), `/customer/invoice/${invoice.id}`), children: /* @__PURE__ */ jsx(Typography, { component: "span", children: invoice.number }) }) }),
68
69
  /* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx(Typography, { children: formatToDate(invoice.created_at) }) }),
69
70
  /* @__PURE__ */ jsx(Box, { flex: 2, children: /* @__PURE__ */ jsxs(Typography, { textAlign: "right", children: [
70
71
  fromUnitToToken(invoice.total, invoice.paymentCurrency.decimal),
@@ -3,6 +3,7 @@ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
3
3
  import { Box, Button, CircularProgress, Divider, List, ListItem, ListSubheader, Typography } from "@mui/material";
4
4
  import { fromUnitToToken } from "@ocap/util";
5
5
  import { useRequest } from "ahooks";
6
+ import { joinURL } from "ufo";
6
7
  import api from "../../api.js";
7
8
  import Status from "../../components/status.js";
8
9
  import {
@@ -10,6 +11,7 @@ import {
10
11
  formatTime,
11
12
  formatToDate,
12
13
  getInvoiceStatusColor,
14
+ getPrefix,
13
15
  getSubscriptionStatusColor
14
16
  } from "../../util.js";
15
17
  const fetchInvoiceData = (params = {}) => {
@@ -29,12 +31,10 @@ export default function MiniInvoiceList() {
29
31
  const { data } = useRequest(
30
32
  () => fetchInvoiceData({ page: 1, pageSize: 10, status: "open,paid,uncollectible", subscription_id: subscriptionId })
31
33
  );
32
- if (!data || !subscription) {
34
+ if (!subscription || !data) {
33
35
  return /* @__PURE__ */ jsx(Position, { children: /* @__PURE__ */ jsx(CircularProgress, {}) });
34
36
  }
35
- if (data && data.list.length === 0) {
36
- return /* @__PURE__ */ jsx(Position, { children: /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: t("payment.customer.invoice.empty") }) });
37
- }
37
+ const invoices = data.list || [];
38
38
  const infoList = [
39
39
  {
40
40
  name: t("payment.customer.subscriptions.plan"),
@@ -43,8 +43,10 @@ export default function MiniInvoiceList() {
43
43
  {
44
44
  name: t("common.status"),
45
45
  value: /* @__PURE__ */ jsx(Status, { label: subscription.status, color: getSubscriptionStatusColor(subscription.status) })
46
- },
47
- {
46
+ }
47
+ ];
48
+ if (subscription.status === "active" || subscription.status === "trailing") {
49
+ infoList.push({
48
50
  name: t("payment.customer.subscriptions.nextInvoice"),
49
51
  value: /* @__PURE__ */ jsx(
50
52
  Typography,
@@ -57,13 +59,14 @@ export default function MiniInvoiceList() {
57
59
  children: formatTime(subscription.current_period_end * 1e3)
58
60
  }
59
61
  )
60
- }
61
- ];
62
+ });
63
+ }
62
64
  return /* @__PURE__ */ jsxs(Position, { children: [
63
65
  /* @__PURE__ */ jsx(Typography, { title: t("payment.checkout.subscription") }),
64
66
  /* @__PURE__ */ jsxs(
65
67
  Box,
66
68
  {
69
+ className: "mini-invoice-wrap",
67
70
  sx: {
68
71
  display: "flex",
69
72
  flexDirection: "column",
@@ -82,28 +85,30 @@ export default function MiniInvoiceList() {
82
85
  ] }, name);
83
86
  }) }) }),
84
87
  /* @__PURE__ */ jsx(Divider, {}),
85
- /* @__PURE__ */ jsx(Box, { sx: { marginTop: "12px" }, children: /* @__PURE__ */ jsxs(
86
- List,
88
+ /* @__PURE__ */ jsx(Box, { sx: { marginTop: "12px", flex: 1 }, children: /* @__PURE__ */ jsxs(List, { sx: { overflow: "auto" }, className: "mini-invoice-list", children: [
89
+ /* @__PURE__ */ jsx(ListSubheader, { disableGutters: true, sx: { padding: 0 }, children: /* @__PURE__ */ jsx(Typography, { component: "h2", variant: "h6", fontSize: "16px", children: t("payment.customer.invoices") }) }),
90
+ invoices.length === 0 ? /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: t("payment.customer.invoice.empty") }) : invoices.map((item) => {
91
+ return /* @__PURE__ */ jsxs(ListItem, { disableGutters: true, sx: { display: "flex", justifyContent: "space-between" }, children: [
92
+ /* @__PURE__ */ jsx(Typography, { component: "span", sx: { flex: 3 }, children: formatToDate(item.created_at) }),
93
+ /* @__PURE__ */ jsxs(Typography, { component: "span", sx: { flex: 1, textAlign: "right" }, children: [
94
+ fromUnitToToken(item.total, item.paymentCurrency.decimal),
95
+ "\xA0",
96
+ item.paymentCurrency.symbol
97
+ ] }),
98
+ /* @__PURE__ */ jsx(Typography, { component: "span", sx: { flex: 2, textAlign: "right" }, children: /* @__PURE__ */ jsx(Status, { label: item.status, color: getInvoiceStatusColor(item.status), sx: { flex: 2 } }) })
99
+ ] }, item.id);
100
+ })
101
+ ] }) }),
102
+ /* @__PURE__ */ jsx(
103
+ Button,
87
104
  {
88
- sx: { overflow: "auto", maxHeight: { xs: "240px", md: "360px", padding: 0 } },
89
- className: "mini-invoice-list",
90
- children: [
91
- /* @__PURE__ */ jsx(ListSubheader, { disableGutters: true, sx: { padding: 0 }, children: /* @__PURE__ */ jsx(Typography, { component: "h2", variant: "h6", fontSize: "16px", children: t("payment.customer.invoices") }) }),
92
- (data.list || []).map((item) => {
93
- return /* @__PURE__ */ jsxs(ListItem, { disableGutters: true, sx: { display: "flex", justifyContent: "space-between" }, children: [
94
- /* @__PURE__ */ jsx(Typography, { component: "span", sx: { flex: 3 }, children: formatToDate(item.created_at) }),
95
- /* @__PURE__ */ jsxs(Typography, { component: "span", sx: { flex: 1 }, children: [
96
- fromUnitToToken(item.total, item.paymentCurrency.decimal),
97
- "\xA0",
98
- item.paymentCurrency.symbol
99
- ] }),
100
- /* @__PURE__ */ jsx(Typography, { component: "span", sx: { flex: 2, textAlign: "right" }, children: /* @__PURE__ */ jsx(Status, { label: item.status, color: getInvoiceStatusColor(item.status), sx: { flex: 2 } }) })
101
- ] }, item.id);
102
- })
103
- ]
105
+ target: "_blank",
106
+ variant: "contained",
107
+ sx: { marginTop: "10px 0", width: "100%", color: "#fff!important" },
108
+ href: joinURL(window.location.origin, getPrefix(), `/customer/subscription/${subscription.id}`),
109
+ children: t("payment.customer.subscriptions.title")
104
110
  }
105
- ) }),
106
- /* @__PURE__ */ jsx(Button, { target: "_top", variant: "contained", sx: { marginTop: "10px 0", width: "100%" }, href: "", children: t("payment.customer.subscriptions.title") })
111
+ )
107
112
  ]
108
113
  }
109
114
  )
@@ -115,7 +120,6 @@ function Position({ children }) {
115
120
  {
116
121
  className: "mini-invoice-box",
117
122
  sx: {
118
- justifyContent: "center",
119
123
  padding: "8px",
120
124
  width: "100%",
121
125
  maxWidth: "500px",
@@ -4,6 +4,7 @@ import { Box, Button, CircularProgress, Stack, Typography } from "@mui/material"
4
4
  import { fromUnitToToken } from "@ocap/util";
5
5
  import { useInfiniteScroll } from "ahooks";
6
6
  import api from "../../api.js";
7
+ import TxLink from "../../components/blockchain/tx.js";
7
8
  import Status from "../../components/status.js";
8
9
  import { formatToDate, getPaymentIntentStatusColor } from "../../util.js";
9
10
  const groupByDate = (items) => {
@@ -69,7 +70,15 @@ export default function CustomerPaymentList({ customer_id }) {
69
70
  item.paymentCurrency.symbol
70
71
  ] }) }),
71
72
  /* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx(Status, { label: item.status, color: getPaymentIntentStatusColor(item.status) }) }),
72
- /* @__PURE__ */ jsx(Box, { flex: 4, children: /* @__PURE__ */ jsx(Typography, { children: item.description || item.id }) })
73
+ /* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx(Typography, { children: item.description || "-" }) }),
74
+ /* @__PURE__ */ jsx(Box, { flex: 3, sx: { minWidth: "220px" }, children: item.payment_details?.arcblock?.tx_hash && /* @__PURE__ */ jsx(
75
+ TxLink,
76
+ {
77
+ details: item.payment_details,
78
+ method: item.paymentMethod,
79
+ mode: "customer"
80
+ }
81
+ ) })
73
82
  ]
74
83
  },
75
84
  item.id
package/es/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import api from './api';
2
2
  import CheckoutForm from './checkout/form';
3
3
  import CheckoutTable from './checkout/table';
4
+ import TxLink from './components/blockchain/tx';
4
5
  import ConfirmDialog from './components/confirm';
5
6
  import FormInput from './components/input';
6
7
  import Livemode from './components/livemode';
@@ -18,4 +19,4 @@ import ProductSkeleton from './payment/product-skeleton';
18
19
  export * from './util';
19
20
  export * from './contexts/payment';
20
21
  export { translations, createTranslator } from './locales';
21
- export { api, dayjs, FormInput, PhoneInput, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, Payment, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, };
22
+ export { api, dayjs, FormInput, PhoneInput, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, Payment, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, };
package/es/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import api from "./api.js";
2
2
  import CheckoutForm from "./checkout/form.js";
3
3
  import CheckoutTable from "./checkout/table.js";
4
+ import TxLink from "./components/blockchain/tx.js";
4
5
  import ConfirmDialog from "./components/confirm.js";
5
6
  import FormInput from "./components/input.js";
6
7
  import Livemode from "./components/livemode.js";
@@ -35,5 +36,6 @@ export {
35
36
  Amount,
36
37
  CustomerInvoiceList,
37
38
  CustomerPaymentList,
38
- MiniInvoiceList
39
+ MiniInvoiceList,
40
+ TxLink
39
41
  };
package/es/locales/en.js CHANGED
@@ -202,17 +202,17 @@ export default flat({
202
202
  pay: "Pay this invoice",
203
203
  paySuccess: "You have successfully paid the invoice",
204
204
  payError: "Failed to paid the invoice",
205
- empty: "Seems you do not have any invoice here"
205
+ empty: "There are no invoices here"
206
206
  },
207
207
  payment: {
208
- empty: "Seems you do not have any payment here"
208
+ empty: "There are no payments here"
209
209
  },
210
210
  subscriptions: {
211
211
  plan: "Plan",
212
212
  nextInvoice: "Next Invoice",
213
213
  title: "Manage subscriptions",
214
214
  current: "Current subscription",
215
- empty: "Seems you do not have any subscriptions here"
215
+ empty: "There are no subscriptions here"
216
216
  }
217
217
  }
218
218
  }
package/es/locales/zh.js CHANGED
@@ -202,17 +202,17 @@ export default flat({
202
202
  pay: "\u652F\u4ED8\u6B64\u53D1\u7968",
203
203
  paySuccess: "\u652F\u4ED8\u6210\u529F",
204
204
  payError: "\u652F\u4ED8\u5931\u8D25",
205
- empty: "\u4F60\u6CA1\u6709\u4EFB\u4F55\u53D1\u7968"
205
+ empty: "\u6CA1\u6709\u4EFB\u4F55\u53D1\u7968"
206
206
  },
207
207
  payment: {
208
- empty: "\u4F60\u6CA1\u6709\u4EFB\u4F55\u652F\u4ED8"
208
+ empty: "\u6CA1\u6709\u4EFB\u4F55\u652F\u4ED8"
209
209
  },
210
210
  subscriptions: {
211
211
  plan: "\u8BA2\u9605",
212
212
  nextInvoice: "\u4E0B\u4E00\u5F20\u53D1\u7968",
213
213
  title: "\u8BA2\u9605\u7BA1\u7406",
214
214
  current: "\u5F53\u524D\u8BA2\u9605",
215
- empty: "\u4F60\u8FD8\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605"
215
+ empty: "\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605"
216
216
  }
217
217
  }
218
218
  }
@@ -250,7 +250,7 @@ export const Root = styled(Box)`
250
250
 
251
251
  .cko-container {
252
252
  width: 100%;
253
- max-width: 1000px;
253
+ max-width: ${(props) => props.mode.endsWith("-minimal") ? "400px" : "1000px"};
254
254
  display: flex;
255
255
  flex-direction: row;
256
256
  justify-content: space-between;
@@ -259,9 +259,10 @@ export const Root = styled(Box)`
259
259
  }
260
260
 
261
261
  .cko-overview {
262
- width: 400px;
262
+ width: ${(props) => props.mode.endsWith("-minimal") ? "100%" : "400px"};
263
263
  min-height: ${(props) => props.mode === "standalone" ? "540px" : "auto"};
264
264
  position: relative;
265
+ display: ${(props) => props.mode.endsWith("-minimal") ? "none" : "block"};
265
266
  }
266
267
  .cko-header {
267
268
  left: 0;
@@ -278,7 +279,7 @@ export const Root = styled(Box)`
278
279
  }
279
280
 
280
281
  .cko-payment {
281
- width: 400px;
282
+ width: ${(props) => props.mode.endsWith("-minimal") ? "100%" : "400px"};
282
283
  .MuiInputBase-root {
283
284
  border-radius: 0;
284
285
  }
@@ -367,6 +368,7 @@ export const Root = styled(Box)`
367
368
  bottom: 0;
368
369
  left: 12px;
369
370
  margin: 12px 0;
371
+ display: ${(props) => props.mode.endsWith("-minimal") ? "none" : "block"};
370
372
  }
371
373
 
372
374
  @media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
@@ -11,7 +11,7 @@ export type CheckoutContext = {
11
11
  export type CheckoutProps = Partial<CheckoutCallbacks> & {
12
12
  id: string;
13
13
  extraParams?: Record<string, any>;
14
- mode?: LiteralUnion<'standalone' | 'inline' | 'popup', string>;
14
+ mode?: LiteralUnion<'standalone' | 'inline' | 'popup' | 'inline-minimal' | 'popup-minimal', string>;
15
15
  };
16
16
  export type CheckoutCallbacks = {
17
17
  onPaid: (res: CheckoutContext) => void;
package/es/util.d.ts CHANGED
@@ -22,6 +22,7 @@ export declare function formatLineItemPricing(item: TLineItemExpanded, currency:
22
22
  };
23
23
  export declare function getSubscriptionStatusColor(status: string): "success" | "primary" | "warning" | "error" | "default";
24
24
  export declare function getPaymentIntentStatusColor(status: string): "success" | "warning" | "default";
25
+ export declare function getRefundStatusColor(status: string): "success" | "warning" | "default";
25
26
  export declare function getInvoiceStatusColor(status: string): "success" | "warning" | "default" | "secondary";
26
27
  export declare function getWebhookStatusColor(status: string): "success" | "default";
27
28
  export declare function getCheckoutAmount(items: TLineItemExpanded[], currency: TPaymentCurrency, includeFreeTrial?: boolean, upsell?: boolean): {
package/es/util.js CHANGED
@@ -201,6 +201,18 @@ export function getPaymentIntentStatusColor(status) {
201
201
  return "default";
202
202
  }
203
203
  }
204
+ export function getRefundStatusColor(status) {
205
+ switch (status) {
206
+ case "succeeded":
207
+ return "success";
208
+ case "requires_action":
209
+ return "warning";
210
+ case "canceled":
211
+ case "pending":
212
+ default:
213
+ return "default";
214
+ }
215
+ }
204
216
  export function getInvoiceStatusColor(status) {
205
217
  switch (status) {
206
218
  case "paid":
@@ -226,9 +238,12 @@ export function getWebhookStatusColor(status) {
226
238
  }
227
239
  export function getCheckoutAmount(items, currency, includeFreeTrial = false, upsell = true) {
228
240
  let renew = new BN(0);
229
- const total = items.reduce((acc, x) => {
241
+ const total = items.filter((x) => {
242
+ const price = upsell ? x.upsell_price || x.price : x.price;
243
+ return price != null;
244
+ }).reduce((acc, x) => {
230
245
  const price = upsell ? x.upsell_price || x.price : x.price;
231
- if (price.type === "recurring") {
246
+ if (price?.type === "recurring") {
232
247
  renew = renew.add(new BN(getPriceUintAmountByCurrency(price, currency)).mul(new BN(x.quantity)));
233
248
  if (includeFreeTrial) {
234
249
  return acc;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
3
+ declare function TxLink(props: {
4
+ details: PaymentDetails;
5
+ method: TPaymentMethod;
6
+ mode?: 'customer' | 'dashboard';
7
+ }): import("react").JSX.Element;
8
+ declare namespace TxLink {
9
+ var defaultProps: {
10
+ mode: string;
11
+ };
12
+ }
13
+ export default TxLink;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = TxLink;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ var _iconsMaterial = require("@mui/icons-material");
9
+ var _material = require("@mui/material");
10
+ var _ufo = require("ufo");
11
+ const getTxLink = (method, details) => {
12
+ if (method.type === "arcblock" && details.arcblock?.tx_hash) {
13
+ return {
14
+ link: (0, _ufo.joinURL)(method.settings.arcblock?.explorer_host, "/txs", details.arcblock?.tx_hash),
15
+ text: details.arcblock?.tx_hash
16
+ };
17
+ }
18
+ if (method.type === "bitcoin" && details.bitcoin?.tx_hash) {
19
+ return {
20
+ link: (0, _ufo.joinURL)(method.settings.bitcoin?.explorer_host, "/tx", details.bitcoin?.tx_hash),
21
+ text: details.bitcoin?.tx_hash
22
+ };
23
+ }
24
+ if (method.type === "ethereum" && details.ethereum?.tx_hash) {
25
+ return {
26
+ link: (0, _ufo.joinURL)(method.settings.ethereum?.explorer_host, "/tx", details.ethereum?.tx_hash),
27
+ text: details.ethereum?.tx_hash
28
+ };
29
+ }
30
+ if (method.type === "stripe") {
31
+ const dashboard = method.livemode ? "https://dashboard.stripe.com" : "https://dashboard.stripe.com/test";
32
+ return {
33
+ link: (0, _ufo.joinURL)(method.settings.stripe?.dashboard || dashboard, "payments", details.stripe?.payment_intent_id),
34
+ text: details.stripe?.payment_intent_id
35
+ };
36
+ }
37
+ return {
38
+ text: "N/A",
39
+ link: ""
40
+ };
41
+ };
42
+ TxLink.defaultProps = {
43
+ mode: "dashboard"
44
+ };
45
+ function TxLink(props) {
46
+ if (!props.details || props.mode === "customer" && props.method.type === "stripe") {
47
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
48
+ component: "small",
49
+ color: "text.secondary",
50
+ children: "None"
51
+ });
52
+ }
53
+ const {
54
+ text,
55
+ link
56
+ } = getTxLink(props.method, props.details);
57
+ if (link) {
58
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Link, {
59
+ href: link,
60
+ target: "_blank",
61
+ rel: "noopener noreferrer",
62
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
63
+ component: "span",
64
+ direction: "row",
65
+ alignItems: "center",
66
+ spacing: 1,
67
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
68
+ component: "span",
69
+ color: "primary",
70
+ children: text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join("...") : text
71
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.OpenInNewOutlined, {
72
+ fontSize: "small"
73
+ })]
74
+ })
75
+ });
76
+ }
77
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
78
+ component: "small",
79
+ color: "text.secondary",
80
+ children: "None"
81
+ });
82
+ }
@@ -9,6 +9,7 @@ var _context = require("@arcblock/ux/lib/Locale/context");
9
9
  var _material = require("@mui/material");
10
10
  var _util = require("@ocap/util");
11
11
  var _ahooks = require("ahooks");
12
+ var _ufo = require("ufo");
12
13
  var _api = _interopRequireDefault(require("../../api"));
13
14
  var _status = _interopRequireDefault(require("../../components/status"));
14
15
  var _util2 = require("../../util");
@@ -101,7 +102,7 @@ function CustomerInvoiceList({
101
102
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
102
103
  flex: 3,
103
104
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
104
- href: `/customer/invoice/${invoice.id}`,
105
+ href: (0, _ufo.joinURL)(window.location.origin, (0, _util2.getPrefix)(), `/customer/invoice/${invoice.id}`),
105
106
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
106
107
  component: "span",
107
108
  children: invoice.number
@@ -9,6 +9,7 @@ var _context = require("@arcblock/ux/lib/Locale/context");
9
9
  var _material = require("@mui/material");
10
10
  var _util = require("@ocap/util");
11
11
  var _ahooks = require("ahooks");
12
+ var _ufo = require("ufo");
12
13
  var _api = _interopRequireDefault(require("../../api"));
13
14
  var _status = _interopRequireDefault(require("../../components/status"));
14
15
  var _util2 = require("../../util");
@@ -39,19 +40,12 @@ function MiniInvoiceList() {
39
40
  status: "open,paid,uncollectible",
40
41
  subscription_id: subscriptionId
41
42
  }));
42
- if (!data || !subscription) {
43
+ if (!subscription || !data) {
43
44
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(Position, {
44
45
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
45
46
  });
46
47
  }
47
- if (data && data.list.length === 0) {
48
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(Position, {
49
- children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
50
- color: "text.secondary",
51
- children: t("payment.customer.invoice.empty")
52
- })
53
- });
54
- }
48
+ const invoices = data.list || [];
55
49
  const infoList = [{
56
50
  name: t("payment.customer.subscriptions.plan"),
57
51
  value: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
@@ -67,21 +61,25 @@ function MiniInvoiceList() {
67
61
  label: subscription.status,
68
62
  color: (0, _util2.getSubscriptionStatusColor)(subscription.status)
69
63
  })
70
- }, {
71
- name: t("payment.customer.subscriptions.nextInvoice"),
72
- value: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
73
- sx: {
74
- color: "#34BE74",
75
- fontWeight: "bold",
76
- marginRight: "10px"
77
- },
78
- children: (0, _util2.formatTime)(subscription.current_period_end * 1e3)
79
- })
80
64
  }];
65
+ if (subscription.status === "active" || subscription.status === "trailing") {
66
+ infoList.push({
67
+ name: t("payment.customer.subscriptions.nextInvoice"),
68
+ value: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
69
+ sx: {
70
+ color: "#34BE74",
71
+ fontWeight: "bold",
72
+ marginRight: "10px"
73
+ },
74
+ children: (0, _util2.formatTime)(subscription.current_period_end * 1e3)
75
+ })
76
+ });
77
+ }
81
78
  return /* @__PURE__ */(0, _jsxRuntime.jsxs)(Position, {
82
79
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
83
80
  title: t("payment.checkout.subscription")
84
81
  }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
82
+ className: "mini-invoice-wrap",
85
83
  sx: {
86
84
  display: "flex",
87
85
  flexDirection: "column",
@@ -126,16 +124,12 @@ function MiniInvoiceList() {
126
124
  })
127
125
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
128
126
  sx: {
129
- marginTop: "12px"
127
+ marginTop: "12px",
128
+ flex: 1
130
129
  },
131
130
  children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.List, {
132
131
  sx: {
133
- overflow: "auto",
134
- maxHeight: {
135
- xs: "240px",
136
- md: "360px",
137
- padding: 0
138
- }
132
+ overflow: "auto"
139
133
  },
140
134
  className: "mini-invoice-list",
141
135
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.ListSubheader, {
@@ -149,7 +143,10 @@ function MiniInvoiceList() {
149
143
  fontSize: "16px",
150
144
  children: t("payment.customer.invoices")
151
145
  })
152
- }), (data.list || []).map(item => {
146
+ }), invoices.length === 0 ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
147
+ color: "text.secondary",
148
+ children: t("payment.customer.invoice.empty")
149
+ }) : invoices.map(item => {
153
150
  return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.ListItem, {
154
151
  disableGutters: true,
155
152
  sx: {
@@ -165,7 +162,8 @@ function MiniInvoiceList() {
165
162
  }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
166
163
  component: "span",
167
164
  sx: {
168
- flex: 1
165
+ flex: 1,
166
+ textAlign: "right"
169
167
  },
170
168
  children: [(0, _util.fromUnitToToken)(item.total, item.paymentCurrency.decimal), "\xA0", item.paymentCurrency.symbol]
171
169
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
@@ -186,13 +184,14 @@ function MiniInvoiceList() {
186
184
  })]
187
185
  })
188
186
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
189
- target: "_top",
187
+ target: "_blank",
190
188
  variant: "contained",
191
189
  sx: {
192
190
  marginTop: "10px 0",
193
- width: "100%"
191
+ width: "100%",
192
+ color: "#fff!important"
194
193
  },
195
- href: "",
194
+ href: (0, _ufo.joinURL)(window.location.origin, (0, _util2.getPrefix)(), `/customer/subscription/${subscription.id}`),
196
195
  children: t("payment.customer.subscriptions.title")
197
196
  })]
198
197
  })]
@@ -204,7 +203,6 @@ function Position({
204
203
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
205
204
  className: "mini-invoice-box",
206
205
  sx: {
207
- justifyContent: "center",
208
206
  padding: "8px",
209
207
  width: "100%",
210
208
  maxWidth: "500px",