payment-kit 1.16.7 → 1.16.8
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.
|
@@ -86,24 +86,25 @@ router.get('/me', sessionMiddleware(), async (req, res) => {
|
|
|
86
86
|
|
|
87
87
|
try {
|
|
88
88
|
const doc = await Customer.findByPkOrDid(req.user.did as string);
|
|
89
|
+
const livemode = req.query.livemode ? !!req?.livemode : !!doc?.livemode;
|
|
89
90
|
if (!doc) {
|
|
90
91
|
if (req.query.fallback) {
|
|
91
92
|
const result = await blocklet.getUser(req.user.did);
|
|
92
|
-
res.json({ ...result.user, address: {} });
|
|
93
|
+
res.json({ ...result.user, address: {}, livemode });
|
|
93
94
|
} else {
|
|
94
95
|
res.json({ error: 'Customer not found' });
|
|
95
96
|
}
|
|
96
97
|
} else {
|
|
97
98
|
const [summary, stake, token] = await Promise.all([
|
|
98
99
|
doc.getSummary(),
|
|
99
|
-
getStakeSummaryByDid(doc.did,
|
|
100
|
-
getTokenSummaryByDid(doc.did,
|
|
100
|
+
getStakeSummaryByDid(doc.did, livemode),
|
|
101
|
+
getTokenSummaryByDid(doc.did, livemode),
|
|
101
102
|
]);
|
|
102
|
-
res.json({ ...doc.toJSON(), summary: { ...summary, stake, token } });
|
|
103
|
+
res.json({ ...doc.toJSON(), summary: { ...summary, stake, token }, livemode });
|
|
103
104
|
}
|
|
104
105
|
} catch (err) {
|
|
105
|
-
console.error(err);
|
|
106
|
-
res.json(
|
|
106
|
+
console.error('get customer failed', err);
|
|
107
|
+
res.status(500).json({ error: `Failed to get customer: ${err.message}` });
|
|
107
108
|
}
|
|
108
109
|
});
|
|
109
110
|
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.8",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@arcblock/validator": "^1.18.150",
|
|
54
54
|
"@blocklet/js-sdk": "1.16.33-beta-20241031-073543-49b1ff9b",
|
|
55
55
|
"@blocklet/logger": "1.16.33-beta-20241031-073543-49b1ff9b",
|
|
56
|
-
"@blocklet/payment-react": "1.16.
|
|
56
|
+
"@blocklet/payment-react": "1.16.8",
|
|
57
57
|
"@blocklet/sdk": "1.16.33-beta-20241031-073543-49b1ff9b",
|
|
58
58
|
"@blocklet/ui-react": "^2.10.74",
|
|
59
59
|
"@blocklet/uploader": "^0.1.53",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@abtnode/types": "1.16.33-beta-20241031-073543-49b1ff9b",
|
|
122
122
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
123
|
-
"@blocklet/payment-types": "1.16.
|
|
123
|
+
"@blocklet/payment-types": "1.16.8",
|
|
124
124
|
"@types/cookie-parser": "^1.4.7",
|
|
125
125
|
"@types/cors": "^2.8.17",
|
|
126
126
|
"@types/debug": "^4.1.12",
|
|
@@ -166,5 +166,5 @@
|
|
|
166
166
|
"parser": "typescript"
|
|
167
167
|
}
|
|
168
168
|
},
|
|
169
|
-
"gitHead": "
|
|
169
|
+
"gitHead": "ad6dca32db4f5074471e000b714ff5046e06608f"
|
|
170
170
|
}
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from '@mui/material';
|
|
29
29
|
import type { SelectChangeEvent } from '@mui/material/Select';
|
|
30
30
|
import { styled, SxProps } from '@mui/system';
|
|
31
|
-
import { useSetState } from 'ahooks';
|
|
31
|
+
import { useRequest, useSetState } from 'ahooks';
|
|
32
32
|
import { flatten, isEmpty } from 'lodash';
|
|
33
33
|
import { memo, useEffect, useMemo, useState } from 'react';
|
|
34
34
|
import { FlagEmoji, defaultCountries, parseCountry } from 'react-international-phone';
|
|
@@ -101,19 +101,14 @@ export default function CustomerHome() {
|
|
|
101
101
|
const navigate = useNavigate();
|
|
102
102
|
const { isMobile } = useMobile('lg');
|
|
103
103
|
const { isPending, startTransition } = useTransitionContext();
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const { data, error, loading, runAsync } = useRequest(fetchData, {
|
|
105
|
+
manual: true,
|
|
106
|
+
});
|
|
106
107
|
const countryDetail = useMemo(() => {
|
|
107
108
|
const item = defaultCountries.find((v) => v[1] === data?.address?.country);
|
|
108
109
|
return item ? parseCountry(item) : { name: '' };
|
|
109
110
|
}, [data]);
|
|
110
111
|
|
|
111
|
-
const runAsync = () => {
|
|
112
|
-
fetchData().then((res) => {
|
|
113
|
-
setData(res);
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
112
|
useEffect(() => {
|
|
118
113
|
runAsync();
|
|
119
114
|
events.on('switch-did', () => {
|
|
@@ -127,6 +122,18 @@ export default function CustomerHome() {
|
|
|
127
122
|
}
|
|
128
123
|
}, [data]);
|
|
129
124
|
|
|
125
|
+
if (loading) {
|
|
126
|
+
return <ProgressBar pending />;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (error) {
|
|
130
|
+
return (
|
|
131
|
+
<Alert sx={{ mt: 3 }} severity="error">
|
|
132
|
+
{formatError(error)}
|
|
133
|
+
</Alert>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
130
137
|
if (!data) {
|
|
131
138
|
return null;
|
|
132
139
|
}
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
getPrefix,
|
|
17
17
|
getSubscriptionStatusColor,
|
|
18
18
|
useDefaultPageSize,
|
|
19
|
+
useMobile,
|
|
19
20
|
} from '@blocklet/payment-react';
|
|
20
21
|
import type { Paginated, TInvoiceExpanded, TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
21
22
|
import {
|
|
@@ -60,6 +61,7 @@ export default function SubscriptionEmbed() {
|
|
|
60
61
|
const subscriptionId = params.get('id') || '';
|
|
61
62
|
const authToken = params.get('authToken') || '';
|
|
62
63
|
const defaultPageSize = useDefaultPageSize(20);
|
|
64
|
+
const { isMobile } = useMobile();
|
|
63
65
|
const { data: subscription, error, loading } = useRequest(() => fetchSubscriptionData(subscriptionId, authToken));
|
|
64
66
|
const { data } = useRequest(
|
|
65
67
|
() =>
|
|
@@ -181,7 +183,7 @@ export default function SubscriptionEmbed() {
|
|
|
181
183
|
width: '100%',
|
|
182
184
|
height: '100%',
|
|
183
185
|
}}>
|
|
184
|
-
<Typography component="h3" sx={{ textAlign: 'center' }} variant="h5" gutterBottom>
|
|
186
|
+
<Typography component="h3" sx={{ textAlign: 'center', fontWeight: 500 }} variant="h5" gutterBottom>
|
|
185
187
|
{t('payment.customer.subscriptions.current')}
|
|
186
188
|
</Typography>
|
|
187
189
|
<Box sx={{ marginTop: '12px' }}>
|
|
@@ -212,8 +214,10 @@ export default function SubscriptionEmbed() {
|
|
|
212
214
|
return (
|
|
213
215
|
<ListItem key={item.id} disableGutters sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
214
216
|
<Typography component="div" sx={{ flex: 3, gap: 1, display: 'flex', alignItems: 'center' }}>
|
|
215
|
-
{
|
|
216
|
-
|
|
217
|
+
<Typography component="span" sx={{ whiteSpace: 'nowrap' }}>
|
|
218
|
+
{formatToDate(item.created_at, locale, 'YYYY-MM-DD')}
|
|
219
|
+
</Typography>
|
|
220
|
+
{!isMobile && <Status label={getInvoiceDescriptionAndReason(item, locale)?.type} />}
|
|
217
221
|
</Typography>
|
|
218
222
|
<Typography component="span" sx={{ flex: 1, textAlign: 'right' }}>
|
|
219
223
|
{formatBNStr(item.total, item.paymentCurrency.decimal)}
|