payment-kit 1.13.113 → 1.13.114

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/blocklet.yml CHANGED
@@ -14,7 +14,7 @@ repository:
14
14
  type: git
15
15
  url: git+https://github.com/blocklet/payment-kit.git
16
16
  specVersion: 1.2.8
17
- version: 1.13.113
17
+ version: 1.13.114
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.13.113",
3
+ "version": "1.13.114",
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.15",
52
52
  "@blocklet/logger": "1.16.23-beta-aeb9f5bd",
53
- "@blocklet/payment-react": "1.13.113",
53
+ "@blocklet/payment-react": "1.13.114",
54
54
  "@blocklet/sdk": "1.16.23-beta-aeb9f5bd",
55
55
  "@blocklet/ui-react": "^2.9.15",
56
56
  "@blocklet/uploader": "^0.0.65",
@@ -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",
113
+ "@blocklet/payment-types": "1.13.114",
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": "d1a99d9bbdb06d4e7742d7741ec511fa0fee4663"
152
+ "gitHead": "c8323e8e3322d6cb7b3a329576900bb8342d8631"
153
153
  }
@@ -1,4 +1,4 @@
1
- import { Checkout } from '@blocklet/payment-react';
1
+ import { CheckoutForm } from '@blocklet/payment-react';
2
2
 
3
3
  type Props = {
4
4
  id: string;
@@ -23,5 +23,5 @@ export default function Payment({ id }: Props) {
23
23
  }
24
24
  };
25
25
 
26
- return <Checkout mode="standalone" id={id} onPaid={onPaid} />;
26
+ return <CheckoutForm mode="standalone" id={id} onPaid={onPaid} />;
27
27
  }
@@ -1,134 +1,20 @@
1
1
  import Center from '@arcblock/ux/lib/Center';
2
- import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
- import Toast from '@arcblock/ux/lib/Toast';
4
- import { Livemode, PricingTable, ProductSkeleton, api } from '@blocklet/payment-react';
5
- import type { TPricingTableExpanded } from '@blocklet/payment-types';
2
+ import { CheckoutTable } from '@blocklet/payment-react';
6
3
  import Header from '@blocklet/ui-react/lib/Header';
7
- import { Alert, Box, Skeleton, Stack, Typography } from '@mui/material';
8
- import { useLocalStorageState, useRequest } from 'ahooks';
9
- import { useSearchParams } from 'react-router-dom';
4
+ import { Box } from '@mui/material';
10
5
 
11
6
  type Props = {
12
7
  id: string;
13
8
  };
14
9
 
15
- const fetchData = async (id: string): Promise<TPricingTableExpanded> => {
16
- const { data } = await api.get(`/api/pricing-tables/${id}`);
17
- return data;
18
- };
19
-
20
10
  export default function PricingTablePage({ id }: Props) {
21
- const { t } = useLocaleContext();
22
- const [params] = useSearchParams();
23
- const [livemode] = useLocalStorageState('livemode', { defaultValue: true });
24
- const { error, loading, data } = useRequest(() => fetchData(id));
25
-
26
- if (error) {
27
- return (
28
- <Box
29
- sx={{
30
- width: '100vw',
31
- minHeight: '90vh',
32
- pb: 4,
33
- display: 'flex',
34
- flexDirection: 'column',
35
- }}>
36
- <Header
37
- meta={undefined}
38
- addons={undefined}
39
- sessionManagerProps={undefined}
40
- homeLink={undefined}
41
- theme={undefined}
42
- />
43
- <Center relative="parent">
44
- <Alert severity="error">{error.message}</Alert>
45
- </Center>
46
- </Box>
47
- );
48
- }
49
-
50
- if (loading || !data) {
51
- return (
52
- <Box
53
- sx={{
54
- width: '100vw',
55
- minHeight: '90vh',
56
- pb: 4,
57
- display: 'flex',
58
- flexDirection: 'column',
59
- }}>
60
- <Header
61
- meta={undefined}
62
- addons={undefined}
63
- sessionManagerProps={undefined}
64
- homeLink={undefined}
65
- theme={undefined}
66
- />
67
- <Center>
68
- <Stack direction="column" alignItems="center" spacing={4}>
69
- <Typography component="div" variant="h3" sx={{ width: '40%' }}>
70
- <Skeleton />
71
- </Typography>
72
- <Typography component="div" variant="h6" sx={{ width: '10%' }}>
73
- <Skeleton />
74
- </Typography>
75
- <Stack flexWrap="wrap" direction="row" gap={{ xs: 3, sm: 5, md: 10 }} justifyContent="center">
76
- <ProductSkeleton key={1} count={2} />
77
- <ProductSkeleton key={2} count={3} />
78
- <ProductSkeleton key={3} count={4} />
79
- </Stack>
80
- </Stack>
81
- </Center>
82
- </Box>
83
- );
84
- }
85
-
86
- if (data.items.length === 0) {
87
- return (
88
- <Box
89
- sx={{
90
- width: '100vw',
91
- minHeight: '90vh',
92
- pb: 4,
93
- display: 'flex',
94
- flexDirection: 'column',
95
- }}>
96
- <Header
97
- meta={undefined}
98
- addons={undefined}
99
- sessionManagerProps={undefined}
100
- homeLink={undefined}
101
- theme={undefined}
102
- />
103
- <Center relative="parent">
104
- <Alert severity="warning">{t('payment.checkout.noPricing')}</Alert>
105
- </Center>
106
- </Box>
107
- );
108
- }
109
-
110
- const onStartCheckoutSession = (priceId: string) => {
111
- api
112
- .post(`/api/pricing-tables/${data.id}/checkout/${priceId}?${params.toString()}`)
113
- .then((res) => {
114
- window.location.href = res.data.url;
115
- })
116
- .catch((err) => {
117
- console.error(err);
118
- Toast.error(err.message);
119
- });
120
- };
121
-
122
11
  return (
123
12
  <Box
124
13
  sx={{
125
14
  width: '100vw',
126
15
  minHeight: '90vh',
127
16
  pb: 4,
128
- display: {
129
- xs: 'block',
130
- sm: 'flex',
131
- },
17
+ display: 'flex',
132
18
  flexDirection: 'column',
133
19
  }}>
134
20
  <Header
@@ -139,13 +25,7 @@ export default function PricingTablePage({ id }: Props) {
139
25
  theme={undefined}
140
26
  />
141
27
  <Center relative="parent">
142
- <Stack direction="column" alignItems="center" spacing={4}>
143
- <Typography variant="h4" color="text.primary" fontWeight={600}>
144
- {data.name}
145
- {!livemode && <Livemode />}
146
- </Typography>
147
- <PricingTable table={data} onSelect={onStartCheckoutSession} />
148
- </Stack>
28
+ <CheckoutTable id={id} mode="standalone" />;
149
29
  </Center>
150
30
  </Box>
151
31
  );