payment-kit 1.15.21 → 1.15.23
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/index.ts +2 -1
- package/api/src/libs/audit.ts +4 -1
- package/api/src/libs/context.ts +48 -0
- package/api/src/libs/invoice.ts +2 -2
- package/api/src/libs/middleware.ts +39 -1
- package/api/src/queues/checkout-session.ts +15 -0
- package/api/src/queues/event.ts +13 -4
- package/api/src/queues/invoice.ts +21 -3
- package/api/src/queues/payment.ts +3 -0
- package/api/src/queues/refund.ts +3 -0
- package/api/src/queues/usage-record.ts +4 -0
- package/api/src/queues/webhook.ts +9 -0
- package/api/src/routes/checkout-sessions.ts +40 -2
- package/api/src/routes/donations.ts +5 -1
- package/api/src/routes/events.ts +9 -4
- package/api/src/routes/invoices.ts +24 -24
- package/api/src/routes/payment-links.ts +40 -20
- package/api/src/routes/prices.ts +17 -4
- package/api/src/routes/products.ts +21 -2
- package/api/src/routes/refunds.ts +20 -3
- package/api/src/routes/subscription-items.ts +39 -2
- package/api/src/routes/subscriptions.ts +36 -4
- package/api/src/routes/usage-records.ts +29 -0
- package/api/src/store/models/event.ts +1 -0
- package/blocklet.yml +1 -1
- package/package.json +4 -4
- package/src/components/webhook/attempts.tsx +122 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import CodeBlock from '@arcblock/ux/lib/CodeBlock';
|
|
3
3
|
import { api, formatTime } from '@blocklet/payment-react';
|
|
4
4
|
import type { Paginated, TEvent, TWebhookAttemptExpanded } from '@blocklet/payment-types';
|
|
5
|
-
import { CheckCircleOutlined, ErrorOutlined } from '@mui/icons-material';
|
|
5
|
+
import { CheckCircleOutlined, ErrorOutlined, InfoOutlined } from '@mui/icons-material';
|
|
6
6
|
import {
|
|
7
7
|
Box,
|
|
8
8
|
Button,
|
|
@@ -15,12 +15,15 @@ import {
|
|
|
15
15
|
ListSubheader,
|
|
16
16
|
Stack,
|
|
17
17
|
Typography,
|
|
18
|
+
Popper,
|
|
19
|
+
Paper,
|
|
18
20
|
} from '@mui/material';
|
|
19
21
|
import { useInfiniteScroll } from 'ahooks';
|
|
20
22
|
import React, { useEffect, useState } from 'react';
|
|
21
23
|
|
|
22
24
|
import { isEmpty } from 'lodash';
|
|
23
25
|
import { isSuccessAttempt } from '../../libs/util';
|
|
26
|
+
import InfoCard from '../info-card';
|
|
24
27
|
|
|
25
28
|
const fetchData = (params: Record<string, any> = {}): Promise<Paginated<TWebhookAttemptExpanded>> => {
|
|
26
29
|
const search = new URLSearchParams();
|
|
@@ -45,7 +48,7 @@ const groupAttemptsByDate = (attempts: TWebhookAttemptExpanded[]) => {
|
|
|
45
48
|
type Props = {
|
|
46
49
|
event_id?: string;
|
|
47
50
|
webhook_endpoint_id?: string;
|
|
48
|
-
event?: TEvent;
|
|
51
|
+
event?: TEvent & { requestInfo?: { avatar: string; email: string; did: string } };
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
WebhookAttempts.defaultProps = {
|
|
@@ -82,6 +85,35 @@ export default function WebhookAttempts({ event_id, webhook_endpoint_id, event }
|
|
|
82
85
|
setSelected(attempt);
|
|
83
86
|
};
|
|
84
87
|
|
|
88
|
+
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
89
|
+
|
|
90
|
+
const handleClick = (e: React.MouseEvent<HTMLElement>) => {
|
|
91
|
+
setAnchorEl(anchorEl ? null : e.currentTarget);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const handleClickOutside = (e: MouseEvent) => {
|
|
96
|
+
if (anchorEl && !anchorEl.contains(e.target as Node) && !(e.target as Element).closest('.popper-content')) {
|
|
97
|
+
setAnchorEl(null);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const handleScroll = (e: Event) => {
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
if (anchorEl && !e.target?.closest('.popper-content')) {
|
|
104
|
+
setAnchorEl(null);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
document.addEventListener('click', handleClickOutside);
|
|
109
|
+
window.addEventListener('scroll', handleScroll, true);
|
|
110
|
+
|
|
111
|
+
return () => {
|
|
112
|
+
document.removeEventListener('click', handleClickOutside);
|
|
113
|
+
window.removeEventListener('scroll', handleScroll, true);
|
|
114
|
+
};
|
|
115
|
+
}, [anchorEl]);
|
|
116
|
+
|
|
85
117
|
if (loading) {
|
|
86
118
|
return <CircularProgress />;
|
|
87
119
|
}
|
|
@@ -146,7 +178,94 @@ export default function WebhookAttempts({ event_id, webhook_endpoint_id, event }
|
|
|
146
178
|
)}
|
|
147
179
|
{data?.list.length === 0 && event && (
|
|
148
180
|
<Box>
|
|
149
|
-
<
|
|
181
|
+
<Stack direction="row" alignItems="center" spacing={1}>
|
|
182
|
+
<Typography variant="h6">Event Data</Typography>
|
|
183
|
+
<>
|
|
184
|
+
{/* @ts-ignore */}
|
|
185
|
+
<InfoOutlined
|
|
186
|
+
fontSize="small"
|
|
187
|
+
onClick={handleClick}
|
|
188
|
+
sx={{
|
|
189
|
+
color: 'text.secondary',
|
|
190
|
+
opacity: 0.6,
|
|
191
|
+
cursor: 'pointer',
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
<Popper
|
|
195
|
+
open={Boolean(anchorEl)}
|
|
196
|
+
anchorEl={anchorEl}
|
|
197
|
+
placement="right"
|
|
198
|
+
sx={{
|
|
199
|
+
zIndex: 1000,
|
|
200
|
+
'@media (max-width: 600px)': {
|
|
201
|
+
'& .MuiPaper-root': {
|
|
202
|
+
width: 'calc(100vw - 32px)',
|
|
203
|
+
maxWidth: 'none',
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
}}
|
|
207
|
+
modifiers={[
|
|
208
|
+
{
|
|
209
|
+
name: 'preventOverflow',
|
|
210
|
+
options: {
|
|
211
|
+
boundary: window,
|
|
212
|
+
altAxis: true,
|
|
213
|
+
padding: 16,
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: 'flip',
|
|
218
|
+
options: {
|
|
219
|
+
fallbackPlacements: ['bottom'],
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'matchWidth',
|
|
224
|
+
enabled: true,
|
|
225
|
+
fn: ({ state }) => {
|
|
226
|
+
if (window.innerWidth <= 600) {
|
|
227
|
+
state.styles.popper = {
|
|
228
|
+
...state.styles.popper,
|
|
229
|
+
width: 'calc(100vw - 32px)',
|
|
230
|
+
maxWidth: 'none',
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
return state;
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
]}>
|
|
237
|
+
<Paper
|
|
238
|
+
className="popper-content"
|
|
239
|
+
elevation={3}
|
|
240
|
+
sx={{
|
|
241
|
+
p: 2,
|
|
242
|
+
border: '1px solid',
|
|
243
|
+
borderColor: 'divider',
|
|
244
|
+
maxWidth: 300,
|
|
245
|
+
'@media (max-width: 600px)': {
|
|
246
|
+
maxWidth: 'none',
|
|
247
|
+
margin: '0 auto',
|
|
248
|
+
},
|
|
249
|
+
}}>
|
|
250
|
+
{event.requestInfo ? (
|
|
251
|
+
<>
|
|
252
|
+
<Typography variant="caption" color="text.secondary" sx={{ mb: 1, display: 'block' }}>
|
|
253
|
+
Requested by:
|
|
254
|
+
</Typography>
|
|
255
|
+
<InfoCard
|
|
256
|
+
logo={event.requestInfo.avatar}
|
|
257
|
+
name={event.requestInfo.email}
|
|
258
|
+
description={event.requestInfo.did || event.request.requested_by}
|
|
259
|
+
size={40}
|
|
260
|
+
/>
|
|
261
|
+
</>
|
|
262
|
+
) : (
|
|
263
|
+
<Typography>Requested by: {event.request?.requested_by || 'system'}</Typography>
|
|
264
|
+
)}
|
|
265
|
+
</Paper>
|
|
266
|
+
</Popper>
|
|
267
|
+
</>
|
|
268
|
+
</Stack>
|
|
150
269
|
<CodeBlock language="json">{JSON.stringify(event.data, null, 2)}</CodeBlock>
|
|
151
270
|
</Box>
|
|
152
271
|
)}
|