payment-kit 1.13.211 → 1.13.213
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/subscription/portal/actions.tsx +12 -6
- package/src/components/subscription/portal/list.tsx +5 -1
- 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.213",
|
|
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.213",
|
|
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.213",
|
|
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": "209467c5da3ab2fa17f5ce802bcd8b086e7c08e5"
|
|
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
|
+
`;
|
|
@@ -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
|
+
};
|
|
@@ -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
|
+
`;
|