payment-kit 1.13.212 → 1.13.214
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/api/src/store/models/payment-method.ts +9 -5
- package/blocklet.yml +1 -1
- package/package.json +4 -4
- package/src/components/info-row.tsx +25 -8
- package/src/components/payouts/list.tsx +5 -3
- package/src/components/refund/list.tsx +4 -2
- package/src/components/subscription/portal/actions.tsx +12 -6
- package/src/components/subscription/portal/list.tsx +5 -1
- package/src/pages/admin/billing/invoices/detail.tsx +17 -1
- package/src/pages/admin/customers/customers/detail.tsx +33 -3
- package/src/pages/customer/index.tsx +2 -9
- package/src/pages/customer/invoice/detail.tsx +16 -3
|
@@ -176,11 +176,15 @@ export class PaymentMethod extends Model<InferAttributes<PaymentMethod>, InferCr
|
|
|
176
176
|
return stripeClients.get(this.id) as Stripe;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
try {
|
|
180
|
+
const settings = PaymentMethod.decryptSettings(this.settings);
|
|
181
|
+
const client = new Stripe(settings.stripe?.secret_key as string, { apiVersion: STRIPE_API_VERSION });
|
|
182
|
+
stripeClients.set(this.id, client);
|
|
183
|
+
|
|
184
|
+
return client as Stripe;
|
|
185
|
+
} catch (e) {
|
|
186
|
+
return {} as Stripe;
|
|
187
|
+
}
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
getOcapClient() {
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.214",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "cross-env COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@arcblock/ux": "^2.9.66",
|
|
52
52
|
"@arcblock/validator": "^1.18.115",
|
|
53
53
|
"@blocklet/logger": "1.16.25",
|
|
54
|
-
"@blocklet/payment-react": "1.13.
|
|
54
|
+
"@blocklet/payment-react": "1.13.214",
|
|
55
55
|
"@blocklet/sdk": "1.16.25",
|
|
56
56
|
"@blocklet/ui-react": "^2.9.66",
|
|
57
57
|
"@blocklet/uploader": "^0.0.76",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@abtnode/types": "1.16.25",
|
|
113
113
|
"@arcblock/eslint-config-ts": "^0.3.0",
|
|
114
|
-
"@blocklet/payment-types": "1.13.
|
|
114
|
+
"@blocklet/payment-types": "1.13.214",
|
|
115
115
|
"@types/cookie-parser": "^1.4.6",
|
|
116
116
|
"@types/cors": "^2.8.17",
|
|
117
117
|
"@types/dotenv-flow": "^3.3.3",
|
|
@@ -150,5 +150,5 @@
|
|
|
150
150
|
"parser": "typescript"
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
|
-
"gitHead": "
|
|
153
|
+
"gitHead": "430206bb27ea5749a12717d5bd3caf00a04b610a"
|
|
154
154
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import { Box, Stack } from '@mui/material';
|
|
3
|
+
import { styled } from '@mui/system';
|
|
3
4
|
import type { ReactNode } from 'react';
|
|
4
5
|
|
|
5
6
|
type Props = {
|
|
@@ -20,13 +21,29 @@ export default function InfoRow(props: Props) {
|
|
|
20
21
|
const isNone = props.value === '' || typeof props.value === 'undefined';
|
|
21
22
|
const sizes = props.sizes || [1, 3];
|
|
22
23
|
return (
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
<Root>
|
|
25
|
+
<Stack
|
|
26
|
+
direction="row"
|
|
27
|
+
alignItems={props.alignItems}
|
|
28
|
+
justifyContent="space-between"
|
|
29
|
+
flexWrap="wrap"
|
|
30
|
+
sx={{ mb: 1 }}
|
|
31
|
+
className="info-row-wrapper">
|
|
32
|
+
<Box flex={sizes[0]} color="text.secondary">
|
|
33
|
+
{props.label}
|
|
34
|
+
</Box>
|
|
35
|
+
<Box flex={sizes[1]} color={isNone ? 'text.disabled' : 'color.primary'}>
|
|
36
|
+
{isNone ? t('common.none') : props.value}
|
|
37
|
+
</Box>
|
|
38
|
+
</Stack>
|
|
39
|
+
</Root>
|
|
31
40
|
);
|
|
32
41
|
}
|
|
42
|
+
|
|
43
|
+
const Root = styled(Box)`
|
|
44
|
+
@media (max-width: 600px) {
|
|
45
|
+
.info-row-wrapper {
|
|
46
|
+
display: block !important;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
@@ -45,6 +45,7 @@ type ListProps = {
|
|
|
45
45
|
filter?: boolean;
|
|
46
46
|
footer?: boolean;
|
|
47
47
|
};
|
|
48
|
+
status?: string;
|
|
48
49
|
customer_id?: string;
|
|
49
50
|
payment_intent_id?: string;
|
|
50
51
|
};
|
|
@@ -60,23 +61,24 @@ const getListKey = (props: ListProps) => {
|
|
|
60
61
|
return 'payouts';
|
|
61
62
|
};
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
PayoutList.defaultProps = {
|
|
64
65
|
features: {
|
|
65
66
|
customer: true,
|
|
66
67
|
filter: true,
|
|
67
68
|
},
|
|
69
|
+
status: '',
|
|
68
70
|
customer_id: '',
|
|
69
71
|
payment_intent_id: '',
|
|
70
72
|
};
|
|
71
73
|
|
|
72
|
-
export default function
|
|
74
|
+
export default function PayoutList({ customer_id, payment_intent_id, status, features }: ListProps) {
|
|
73
75
|
const { t } = useLocaleContext();
|
|
74
76
|
const navigate = useNavigate();
|
|
75
77
|
|
|
76
78
|
const listKey = getListKey({ customer_id, payment_intent_id });
|
|
77
79
|
const [search, setSearch] = useLocalStorageState<SearchProps>(listKey, {
|
|
78
80
|
defaultValue: {
|
|
79
|
-
status:
|
|
81
|
+
status: status as string,
|
|
80
82
|
customer_id,
|
|
81
83
|
payment_intent_id,
|
|
82
84
|
pageSize: 20,
|
|
@@ -47,6 +47,7 @@ type ListProps = {
|
|
|
47
47
|
};
|
|
48
48
|
customer_id?: string;
|
|
49
49
|
invoice_id?: string;
|
|
50
|
+
status?: string;
|
|
50
51
|
subscription_id?: string;
|
|
51
52
|
};
|
|
52
53
|
|
|
@@ -71,10 +72,11 @@ RefundList.defaultProps = {
|
|
|
71
72
|
},
|
|
72
73
|
customer_id: '',
|
|
73
74
|
invoice_id: '',
|
|
75
|
+
status: '',
|
|
74
76
|
subscription_id: '',
|
|
75
77
|
};
|
|
76
78
|
|
|
77
|
-
export default function RefundList({ customer_id, invoice_id, subscription_id, features }: ListProps) {
|
|
79
|
+
export default function RefundList({ customer_id, invoice_id, subscription_id, status, features }: ListProps) {
|
|
78
80
|
const { t } = useLocaleContext();
|
|
79
81
|
const navigate = useNavigate();
|
|
80
82
|
const { startTransition } = useTransitionContext();
|
|
@@ -82,7 +84,7 @@ export default function RefundList({ customer_id, invoice_id, subscription_id, f
|
|
|
82
84
|
|
|
83
85
|
const [search, setSearch] = useLocalStorageState<SearchProps>(listKey, {
|
|
84
86
|
defaultValue: {
|
|
85
|
-
status:
|
|
87
|
+
status: status as string,
|
|
86
88
|
customer_id,
|
|
87
89
|
invoice_id,
|
|
88
90
|
subscription_id,
|
|
@@ -6,6 +6,7 @@ import type { TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
|
6
6
|
import { Button, Link, Stack } from '@mui/material';
|
|
7
7
|
import { useRequest, useSetState } from 'ahooks';
|
|
8
8
|
import isEmpty from 'lodash/isEmpty';
|
|
9
|
+
import { useState } from 'react';
|
|
9
10
|
import { FormProvider, useForm, useFormContext } from 'react-hook-form';
|
|
10
11
|
import { useNavigate } from 'react-router-dom';
|
|
11
12
|
|
|
@@ -14,11 +15,12 @@ import CustomerCancelForm from './cancel';
|
|
|
14
15
|
type Props = {
|
|
15
16
|
subscription: TSubscriptionExpanded;
|
|
16
17
|
showExtra?: boolean;
|
|
17
|
-
onChange
|
|
18
|
+
onChange?: (action?: string) => any | Promise<any>;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
SubscriptionActions.defaultProps = {
|
|
21
22
|
showExtra: false,
|
|
23
|
+
onChange: null,
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
const fetchExtraActions = async ({
|
|
@@ -56,7 +58,8 @@ export function SubscriptionActionsInner({ subscription, showExtra, onChange }:
|
|
|
56
58
|
const { t, locale } = useLocaleContext();
|
|
57
59
|
const { reset, getValues } = useFormContext();
|
|
58
60
|
const navigate = useNavigate();
|
|
59
|
-
const
|
|
61
|
+
const [subs, setSubscription] = useState(subscription);
|
|
62
|
+
const action = getSubscriptionAction(subs);
|
|
60
63
|
|
|
61
64
|
const { data: extraActions } = useRequest(() => fetchExtraActions({ id: subscription.id, showExtra: !!showExtra }));
|
|
62
65
|
|
|
@@ -69,11 +72,12 @@ export function SubscriptionActionsInner({ subscription, showExtra, onChange }:
|
|
|
69
72
|
const handleCancel = async () => {
|
|
70
73
|
try {
|
|
71
74
|
setState({ loading: true });
|
|
72
|
-
await api
|
|
75
|
+
const sub = await api
|
|
73
76
|
.put(`/api/subscriptions/${state.subscription}/cancel`, { at: 'current_period_end', ...getValues().cancel })
|
|
74
77
|
.then((res) => res.data);
|
|
78
|
+
setSubscription(sub);
|
|
75
79
|
Toast.success(t('common.saved'));
|
|
76
|
-
onChange(state.action);
|
|
80
|
+
if (onChange) onChange(state.action);
|
|
77
81
|
} catch (err) {
|
|
78
82
|
console.error(err);
|
|
79
83
|
Toast.error(formatError(err));
|
|
@@ -86,9 +90,10 @@ export function SubscriptionActionsInner({ subscription, showExtra, onChange }:
|
|
|
86
90
|
const handleRecover = async () => {
|
|
87
91
|
try {
|
|
88
92
|
setState({ loading: true });
|
|
89
|
-
await api.put(`/api/subscriptions/${state.subscription}/recover`).then((res) => res.data);
|
|
93
|
+
const sub = await api.put(`/api/subscriptions/${state.subscription}/recover`).then((res) => res.data);
|
|
94
|
+
setSubscription(sub);
|
|
90
95
|
Toast.success(t('common.saved'));
|
|
91
|
-
onChange(state.action);
|
|
96
|
+
if (onChange) onChange(state.action);
|
|
92
97
|
} catch (err) {
|
|
93
98
|
console.error(err);
|
|
94
99
|
Toast.error(formatError(err));
|
|
@@ -197,4 +202,5 @@ export default function SubscriptionActions(props: Props) {
|
|
|
197
202
|
|
|
198
203
|
SubscriptionActionsInner.defaultProps = {
|
|
199
204
|
showExtra: false,
|
|
205
|
+
onChange: null,
|
|
200
206
|
};
|
|
@@ -24,7 +24,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<Paginated<TSubscri
|
|
|
24
24
|
|
|
25
25
|
type Props = {
|
|
26
26
|
id: string;
|
|
27
|
-
onChange
|
|
27
|
+
onChange?: (action?: string) => any | Promise<any>;
|
|
28
28
|
onClickSubscription: (subscription: TSubscriptionExpanded) => void | Promise<void>;
|
|
29
29
|
} & Omit<StackProps, 'onChange'>;
|
|
30
30
|
|
|
@@ -145,3 +145,7 @@ export default function CurrentSubscriptions({ id, onChange, onClickSubscription
|
|
|
145
145
|
</Stack>
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
|
+
|
|
149
|
+
CurrentSubscriptions.defaultProps = {
|
|
150
|
+
onChange: null,
|
|
151
|
+
};
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Status,
|
|
6
|
+
TxLink,
|
|
7
|
+
api,
|
|
8
|
+
formatBNStr,
|
|
9
|
+
formatError,
|
|
10
|
+
formatTime,
|
|
11
|
+
getInvoiceStatusColor,
|
|
12
|
+
} from '@blocklet/payment-react';
|
|
5
13
|
import type { TInvoice, TInvoiceExpanded } from '@blocklet/payment-types';
|
|
6
14
|
import { ArrowBackOutlined, Edit } from '@mui/icons-material';
|
|
7
15
|
import { Alert, Box, Button, CircularProgress, Stack, Typography } from '@mui/material';
|
|
@@ -131,6 +139,14 @@ export default function InvoiceDetail(props: { id: string }) {
|
|
|
131
139
|
label={t('admin.paymentCurrency.name')}
|
|
132
140
|
value={<Currency logo={data.paymentCurrency.logo} name={data.paymentCurrency.symbol} />}
|
|
133
141
|
/>
|
|
142
|
+
{data.paymentIntent && data.paymentIntent.payment_details && (
|
|
143
|
+
<InfoRow
|
|
144
|
+
label={t(`common.${data.paymentIntent.payment_details?.arcblock?.type || 'transfer'}TxHash`)}
|
|
145
|
+
value={
|
|
146
|
+
<TxLink details={data.paymentIntent.payment_details} method={data.paymentMethod} mode="customer" />
|
|
147
|
+
}
|
|
148
|
+
/>
|
|
149
|
+
)}
|
|
134
150
|
{data.subscription && (
|
|
135
151
|
<InfoRow
|
|
136
152
|
label={t('admin.subscription.name')}
|
|
@@ -22,6 +22,8 @@ import InfoRow from '../../../../components/info-row';
|
|
|
22
22
|
import InvoiceList from '../../../../components/invoice/list';
|
|
23
23
|
import MetadataEditor from '../../../../components/metadata/editor';
|
|
24
24
|
import PaymentList from '../../../../components/payment-intent/list';
|
|
25
|
+
import PayoutList from '../../../../components/payouts/list';
|
|
26
|
+
import RefundList from '../../../../components/refund/list';
|
|
25
27
|
import SectionHeader from '../../../../components/section/header';
|
|
26
28
|
import SubscriptionList from '../../../../components/subscription/list';
|
|
27
29
|
|
|
@@ -242,7 +244,21 @@ export default function CustomerDetail(props: { id: string }) {
|
|
|
242
244
|
<Box className="section">
|
|
243
245
|
<SectionHeader title={t('admin.subscriptions')} mb={0} />
|
|
244
246
|
<Box className="section-body">
|
|
245
|
-
<SubscriptionList
|
|
247
|
+
<SubscriptionList
|
|
248
|
+
features={{ customer: false, toolbar: false }}
|
|
249
|
+
customer_id={data.customer.id}
|
|
250
|
+
status={['active', 'trialing', 'paused', 'past_due', 'canceled'].join(',')}
|
|
251
|
+
/>
|
|
252
|
+
</Box>
|
|
253
|
+
</Box>
|
|
254
|
+
<Box className="section">
|
|
255
|
+
<SectionHeader title={t('admin.invoices')} mb={0} />
|
|
256
|
+
<Box className="section-body">
|
|
257
|
+
<InvoiceList
|
|
258
|
+
features={{ customer: false, toolbar: false }}
|
|
259
|
+
customer_id={data.customer.id}
|
|
260
|
+
status={['open', 'paid', 'uncollectible', 'draft', 'void'].join(',')}
|
|
261
|
+
/>
|
|
246
262
|
</Box>
|
|
247
263
|
</Box>
|
|
248
264
|
<Box className="section">
|
|
@@ -252,9 +268,23 @@ export default function CustomerDetail(props: { id: string }) {
|
|
|
252
268
|
</Box>
|
|
253
269
|
</Box>
|
|
254
270
|
<Box className="section">
|
|
255
|
-
<SectionHeader title={t('admin.
|
|
271
|
+
<SectionHeader title={t('admin.payouts')} mb={0} />
|
|
256
272
|
<Box className="section-body">
|
|
257
|
-
<
|
|
273
|
+
<PayoutList
|
|
274
|
+
features={{ customer: false, toolbar: false }}
|
|
275
|
+
customer_id={data.customer.id}
|
|
276
|
+
status={['paid', 'pending', 'failed', 'canceled'].join(',')}
|
|
277
|
+
/>
|
|
278
|
+
</Box>
|
|
279
|
+
</Box>
|
|
280
|
+
<Box className="section">
|
|
281
|
+
<SectionHeader title={t('admin.refunds')} mb={0} />
|
|
282
|
+
<Box className="section-body">
|
|
283
|
+
<RefundList
|
|
284
|
+
features={{ customer: false, toolbar: false }}
|
|
285
|
+
customer_id={data.customer.id}
|
|
286
|
+
status={['succeeded', 'canceled', 'failed', 'requires_action', 'pending'].join(',')}
|
|
287
|
+
/>
|
|
258
288
|
</Box>
|
|
259
289
|
</Box>
|
|
260
290
|
<Box className="section">
|
|
@@ -4,7 +4,7 @@ import Toast from '@arcblock/ux/lib/Toast';
|
|
|
4
4
|
import { CustomerInvoiceList, PaymentProvider, formatError, getPrefix } from '@blocklet/payment-react';
|
|
5
5
|
import type { GroupedBN, TCustomerExpanded } from '@blocklet/payment-types';
|
|
6
6
|
import { Edit } from '@mui/icons-material';
|
|
7
|
-
import {
|
|
7
|
+
import { Box, Button, CircularProgress, Grid, Stack, Tooltip } from '@mui/material';
|
|
8
8
|
import { styled } from '@mui/system';
|
|
9
9
|
import { useSetState } from 'ahooks';
|
|
10
10
|
import { isEmpty } from 'lodash';
|
|
@@ -50,11 +50,7 @@ export default function CustomerHome() {
|
|
|
50
50
|
}, []);
|
|
51
51
|
|
|
52
52
|
if (!data) {
|
|
53
|
-
return
|
|
54
|
-
<Alert sx={{ mt: 3 }} severity="info">
|
|
55
|
-
{t('payment.customer.empty')}
|
|
56
|
-
</Alert>
|
|
57
|
-
);
|
|
53
|
+
return <CircularProgress />;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
const onUpdateInfo = async (updates: TCustomerExpanded) => {
|
|
@@ -82,9 +78,6 @@ export default function CustomerHome() {
|
|
|
82
78
|
<Box className="section-body">
|
|
83
79
|
<CurrentSubscriptions
|
|
84
80
|
id={data.id}
|
|
85
|
-
onChange={() => {
|
|
86
|
-
runAsync();
|
|
87
|
-
}}
|
|
88
81
|
style={{
|
|
89
82
|
cursor: 'pointer',
|
|
90
83
|
}}
|
|
@@ -5,6 +5,7 @@ import { Status, TxLink, api, formatError, formatTime, getInvoiceStatusColor } f
|
|
|
5
5
|
import type { TInvoiceExpanded } from '@blocklet/payment-types';
|
|
6
6
|
import { ArrowBackOutlined } from '@mui/icons-material';
|
|
7
7
|
import { Alert, Box, Button, CircularProgress, Stack, Typography } from '@mui/material';
|
|
8
|
+
import { styled } from '@mui/system';
|
|
8
9
|
import { useRequest, useSetState } from 'ahooks';
|
|
9
10
|
import { useEffect } from 'react';
|
|
10
11
|
import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
|
@@ -130,9 +131,9 @@ export default function CustomerInvoiceDetail() {
|
|
|
130
131
|
)}
|
|
131
132
|
</Stack>
|
|
132
133
|
</Stack>
|
|
133
|
-
<
|
|
134
|
+
<Root>
|
|
134
135
|
<SectionHeader title={t('payment.customer.invoice.summary')} />
|
|
135
|
-
<Stack
|
|
136
|
+
<Stack className="invoice-summary-wrapper">
|
|
136
137
|
<InfoRow label={t('admin.invoice.from')} value={data.statement_descriptor || blocklet.appName} />
|
|
137
138
|
<InfoRow label={t('admin.invoice.number')} value={data.number} />
|
|
138
139
|
<InfoRow
|
|
@@ -175,7 +176,7 @@ export default function CustomerInvoiceDetail() {
|
|
|
175
176
|
value={<CustomerLink customer={data.customer} linked={false} />}
|
|
176
177
|
/>
|
|
177
178
|
</Stack>
|
|
178
|
-
</
|
|
179
|
+
</Root>
|
|
179
180
|
<Box>
|
|
180
181
|
<SectionHeader title={t('payment.customer.invoice.details')} />
|
|
181
182
|
<InvoiceTable invoice={data} simple />
|
|
@@ -189,3 +190,15 @@ export default function CustomerInvoiceDetail() {
|
|
|
189
190
|
</Stack>
|
|
190
191
|
);
|
|
191
192
|
}
|
|
193
|
+
|
|
194
|
+
const Root = styled(Box)`
|
|
195
|
+
.invoice-summary-wrapper {
|
|
196
|
+
display: 'grid';
|
|
197
|
+
gridtemplatecolumns: '50% 50%';
|
|
198
|
+
}
|
|
199
|
+
@media (max-width: 600px) {
|
|
200
|
+
.invoice-summary-wrapper {
|
|
201
|
+
display: block !important;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
`;
|