@blocklet/payment-react 1.13.235 → 1.13.237
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/checkout/donate.d.ts +1 -1
- package/es/checkout/donate.js +1 -2
- package/es/contexts/payment.d.ts +1 -1
- package/es/contexts/payment.js +2 -2
- package/es/history/invoice/list.js +21 -4
- package/es/history/mini-invoice/list.js +3 -4
- package/es/locales/en.js +1 -1
- package/es/locales/zh.js +1 -1
- package/es/payment/form/index.js +28 -5
- package/lib/checkout/donate.d.ts +1 -1
- package/lib/checkout/donate.js +1 -1
- package/lib/contexts/payment.d.ts +1 -1
- package/lib/contexts/payment.js +1 -1
- package/lib/history/invoice/list.js +26 -11
- package/lib/history/mini-invoice/list.js +2 -10
- package/lib/locales/en.js +1 -1
- package/lib/locales/zh.js +1 -1
- package/lib/payment/form/index.js +28 -5
- package/package.json +5 -5
- package/src/checkout/donate.tsx +1 -2
- package/src/contexts/payment.tsx +3 -3
- package/src/history/invoice/list.tsx +30 -10
- package/src/history/mini-invoice/list.tsx +3 -6
- package/src/locales/en.tsx +2 -1
- package/src/locales/zh.tsx +1 -1
- package/src/payment/form/index.tsx +31 -6
package/es/checkout/donate.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
|
11
11
|
settings: DonationSettings;
|
|
12
12
|
livemode?: boolean;
|
|
13
13
|
};
|
|
14
|
-
declare function CheckoutDonate({ settings, livemode, onPaid, onError }: DonateProps): import("react").JSX.Element;
|
|
14
|
+
declare function CheckoutDonate({ settings, livemode, onPaid, onError }: DonateProps): import("react").JSX.Element | null;
|
|
15
15
|
declare namespace CheckoutDonate {
|
|
16
16
|
var defaultProps: {
|
|
17
17
|
livemode: boolean;
|
package/es/checkout/donate.js
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
AvatarGroup,
|
|
8
8
|
Box,
|
|
9
9
|
Button,
|
|
10
|
-
CircularProgress,
|
|
11
10
|
Hidden,
|
|
12
11
|
Stack,
|
|
13
12
|
Table,
|
|
@@ -147,7 +146,7 @@ export default function CheckoutDonate({ settings, livemode, onPaid, onError })
|
|
|
147
146
|
return /* @__PURE__ */ jsx(Alert, { severity: "error", children: formatError(donation.error) });
|
|
148
147
|
}
|
|
149
148
|
if (donation.loading || !donation.data) {
|
|
150
|
-
return
|
|
149
|
+
return null;
|
|
151
150
|
}
|
|
152
151
|
return /* @__PURE__ */ jsxs(
|
|
153
152
|
Box,
|
package/es/contexts/payment.d.ts
CHANGED
package/es/contexts/payment.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Alert
|
|
2
|
+
import { Alert } from "@mui/material";
|
|
3
3
|
import { useLocalStorageState, useRequest } from "ahooks";
|
|
4
4
|
import { createContext, useContext } from "react";
|
|
5
5
|
import api from "../api.js";
|
|
@@ -22,7 +22,7 @@ function PaymentProvider({ children, session, connect }) {
|
|
|
22
22
|
return /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message });
|
|
23
23
|
}
|
|
24
24
|
if (loading) {
|
|
25
|
-
return
|
|
25
|
+
return null;
|
|
26
26
|
}
|
|
27
27
|
return /* @__PURE__ */ jsx(
|
|
28
28
|
Provider,
|
|
@@ -54,7 +54,7 @@ export default function CustomerInvoiceList({
|
|
|
54
54
|
target,
|
|
55
55
|
action
|
|
56
56
|
}) {
|
|
57
|
-
const { t } = useLocaleContext();
|
|
57
|
+
const { t, locale } = useLocaleContext();
|
|
58
58
|
const size = pageSize || 10;
|
|
59
59
|
const { data, loadMore, loadingMore, loading } = useInfiniteScroll(
|
|
60
60
|
(d) => {
|
|
@@ -100,20 +100,33 @@ export default function CustomerInvoiceList({
|
|
|
100
100
|
sm: 1.5,
|
|
101
101
|
md: 3
|
|
102
102
|
},
|
|
103
|
+
alignItems: "center",
|
|
103
104
|
flexWrap: "nowrap",
|
|
104
105
|
children: [
|
|
105
106
|
/* @__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: [
|
|
106
107
|
/* @__PURE__ */ jsx(Typography, { component: "span", children: invoice.number }),
|
|
107
108
|
link.external && /* @__PURE__ */ jsx(Hidden, { mdDown: true, children: /* @__PURE__ */ jsx(OpenInNewOutlined, { fontSize: "small", sx: { color: "text.secondary" } }) })
|
|
108
109
|
] }) }) }),
|
|
109
|
-
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsx(Typography, { children: formatToDate(invoice.created_at, "en", "HH:mm:ss") }) }),
|
|
110
110
|
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsxs(Typography, { children: [
|
|
111
111
|
formatBNStr(invoice.total, invoice.paymentCurrency.decimal),
|
|
112
112
|
"\xA0",
|
|
113
113
|
invoice.paymentCurrency.symbol
|
|
114
114
|
] }) }),
|
|
115
|
-
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsx(
|
|
116
|
-
/* @__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 }) }) })
|
|
115
|
+
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsx(Typography, { children: formatToDate(invoice.created_at, locale, "HH:mm:ss") }) }),
|
|
116
|
+
!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 }) }) }),
|
|
117
|
+
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: action ? /* @__PURE__ */ jsx(
|
|
118
|
+
Button,
|
|
119
|
+
{
|
|
120
|
+
component: "a",
|
|
121
|
+
variant: "contained",
|
|
122
|
+
color: "primary",
|
|
123
|
+
size: "small",
|
|
124
|
+
href: link.url,
|
|
125
|
+
target: link.external ? "_blank" : target,
|
|
126
|
+
rel: "noreferrer",
|
|
127
|
+
children: t("payment.customer.invoice.pay")
|
|
128
|
+
}
|
|
129
|
+
) : /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) })
|
|
117
130
|
]
|
|
118
131
|
},
|
|
119
132
|
invoice.id
|
|
@@ -145,4 +158,8 @@ const Root = styled(Stack)`
|
|
|
145
158
|
display: none !important;
|
|
146
159
|
}
|
|
147
160
|
}
|
|
161
|
+
|
|
162
|
+
a.MuiButton-root {
|
|
163
|
+
text-decoration: none !important;
|
|
164
|
+
}
|
|
148
165
|
`;
|
|
@@ -19,10 +19,10 @@ import api from "../../api.js";
|
|
|
19
19
|
import Status from "../../components/status.js";
|
|
20
20
|
import {
|
|
21
21
|
formatBNStr,
|
|
22
|
-
formatDateTime,
|
|
23
22
|
formatError,
|
|
24
23
|
formatSubscriptionProduct,
|
|
25
24
|
formatTime,
|
|
25
|
+
formatToDate,
|
|
26
26
|
getInvoiceStatusColor,
|
|
27
27
|
getPrefix,
|
|
28
28
|
getSubscriptionStatusColor
|
|
@@ -118,14 +118,13 @@ export default function MiniInvoiceList() {
|
|
|
118
118
|
/* @__PURE__ */ jsx(ListSubheader, { disableGutters: true, sx: { padding: 0 }, children: /* @__PURE__ */ jsx(Typography, { component: "h2", variant: "h6", fontSize: "16px", children: t("payment.customer.invoices") }) }),
|
|
119
119
|
invoices.length === 0 ? /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: t("payment.customer.invoice.empty") }) : invoices.map((item) => {
|
|
120
120
|
return /* @__PURE__ */ jsxs(ListItem, { disableGutters: true, sx: { display: "flex", justifyContent: "space-between" }, children: [
|
|
121
|
-
/* @__PURE__ */ jsx(Typography, { component: "span", sx: { flex: 3 }, children:
|
|
121
|
+
/* @__PURE__ */ jsx(Typography, { component: "span", sx: { flex: 3 }, children: formatToDate(item.created_at, locale, "YYYY-MM-DD") }),
|
|
122
122
|
/* @__PURE__ */ jsxs(Typography, { component: "span", sx: { flex: 1, textAlign: "right" }, children: [
|
|
123
123
|
formatBNStr(item.total, item.paymentCurrency.decimal),
|
|
124
124
|
"\xA0",
|
|
125
125
|
item.paymentCurrency.symbol
|
|
126
126
|
] }),
|
|
127
|
-
/* @__PURE__ */ jsx(Typography, { component: "span", sx: { flex: 2, textAlign: "
|
|
128
|
-
/* @__PURE__ */ jsx(Typography, { component: "span", sx: { flex: 3 }, children: /* @__PURE__ */ jsx(Typography, { children: item.description || item.id }) })
|
|
127
|
+
/* @__PURE__ */ jsx(Typography, { component: "span", sx: { flex: 2, textAlign: "right" }, children: /* @__PURE__ */ jsx(Status, { label: item.status, color: getInvoiceStatusColor(item.status) }) })
|
|
129
128
|
] }, item.id);
|
|
130
129
|
})
|
|
131
130
|
] }) }),
|
package/es/locales/en.js
CHANGED
|
@@ -197,7 +197,7 @@ export default flat({
|
|
|
197
197
|
pastDue: {
|
|
198
198
|
button: "Pay",
|
|
199
199
|
invoices: "Past Due Invoices",
|
|
200
|
-
warning: "Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore.",
|
|
200
|
+
warning: "Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore. Please pay these invoices one by one.",
|
|
201
201
|
alert: {
|
|
202
202
|
title: "You have unpaid invoices",
|
|
203
203
|
description: "Seems you have unpaid invoices from previous subscriptions, new purchases are not allowed unless you have paid all past due invoices.",
|
package/es/locales/zh.js
CHANGED
|
@@ -197,7 +197,7 @@ export default flat({
|
|
|
197
197
|
pastDue: {
|
|
198
198
|
button: "\u7EED\u8D39",
|
|
199
199
|
invoices: "\u6B20\u8D39\u5E10\u5355",
|
|
200
|
-
warning: "\u8BF7\u5C3D\u5FEB\u652F\u4ED8\u6B20\u8D39\u8D26\u5355\uFF0C\u5426\u5219\u4F60\u5C06\u65E0\u6CD5\u7EE7\u7EED\u4F7F\u7528\u670D\u52A1\u6216\u8D2D\u4E70\u65B0\u670D\u52A1",
|
|
200
|
+
warning: "\u8BF7\u5C3D\u5FEB\u652F\u4ED8\u6B20\u8D39\u8D26\u5355\uFF0C\u5426\u5219\u4F60\u5C06\u65E0\u6CD5\u7EE7\u7EED\u4F7F\u7528\u670D\u52A1\u6216\u8D2D\u4E70\u65B0\u670D\u52A1\uFF0C\u8BF7\u9010\u4E2A\u6253\u5F00\u8D26\u5355\u8BE6\u60C5\u5E76\u5B8C\u6210\u652F\u4ED8",
|
|
201
201
|
alert: {
|
|
202
202
|
title: "\u4F60\u6709\u6B20\u8D39\u8D26\u5355",
|
|
203
203
|
description: "\u770B\u8D77\u6765\u4F60\u6709\u6B20\u8D39\u7684\u8D26\u5355\uFF0C\u5728\u4F60\u652F\u4ED8\u6240\u6709\u6B20\u8D39\u8D26\u5355\u4E4B\u524D\uFF0C\u65B0\u7684\u8D2D\u4E70\u6216\u8005\u8BA2\u9605\u5C06\u88AB\u7981\u6B62\uFF0C\u8BF7\u4E0D\u8981\u8C03\u76AE\u3002",
|
package/es/payment/form/index.js
CHANGED
|
@@ -39,6 +39,10 @@ const waitForCheckoutComplete = async (sessionId) => {
|
|
|
39
39
|
);
|
|
40
40
|
return result;
|
|
41
41
|
};
|
|
42
|
+
const hasDidWallet = (user) => {
|
|
43
|
+
const connected = user?.connectedAccounts || user?.extraConfigs?.connectedAccounts || [];
|
|
44
|
+
return connected.some((x) => x.provider === "wallet");
|
|
45
|
+
};
|
|
42
46
|
PaymentForm.defaultProps = {};
|
|
43
47
|
export default function PaymentForm({
|
|
44
48
|
checkoutSession,
|
|
@@ -213,19 +217,38 @@ export default function PaymentForm({
|
|
|
213
217
|
setState({ submitting: false });
|
|
214
218
|
}
|
|
215
219
|
};
|
|
216
|
-
const onFormError = () => {
|
|
220
|
+
const onFormError = (err) => {
|
|
221
|
+
if (err) {
|
|
222
|
+
console.error(err);
|
|
223
|
+
}
|
|
217
224
|
setState({ submitting: false });
|
|
218
225
|
};
|
|
219
226
|
const onAction = () => {
|
|
220
227
|
if (session?.user) {
|
|
221
|
-
|
|
228
|
+
if (hasDidWallet(session.user)) {
|
|
229
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
230
|
+
} else {
|
|
231
|
+
session.bindWallet(() => {
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
234
|
+
}, 2e3);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
222
237
|
} else {
|
|
223
238
|
session?.login(() => {
|
|
224
239
|
setState({ submitting: true });
|
|
225
240
|
onUserLoggedIn().then(() => {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
241
|
+
if (hasDidWallet(session.user)) {
|
|
242
|
+
setTimeout(() => {
|
|
243
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
244
|
+
}, 80);
|
|
245
|
+
} else {
|
|
246
|
+
session.bindWallet(() => {
|
|
247
|
+
setTimeout(() => {
|
|
248
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
249
|
+
}, 2e3);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
229
252
|
}).catch((err) => {
|
|
230
253
|
console.error(err);
|
|
231
254
|
setState({ submitting: false });
|
package/lib/checkout/donate.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
|
11
11
|
settings: DonationSettings;
|
|
12
12
|
livemode?: boolean;
|
|
13
13
|
};
|
|
14
|
-
declare function CheckoutDonate({ settings, livemode, onPaid, onError }: DonateProps): import("react").JSX.Element;
|
|
14
|
+
declare function CheckoutDonate({ settings, livemode, onPaid, onError }: DonateProps): import("react").JSX.Element | null;
|
|
15
15
|
declare namespace CheckoutDonate {
|
|
16
16
|
var defaultProps: {
|
|
17
17
|
livemode: boolean;
|
package/lib/checkout/donate.js
CHANGED
|
@@ -225,7 +225,7 @@ function CheckoutDonate({
|
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
if (donation.loading || !donation.data) {
|
|
228
|
-
return
|
|
228
|
+
return null;
|
|
229
229
|
}
|
|
230
230
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
231
231
|
sx: {
|
package/lib/contexts/payment.js
CHANGED
|
@@ -58,7 +58,8 @@ function CustomerInvoiceList({
|
|
|
58
58
|
action
|
|
59
59
|
}) {
|
|
60
60
|
const {
|
|
61
|
-
t
|
|
61
|
+
t,
|
|
62
|
+
locale
|
|
62
63
|
} = (0, _context.useLocaleContext)();
|
|
63
64
|
const size = pageSize || 10;
|
|
64
65
|
const {
|
|
@@ -133,6 +134,7 @@ function CustomerInvoiceList({
|
|
|
133
134
|
sm: 1.5,
|
|
134
135
|
md: 3
|
|
135
136
|
},
|
|
137
|
+
alignItems: "center",
|
|
136
138
|
flexWrap: "nowrap",
|
|
137
139
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
138
140
|
flex: 2,
|
|
@@ -158,12 +160,6 @@ function CustomerInvoiceList({
|
|
|
158
160
|
})]
|
|
159
161
|
})
|
|
160
162
|
})
|
|
161
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
162
|
-
flex: 1,
|
|
163
|
-
textAlign: "right",
|
|
164
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
165
|
-
children: (0, _util.formatToDate)(invoice.created_at, "en", "HH:mm:ss")
|
|
166
|
-
})
|
|
167
163
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
168
164
|
flex: 1,
|
|
169
165
|
textAlign: "right",
|
|
@@ -173,11 +169,10 @@ function CustomerInvoiceList({
|
|
|
173
169
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
174
170
|
flex: 1,
|
|
175
171
|
textAlign: "right",
|
|
176
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
177
|
-
|
|
178
|
-
color: (0, _util.getInvoiceStatusColor)(invoice.status)
|
|
172
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
173
|
+
children: (0, _util.formatToDate)(invoice.created_at, locale, "HH:mm:ss")
|
|
179
174
|
})
|
|
180
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Hidden, {
|
|
175
|
+
}), !action && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Hidden, {
|
|
181
176
|
mdDown: true,
|
|
182
177
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
183
178
|
flex: 2,
|
|
@@ -187,6 +182,22 @@ function CustomerInvoiceList({
|
|
|
187
182
|
children: invoice.description || invoice.id
|
|
188
183
|
})
|
|
189
184
|
})
|
|
185
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
186
|
+
flex: 1,
|
|
187
|
+
textAlign: "right",
|
|
188
|
+
children: action ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
189
|
+
component: "a",
|
|
190
|
+
variant: "contained",
|
|
191
|
+
color: "primary",
|
|
192
|
+
size: "small",
|
|
193
|
+
href: link.url,
|
|
194
|
+
target: link.external ? "_blank" : target,
|
|
195
|
+
rel: "noreferrer",
|
|
196
|
+
children: t("payment.customer.invoice.pay")
|
|
197
|
+
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
198
|
+
label: invoice.status,
|
|
199
|
+
color: (0, _util.getInvoiceStatusColor)(invoice.status)
|
|
200
|
+
})
|
|
190
201
|
})]
|
|
191
202
|
}, invoice.id);
|
|
192
203
|
})]
|
|
@@ -230,4 +241,8 @@ const Root = (0, _system.styled)(_material.Stack)`
|
|
|
230
241
|
display: none !important;
|
|
231
242
|
}
|
|
232
243
|
}
|
|
244
|
+
|
|
245
|
+
a.MuiButton-root {
|
|
246
|
+
text-decoration: none !important;
|
|
247
|
+
}
|
|
233
248
|
`;
|
|
@@ -176,7 +176,7 @@ function MiniInvoiceList() {
|
|
|
176
176
|
sx: {
|
|
177
177
|
flex: 3
|
|
178
178
|
},
|
|
179
|
-
children: (0, _util.
|
|
179
|
+
children: (0, _util.formatToDate)(item.created_at, locale, "YYYY-MM-DD")
|
|
180
180
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
181
181
|
component: "span",
|
|
182
182
|
sx: {
|
|
@@ -188,20 +188,12 @@ function MiniInvoiceList() {
|
|
|
188
188
|
component: "span",
|
|
189
189
|
sx: {
|
|
190
190
|
flex: 2,
|
|
191
|
-
textAlign: "
|
|
191
|
+
textAlign: "right"
|
|
192
192
|
},
|
|
193
193
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
194
194
|
label: item.status,
|
|
195
195
|
color: (0, _util.getInvoiceStatusColor)(item.status)
|
|
196
196
|
})
|
|
197
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
198
|
-
component: "span",
|
|
199
|
-
sx: {
|
|
200
|
-
flex: 3
|
|
201
|
-
},
|
|
202
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
203
|
-
children: item.description || item.id
|
|
204
|
-
})
|
|
205
197
|
})]
|
|
206
198
|
}, item.id);
|
|
207
199
|
})]
|
package/lib/locales/en.js
CHANGED
|
@@ -204,7 +204,7 @@ module.exports = (0, _flat.default)({
|
|
|
204
204
|
pastDue: {
|
|
205
205
|
button: "Pay",
|
|
206
206
|
invoices: "Past Due Invoices",
|
|
207
|
-
warning: "Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore.",
|
|
207
|
+
warning: "Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore. Please pay these invoices one by one.",
|
|
208
208
|
alert: {
|
|
209
209
|
title: "You have unpaid invoices",
|
|
210
210
|
description: "Seems you have unpaid invoices from previous subscriptions, new purchases are not allowed unless you have paid all past due invoices.",
|
package/lib/locales/zh.js
CHANGED
|
@@ -204,7 +204,7 @@ module.exports = (0, _flat.default)({
|
|
|
204
204
|
pastDue: {
|
|
205
205
|
button: "\u7EED\u8D39",
|
|
206
206
|
invoices: "\u6B20\u8D39\u5E10\u5355",
|
|
207
|
-
warning: "\u8BF7\u5C3D\u5FEB\u652F\u4ED8\u6B20\u8D39\u8D26\u5355\uFF0C\u5426\u5219\u4F60\u5C06\u65E0\u6CD5\u7EE7\u7EED\u4F7F\u7528\u670D\u52A1\u6216\u8D2D\u4E70\u65B0\u670D\u52A1",
|
|
207
|
+
warning: "\u8BF7\u5C3D\u5FEB\u652F\u4ED8\u6B20\u8D39\u8D26\u5355\uFF0C\u5426\u5219\u4F60\u5C06\u65E0\u6CD5\u7EE7\u7EED\u4F7F\u7528\u670D\u52A1\u6216\u8D2D\u4E70\u65B0\u670D\u52A1\uFF0C\u8BF7\u9010\u4E2A\u6253\u5F00\u8D26\u5355\u8BE6\u60C5\u5E76\u5B8C\u6210\u652F\u4ED8",
|
|
208
208
|
alert: {
|
|
209
209
|
title: "\u4F60\u6709\u6B20\u8D39\u8D26\u5355",
|
|
210
210
|
description: "\u770B\u8D77\u6765\u4F60\u6709\u6B20\u8D39\u7684\u8D26\u5355\uFF0C\u5728\u4F60\u652F\u4ED8\u6240\u6709\u6B20\u8D39\u8D26\u5355\u4E4B\u524D\uFF0C\u65B0\u7684\u8D2D\u4E70\u6216\u8005\u8BA2\u9605\u5C06\u88AB\u7981\u6B62\uFF0C\u8BF7\u4E0D\u8981\u8C03\u76AE\u3002",
|
|
@@ -48,6 +48,10 @@ const waitForCheckoutComplete = async sessionId => {
|
|
|
48
48
|
});
|
|
49
49
|
return result;
|
|
50
50
|
};
|
|
51
|
+
const hasDidWallet = user => {
|
|
52
|
+
const connected = user?.connectedAccounts || user?.extraConfigs?.connectedAccounts || [];
|
|
53
|
+
return connected.some(x => x.provider === "wallet");
|
|
54
|
+
};
|
|
51
55
|
PaymentForm.defaultProps = {};
|
|
52
56
|
function PaymentForm({
|
|
53
57
|
checkoutSession,
|
|
@@ -264,23 +268,42 @@ function PaymentForm({
|
|
|
264
268
|
});
|
|
265
269
|
}
|
|
266
270
|
};
|
|
267
|
-
const onFormError =
|
|
271
|
+
const onFormError = err => {
|
|
272
|
+
if (err) {
|
|
273
|
+
console.error(err);
|
|
274
|
+
}
|
|
268
275
|
setState({
|
|
269
276
|
submitting: false
|
|
270
277
|
});
|
|
271
278
|
};
|
|
272
279
|
const onAction = () => {
|
|
273
280
|
if (session?.user) {
|
|
274
|
-
|
|
281
|
+
if (hasDidWallet(session.user)) {
|
|
282
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
283
|
+
} else {
|
|
284
|
+
session.bindWallet(() => {
|
|
285
|
+
setTimeout(() => {
|
|
286
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
287
|
+
}, 2e3);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
275
290
|
} else {
|
|
276
291
|
session?.login(() => {
|
|
277
292
|
setState({
|
|
278
293
|
submitting: true
|
|
279
294
|
});
|
|
280
295
|
onUserLoggedIn().then(() => {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
296
|
+
if (hasDidWallet(session.user)) {
|
|
297
|
+
setTimeout(() => {
|
|
298
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
299
|
+
}, 80);
|
|
300
|
+
} else {
|
|
301
|
+
session.bindWallet(() => {
|
|
302
|
+
setTimeout(() => {
|
|
303
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
304
|
+
}, 2e3);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
284
307
|
}).catch(err => {
|
|
285
308
|
console.error(err);
|
|
286
309
|
setState({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.237",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@arcblock/did-connect": "^2.9.
|
|
56
|
-
"@arcblock/ux": "^2.9.
|
|
55
|
+
"@arcblock/did-connect": "^2.9.75",
|
|
56
|
+
"@arcblock/ux": "^2.9.75",
|
|
57
57
|
"@mui/icons-material": "^5.15.15",
|
|
58
58
|
"@mui/lab": "^5.0.0-alpha.170",
|
|
59
59
|
"@mui/material": "^5.15.15",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@babel/core": "^7.24.4",
|
|
91
91
|
"@babel/preset-env": "^7.24.4",
|
|
92
92
|
"@babel/preset-react": "^7.24.1",
|
|
93
|
-
"@blocklet/payment-types": "1.13.
|
|
93
|
+
"@blocklet/payment-types": "1.13.237",
|
|
94
94
|
"@storybook/addon-essentials": "^7.6.17",
|
|
95
95
|
"@storybook/addon-interactions": "^7.6.17",
|
|
96
96
|
"@storybook/addon-links": "^7.6.17",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"vite-plugin-babel": "^1.2.0",
|
|
120
120
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "895430a130d53b62707f4f78c5295b06ce55d4db"
|
|
123
123
|
}
|
package/src/checkout/donate.tsx
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
AvatarGroup,
|
|
15
15
|
Box,
|
|
16
16
|
Button,
|
|
17
|
-
CircularProgress,
|
|
18
17
|
Hidden,
|
|
19
18
|
Stack,
|
|
20
19
|
Table,
|
|
@@ -206,7 +205,7 @@ export default function CheckoutDonate({ settings, livemode, onPaid, onError }:
|
|
|
206
205
|
}
|
|
207
206
|
|
|
208
207
|
if (donation.loading || !donation.data) {
|
|
209
|
-
return
|
|
208
|
+
return null;
|
|
210
209
|
}
|
|
211
210
|
|
|
212
211
|
return (
|
package/src/contexts/payment.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TPaymentCurrency, TPaymentMethodExpanded } from '@blocklet/payment-types';
|
|
2
|
-
import { Alert
|
|
2
|
+
import { Alert } from '@mui/material';
|
|
3
3
|
import { useLocalStorageState, useRequest } from 'ahooks';
|
|
4
4
|
import type { Axios } from 'axios';
|
|
5
5
|
import { createContext, useContext } from 'react';
|
|
@@ -41,7 +41,7 @@ const getCurrency = (currencyId: string, methods: TPaymentMethodExpanded[]) => {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
// eslint-disable-next-line react/prop-types
|
|
44
|
-
function PaymentProvider({ children, session, connect }: { children: any; session: any; connect: any })
|
|
44
|
+
function PaymentProvider({ children, session, connect }: { children: any; session: any; connect: any }) {
|
|
45
45
|
const { data, error, run, loading } = useRequest(getSettings);
|
|
46
46
|
const [livemode, setLivemode] = useLocalStorageState('livemode', { defaultValue: true });
|
|
47
47
|
|
|
@@ -50,7 +50,7 @@ function PaymentProvider({ children, session, connect }: { children: any; sessio
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
if (loading) {
|
|
53
|
-
return
|
|
53
|
+
return null;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
return (
|
|
@@ -74,7 +74,7 @@ export default function CustomerInvoiceList({
|
|
|
74
74
|
target,
|
|
75
75
|
action,
|
|
76
76
|
}: Props) {
|
|
77
|
-
const { t } = useLocaleContext();
|
|
77
|
+
const { t, locale } = useLocaleContext();
|
|
78
78
|
const size = pageSize || 10;
|
|
79
79
|
|
|
80
80
|
const { data, loadMore, loadingMore, loading } = useInfiniteScroll<Result>(
|
|
@@ -137,6 +137,7 @@ export default function CustomerInvoiceList({
|
|
|
137
137
|
sm: 1.5,
|
|
138
138
|
md: 3,
|
|
139
139
|
}}
|
|
140
|
+
alignItems="center"
|
|
140
141
|
flexWrap="nowrap">
|
|
141
142
|
<Box flex={2}>
|
|
142
143
|
<a href={link.url} target={link.external ? '_blank' : target} rel="noreferrer">
|
|
@@ -150,9 +151,6 @@ export default function CustomerInvoiceList({
|
|
|
150
151
|
</Stack>
|
|
151
152
|
</a>
|
|
152
153
|
</Box>
|
|
153
|
-
<Box flex={1} textAlign="right">
|
|
154
|
-
<Typography>{formatToDate(invoice.created_at, 'en', 'HH:mm:ss')}</Typography>
|
|
155
|
-
</Box>
|
|
156
154
|
<Box flex={1} textAlign="right">
|
|
157
155
|
<Typography>
|
|
158
156
|
{formatBNStr(invoice.total, invoice.paymentCurrency.decimal)}
|
|
@@ -160,13 +158,31 @@ export default function CustomerInvoiceList({
|
|
|
160
158
|
</Typography>
|
|
161
159
|
</Box>
|
|
162
160
|
<Box flex={1} textAlign="right">
|
|
163
|
-
<
|
|
161
|
+
<Typography>{formatToDate(invoice.created_at, locale, 'HH:mm:ss')}</Typography>
|
|
162
|
+
</Box>
|
|
163
|
+
{!action && (
|
|
164
|
+
<Hidden mdDown>
|
|
165
|
+
<Box flex={2} className="invoice-description" textAlign="right">
|
|
166
|
+
<Typography>{invoice.description || invoice.id}</Typography>
|
|
167
|
+
</Box>
|
|
168
|
+
</Hidden>
|
|
169
|
+
)}
|
|
170
|
+
<Box flex={1} textAlign="right">
|
|
171
|
+
{action ? (
|
|
172
|
+
<Button
|
|
173
|
+
component="a"
|
|
174
|
+
variant="contained"
|
|
175
|
+
color="primary"
|
|
176
|
+
size="small"
|
|
177
|
+
href={link.url}
|
|
178
|
+
target={link.external ? '_blank' : target}
|
|
179
|
+
rel="noreferrer">
|
|
180
|
+
{t('payment.customer.invoice.pay')}
|
|
181
|
+
</Button>
|
|
182
|
+
) : (
|
|
183
|
+
<Status label={invoice.status} color={getInvoiceStatusColor(invoice.status)} />
|
|
184
|
+
)}
|
|
164
185
|
</Box>
|
|
165
|
-
<Hidden mdDown>
|
|
166
|
-
<Box flex={2} className="invoice-description" textAlign="right">
|
|
167
|
-
<Typography>{invoice.description || invoice.id}</Typography>
|
|
168
|
-
</Box>
|
|
169
|
-
</Hidden>
|
|
170
186
|
</Stack>
|
|
171
187
|
);
|
|
172
188
|
})}
|
|
@@ -210,4 +226,8 @@ const Root = styled(Stack)`
|
|
|
210
226
|
display: none !important;
|
|
211
227
|
}
|
|
212
228
|
}
|
|
229
|
+
|
|
230
|
+
a.MuiButton-root {
|
|
231
|
+
text-decoration: none !important;
|
|
232
|
+
}
|
|
213
233
|
`;
|
|
@@ -21,10 +21,10 @@ import api from '../../api';
|
|
|
21
21
|
import Status from '../../components/status';
|
|
22
22
|
import {
|
|
23
23
|
formatBNStr,
|
|
24
|
-
formatDateTime,
|
|
25
24
|
formatError,
|
|
26
25
|
formatSubscriptionProduct,
|
|
27
26
|
formatTime,
|
|
27
|
+
formatToDate,
|
|
28
28
|
getInvoiceStatusColor,
|
|
29
29
|
getPrefix,
|
|
30
30
|
getSubscriptionStatusColor,
|
|
@@ -158,18 +158,15 @@ export default function MiniInvoiceList() {
|
|
|
158
158
|
return (
|
|
159
159
|
<ListItem key={item.id} disableGutters sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
160
160
|
<Typography component="span" sx={{ flex: 3 }}>
|
|
161
|
-
{
|
|
161
|
+
{formatToDate(item.created_at, locale, 'YYYY-MM-DD')}
|
|
162
162
|
</Typography>
|
|
163
163
|
<Typography component="span" sx={{ flex: 1, textAlign: 'right' }}>
|
|
164
164
|
{formatBNStr(item.total, item.paymentCurrency.decimal)}
|
|
165
165
|
{item.paymentCurrency.symbol}
|
|
166
166
|
</Typography>
|
|
167
|
-
<Typography component="span" sx={{ flex: 2, textAlign: '
|
|
167
|
+
<Typography component="span" sx={{ flex: 2, textAlign: 'right' }}>
|
|
168
168
|
<Status label={item.status} color={getInvoiceStatusColor(item.status)} />
|
|
169
169
|
</Typography>
|
|
170
|
-
<Typography component="span" sx={{ flex: 3 }}>
|
|
171
|
-
<Typography>{item.description || item.id}</Typography>
|
|
172
|
-
</Typography>
|
|
173
170
|
</ListItem>
|
|
174
171
|
);
|
|
175
172
|
})
|
package/src/locales/en.tsx
CHANGED
|
@@ -203,7 +203,8 @@ export default flat({
|
|
|
203
203
|
pastDue: {
|
|
204
204
|
button: 'Pay',
|
|
205
205
|
invoices: 'Past Due Invoices',
|
|
206
|
-
warning:
|
|
206
|
+
warning:
|
|
207
|
+
'Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore. Please pay these invoices one by one.',
|
|
207
208
|
alert: {
|
|
208
209
|
title: 'You have unpaid invoices',
|
|
209
210
|
description:
|
package/src/locales/zh.tsx
CHANGED
|
@@ -199,7 +199,7 @@ export default flat({
|
|
|
199
199
|
pastDue: {
|
|
200
200
|
button: '续费',
|
|
201
201
|
invoices: '欠费帐单',
|
|
202
|
-
warning: '
|
|
202
|
+
warning: '请尽快支付欠费账单,否则你将无法继续使用服务或购买新服务,请逐个打开账单详情并完成支付',
|
|
203
203
|
alert: {
|
|
204
204
|
title: '你有欠费账单',
|
|
205
205
|
description: '看起来你有欠费的账单,在你支付所有欠费账单之前,新的购买或者订阅将被禁止,请不要调皮。',
|
|
@@ -57,6 +57,11 @@ const waitForCheckoutComplete = async (sessionId: string) => {
|
|
|
57
57
|
return result;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
const hasDidWallet = (user: any) => {
|
|
61
|
+
const connected = user?.connectedAccounts || user?.extraConfigs?.connectedAccounts || [];
|
|
62
|
+
return connected.some((x: any) => x.provider === 'wallet');
|
|
63
|
+
};
|
|
64
|
+
|
|
60
65
|
type PageData = CheckoutContext & CheckoutCallbacks;
|
|
61
66
|
|
|
62
67
|
PaymentForm.defaultProps = {};
|
|
@@ -219,7 +224,6 @@ export default function PaymentForm({
|
|
|
219
224
|
if (result.data.balance?.sufficient || result.data.delegation?.sufficient) {
|
|
220
225
|
await handleConnected();
|
|
221
226
|
} else {
|
|
222
|
-
// @FIXME: 需要考虑如何正确地适配前端组件的使用 @wangshijun
|
|
223
227
|
connect.open({
|
|
224
228
|
containerEl: undefined as unknown as Element,
|
|
225
229
|
action: checkoutSession.mode,
|
|
@@ -267,21 +271,42 @@ export default function PaymentForm({
|
|
|
267
271
|
}
|
|
268
272
|
};
|
|
269
273
|
|
|
270
|
-
const onFormError = () => {
|
|
274
|
+
const onFormError = (err: unknown) => {
|
|
275
|
+
if (err) {
|
|
276
|
+
console.error(err);
|
|
277
|
+
}
|
|
271
278
|
setState({ submitting: false });
|
|
272
279
|
};
|
|
273
280
|
|
|
274
281
|
const onAction = () => {
|
|
275
282
|
if (session?.user) {
|
|
276
|
-
|
|
283
|
+
if (hasDidWallet(session.user)) {
|
|
284
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
285
|
+
} else {
|
|
286
|
+
session.bindWallet(() => {
|
|
287
|
+
// timeout required because https://github.com/ArcBlock/ux/issues/1241
|
|
288
|
+
setTimeout(() => {
|
|
289
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
290
|
+
}, 2000);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
277
293
|
} else {
|
|
278
294
|
session?.login(() => {
|
|
279
295
|
setState({ submitting: true });
|
|
280
296
|
onUserLoggedIn()
|
|
281
297
|
.then(() => {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
298
|
+
if (hasDidWallet(session.user)) {
|
|
299
|
+
setTimeout(() => {
|
|
300
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
301
|
+
}, 80);
|
|
302
|
+
} else {
|
|
303
|
+
session.bindWallet(() => {
|
|
304
|
+
// timeout required because https://github.com/ArcBlock/ux/issues/1241
|
|
305
|
+
setTimeout(() => {
|
|
306
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
307
|
+
}, 2000);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
285
310
|
})
|
|
286
311
|
.catch((err) => {
|
|
287
312
|
console.error(err);
|