payment-kit 1.13.119 → 1.13.121
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/integrations/blocklet/resource.ts +1 -0
- package/api/src/libs/resource.ts +21 -29
- package/blocklet.yml +1 -1
- package/package.json +4 -4
- package/src/components/portal/subscription/list.tsx +3 -4
- package/src/components/subscription/description.tsx +35 -0
- package/src/components/subscription/list.tsx +3 -2
- package/src/pages/admin/billing/subscriptions/detail.tsx +1 -0
- package/src/pages/customer/subscription/detail.tsx +2 -4
|
@@ -10,5 +10,6 @@ const handlePaywallResources = () => {
|
|
|
10
10
|
|
|
11
11
|
export function initResourceHandler() {
|
|
12
12
|
events.on(Events.componentAdded, handlePaywallResources);
|
|
13
|
+
events.on(Events.componentStarted, handlePaywallResources);
|
|
13
14
|
events.on(Events.envUpdate, handlePaywallResources);
|
|
14
15
|
}
|
package/api/src/libs/resource.ts
CHANGED
|
@@ -54,19 +54,17 @@ export async function initPaywallResources() {
|
|
|
54
54
|
const config: any = JSON.parse(
|
|
55
55
|
replace(fs.readFileSync(path.join(configPath!, 'config.json'), 'utf8'), {
|
|
56
56
|
...env,
|
|
57
|
-
// @ts-ignore
|
|
58
57
|
monthPrice: resource.env?.MONTH_PRICE || '5',
|
|
59
|
-
// @ts-ignore
|
|
60
58
|
yearPrice: resource.env?.YEAR_PRICE || '30',
|
|
59
|
+
passport: resource.env?.PASSPORT_NAME || 'discussionSubscriber',
|
|
61
60
|
})
|
|
62
61
|
);
|
|
63
62
|
console.info('try import paywall config', config);
|
|
64
63
|
|
|
65
|
-
if (!
|
|
64
|
+
if (!config.passport) {
|
|
66
65
|
console.warn(`invalid paywall resource from ${configPath}: passport empty`);
|
|
67
66
|
continue;
|
|
68
67
|
}
|
|
69
|
-
|
|
70
68
|
if (!config.product) {
|
|
71
69
|
console.warn(`invalid paywall resource from ${configPath}: product empty`);
|
|
72
70
|
continue;
|
|
@@ -76,7 +74,7 @@ export async function initPaywallResources() {
|
|
|
76
74
|
continue;
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
const metadata = { source: resource.did };
|
|
77
|
+
const metadata = { source: resource.did, passport: config.passport };
|
|
80
78
|
const currency = await PaymentCurrency.findOne({
|
|
81
79
|
where: { is_base_currency: true, livemode: config.product.livemode },
|
|
82
80
|
});
|
|
@@ -92,6 +90,12 @@ export async function initPaywallResources() {
|
|
|
92
90
|
if (existProduct) {
|
|
93
91
|
console.warn(`paywall resource already imported from path: ${configPath}`);
|
|
94
92
|
|
|
93
|
+
await existProduct.update({
|
|
94
|
+
name: config.product.name,
|
|
95
|
+
description: config.product.description,
|
|
96
|
+
metadata,
|
|
97
|
+
});
|
|
98
|
+
|
|
95
99
|
// @ts-ignore
|
|
96
100
|
const monthPrice = existProduct.prices.find(
|
|
97
101
|
// @ts-ignore
|
|
@@ -174,26 +178,18 @@ export async function initPaywallResources() {
|
|
|
174
178
|
});
|
|
175
179
|
console.info('payment link recreated for paywall resource', { link: link.id });
|
|
176
180
|
|
|
177
|
-
await
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
acquire: { pay: link.id },
|
|
182
|
-
})
|
|
183
|
-
)
|
|
184
|
-
);
|
|
181
|
+
await updatePassportExtra(config.passport, {
|
|
182
|
+
payment: { product: existProduct.id },
|
|
183
|
+
acquire: { pay: link.id },
|
|
184
|
+
});
|
|
185
185
|
console.info('product and payment link reassociated with passport');
|
|
186
186
|
} else {
|
|
187
187
|
const existLink = await PaymentLink.findOne({ where: { 'metadata.source': resource.did } });
|
|
188
188
|
if (existLink) {
|
|
189
|
-
await
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
acquire: { pay: existLink.id },
|
|
194
|
-
})
|
|
195
|
-
)
|
|
196
|
-
);
|
|
189
|
+
await updatePassportExtra(config.passport, {
|
|
190
|
+
payment: { product: existProduct.id },
|
|
191
|
+
acquire: { pay: existLink.id },
|
|
192
|
+
});
|
|
197
193
|
}
|
|
198
194
|
console.info('product and payment link associated with passport again');
|
|
199
195
|
}
|
|
@@ -257,14 +253,10 @@ export async function initPaywallResources() {
|
|
|
257
253
|
});
|
|
258
254
|
console.info('payment link created for paywall resource', { link: link.id });
|
|
259
255
|
|
|
260
|
-
await
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
acquire: { pay: link.id },
|
|
265
|
-
})
|
|
266
|
-
)
|
|
267
|
-
);
|
|
256
|
+
await updatePassportExtra(config.passport, {
|
|
257
|
+
payment: { product: product.id },
|
|
258
|
+
acquire: { pay: link.id },
|
|
259
|
+
});
|
|
268
260
|
console.info('product and payment link associated with passport');
|
|
269
261
|
}
|
|
270
262
|
console.info(`paywall resource successfully imported from path: ${configPath}`);
|
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.121",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "cross-env COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@arcblock/jwt": "^1.18.108",
|
|
51
51
|
"@arcblock/ux": "^2.9.19",
|
|
52
52
|
"@blocklet/logger": "1.16.23-beta-aeb9f5bd",
|
|
53
|
-
"@blocklet/payment-react": "1.13.
|
|
53
|
+
"@blocklet/payment-react": "1.13.121",
|
|
54
54
|
"@blocklet/sdk": "1.16.23-beta-aeb9f5bd",
|
|
55
55
|
"@blocklet/ui-react": "^2.9.19",
|
|
56
56
|
"@blocklet/uploader": "^0.0.67",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@abtnode/types": "1.16.23-beta-aeb9f5bd",
|
|
112
112
|
"@arcblock/eslint-config-ts": "^0.2.4",
|
|
113
|
-
"@blocklet/payment-types": "1.13.
|
|
113
|
+
"@blocklet/payment-types": "1.13.121",
|
|
114
114
|
"@types/cookie-parser": "^1.4.6",
|
|
115
115
|
"@types/cors": "^2.8.17",
|
|
116
116
|
"@types/dotenv-flow": "^3.3.3",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"parser": "typescript"
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "c02f337493cf7dac11324447534cf8684b763064"
|
|
153
153
|
}
|
|
@@ -5,7 +5,8 @@ import type { Paginated, TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
|
5
5
|
import { Avatar, AvatarGroup, Box, Button, CircularProgress, Stack, StackProps, Typography } from '@mui/material';
|
|
6
6
|
import { useInfiniteScroll } from 'ahooks';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { getSubscriptionStatusColor } from '../../../libs/util';
|
|
9
|
+
import SubscriptionDescription from '../../subscription/description';
|
|
9
10
|
import SubscriptionActions from './actions';
|
|
10
11
|
|
|
11
12
|
const fetchData = (params: Record<string, any> = {}): Promise<Paginated<TSubscriptionExpanded>> => {
|
|
@@ -96,9 +97,7 @@ export default function CurrentSubscriptions({ id, onChange, onClickSubscription
|
|
|
96
97
|
</AvatarGroup>
|
|
97
98
|
<Stack direction="column" spacing={0.5}>
|
|
98
99
|
<Stack direction="row" spacing={2} alignItems="center">
|
|
99
|
-
<
|
|
100
|
-
{formatSubscriptionProduct(subscription.items)}
|
|
101
|
-
</Typography>
|
|
100
|
+
<SubscriptionDescription subscription={subscription} />
|
|
102
101
|
<Status
|
|
103
102
|
size="small"
|
|
104
103
|
sx={{ height: 18 }}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
2
|
+
import { InfoOutlined } from '@mui/icons-material';
|
|
3
|
+
import { Stack, Tooltip, Typography } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
import { formatSubscriptionProduct } from '../../libs/util';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
subscription: TSubscriptionExpanded;
|
|
9
|
+
variant?: 'body1' | 'h5';
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default function SubscriptionDescription({ subscription, variant }: Props) {
|
|
13
|
+
if (subscription.description) {
|
|
14
|
+
return (
|
|
15
|
+
<Stack direction="row" alignItems="center" spacing={1}>
|
|
16
|
+
<Typography variant={variant} fontWeight={600}>
|
|
17
|
+
{subscription.description}
|
|
18
|
+
</Typography>
|
|
19
|
+
<Tooltip title={formatSubscriptionProduct(subscription.items)}>
|
|
20
|
+
<InfoOutlined sx={{ color: 'text.secondary' }} fontSize="small" />
|
|
21
|
+
</Tooltip>
|
|
22
|
+
</Stack>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Typography variant={variant} fontWeight={600}>
|
|
28
|
+
{formatSubscriptionProduct(subscription.items)}
|
|
29
|
+
</Typography>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
SubscriptionDescription.defaultProps = {
|
|
34
|
+
variant: 'body1',
|
|
35
|
+
};
|
|
@@ -8,9 +8,9 @@ import { useRequest } from 'ahooks';
|
|
|
8
8
|
import { useEffect, useState } from 'react';
|
|
9
9
|
import { useNavigate } from 'react-router-dom';
|
|
10
10
|
|
|
11
|
-
import { formatSubscriptionProduct } from '../../libs/util';
|
|
12
11
|
import Table from '../table';
|
|
13
12
|
import SubscriptionActions from './actions';
|
|
13
|
+
import SubscriptionDescription from './description';
|
|
14
14
|
import SubscriptionStatus from './status';
|
|
15
15
|
|
|
16
16
|
const fetchData = (params: Record<string, any> = {}): Promise<{ list: TSubscriptionExpanded[]; count: number }> => {
|
|
@@ -88,7 +88,7 @@ export default function SubscriptionList({ customer_id, features, status }: List
|
|
|
88
88
|
options: {
|
|
89
89
|
customBodyRenderLite: (_: string, index: number) => {
|
|
90
90
|
const item = data.list[index] as TSubscriptionExpanded;
|
|
91
|
-
return
|
|
91
|
+
return <SubscriptionDescription subscription={item} />;
|
|
92
92
|
},
|
|
93
93
|
},
|
|
94
94
|
},
|
|
@@ -146,6 +146,7 @@ export default function SubscriptionList({ customer_id, features, status }: List
|
|
|
146
146
|
label: t('common.customer'),
|
|
147
147
|
name: 'customer_id',
|
|
148
148
|
options: {
|
|
149
|
+
// @ts-ignore
|
|
149
150
|
customBodyRenderLite: (_: string, index: number) => {
|
|
150
151
|
const item = data.list[index] as TSubscriptionExpanded;
|
|
151
152
|
return item.customer.email;
|
|
@@ -161,6 +161,7 @@ export default function SubscriptionDetail(props: { id: string }) {
|
|
|
161
161
|
value={<TxLink details={data.payment_details} method={data.paymentMethod} />}
|
|
162
162
|
/>
|
|
163
163
|
)}
|
|
164
|
+
{!!data.description && <InfoRow label={t('common.description')} value={data.description} />}
|
|
164
165
|
</Stack>
|
|
165
166
|
</Box>
|
|
166
167
|
<Box className="section">
|
|
@@ -14,10 +14,10 @@ import InfoRow from '../../../components/info-row';
|
|
|
14
14
|
import InvoiceList from '../../../components/invoice/list';
|
|
15
15
|
import SubscriptionActions from '../../../components/portal/subscription/actions';
|
|
16
16
|
import SectionHeader from '../../../components/section/header';
|
|
17
|
+
import SubscriptionDescription from '../../../components/subscription/description';
|
|
17
18
|
import SubscriptionItemList from '../../../components/subscription/items';
|
|
18
19
|
import SubscriptionMetrics from '../../../components/subscription/metrics';
|
|
19
20
|
import SubscriptionStatus from '../../../components/subscription/status';
|
|
20
|
-
import { formatSubscriptionProduct } from '../../../libs/util';
|
|
21
21
|
|
|
22
22
|
const fetchData = (id: string | undefined): Promise<TSubscriptionExpanded> => {
|
|
23
23
|
return api.get(`/api/subscriptions/${id}`).then((res) => res.data);
|
|
@@ -53,9 +53,7 @@ export default function CustomerSubscriptionDetail() {
|
|
|
53
53
|
<Box mt={2}>
|
|
54
54
|
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
|
55
55
|
<Stack direction="row" alignItems="center">
|
|
56
|
-
<
|
|
57
|
-
{formatSubscriptionProduct(data.items)}
|
|
58
|
-
</Typography>
|
|
56
|
+
<SubscriptionDescription subscription={data} variant="h5" />
|
|
59
57
|
<SubscriptionStatus subscription={data} sx={{ ml: 1 }} />
|
|
60
58
|
</Stack>
|
|
61
59
|
<SubscriptionActions subscription={data} onChange={() => refresh()} showUpdate />
|