payment-kit 1.13.129 → 1.13.131
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/libs/session.ts +2 -2
- package/blocklet.yml +1 -1
- package/package.json +4 -4
- package/src/app.tsx +2 -0
- package/src/global.css +0 -3
- package/src/pages/admin/billing/subscriptions/detail.tsx +1 -2
- package/src/pages/admin/payments/intents/detail.tsx +1 -2
- package/src/pages/customer/invoice.tsx +1 -2
- package/src/pages/customer/subscription/detail.tsx +1 -2
- package/src/components/blockchain/tx.tsx +0 -77
package/api/src/libs/session.ts
CHANGED
|
@@ -60,13 +60,13 @@ export function getCheckoutAmount(items: TLineItemExpanded[], currencyId: string
|
|
|
60
60
|
const total = items
|
|
61
61
|
.reduce((acc, x) => {
|
|
62
62
|
const price = x.upsell_price || x.price;
|
|
63
|
-
if (price
|
|
63
|
+
if (price?.type === 'recurring') {
|
|
64
64
|
renew = renew.add(new BN(getPriceUintAmountByCurrency(price, currencyId)).mul(new BN(x.quantity)));
|
|
65
65
|
|
|
66
66
|
if (includeFreeTrial) {
|
|
67
67
|
return acc;
|
|
68
68
|
}
|
|
69
|
-
if (price
|
|
69
|
+
if (price?.recurring?.usage_type === 'metered') {
|
|
70
70
|
return acc;
|
|
71
71
|
}
|
|
72
72
|
}
|
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.131",
|
|
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.23",
|
|
52
52
|
"@blocklet/logger": "1.16.23-beta-aeb9f5bd",
|
|
53
|
-
"@blocklet/payment-react": "1.13.
|
|
53
|
+
"@blocklet/payment-react": "1.13.131",
|
|
54
54
|
"@blocklet/sdk": "1.16.23-beta-aeb9f5bd",
|
|
55
55
|
"@blocklet/ui-react": "^2.9.23",
|
|
56
56
|
"@blocklet/uploader": "^0.0.69",
|
|
@@ -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.131",
|
|
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": "a1a5072b1a0c564cce5ba4aee5fc4801cfef4a46"
|
|
153
153
|
}
|
package/src/app.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import Center from '@arcblock/ux/lib/Center';
|
|
|
4
4
|
import { LocaleProvider } from '@arcblock/ux/lib/Locale/context';
|
|
5
5
|
import { ThemeProvider, createTheme } from '@arcblock/ux/lib/Theme';
|
|
6
6
|
import { ToastProvider } from '@arcblock/ux/lib/Toast';
|
|
7
|
+
import { MiniInvoiceList } from '@blocklet/payment-react';
|
|
7
8
|
import { CircularProgress } from '@mui/material';
|
|
8
9
|
import React, { Suspense } from 'react';
|
|
9
10
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
@@ -77,6 +78,7 @@ function App() {
|
|
|
77
78
|
</Layout>
|
|
78
79
|
}
|
|
79
80
|
/>
|
|
81
|
+
<Route key="subscription-embed" path="/customer/embed/subscription" element={<MiniInvoiceList />} />,
|
|
80
82
|
<Route
|
|
81
83
|
key="customer-invoice"
|
|
82
84
|
path="/customer/invoice/:id"
|
package/src/global.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 { api, formatError, formatTime } from '@blocklet/payment-react';
|
|
4
|
+
import { TxLink, api, formatError, formatTime } from '@blocklet/payment-react';
|
|
5
5
|
import type { TProduct, TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
6
6
|
import { ArrowBackOutlined, Edit } from '@mui/icons-material';
|
|
7
7
|
import { Alert, Box, Button, CircularProgress, Stack, Typography } from '@mui/material';
|
|
@@ -10,7 +10,6 @@ import { useRequest, useSetState } from 'ahooks';
|
|
|
10
10
|
import { isEmpty } from 'lodash';
|
|
11
11
|
import { Link } from 'react-router-dom';
|
|
12
12
|
|
|
13
|
-
import TxLink from '../../../../components/blockchain/tx';
|
|
14
13
|
import Copyable from '../../../../components/copyable';
|
|
15
14
|
import Currency from '../../../../components/currency';
|
|
16
15
|
import EventList from '../../../../components/event/list';
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { Amount, Status, api, formatError, formatTime } from '@blocklet/payment-react';
|
|
4
|
+
import { Amount, Status, TxLink, api, formatError, formatTime } from '@blocklet/payment-react';
|
|
5
5
|
import type { TPaymentIntentExpanded } from '@blocklet/payment-types';
|
|
6
6
|
import { ArrowBackOutlined, Edit, InfoOutlined } from '@mui/icons-material';
|
|
7
7
|
import { Alert, Box, Button, CircularProgress, Stack, Tooltip, Typography } from '@mui/material';
|
|
@@ -11,7 +11,6 @@ import { useRequest, useSetState } from 'ahooks';
|
|
|
11
11
|
import { isEmpty } from 'lodash';
|
|
12
12
|
import { Link } from 'react-router-dom';
|
|
13
13
|
|
|
14
|
-
import TxLink from '../../../../components/blockchain/tx';
|
|
15
14
|
import Copyable from '../../../../components/copyable';
|
|
16
15
|
import Currency from '../../../../components/currency';
|
|
17
16
|
import EventList from '../../../../components/event/list';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
-
import { Status, api, formatError, formatTime } from '@blocklet/payment-react';
|
|
4
|
+
import { Status, TxLink, api, formatError, formatTime } from '@blocklet/payment-react';
|
|
5
5
|
import type { TInvoiceExpanded } from '@blocklet/payment-types';
|
|
6
6
|
import { ArrowBackOutlined } from '@mui/icons-material';
|
|
7
7
|
import { Alert, Box, Button, CircularProgress, Grid, Stack, Typography } from '@mui/material';
|
|
@@ -9,7 +9,6 @@ import { useRequest, useSetState } from 'ahooks';
|
|
|
9
9
|
import { useEffect } from 'react';
|
|
10
10
|
import { Link, useParams, useSearchParams } from 'react-router-dom';
|
|
11
11
|
|
|
12
|
-
import TxLink from '../../components/blockchain/tx';
|
|
13
12
|
import Currency from '../../components/currency';
|
|
14
13
|
import InfoRow from '../../components/info-row';
|
|
15
14
|
import InvoiceTable from '../../components/invoice/table';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
import { api, formatTime } from '@blocklet/payment-react';
|
|
3
|
+
import { TxLink, api, formatTime } from '@blocklet/payment-react';
|
|
4
4
|
import type { TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
5
5
|
import { ArrowBackOutlined } from '@mui/icons-material';
|
|
6
6
|
import { Alert, Box, CircularProgress, Stack, Typography } from '@mui/material';
|
|
@@ -8,7 +8,6 @@ import { styled } from '@mui/system';
|
|
|
8
8
|
import { useRequest } from 'ahooks';
|
|
9
9
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
|
10
10
|
|
|
11
|
-
import TxLink from '../../../components/blockchain/tx';
|
|
12
11
|
import Currency from '../../../components/currency';
|
|
13
12
|
import InfoRow from '../../../components/info-row';
|
|
14
13
|
import InvoiceList from '../../../components/invoice/list';
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
|
|
2
|
-
import { OpenInNewOutlined } from '@mui/icons-material';
|
|
3
|
-
import { Link, Stack, Typography } from '@mui/material';
|
|
4
|
-
import { joinURL } from 'ufo';
|
|
5
|
-
|
|
6
|
-
const getTxLink = (method: TPaymentMethod, details: PaymentDetails) => {
|
|
7
|
-
if (method.type === 'arcblock' && details.arcblock?.tx_hash) {
|
|
8
|
-
return {
|
|
9
|
-
link: joinURL(method.settings.arcblock?.explorer_host as string, '/txs', details.arcblock?.tx_hash as string),
|
|
10
|
-
text: details.arcblock?.tx_hash as string,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
if (method.type === 'bitcoin' && details.bitcoin?.tx_hash) {
|
|
14
|
-
return {
|
|
15
|
-
link: joinURL(method.settings.bitcoin?.explorer_host as string, '/tx', details.bitcoin?.tx_hash as string),
|
|
16
|
-
text: details.bitcoin?.tx_hash as string,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
if (method.type === 'ethereum' && details.ethereum?.tx_hash) {
|
|
20
|
-
return {
|
|
21
|
-
link: joinURL(method.settings.ethereum?.explorer_host as string, '/tx', details.ethereum?.tx_hash as string),
|
|
22
|
-
text: details.ethereum?.tx_hash as string,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (method.type === 'stripe') {
|
|
26
|
-
const dashboard = method.livemode ? 'https://dashboard.stripe.com' : 'https://dashboard.stripe.com/test';
|
|
27
|
-
return {
|
|
28
|
-
link: joinURL(
|
|
29
|
-
method.settings.stripe?.dashboard || dashboard,
|
|
30
|
-
'payments',
|
|
31
|
-
details.stripe?.payment_intent_id as string
|
|
32
|
-
),
|
|
33
|
-
text: details.stripe?.payment_intent_id as string,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return { text: 'N/A', link: '' };
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
TxLink.defaultProps = {
|
|
41
|
-
mode: 'dashboard',
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default function TxLink(props: {
|
|
45
|
-
details: PaymentDetails;
|
|
46
|
-
method: TPaymentMethod;
|
|
47
|
-
mode?: 'customer' | 'dashboard';
|
|
48
|
-
}) {
|
|
49
|
-
if (!props.details || (props.mode === 'customer' && props.method.type === 'stripe')) {
|
|
50
|
-
return (
|
|
51
|
-
<Typography component="small" color="text.secondary">
|
|
52
|
-
None
|
|
53
|
-
</Typography>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const { text, link } = getTxLink(props.method, props.details);
|
|
58
|
-
|
|
59
|
-
if (link) {
|
|
60
|
-
return (
|
|
61
|
-
<Link href={link} target="_blank" rel="noopener noreferrer">
|
|
62
|
-
<Stack component="span" direction="row" alignItems="center" spacing={1}>
|
|
63
|
-
<Typography component="span" color="primary">
|
|
64
|
-
{text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join('...') : text}
|
|
65
|
-
</Typography>
|
|
66
|
-
<OpenInNewOutlined fontSize="small" />
|
|
67
|
-
</Stack>
|
|
68
|
-
</Link>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<Typography component="small" color="text.secondary">
|
|
74
|
-
None
|
|
75
|
-
</Typography>
|
|
76
|
-
);
|
|
77
|
-
}
|