@blocklet/payment-react 1.13.129 → 1.13.131
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/components/blockchain/tx.d.ts +13 -0
- package/es/components/blockchain/tx.js +52 -0
- package/es/history/invoice/list.d.ts +13 -0
- package/es/{histroy → history}/invoice/list.js +12 -5
- package/es/history/mini-invoice/list.d.ts +2 -0
- package/es/{histroy → history}/mini-invoice/list.js +42 -35
- package/es/{histroy → history}/payment/list.js +10 -1
- package/es/index.d.ts +5 -4
- package/es/index.js +6 -4
- package/es/locales/en.js +4 -4
- package/es/locales/zh.js +3 -3
- package/es/util.js +5 -2
- package/lib/components/blockchain/tx.d.ts +13 -0
- package/lib/components/blockchain/tx.js +82 -0
- package/lib/history/invoice/list.d.ts +13 -0
- package/lib/{histroy → history}/invoice/list.js +14 -5
- package/lib/history/mini-invoice/list.d.ts +2 -0
- package/lib/{histroy → history}/mini-invoice/list.js +70 -59
- package/lib/{histroy → history}/payment/list.js +12 -1
- package/lib/index.d.ts +5 -4
- package/lib/index.js +11 -3
- package/lib/locales/en.js +4 -4
- package/lib/locales/zh.js +3 -3
- package/lib/util.js +5 -2
- package/package.json +3 -3
- package/src/components/blockchain/tx.tsx +77 -0
- package/src/{histroy → history}/invoice/list.tsx +15 -6
- package/src/{histroy → history}/mini-invoice/list.tsx +52 -49
- package/src/{histroy → history}/payment/list.tsx +11 -1
- package/src/index.ts +5 -3
- package/src/locales/en.tsx +4 -4
- package/src/locales/zh.tsx +3 -3
- package/src/util.ts +5 -2
- package/es/histroy/invoice/list.d.ts +0 -6
- package/es/histroy/mini-invoice/list.d.ts +0 -7
- package/lib/histroy/invoice/list.d.ts +0 -6
- package/lib/histroy/mini-invoice/list.d.ts +0 -7
- /package/es/{histroy → history}/payment/list.d.ts +0 -0
- /package/lib/{histroy → history}/payment/list.d.ts +0 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = {
|
|
3
|
+
customer_id?: string;
|
|
4
|
+
subscription_id?: string;
|
|
5
|
+
};
|
|
6
|
+
declare function CustomerInvoiceList({ customer_id, subscription_id }: Props): import("react").JSX.Element;
|
|
7
|
+
declare namespace CustomerInvoiceList {
|
|
8
|
+
var defaultProps: {
|
|
9
|
+
customer_id: string;
|
|
10
|
+
subscription_id: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export default CustomerInvoiceList;
|
|
@@ -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) => {
|
|
@@ -20,17 +21,19 @@ const groupByDate = (items) => {
|
|
|
20
21
|
const fetchData = (params = {}) => {
|
|
21
22
|
const search = new URLSearchParams();
|
|
22
23
|
Object.keys(params).forEach((key) => {
|
|
23
|
-
|
|
24
|
+
if (params[key]) {
|
|
25
|
+
search.set(key, String(params[key]));
|
|
26
|
+
}
|
|
24
27
|
});
|
|
25
28
|
return api.get(`/api/invoices?${search.toString()}`).then((res) => res.data);
|
|
26
29
|
};
|
|
27
30
|
const pageSize = 10;
|
|
28
|
-
export default function CustomerInvoiceList({ customer_id }) {
|
|
31
|
+
export default function CustomerInvoiceList({ customer_id, subscription_id }) {
|
|
29
32
|
const { t } = useLocaleContext();
|
|
30
33
|
const { data, loadMore, loadingMore, loading } = useInfiniteScroll(
|
|
31
34
|
(d) => {
|
|
32
35
|
const page = d ? Math.ceil(d.list.length / pageSize) + 1 : 1;
|
|
33
|
-
return fetchData({ page, pageSize, status: "open,paid,uncollectible", customer_id });
|
|
36
|
+
return fetchData({ page, pageSize, status: "open,paid,uncollectible", customer_id, subscription_id });
|
|
34
37
|
},
|
|
35
38
|
{
|
|
36
39
|
reloadDeps: [customer_id]
|
|
@@ -62,7 +65,7 @@ export default function CustomerInvoiceList({ customer_id }) {
|
|
|
62
65
|
},
|
|
63
66
|
flexWrap: "nowrap",
|
|
64
67
|
children: [
|
|
65
|
-
/* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx("a", { href: `/customer/invoice/${invoice.id}
|
|
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 }) }) }),
|
|
66
69
|
/* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx(Typography, { children: formatToDate(invoice.created_at) }) }),
|
|
67
70
|
/* @__PURE__ */ jsx(Box, { flex: 2, children: /* @__PURE__ */ jsxs(Typography, { textAlign: "right", children: [
|
|
68
71
|
fromUnitToToken(invoice.total, invoice.paymentCurrency.decimal),
|
|
@@ -82,3 +85,7 @@ export default function CustomerInvoiceList({ customer_id }) {
|
|
|
82
85
|
] })
|
|
83
86
|
] });
|
|
84
87
|
}
|
|
88
|
+
CustomerInvoiceList.defaultProps = {
|
|
89
|
+
customer_id: "",
|
|
90
|
+
subscription_id: ""
|
|
91
|
+
};
|
|
@@ -2,7 +2,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
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
|
-
import {
|
|
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,61 +11,62 @@ import {
|
|
|
10
11
|
formatTime,
|
|
11
12
|
formatToDate,
|
|
12
13
|
getInvoiceStatusColor,
|
|
14
|
+
getPrefix,
|
|
13
15
|
getSubscriptionStatusColor
|
|
14
16
|
} from "../../util.js";
|
|
15
|
-
const
|
|
17
|
+
const fetchInvoiceData = (params = {}) => {
|
|
16
18
|
const search = new URLSearchParams();
|
|
17
19
|
Object.keys(params).forEach((key) => {
|
|
18
20
|
search.set(key, String(params[key]));
|
|
19
21
|
});
|
|
20
22
|
return api.get(`/api/invoices?${search.toString()}`).then((res) => res.data);
|
|
21
23
|
};
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
+
const fetchSubscriptionData = (id) => {
|
|
25
|
+
return api.get(`/api/subscriptions/${id}`).then((res) => res.data);
|
|
26
|
+
};
|
|
27
|
+
export default function MiniInvoiceList() {
|
|
24
28
|
const { t } = useLocaleContext();
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
reloadDeps: [subscription.id]
|
|
32
|
-
}
|
|
29
|
+
const subscriptionId = new URL(window.location.href).searchParams.get("id");
|
|
30
|
+
const { data: subscription } = useRequest(() => fetchSubscriptionData(subscriptionId));
|
|
31
|
+
const { data } = useRequest(
|
|
32
|
+
() => fetchInvoiceData({ page: 1, pageSize: 10, status: "open,paid,uncollectible", subscription_id: subscriptionId })
|
|
33
33
|
);
|
|
34
|
-
if (
|
|
34
|
+
if (!subscription || !data) {
|
|
35
35
|
return /* @__PURE__ */ jsx(Position, { children: /* @__PURE__ */ jsx(CircularProgress, {}) });
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
return /* @__PURE__ */ jsx(Position, { children: /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: t("payment.customer.invoice.empty") }) });
|
|
39
|
-
}
|
|
37
|
+
const invoices = data.list || [];
|
|
40
38
|
const infoList = [
|
|
41
39
|
{
|
|
42
40
|
name: t("payment.customer.subscriptions.plan"),
|
|
43
41
|
value: /* @__PURE__ */ jsx(Typography, { fontWeight: 600, sx: { marginRight: "10px" }, children: formatSubscriptionProduct(subscription.items) })
|
|
44
42
|
},
|
|
45
43
|
{
|
|
46
|
-
name: t("
|
|
44
|
+
name: t("common.status"),
|
|
47
45
|
value: /* @__PURE__ */ jsx(Status, { label: subscription.status, color: getSubscriptionStatusColor(subscription.status) })
|
|
48
|
-
}
|
|
49
|
-
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
if (subscription.status === "active" || subscription.status === "trailing") {
|
|
49
|
+
infoList.push({
|
|
50
50
|
name: t("payment.customer.subscriptions.nextInvoice"),
|
|
51
51
|
value: /* @__PURE__ */ jsx(
|
|
52
52
|
Typography,
|
|
53
53
|
{
|
|
54
54
|
sx: {
|
|
55
55
|
color: "#34BE74",
|
|
56
|
-
fontWeight: "bold"
|
|
56
|
+
fontWeight: "bold",
|
|
57
|
+
marginRight: "10px"
|
|
57
58
|
},
|
|
58
59
|
children: formatTime(subscription.current_period_end * 1e3)
|
|
59
60
|
}
|
|
60
61
|
)
|
|
61
|
-
}
|
|
62
|
-
|
|
62
|
+
});
|
|
63
|
+
}
|
|
63
64
|
return /* @__PURE__ */ jsxs(Position, { children: [
|
|
64
65
|
/* @__PURE__ */ jsx(Typography, { title: t("payment.checkout.subscription") }),
|
|
65
66
|
/* @__PURE__ */ jsxs(
|
|
66
67
|
Box,
|
|
67
68
|
{
|
|
69
|
+
className: "mini-invoice-wrap",
|
|
68
70
|
sx: {
|
|
69
71
|
display: "flex",
|
|
70
72
|
flexDirection: "column",
|
|
@@ -83,21 +85,30 @@ export default function MiniInvoiceList({ subscription }) {
|
|
|
83
85
|
] }, name);
|
|
84
86
|
}) }) }),
|
|
85
87
|
/* @__PURE__ */ jsx(Divider, {}),
|
|
86
|
-
/* @__PURE__ */ jsx(Box, { sx: { marginTop: "12px" }, children: /* @__PURE__ */ jsxs(List, { sx: { overflow: "auto"
|
|
88
|
+
/* @__PURE__ */ jsx(Box, { sx: { marginTop: "12px", flex: 1 }, children: /* @__PURE__ */ jsxs(List, { sx: { overflow: "auto" }, className: "mini-invoice-list", children: [
|
|
87
89
|
/* @__PURE__ */ jsx(ListSubheader, { disableGutters: true, sx: { padding: 0 }, children: /* @__PURE__ */ jsx(Typography, { component: "h2", variant: "h6", fontSize: "16px", children: t("payment.customer.invoices") }) }),
|
|
88
|
-
(
|
|
90
|
+
invoices.length === 0 ? /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: t("payment.customer.invoice.empty") }) : invoices.map((item) => {
|
|
89
91
|
return /* @__PURE__ */ jsxs(ListItem, { disableGutters: true, sx: { display: "flex", justifyContent: "space-between" }, children: [
|
|
90
|
-
/* @__PURE__ */ jsx(Typography, { component: "span", children: formatToDate(item.created_at) }),
|
|
91
|
-
/* @__PURE__ */ jsxs(Typography, { component: "span", 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: [
|
|
92
94
|
fromUnitToToken(item.total, item.paymentCurrency.decimal),
|
|
93
95
|
"\xA0",
|
|
94
96
|
item.paymentCurrency.symbol
|
|
95
97
|
] }),
|
|
96
|
-
/* @__PURE__ */ jsx(Status, { label: item.status, color: getInvoiceStatusColor(item.status) })
|
|
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 } }) })
|
|
97
99
|
] }, item.id);
|
|
98
100
|
})
|
|
99
101
|
] }) }),
|
|
100
|
-
/* @__PURE__ */ jsx(
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
103
|
+
Button,
|
|
104
|
+
{
|
|
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")
|
|
110
|
+
}
|
|
111
|
+
)
|
|
101
112
|
]
|
|
102
113
|
}
|
|
103
114
|
)
|
|
@@ -109,15 +120,11 @@ function Position({ children }) {
|
|
|
109
120
|
{
|
|
110
121
|
className: "mini-invoice-box",
|
|
111
122
|
sx: {
|
|
112
|
-
position: "absolute",
|
|
113
|
-
right: 0,
|
|
114
|
-
top: "30px",
|
|
115
|
-
justifyContent: "center",
|
|
116
123
|
padding: "8px",
|
|
117
|
-
|
|
124
|
+
width: "100%",
|
|
125
|
+
maxWidth: "500px",
|
|
118
126
|
background: "#fff",
|
|
119
|
-
|
|
120
|
-
boxShadow: "0 4px 8px rgba(0, 0, 0, 20%)"
|
|
127
|
+
margin: "0 auto"
|
|
121
128
|
},
|
|
122
129
|
children
|
|
123
130
|
}
|
|
@@ -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:
|
|
73
|
+
/* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx(Typography, { children: item.description || item.id }) }),
|
|
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';
|
|
@@ -8,9 +9,9 @@ import PricingTable from './components/pricing-table';
|
|
|
8
9
|
import Status from './components/status';
|
|
9
10
|
import Switch from './components/switch-button';
|
|
10
11
|
import dayjs from './dayjs';
|
|
11
|
-
import CustomerInvoiceList from './
|
|
12
|
-
import MiniInvoiceList from './
|
|
13
|
-
import CustomerPaymentList from './
|
|
12
|
+
import CustomerInvoiceList from './history/invoice/list';
|
|
13
|
+
import MiniInvoiceList from './history/mini-invoice/list';
|
|
14
|
+
import CustomerPaymentList from './history/payment/list';
|
|
14
15
|
import Amount from './payment/amount';
|
|
15
16
|
import PhoneInput from './payment/form/phone';
|
|
16
17
|
import Payment from './payment/index';
|
|
@@ -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";
|
|
@@ -8,9 +9,9 @@ import PricingTable from "./components/pricing-table.js";
|
|
|
8
9
|
import Status from "./components/status.js";
|
|
9
10
|
import Switch from "./components/switch-button.js";
|
|
10
11
|
import dayjs from "./dayjs.js";
|
|
11
|
-
import CustomerInvoiceList from "./
|
|
12
|
-
import MiniInvoiceList from "./
|
|
13
|
-
import CustomerPaymentList from "./
|
|
12
|
+
import CustomerInvoiceList from "./history/invoice/list.js";
|
|
13
|
+
import MiniInvoiceList from "./history/mini-invoice/list.js";
|
|
14
|
+
import CustomerPaymentList from "./history/payment/list.js";
|
|
14
15
|
import Amount from "./payment/amount.js";
|
|
15
16
|
import PhoneInput from "./payment/form/phone.js";
|
|
16
17
|
import Payment from "./payment/index.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: "
|
|
205
|
+
empty: "There are no invoices here"
|
|
206
206
|
},
|
|
207
207
|
payment: {
|
|
208
|
-
empty: "
|
|
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
|
-
current: "Current
|
|
215
|
-
empty: "
|
|
214
|
+
current: "Current subscription",
|
|
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: "\
|
|
205
|
+
empty: "\u6CA1\u6709\u4EFB\u4F55\u53D1\u7968"
|
|
206
206
|
},
|
|
207
207
|
payment: {
|
|
208
|
-
empty: "\
|
|
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: "\
|
|
215
|
+
empty: "\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605"
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
}
|
package/es/util.js
CHANGED
|
@@ -226,9 +226,12 @@ export function getWebhookStatusColor(status) {
|
|
|
226
226
|
}
|
|
227
227
|
export function getCheckoutAmount(items, currency, includeFreeTrial = false, upsell = true) {
|
|
228
228
|
let renew = new BN(0);
|
|
229
|
-
const total = items.
|
|
229
|
+
const total = items.filter((x) => {
|
|
230
230
|
const price = upsell ? x.upsell_price || x.price : x.price;
|
|
231
|
-
|
|
231
|
+
return price != null;
|
|
232
|
+
}).reduce((acc, x) => {
|
|
233
|
+
const price = upsell ? x.upsell_price || x.price : x.price;
|
|
234
|
+
if (price?.type === "recurring") {
|
|
232
235
|
renew = renew.add(new BN(getPriceUintAmountByCurrency(price, currency)).mul(new BN(x.quantity)));
|
|
233
236
|
if (includeFreeTrial) {
|
|
234
237
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = {
|
|
3
|
+
customer_id?: string;
|
|
4
|
+
subscription_id?: string;
|
|
5
|
+
};
|
|
6
|
+
declare function CustomerInvoiceList({ customer_id, subscription_id }: Props): import("react").JSX.Element;
|
|
7
|
+
declare namespace CustomerInvoiceList {
|
|
8
|
+
var defaultProps: {
|
|
9
|
+
customer_id: string;
|
|
10
|
+
subscription_id: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export default CustomerInvoiceList;
|
|
@@ -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");
|
|
@@ -27,13 +28,16 @@ const groupByDate = items => {
|
|
|
27
28
|
const fetchData = (params = {}) => {
|
|
28
29
|
const search = new URLSearchParams();
|
|
29
30
|
Object.keys(params).forEach(key => {
|
|
30
|
-
|
|
31
|
+
if (params[key]) {
|
|
32
|
+
search.set(key, String(params[key]));
|
|
33
|
+
}
|
|
31
34
|
});
|
|
32
35
|
return _api.default.get(`/api/invoices?${search.toString()}`).then(res => res.data);
|
|
33
36
|
};
|
|
34
37
|
const pageSize = 10;
|
|
35
38
|
function CustomerInvoiceList({
|
|
36
|
-
customer_id
|
|
39
|
+
customer_id,
|
|
40
|
+
subscription_id
|
|
37
41
|
}) {
|
|
38
42
|
const {
|
|
39
43
|
t
|
|
@@ -49,7 +53,8 @@ function CustomerInvoiceList({
|
|
|
49
53
|
page,
|
|
50
54
|
pageSize,
|
|
51
55
|
status: "open,paid,uncollectible",
|
|
52
|
-
customer_id
|
|
56
|
+
customer_id,
|
|
57
|
+
subscription_id
|
|
53
58
|
});
|
|
54
59
|
}, {
|
|
55
60
|
reloadDeps: [customer_id]
|
|
@@ -97,7 +102,7 @@ function CustomerInvoiceList({
|
|
|
97
102
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
98
103
|
flex: 3,
|
|
99
104
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
|
|
100
|
-
href: `/customer/invoice/${invoice.id}
|
|
105
|
+
href: (0, _ufo.joinURL)(window.location.origin, (0, _util2.getPrefix)(), `/customer/invoice/${invoice.id}`),
|
|
101
106
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
102
107
|
component: "span",
|
|
103
108
|
children: invoice.number
|
|
@@ -147,4 +152,8 @@ function CustomerInvoiceList({
|
|
|
147
152
|
})]
|
|
148
153
|
})]
|
|
149
154
|
});
|
|
150
|
-
}
|
|
155
|
+
}
|
|
156
|
+
CustomerInvoiceList.defaultProps = {
|
|
157
|
+
customer_id: "",
|
|
158
|
+
subscription_id: ""
|
|
159
|
+
};
|