@blocklet/payment-react 1.13.175 → 1.13.177
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/history/mini-invoice/list.js +41 -12
- package/es/locales/en.js +8 -1
- package/es/locales/zh.js +8 -1
- package/es/payment/index.js +1 -0
- package/es/payment/success.d.ts +3 -1
- package/es/payment/success.js +9 -2
- package/lib/history/mini-invoice/list.js +30 -9
- package/lib/locales/en.js +8 -1
- package/lib/locales/zh.js +8 -1
- package/lib/payment/index.js +1 -0
- package/lib/payment/success.d.ts +3 -1
- package/lib/payment/success.js +31 -12
- package/package.json +3 -3
- package/src/history/mini-invoice/list.tsx +35 -9
- package/src/locales/en.tsx +8 -1
- package/src/locales/zh.tsx +8 -1
- package/src/payment/index.tsx +1 -0
- package/src/payment/success.tsx +23 -8
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
Button,
|
|
6
|
+
CircularProgress,
|
|
7
|
+
Divider,
|
|
8
|
+
Link,
|
|
9
|
+
List,
|
|
10
|
+
ListItem,
|
|
11
|
+
ListSubheader,
|
|
12
|
+
Stack,
|
|
13
|
+
Typography
|
|
14
|
+
} from "@mui/material";
|
|
4
15
|
import { fromUnitToToken } from "@ocap/util";
|
|
5
16
|
import { useRequest } from "ahooks";
|
|
6
17
|
import { joinURL } from "ufo";
|
|
@@ -25,7 +36,7 @@ const fetchSubscriptionData = (id) => {
|
|
|
25
36
|
return api.get(`/api/subscriptions/${id}`).then((res) => res.data);
|
|
26
37
|
};
|
|
27
38
|
export default function MiniInvoiceList() {
|
|
28
|
-
const { t } = useLocaleContext();
|
|
39
|
+
const { t, locale } = useLocaleContext();
|
|
29
40
|
const subscriptionId = new URL(window.location.href).searchParams.get("id");
|
|
30
41
|
const { data: subscription } = useRequest(() => fetchSubscriptionData(subscriptionId));
|
|
31
42
|
const { data } = useRequest(
|
|
@@ -99,16 +110,34 @@ export default function MiniInvoiceList() {
|
|
|
99
110
|
] }, item.id);
|
|
100
111
|
})
|
|
101
112
|
] }) }),
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "center", spacing: 2, sx: { mt: 2 }, children: [
|
|
114
|
+
subscription.service_actions?.map((x) => (
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
/* @__PURE__ */ jsx(
|
|
117
|
+
Button,
|
|
118
|
+
{
|
|
119
|
+
component: Link,
|
|
120
|
+
variant: x.variant,
|
|
121
|
+
color: x.color,
|
|
122
|
+
href: x.link,
|
|
123
|
+
size: "small",
|
|
124
|
+
sx: { textDecoration: "none !important" },
|
|
125
|
+
children: x.text[locale] || x.text.en || x.name
|
|
126
|
+
},
|
|
127
|
+
x.name
|
|
128
|
+
)
|
|
129
|
+
)),
|
|
130
|
+
/* @__PURE__ */ jsx(
|
|
131
|
+
Button,
|
|
132
|
+
{
|
|
133
|
+
target: "_blank",
|
|
134
|
+
variant: "contained",
|
|
135
|
+
sx: { color: "#fff!important", width: subscription.service_actions?.length ? "auto" : "100%" },
|
|
136
|
+
href: joinURL(window.location.origin, getPrefix(), `/customer/subscription/${subscription.id}`),
|
|
137
|
+
children: t("payment.customer.subscriptions.title")
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
] })
|
|
112
141
|
]
|
|
113
142
|
}
|
|
114
143
|
)
|
package/es/locales/en.js
CHANGED
|
@@ -39,6 +39,10 @@ export default flat({
|
|
|
39
39
|
email: "Email",
|
|
40
40
|
did: "DID",
|
|
41
41
|
txHash: "Transaction",
|
|
42
|
+
delegateTxHash: "Delegate Transaction",
|
|
43
|
+
stakeTxHash: "Stake Transaction",
|
|
44
|
+
slashTxHash: "Slash Transaction",
|
|
45
|
+
transferTxHash: "Transfer Transaction",
|
|
42
46
|
customer: "Customer",
|
|
43
47
|
currency: "Currency",
|
|
44
48
|
custom: "Custom",
|
|
@@ -90,7 +94,10 @@ export default flat({
|
|
|
90
94
|
continue: "Confirm {action}",
|
|
91
95
|
connect: "Connect and {action}",
|
|
92
96
|
login: "Login to load and save contact information",
|
|
93
|
-
|
|
97
|
+
next: {
|
|
98
|
+
subscription: "View subscription",
|
|
99
|
+
invoice: "View invoice"
|
|
100
|
+
},
|
|
94
101
|
cardPay: "{action} with card",
|
|
95
102
|
empty: "No thing to pay",
|
|
96
103
|
per: "per",
|
package/es/locales/zh.js
CHANGED
|
@@ -39,6 +39,10 @@ export default flat({
|
|
|
39
39
|
email: "\u90AE\u7BB1",
|
|
40
40
|
did: "DID",
|
|
41
41
|
txHash: "\u4EA4\u6613\u54C8\u5E0C",
|
|
42
|
+
delegateTxHash: "\u6388\u6743\u4EA4\u6613",
|
|
43
|
+
stakeTxHash: "\u8D28\u62BC\u4EA4\u6613",
|
|
44
|
+
slashTxHash: "\u7F5A\u6CA1\u4EA4\u6613",
|
|
45
|
+
transferTxHash: "\u6263\u6B3E\u4EA4\u6613",
|
|
42
46
|
customer: "\u5BA2\u6237",
|
|
43
47
|
currency: "\u5E01\u79CD",
|
|
44
48
|
custom: "\u81EA\u5B9A\u4E49",
|
|
@@ -90,7 +94,10 @@ export default flat({
|
|
|
90
94
|
continue: "\u786E\u8BA4{action}",
|
|
91
95
|
connect: "\u8FDE\u63A5\u5E76{action}",
|
|
92
96
|
login: "\u767B\u5F55\u4EE5\u52A0\u8F7D\u5E76\u4FDD\u5B58\u8054\u7CFB\u4FE1\u606F",
|
|
93
|
-
|
|
97
|
+
next: {
|
|
98
|
+
subscription: "\u67E5\u770B\u8BA2\u9605",
|
|
99
|
+
invoice: "\u67E5\u770B\u8D26\u5355"
|
|
100
|
+
},
|
|
94
101
|
cardPay: "\u4F7F\u7528\u5361\u7247{action}",
|
|
95
102
|
empty: "\u6CA1\u6709\u53EF\u652F\u4ED8\u7684\u9879\u76EE",
|
|
96
103
|
per: "\u6BCF",
|
package/es/payment/index.js
CHANGED
|
@@ -213,6 +213,7 @@ export function PaymentInner({
|
|
|
213
213
|
{
|
|
214
214
|
payee: getStatementDescriptor(state.checkoutSession.line_items),
|
|
215
215
|
action: state.checkoutSession.mode,
|
|
216
|
+
invoiceId: state.checkoutSession.invoice_id,
|
|
216
217
|
subscriptionId: state.checkoutSession.subscription_id,
|
|
217
218
|
message: paymentLink?.after_completion?.hosted_confirmation?.custom_message || t(`payment.checkout.completed.${state.checkoutSession.mode}`)
|
|
218
219
|
}
|
package/es/payment/success.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ type Props = {
|
|
|
3
3
|
message: string;
|
|
4
4
|
action: string;
|
|
5
5
|
payee: string;
|
|
6
|
+
invoiceId?: string;
|
|
6
7
|
subscriptionId?: string;
|
|
7
8
|
};
|
|
8
|
-
declare function PaymentSuccess({ message, action, payee, subscriptionId }: Props): import("react").JSX.Element;
|
|
9
|
+
declare function PaymentSuccess({ message, action, payee, invoiceId, subscriptionId }: Props): import("react").JSX.Element;
|
|
9
10
|
declare namespace PaymentSuccess {
|
|
10
11
|
var defaultProps: {
|
|
12
|
+
invoiceId: string;
|
|
11
13
|
subscriptionId: string;
|
|
12
14
|
};
|
|
13
15
|
}
|
package/es/payment/success.js
CHANGED
|
@@ -4,9 +4,15 @@ import { Grow, Link, Stack, Typography } from "@mui/material";
|
|
|
4
4
|
import { styled } from "@mui/system";
|
|
5
5
|
import { joinURL } from "ufo";
|
|
6
6
|
import { usePaymentContext } from "../contexts/payment.js";
|
|
7
|
-
export default function PaymentSuccess({ message, action, payee, subscriptionId }) {
|
|
7
|
+
export default function PaymentSuccess({ message, action, payee, invoiceId, subscriptionId }) {
|
|
8
8
|
const { t } = useLocaleContext();
|
|
9
9
|
const { prefix } = usePaymentContext();
|
|
10
|
+
let next = null;
|
|
11
|
+
if (["subscription", "setup"].includes(action) && subscriptionId) {
|
|
12
|
+
next = /* @__PURE__ */ jsx(Typography, { textAlign: "center", sx: { mt: 2 }, children: /* @__PURE__ */ jsx(Link, { href: joinURL(prefix, `/customer/subscription/${subscriptionId}`), children: t("payment.checkout.next.subscription", { payee }) }) });
|
|
13
|
+
} else if (invoiceId) {
|
|
14
|
+
next = /* @__PURE__ */ jsx(Typography, { textAlign: "center", sx: { mt: 2 }, children: /* @__PURE__ */ jsx(Link, { href: joinURL(prefix, `/customer/invoice/${invoiceId}`), children: t("payment.checkout.next.invoice", { payee }) }) });
|
|
15
|
+
}
|
|
10
16
|
return /* @__PURE__ */ jsx(Grow, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "center", justifyContent: "center", sx: { height: 360 }, children: [
|
|
11
17
|
/* @__PURE__ */ jsx(Div, { children: /* @__PURE__ */ jsxs("div", { className: "check-icon", children: [
|
|
12
18
|
/* @__PURE__ */ jsx("span", { className: "icon-line line-tip" }),
|
|
@@ -16,10 +22,11 @@ export default function PaymentSuccess({ message, action, payee, subscriptionId
|
|
|
16
22
|
] }) }),
|
|
17
23
|
/* @__PURE__ */ jsx(Typography, { variant: "h5", color: "text.primary", mb: 3, children: message }),
|
|
18
24
|
/* @__PURE__ */ jsx(Typography, { variant: "body1", color: "text.secondary", textAlign: "center", children: t("payment.checkout.completed.tip", { payee }) }),
|
|
19
|
-
|
|
25
|
+
next
|
|
20
26
|
] }) });
|
|
21
27
|
}
|
|
22
28
|
PaymentSuccess.defaultProps = {
|
|
29
|
+
invoiceId: "",
|
|
23
30
|
subscriptionId: ""
|
|
24
31
|
};
|
|
25
32
|
const Div = styled("div")`
|
|
@@ -26,7 +26,8 @@ const fetchSubscriptionData = id => {
|
|
|
26
26
|
};
|
|
27
27
|
function MiniInvoiceList() {
|
|
28
28
|
const {
|
|
29
|
-
t
|
|
29
|
+
t,
|
|
30
|
+
locale
|
|
30
31
|
} = (0, _context.useLocaleContext)();
|
|
31
32
|
const subscriptionId = new URL(window.location.href).searchParams.get("id");
|
|
32
33
|
const {
|
|
@@ -183,16 +184,36 @@ function MiniInvoiceList() {
|
|
|
183
184
|
}, item.id);
|
|
184
185
|
})]
|
|
185
186
|
})
|
|
186
|
-
}), /* @__PURE__ */(0, _jsxRuntime.
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
188
|
+
direction: "row",
|
|
189
|
+
justifyContent: "center",
|
|
190
|
+
spacing: 2,
|
|
189
191
|
sx: {
|
|
190
|
-
|
|
191
|
-
width: "100%",
|
|
192
|
-
color: "#fff!important"
|
|
192
|
+
mt: 2
|
|
193
193
|
},
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
children: [subscription.service_actions?.map(x =>
|
|
195
|
+
// @ts-ignore
|
|
196
|
+
/* @__PURE__ */
|
|
197
|
+
(0, _jsxRuntime.jsx)(_material.Button, {
|
|
198
|
+
component: _material.Link,
|
|
199
|
+
variant: x.variant,
|
|
200
|
+
color: x.color,
|
|
201
|
+
href: x.link,
|
|
202
|
+
size: "small",
|
|
203
|
+
sx: {
|
|
204
|
+
textDecoration: "none !important"
|
|
205
|
+
},
|
|
206
|
+
children: x.text[locale] || x.text.en || x.name
|
|
207
|
+
}, x.name)), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
208
|
+
target: "_blank",
|
|
209
|
+
variant: "contained",
|
|
210
|
+
sx: {
|
|
211
|
+
color: "#fff!important",
|
|
212
|
+
width: subscription.service_actions?.length ? "auto" : "100%"
|
|
213
|
+
},
|
|
214
|
+
href: (0, _ufo.joinURL)(window.location.origin, (0, _util2.getPrefix)(), `/customer/subscription/${subscription.id}`),
|
|
215
|
+
children: t("payment.customer.subscriptions.title")
|
|
216
|
+
})]
|
|
196
217
|
})]
|
|
197
218
|
})]
|
|
198
219
|
});
|
package/lib/locales/en.js
CHANGED
|
@@ -46,6 +46,10 @@ module.exports = (0, _flat.default)({
|
|
|
46
46
|
email: "Email",
|
|
47
47
|
did: "DID",
|
|
48
48
|
txHash: "Transaction",
|
|
49
|
+
delegateTxHash: "Delegate Transaction",
|
|
50
|
+
stakeTxHash: "Stake Transaction",
|
|
51
|
+
slashTxHash: "Slash Transaction",
|
|
52
|
+
transferTxHash: "Transfer Transaction",
|
|
49
53
|
customer: "Customer",
|
|
50
54
|
currency: "Currency",
|
|
51
55
|
custom: "Custom",
|
|
@@ -97,7 +101,10 @@ module.exports = (0, _flat.default)({
|
|
|
97
101
|
continue: "Confirm {action}",
|
|
98
102
|
connect: "Connect and {action}",
|
|
99
103
|
login: "Login to load and save contact information",
|
|
100
|
-
|
|
104
|
+
next: {
|
|
105
|
+
subscription: "View subscription",
|
|
106
|
+
invoice: "View invoice"
|
|
107
|
+
},
|
|
101
108
|
cardPay: "{action} with card",
|
|
102
109
|
empty: "No thing to pay",
|
|
103
110
|
per: "per",
|
package/lib/locales/zh.js
CHANGED
|
@@ -46,6 +46,10 @@ module.exports = (0, _flat.default)({
|
|
|
46
46
|
email: "\u90AE\u7BB1",
|
|
47
47
|
did: "DID",
|
|
48
48
|
txHash: "\u4EA4\u6613\u54C8\u5E0C",
|
|
49
|
+
delegateTxHash: "\u6388\u6743\u4EA4\u6613",
|
|
50
|
+
stakeTxHash: "\u8D28\u62BC\u4EA4\u6613",
|
|
51
|
+
slashTxHash: "\u7F5A\u6CA1\u4EA4\u6613",
|
|
52
|
+
transferTxHash: "\u6263\u6B3E\u4EA4\u6613",
|
|
49
53
|
customer: "\u5BA2\u6237",
|
|
50
54
|
currency: "\u5E01\u79CD",
|
|
51
55
|
custom: "\u81EA\u5B9A\u4E49",
|
|
@@ -97,7 +101,10 @@ module.exports = (0, _flat.default)({
|
|
|
97
101
|
continue: "\u786E\u8BA4{action}",
|
|
98
102
|
connect: "\u8FDE\u63A5\u5E76{action}",
|
|
99
103
|
login: "\u767B\u5F55\u4EE5\u52A0\u8F7D\u5E76\u4FDD\u5B58\u8054\u7CFB\u4FE1\u606F",
|
|
100
|
-
|
|
104
|
+
next: {
|
|
105
|
+
subscription: "\u67E5\u770B\u8BA2\u9605",
|
|
106
|
+
invoice: "\u67E5\u770B\u8D26\u5355"
|
|
107
|
+
},
|
|
101
108
|
cardPay: "\u4F7F\u7528\u5361\u7247{action}",
|
|
102
109
|
empty: "\u6CA1\u6709\u53EF\u652F\u4ED8\u7684\u9879\u76EE",
|
|
103
110
|
per: "\u6BCF",
|
package/lib/payment/index.js
CHANGED
|
@@ -280,6 +280,7 @@ function PaymentInner({
|
|
|
280
280
|
children: [completed && /* @__PURE__ */(0, _jsxRuntime.jsx)(_success.default, {
|
|
281
281
|
payee: (0, _util.getStatementDescriptor)(state.checkoutSession.line_items),
|
|
282
282
|
action: state.checkoutSession.mode,
|
|
283
|
+
invoiceId: state.checkoutSession.invoice_id,
|
|
283
284
|
subscriptionId: state.checkoutSession.subscription_id,
|
|
284
285
|
message: paymentLink?.after_completion?.hosted_confirmation?.custom_message || t(`payment.checkout.completed.${state.checkoutSession.mode}`)
|
|
285
286
|
}), !completed && /* @__PURE__ */(0, _jsxRuntime.jsx)(_form.default, {
|
package/lib/payment/success.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ type Props = {
|
|
|
3
3
|
message: string;
|
|
4
4
|
action: string;
|
|
5
5
|
payee: string;
|
|
6
|
+
invoiceId?: string;
|
|
6
7
|
subscriptionId?: string;
|
|
7
8
|
};
|
|
8
|
-
declare function PaymentSuccess({ message, action, payee, subscriptionId }: Props): import("react").JSX.Element;
|
|
9
|
+
declare function PaymentSuccess({ message, action, payee, invoiceId, subscriptionId }: Props): import("react").JSX.Element;
|
|
9
10
|
declare namespace PaymentSuccess {
|
|
10
11
|
var defaultProps: {
|
|
12
|
+
invoiceId: string;
|
|
11
13
|
subscriptionId: string;
|
|
12
14
|
};
|
|
13
15
|
}
|
package/lib/payment/success.js
CHANGED
|
@@ -14,6 +14,7 @@ function PaymentSuccess({
|
|
|
14
14
|
message,
|
|
15
15
|
action,
|
|
16
16
|
payee,
|
|
17
|
+
invoiceId,
|
|
17
18
|
subscriptionId
|
|
18
19
|
}) {
|
|
19
20
|
const {
|
|
@@ -22,6 +23,34 @@ function PaymentSuccess({
|
|
|
22
23
|
const {
|
|
23
24
|
prefix
|
|
24
25
|
} = (0, _payment.usePaymentContext)();
|
|
26
|
+
let next = null;
|
|
27
|
+
if (["subscription", "setup"].includes(action) && subscriptionId) {
|
|
28
|
+
next = /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
29
|
+
textAlign: "center",
|
|
30
|
+
sx: {
|
|
31
|
+
mt: 2
|
|
32
|
+
},
|
|
33
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Link, {
|
|
34
|
+
href: (0, _ufo.joinURL)(prefix, `/customer/subscription/${subscriptionId}`),
|
|
35
|
+
children: t("payment.checkout.next.subscription", {
|
|
36
|
+
payee
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
} else if (invoiceId) {
|
|
41
|
+
next = /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
42
|
+
textAlign: "center",
|
|
43
|
+
sx: {
|
|
44
|
+
mt: 2
|
|
45
|
+
},
|
|
46
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Link, {
|
|
47
|
+
href: (0, _ufo.joinURL)(prefix, `/customer/invoice/${invoiceId}`),
|
|
48
|
+
children: t("payment.checkout.next.invoice", {
|
|
49
|
+
payee
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
}
|
|
25
54
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Grow, {
|
|
26
55
|
in: true,
|
|
27
56
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
@@ -56,22 +85,12 @@ function PaymentSuccess({
|
|
|
56
85
|
children: t("payment.checkout.completed.tip", {
|
|
57
86
|
payee
|
|
58
87
|
})
|
|
59
|
-
}),
|
|
60
|
-
textAlign: "center",
|
|
61
|
-
sx: {
|
|
62
|
-
mt: 2
|
|
63
|
-
},
|
|
64
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Link, {
|
|
65
|
-
href: (0, _ufo.joinURL)(prefix, `/customer/subscription/${subscriptionId}`),
|
|
66
|
-
children: t("payment.checkout.portal", {
|
|
67
|
-
payee
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
})]
|
|
88
|
+
}), next]
|
|
71
89
|
})
|
|
72
90
|
});
|
|
73
91
|
}
|
|
74
92
|
PaymentSuccess.defaultProps = {
|
|
93
|
+
invoiceId: "",
|
|
75
94
|
subscriptionId: ""
|
|
76
95
|
};
|
|
77
96
|
const Div = (0, _system.styled)("div")`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.177",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@babel/core": "^7.23.9",
|
|
90
90
|
"@babel/preset-env": "^7.23.9",
|
|
91
91
|
"@babel/preset-react": "^7.23.3",
|
|
92
|
-
"@blocklet/payment-types": "1.13.
|
|
92
|
+
"@blocklet/payment-types": "1.13.177",
|
|
93
93
|
"@storybook/addon-essentials": "^7.6.13",
|
|
94
94
|
"@storybook/addon-interactions": "^7.6.13",
|
|
95
95
|
"@storybook/addon-links": "^7.6.13",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"vite-plugin-babel": "^1.2.0",
|
|
119
119
|
"vite-plugin-node-polyfills": "^0.19.0"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "be1b8ffce6d158f52c0103eefa415577fb793be2"
|
|
122
122
|
}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import type { Paginated, TInvoiceExpanded, TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Box,
|
|
6
|
+
Button,
|
|
7
|
+
CircularProgress,
|
|
8
|
+
Divider,
|
|
9
|
+
Link,
|
|
10
|
+
List,
|
|
11
|
+
ListItem,
|
|
12
|
+
ListSubheader,
|
|
13
|
+
Stack,
|
|
14
|
+
Typography,
|
|
15
|
+
} from '@mui/material';
|
|
5
16
|
import { fromUnitToToken } from '@ocap/util';
|
|
6
17
|
import { useRequest } from 'ahooks';
|
|
7
18
|
import { joinURL } from 'ufo';
|
|
@@ -30,7 +41,7 @@ const fetchSubscriptionData = (id: string): Promise<TSubscriptionExpanded> => {
|
|
|
30
41
|
};
|
|
31
42
|
|
|
32
43
|
export default function MiniInvoiceList() {
|
|
33
|
-
const { t } = useLocaleContext();
|
|
44
|
+
const { t, locale } = useLocaleContext();
|
|
34
45
|
|
|
35
46
|
const subscriptionId = new URL(window.location.href).searchParams.get('id');
|
|
36
47
|
|
|
@@ -139,13 +150,28 @@ export default function MiniInvoiceList() {
|
|
|
139
150
|
)}
|
|
140
151
|
</List>
|
|
141
152
|
</Box>
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
<Stack direction="row" justifyContent="center" spacing={2} sx={{ mt: 2 }}>
|
|
154
|
+
{subscription.service_actions?.map((x) => (
|
|
155
|
+
// @ts-ignore
|
|
156
|
+
<Button
|
|
157
|
+
component={Link}
|
|
158
|
+
key={x.name}
|
|
159
|
+
variant={x.variant}
|
|
160
|
+
color={x.color}
|
|
161
|
+
href={x.link}
|
|
162
|
+
size="small"
|
|
163
|
+
sx={{ textDecoration: 'none !important' }}>
|
|
164
|
+
{x.text[locale] || x.text.en || x.name}
|
|
165
|
+
</Button>
|
|
166
|
+
))}
|
|
167
|
+
<Button
|
|
168
|
+
target="_blank"
|
|
169
|
+
variant="contained"
|
|
170
|
+
sx={{ color: '#fff!important', width: subscription.service_actions?.length ? 'auto' : '100%' }}
|
|
171
|
+
href={joinURL(window.location.origin, getPrefix(), `/customer/subscription/${subscription.id}`)}>
|
|
172
|
+
{t('payment.customer.subscriptions.title')}
|
|
173
|
+
</Button>
|
|
174
|
+
</Stack>
|
|
149
175
|
</Box>
|
|
150
176
|
</Position>
|
|
151
177
|
);
|
package/src/locales/en.tsx
CHANGED
|
@@ -40,6 +40,10 @@ export default flat({
|
|
|
40
40
|
email: 'Email',
|
|
41
41
|
did: 'DID',
|
|
42
42
|
txHash: 'Transaction',
|
|
43
|
+
delegateTxHash: 'Delegate Transaction',
|
|
44
|
+
stakeTxHash: 'Stake Transaction',
|
|
45
|
+
slashTxHash: 'Slash Transaction',
|
|
46
|
+
transferTxHash: 'Transfer Transaction',
|
|
43
47
|
customer: 'Customer',
|
|
44
48
|
currency: 'Currency',
|
|
45
49
|
custom: 'Custom',
|
|
@@ -91,7 +95,10 @@ export default flat({
|
|
|
91
95
|
continue: 'Confirm {action}',
|
|
92
96
|
connect: 'Connect and {action}',
|
|
93
97
|
login: 'Login to load and save contact information',
|
|
94
|
-
|
|
98
|
+
next: {
|
|
99
|
+
subscription: 'View subscription',
|
|
100
|
+
invoice: 'View invoice',
|
|
101
|
+
},
|
|
95
102
|
cardPay: '{action} with card',
|
|
96
103
|
empty: 'No thing to pay',
|
|
97
104
|
per: 'per',
|
package/src/locales/zh.tsx
CHANGED
|
@@ -40,6 +40,10 @@ export default flat({
|
|
|
40
40
|
email: '邮箱',
|
|
41
41
|
did: 'DID',
|
|
42
42
|
txHash: '交易哈希',
|
|
43
|
+
delegateTxHash: '授权交易',
|
|
44
|
+
stakeTxHash: '质押交易',
|
|
45
|
+
slashTxHash: '罚没交易',
|
|
46
|
+
transferTxHash: '扣款交易',
|
|
43
47
|
customer: '客户',
|
|
44
48
|
currency: '币种',
|
|
45
49
|
custom: '自定义',
|
|
@@ -91,7 +95,10 @@ export default flat({
|
|
|
91
95
|
continue: '确认{action}',
|
|
92
96
|
connect: '连接并{action}',
|
|
93
97
|
login: '登录以加载并保存联系信息',
|
|
94
|
-
|
|
98
|
+
next: {
|
|
99
|
+
subscription: '查看订阅',
|
|
100
|
+
invoice: '查看账单',
|
|
101
|
+
},
|
|
95
102
|
cardPay: '使用卡片{action}',
|
|
96
103
|
empty: '没有可支付的项目',
|
|
97
104
|
per: '每',
|
package/src/payment/index.tsx
CHANGED
|
@@ -255,6 +255,7 @@ export function PaymentInner({
|
|
|
255
255
|
<PaymentSuccess
|
|
256
256
|
payee={getStatementDescriptor(state.checkoutSession.line_items)}
|
|
257
257
|
action={state.checkoutSession.mode}
|
|
258
|
+
invoiceId={state.checkoutSession.invoice_id}
|
|
258
259
|
subscriptionId={state.checkoutSession.subscription_id}
|
|
259
260
|
message={
|
|
260
261
|
paymentLink?.after_completion?.hosted_confirmation?.custom_message ||
|
package/src/payment/success.tsx
CHANGED
|
@@ -9,12 +9,32 @@ type Props = {
|
|
|
9
9
|
message: string;
|
|
10
10
|
action: string;
|
|
11
11
|
payee: string;
|
|
12
|
+
invoiceId?: string;
|
|
12
13
|
subscriptionId?: string;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
export default function PaymentSuccess({ message, action, payee, subscriptionId }: Props) {
|
|
16
|
+
export default function PaymentSuccess({ message, action, payee, invoiceId, subscriptionId }: Props) {
|
|
16
17
|
const { t } = useLocaleContext();
|
|
17
18
|
const { prefix } = usePaymentContext();
|
|
19
|
+
let next: any = null;
|
|
20
|
+
if (['subscription', 'setup'].includes(action) && subscriptionId) {
|
|
21
|
+
next = (
|
|
22
|
+
<Typography textAlign="center" sx={{ mt: 2 }}>
|
|
23
|
+
<Link href={joinURL(prefix, `/customer/subscription/${subscriptionId}`)}>
|
|
24
|
+
{t('payment.checkout.next.subscription', { payee })}
|
|
25
|
+
</Link>
|
|
26
|
+
</Typography>
|
|
27
|
+
);
|
|
28
|
+
} else if (invoiceId) {
|
|
29
|
+
next = (
|
|
30
|
+
<Typography textAlign="center" sx={{ mt: 2 }}>
|
|
31
|
+
<Link href={joinURL(prefix, `/customer/invoice/${invoiceId}`)}>
|
|
32
|
+
{t('payment.checkout.next.invoice', { payee })}
|
|
33
|
+
</Link>
|
|
34
|
+
</Typography>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
18
38
|
return (
|
|
19
39
|
<Grow in>
|
|
20
40
|
<Stack direction="column" alignItems="center" justifyContent="center" sx={{ height: 360 }}>
|
|
@@ -32,19 +52,14 @@ export default function PaymentSuccess({ message, action, payee, subscriptionId
|
|
|
32
52
|
<Typography variant="body1" color="text.secondary" textAlign="center">
|
|
33
53
|
{t('payment.checkout.completed.tip', { payee })}
|
|
34
54
|
</Typography>
|
|
35
|
-
{
|
|
36
|
-
<Typography textAlign="center" sx={{ mt: 2 }}>
|
|
37
|
-
<Link href={joinURL(prefix, `/customer/subscription/${subscriptionId}`)}>
|
|
38
|
-
{t('payment.checkout.portal', { payee })}
|
|
39
|
-
</Link>
|
|
40
|
-
</Typography>
|
|
41
|
-
)}
|
|
55
|
+
{next}
|
|
42
56
|
</Stack>
|
|
43
57
|
</Grow>
|
|
44
58
|
);
|
|
45
59
|
}
|
|
46
60
|
|
|
47
61
|
PaymentSuccess.defaultProps = {
|
|
62
|
+
invoiceId: '',
|
|
48
63
|
subscriptionId: '',
|
|
49
64
|
};
|
|
50
65
|
|