payment-kit 1.18.56 → 1.19.1

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.
Files changed (214) hide show
  1. package/.eslintrc.js +6 -0
  2. package/api/src/crons/index.ts +8 -0
  3. package/api/src/index.ts +4 -0
  4. package/api/src/libs/credit-grant.ts +146 -0
  5. package/api/src/libs/env.ts +1 -0
  6. package/api/src/libs/invoice.ts +4 -3
  7. package/api/src/libs/notification/template/base.ts +388 -2
  8. package/api/src/libs/notification/template/customer-credit-grant-granted.ts +149 -0
  9. package/api/src/libs/notification/template/customer-credit-grant-low-balance.ts +151 -0
  10. package/api/src/libs/notification/template/customer-credit-insufficient.ts +254 -0
  11. package/api/src/libs/notification/template/subscription-canceled.ts +193 -202
  12. package/api/src/libs/notification/template/subscription-refund-succeeded.ts +215 -237
  13. package/api/src/libs/notification/template/subscription-renewed.ts +130 -200
  14. package/api/src/libs/notification/template/subscription-succeeded.ts +100 -202
  15. package/api/src/libs/notification/template/subscription-trial-start.ts +142 -188
  16. package/api/src/libs/notification/template/subscription-trial-will-end.ts +146 -174
  17. package/api/src/libs/notification/template/subscription-upgraded.ts +96 -192
  18. package/api/src/libs/notification/template/subscription-will-canceled.ts +94 -135
  19. package/api/src/libs/notification/template/subscription-will-renew.ts +220 -245
  20. package/api/src/libs/payment.ts +69 -0
  21. package/api/src/libs/queue/index.ts +3 -2
  22. package/api/src/libs/session.ts +8 -0
  23. package/api/src/libs/subscription.ts +74 -3
  24. package/api/src/libs/ws.ts +23 -1
  25. package/api/src/locales/en.ts +33 -0
  26. package/api/src/locales/zh.ts +31 -0
  27. package/api/src/queues/credit-consume.ts +715 -0
  28. package/api/src/queues/credit-grant.ts +572 -0
  29. package/api/src/queues/notification.ts +173 -128
  30. package/api/src/queues/payment.ts +210 -122
  31. package/api/src/queues/subscription.ts +179 -0
  32. package/api/src/routes/checkout-sessions.ts +157 -9
  33. package/api/src/routes/connect/shared.ts +3 -2
  34. package/api/src/routes/credit-grants.ts +241 -0
  35. package/api/src/routes/credit-transactions.ts +208 -0
  36. package/api/src/routes/index.ts +8 -0
  37. package/api/src/routes/meter-events.ts +347 -0
  38. package/api/src/routes/meters.ts +219 -0
  39. package/api/src/routes/payment-currencies.ts +14 -2
  40. package/api/src/routes/payment-links.ts +1 -1
  41. package/api/src/routes/payment-methods.ts +14 -2
  42. package/api/src/routes/prices.ts +43 -0
  43. package/api/src/routes/pricing-table.ts +13 -7
  44. package/api/src/routes/products.ts +63 -4
  45. package/api/src/routes/settings.ts +1 -1
  46. package/api/src/routes/subscriptions.ts +4 -0
  47. package/api/src/store/migrations/20250610-billing-credit.ts +43 -0
  48. package/api/src/store/models/credit-grant.ts +486 -0
  49. package/api/src/store/models/credit-transaction.ts +268 -0
  50. package/api/src/store/models/customer.ts +8 -0
  51. package/api/src/store/models/index.ts +52 -1
  52. package/api/src/store/models/meter-event.ts +423 -0
  53. package/api/src/store/models/meter.ts +176 -0
  54. package/api/src/store/models/payment-currency.ts +66 -14
  55. package/api/src/store/models/price.ts +6 -0
  56. package/api/src/store/models/product.ts +2 -2
  57. package/api/src/store/models/subscription.ts +24 -0
  58. package/api/src/store/models/types.ts +28 -2
  59. package/api/tests/libs/subscription.spec.ts +53 -0
  60. package/blocklet.yml +9 -1
  61. package/package.json +57 -58
  62. package/scripts/sdk.js +233 -1
  63. package/src/app.tsx +10 -0
  64. package/src/components/actions.tsx +22 -9
  65. package/src/components/balance-list.tsx +40 -12
  66. package/src/components/collapse.tsx +33 -15
  67. package/src/components/copyable.tsx +8 -7
  68. package/src/components/currency.tsx +15 -7
  69. package/src/components/customer/actions.tsx +1 -5
  70. package/src/components/customer/credit-grant-item-list.tsx +99 -0
  71. package/src/components/customer/credit-overview.tsx +233 -0
  72. package/src/components/customer/form.tsx +7 -2
  73. package/src/components/customer/link.tsx +4 -12
  74. package/src/components/customer/notification-preference.tsx +18 -9
  75. package/src/components/customer/overdraft-protection.tsx +112 -41
  76. package/src/components/drawer-form.tsx +42 -18
  77. package/src/components/error.tsx +1 -5
  78. package/src/components/event/list.tsx +9 -10
  79. package/src/components/filter-toolbar.tsx +20 -19
  80. package/src/components/info-card.tsx +32 -18
  81. package/src/components/info-metric.tsx +16 -6
  82. package/src/components/info-row-group.tsx +1 -7
  83. package/src/components/info-row.tsx +30 -24
  84. package/src/components/invoice/action.tsx +1 -7
  85. package/src/components/invoice/list.tsx +34 -26
  86. package/src/components/invoice/recharge.tsx +5 -7
  87. package/src/components/invoice/table.tsx +17 -12
  88. package/src/components/layout/user.tsx +1 -1
  89. package/src/components/metadata/form.tsx +290 -94
  90. package/src/components/metadata/list.tsx +11 -3
  91. package/src/components/meter/actions.tsx +101 -0
  92. package/src/components/meter/add-usage-dialog.tsx +239 -0
  93. package/src/components/meter/events-list.tsx +657 -0
  94. package/src/components/meter/form.tsx +245 -0
  95. package/src/components/meter/products.tsx +264 -0
  96. package/src/components/meter/usage-guide.tsx +174 -0
  97. package/src/components/passport/actions.tsx +9 -4
  98. package/src/components/payment-currency/add.tsx +16 -3
  99. package/src/components/payment-currency/form.tsx +14 -6
  100. package/src/components/payment-intent/actions.tsx +24 -16
  101. package/src/components/payment-intent/list.tsx +30 -9
  102. package/src/components/payment-link/actions.tsx +1 -5
  103. package/src/components/payment-link/after-pay.tsx +4 -2
  104. package/src/components/payment-link/before-pay.tsx +14 -4
  105. package/src/components/payment-link/item.tsx +27 -6
  106. package/src/components/payment-link/preview.tsx +9 -9
  107. package/src/components/payment-link/product-select.tsx +69 -15
  108. package/src/components/payment-method/arcblock.tsx +8 -1
  109. package/src/components/payment-method/base.tsx +8 -1
  110. package/src/components/payment-method/bitcoin.tsx +8 -1
  111. package/src/components/payment-method/ethereum.tsx +8 -1
  112. package/src/components/payment-method/evm-rpc-input.tsx +11 -7
  113. package/src/components/payment-method/form.tsx +2 -7
  114. package/src/components/payment-method/stripe.tsx +2 -0
  115. package/src/components/payouts/actions.tsx +1 -5
  116. package/src/components/payouts/list.tsx +30 -10
  117. package/src/components/payouts/portal/list.tsx +11 -9
  118. package/src/components/price/currency-select.tsx +63 -32
  119. package/src/components/price/form.tsx +895 -370
  120. package/src/components/price/upsell-select.tsx +10 -2
  121. package/src/components/price/upsell.tsx +7 -2
  122. package/src/components/pricing-table/actions.tsx +1 -5
  123. package/src/components/pricing-table/customer-settings.tsx +5 -1
  124. package/src/components/pricing-table/payment-settings.tsx +14 -4
  125. package/src/components/pricing-table/preview.tsx +9 -9
  126. package/src/components/pricing-table/price-item.tsx +6 -1
  127. package/src/components/pricing-table/product-item.tsx +6 -1
  128. package/src/components/pricing-table/product-settings.tsx +17 -4
  129. package/src/components/product/actions.tsx +1 -5
  130. package/src/components/product/add-price.tsx +9 -7
  131. package/src/components/product/create.tsx +8 -9
  132. package/src/components/product/cross-sell-select.tsx +5 -1
  133. package/src/components/product/cross-sell.tsx +7 -2
  134. package/src/components/product/edit-price.tsx +21 -12
  135. package/src/components/product/features.tsx +26 -6
  136. package/src/components/product/form.tsx +115 -72
  137. package/src/components/progress-bar.tsx +1 -1
  138. package/src/components/refund/actions.tsx +1 -7
  139. package/src/components/refund/list.tsx +31 -18
  140. package/src/components/section/header.tsx +12 -14
  141. package/src/components/subscription/actions/cancel.tsx +22 -5
  142. package/src/components/subscription/actions/index.tsx +9 -10
  143. package/src/components/subscription/actions/pause.tsx +32 -6
  144. package/src/components/subscription/actions/slash-stake.tsx +5 -3
  145. package/src/components/subscription/description.tsx +12 -8
  146. package/src/components/subscription/items/index.tsx +31 -16
  147. package/src/components/subscription/items/usage-records.tsx +19 -5
  148. package/src/components/subscription/list.tsx +5 -7
  149. package/src/components/subscription/metrics.tsx +62 -15
  150. package/src/components/subscription/portal/actions.tsx +78 -71
  151. package/src/components/subscription/portal/cancel.tsx +10 -3
  152. package/src/components/subscription/portal/list.tsx +48 -26
  153. package/src/components/uploader.tsx +5 -13
  154. package/src/components/webhook/attempts.tsx +51 -16
  155. package/src/components/webhook/request-info.tsx +8 -6
  156. package/src/contexts/products.tsx +27 -10
  157. package/src/hooks/subscription.ts +34 -0
  158. package/src/libs/meter-utils.ts +196 -0
  159. package/src/libs/util.ts +4 -0
  160. package/src/locales/en.tsx +385 -4
  161. package/src/locales/zh.tsx +364 -0
  162. package/src/pages/admin/billing/index.tsx +61 -33
  163. package/src/pages/admin/billing/invoices/detail.tsx +49 -13
  164. package/src/pages/admin/billing/meters/create.tsx +60 -0
  165. package/src/pages/admin/billing/meters/detail.tsx +435 -0
  166. package/src/pages/admin/billing/meters/index.tsx +210 -0
  167. package/src/pages/admin/billing/meters/meter-event.tsx +346 -0
  168. package/src/pages/admin/billing/subscriptions/detail.tsx +90 -25
  169. package/src/pages/admin/customers/customers/credit-grant/detail.tsx +391 -0
  170. package/src/pages/admin/customers/customers/detail.tsx +67 -14
  171. package/src/pages/admin/customers/customers/index.tsx +6 -1
  172. package/src/pages/admin/customers/index.tsx +5 -0
  173. package/src/pages/admin/developers/events/detail.tsx +37 -11
  174. package/src/pages/admin/developers/index.tsx +1 -1
  175. package/src/pages/admin/developers/webhooks/detail.tsx +41 -11
  176. package/src/pages/admin/index.tsx +15 -2
  177. package/src/pages/admin/overview.tsx +107 -19
  178. package/src/pages/admin/payments/intents/detail.tsx +58 -14
  179. package/src/pages/admin/payments/payouts/detail.tsx +63 -15
  180. package/src/pages/admin/payments/refunds/detail.tsx +58 -14
  181. package/src/pages/admin/products/index.tsx +11 -4
  182. package/src/pages/admin/products/links/create.tsx +22 -4
  183. package/src/pages/admin/products/links/detail.tsx +43 -14
  184. package/src/pages/admin/products/passports/index.tsx +23 -4
  185. package/src/pages/admin/products/prices/actions.tsx +16 -9
  186. package/src/pages/admin/products/prices/detail.tsx +73 -14
  187. package/src/pages/admin/products/prices/list.tsx +15 -3
  188. package/src/pages/admin/products/pricing-tables/create.tsx +45 -12
  189. package/src/pages/admin/products/pricing-tables/detail.tsx +45 -14
  190. package/src/pages/admin/products/products/create.tsx +233 -54
  191. package/src/pages/admin/products/products/detail.tsx +74 -18
  192. package/src/pages/admin/settings/index.tsx +8 -1
  193. package/src/pages/admin/settings/payment-methods/index.tsx +87 -19
  194. package/src/pages/admin/settings/vault-config/edit-form.tsx +42 -28
  195. package/src/pages/admin/settings/vault-config/index.tsx +57 -10
  196. package/src/pages/customer/credit-grant/detail.tsx +308 -0
  197. package/src/pages/customer/index.tsx +76 -17
  198. package/src/pages/customer/invoice/detail.tsx +63 -14
  199. package/src/pages/customer/invoice/past-due.tsx +11 -3
  200. package/src/pages/customer/payout/detail.tsx +56 -13
  201. package/src/pages/customer/recharge/account.tsx +78 -18
  202. package/src/pages/customer/recharge/subscription.tsx +86 -25
  203. package/src/pages/customer/refund/list.tsx +60 -24
  204. package/src/pages/customer/subscription/change-payment.tsx +17 -6
  205. package/src/pages/customer/subscription/change-plan.tsx +34 -7
  206. package/src/pages/customer/subscription/detail.tsx +134 -34
  207. package/src/pages/customer/subscription/embed.tsx +25 -5
  208. package/src/pages/home.tsx +26 -4
  209. package/src/pages/integrations/donations/edit-form.tsx +25 -9
  210. package/src/pages/integrations/donations/index.tsx +26 -9
  211. package/src/pages/integrations/donations/preview.tsx +59 -15
  212. package/src/pages/integrations/index.tsx +10 -1
  213. package/src/pages/integrations/overview.tsx +78 -17
  214. package/vite.config.ts +60 -30
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/prop-types */
1
2
  import { getWordBreakStyle } from '@blocklet/payment-react';
2
3
  import { Avatar, Stack, SxProps, Typography, Tooltip } from '@mui/material';
3
4
  import type { LiteralUnion } from 'type-fest';
@@ -14,17 +15,31 @@ type Props = {
14
15
  tooltip?: string | React.ReactNode;
15
16
  };
16
17
 
17
- export default function InfoCard(props: Props) {
18
+ export default function InfoCard(rawProps: Props) {
19
+ const props = Object.assign(
20
+ {
21
+ logo: '',
22
+ size: 40,
23
+ variant: 'rounded',
24
+ sx: {},
25
+ className: '',
26
+ logoName: '',
27
+ tooltip: false,
28
+ },
29
+ rawProps
30
+ );
18
31
  const dimensions = { width: props.size, height: props.size, ...props.sx };
19
32
  const avatarName = typeof props.name === 'string' ? props.name : props.logo;
20
33
 
21
34
  const cardContent = (
22
35
  <Stack
23
36
  direction="row"
24
- alignItems="center"
25
37
  spacing={1}
26
38
  className={`info-card-wrapper ${props.className}`}
27
- sx={{ cursor: props.tooltip ? 'pointer' : 'default' }}>
39
+ sx={{
40
+ alignItems: 'center',
41
+ cursor: props.tooltip ? 'pointer' : 'default',
42
+ }}>
28
43
  {props.logo ? (
29
44
  <Avatar src={props.logo} alt={props.logoName ?? avatarName} variant={props.variant as any} sx={dimensions} />
30
45
  ) : (
@@ -34,18 +49,27 @@ export default function InfoCard(props: Props) {
34
49
  )}
35
50
  <Stack
36
51
  direction="column"
37
- alignItems="flex-start"
38
- justifyContent="space-around"
39
52
  className="info-card"
40
53
  sx={{
54
+ alignItems: 'flex-start',
55
+ justifyContent: 'space-around',
41
56
  wordBreak: getWordBreakStyle(props.name),
42
57
  minWidth: 140,
43
58
  }}>
44
- <Typography variant="body2" color="text.primary" component="div">
59
+ <Typography
60
+ variant="body2"
61
+ component="div"
62
+ sx={{
63
+ color: 'text.primary',
64
+ }}>
45
65
  {props.name}
46
66
  </Typography>
47
67
  {props.description && (
48
- <Typography variant="subtitle2" color="text.secondary">
68
+ <Typography
69
+ variant="subtitle2"
70
+ sx={{
71
+ color: 'text.secondary',
72
+ }}>
49
73
  {props.description}
50
74
  </Typography>
51
75
  )}
@@ -58,7 +82,7 @@ export default function InfoCard(props: Props) {
58
82
  <Tooltip
59
83
  title={props.tooltip}
60
84
  placement="top-start"
61
- componentsProps={{
85
+ slotProps={{
62
86
  tooltip: {
63
87
  sx: {
64
88
  bgcolor: 'background.paper',
@@ -90,13 +114,3 @@ export default function InfoCard(props: Props) {
90
114
 
91
115
  return cardContent;
92
116
  }
93
-
94
- InfoCard.defaultProps = {
95
- logo: '',
96
- size: 40,
97
- variant: 'rounded',
98
- sx: {},
99
- className: '',
100
- logoName: '',
101
- tooltip: false,
102
- };
@@ -10,15 +10,28 @@ type Props = {
10
10
  divider?: boolean;
11
11
  };
12
12
 
13
- export default function InfoMetric(props: Props) {
13
+ export default function InfoMetric(rawProps: Props) {
14
+ const props = Object.assign(
15
+ {
16
+ tip: '',
17
+ divider: false,
18
+ },
19
+ rawProps
20
+ );
21
+
14
22
  const { t } = useLocaleContext();
23
+ // eslint-disable-next-line react/prop-types
15
24
  const isNone = isEmptyExceptNumber(props.value);
16
25
  return (
17
26
  <>
18
27
  <Stack direction="column" alignItems="flex-start">
19
28
  <Typography component="div" variant="subtitle2" mb={1} color="text.primary">
29
+ {/* eslint-disable-next-line react/prop-types */}
20
30
  {props.label}
31
+ {/* eslint-disable-next-line react/prop-types */}
32
+ {/* eslint-disable-next-line react/prop-types */}
21
33
  {!!props.tip && (
34
+ // eslint-disable-next-line react/prop-types
22
35
  <Tooltip title={props.tip}>
23
36
  <InfoOutlined fontSize="small" />
24
37
  </Tooltip>
@@ -29,15 +42,12 @@ export default function InfoMetric(props: Props) {
29
42
  variant="body1"
30
43
  color={isNone ? 'text.disabled' : 'text.secondary'}
31
44
  sx={{ width: '100%', minHeight: '24px' }}>
45
+ {/* eslint-disable-next-line react/prop-types */}
32
46
  {isNone ? t('common.none') : props.value}
33
47
  </Typography>
34
48
  </Stack>
49
+ {/* eslint-disable-next-line react/prop-types */}
35
50
  {props.divider && <Divider orientation="vertical" flexItem />}
36
51
  </>
37
52
  );
38
53
  }
39
-
40
- InfoMetric.defaultProps = {
41
- tip: '',
42
- divider: false,
43
- };
@@ -98,7 +98,7 @@ function InfoRowGroup({ children, loading = false, skeletonHeight = 24, sx = {}
98
98
  },
99
99
  },
100
100
  };
101
- return cloneElement(child as ReactElement, childProps);
101
+ return cloneElement(child as ReactElement<any>, childProps);
102
102
  }
103
103
  return child;
104
104
  });
@@ -113,10 +113,4 @@ function InfoRowGroup({ children, loading = false, skeletonHeight = 24, sx = {}
113
113
  );
114
114
  }
115
115
 
116
- InfoRowGroup.defaultProps = {
117
- loading: false,
118
- skeletonHeight: 24,
119
- sx: {},
120
- };
121
-
122
116
  export default InfoRowGroup;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/prop-types */
1
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
3
  import { Box, Stack, SxProps } from '@mui/material';
3
4
  import { useContext } from 'react';
@@ -16,16 +17,18 @@ type Props = {
16
17
  showLabel?: boolean;
17
18
  };
18
19
 
19
- InfoRow.defaultProps = {
20
- value: undefined,
21
- sizes: [1, 3],
22
- alignItems: 'center',
23
- direction: 'row',
24
- sx: {},
25
- showLabel: true,
26
- };
27
-
28
- export default function InfoRow(props: Props) {
20
+ export default function InfoRow(rawProps: Props) {
21
+ const props = Object.assign(
22
+ {
23
+ value: undefined,
24
+ sizes: [1, 3],
25
+ alignItems: 'center',
26
+ direction: 'row',
27
+ sx: {},
28
+ showLabel: true,
29
+ },
30
+ rawProps
31
+ );
29
32
  const { t } = useLocaleContext();
30
33
  const isNone = isEmptyExceptNumber(props.value);
31
34
  const sizes = props.sizes || [1, 3];
@@ -33,31 +36,33 @@ export default function InfoRow(props: Props) {
33
36
  return (
34
37
  <Stack
35
38
  direction={props.direction || 'row'}
36
- alignItems={props.alignItems}
37
- justifyContent="space-between"
38
- flexWrap="wrap"
39
- gap={1}
39
+ className="info-row-wrapper"
40
40
  sx={{
41
+ alignItems: props.alignItems,
42
+ justifyContent: 'space-between',
43
+ flexWrap: 'wrap',
44
+ gap: 1,
41
45
  mb: 2,
42
46
  ...props.sx,
47
+
43
48
  a: {
44
49
  color: 'text.link',
45
50
  },
46
- }}
47
- className="info-row-wrapper">
51
+ }}>
48
52
  {props.showLabel && (
49
53
  <Box
50
- flex={sizes[0]}
51
54
  className="info-row-label"
52
- color="text.primary"
53
- fontSize={14}
54
55
  sx={{
56
+ color: 'text.primary',
57
+ fontSize: 14,
55
58
  flex: props.direction === 'column' ? 'none' : sizes[0],
56
59
  mb: props.direction === 'column' ? 0.5 : 0,
60
+
57
61
  ...(inGroup && {
58
62
  flex: 'none',
59
63
  whiteSpace: 'nowrap',
60
64
  }),
65
+
61
66
  fontWeight: {
62
67
  xs: 500,
63
68
  md: 400,
@@ -66,13 +71,14 @@ export default function InfoRow(props: Props) {
66
71
  {props.label}
67
72
  </Box>
68
73
  )}
69
-
70
74
  <Box
71
- flex={sizes[1]}
72
- color={isNone ? 'text.disabled' : 'text.secondary'}
73
75
  className="info-row-value"
74
- fontSize={14}
75
- sx={{ wordBreak: getWordBreakStyle(props.value) }}>
76
+ sx={{
77
+ flex: sizes[1],
78
+ color: isNone ? 'text.disabled' : 'text.secondary',
79
+ fontSize: 14,
80
+ wordBreak: getWordBreakStyle(props.value),
81
+ }}>
76
82
  {isNone ? t('common.none') : props.value}
77
83
  </Box>
78
84
  </Stack>
@@ -17,17 +17,11 @@ type Props = {
17
17
  mode?: 'admin' | 'customer';
18
18
  };
19
19
 
20
- InvoiceActions.defaultProps = {
21
- variant: 'compact',
22
-
23
- mode: 'admin',
24
- };
25
-
26
20
  const fetchStakingData = (id: string): Promise<{ value: string }> => {
27
21
  return api.get(`/api/invoices/${id}/return-stake`).then((res: any) => res.data);
28
22
  };
29
23
 
30
- export default function InvoiceActions({ data, variant, onChange, mode }: Props) {
24
+ export default function InvoiceActions({ data, variant = 'compact', onChange, mode = 'admin' }: Props) {
31
25
  const { t } = useLocaleContext();
32
26
  const navigate = useNavigate();
33
27
  const [state, setState] = useSetState({
@@ -12,7 +12,7 @@ import {
12
12
  getTxLink,
13
13
  } from '@blocklet/payment-react';
14
14
  import type { TInvoiceExpanded } from '@blocklet/payment-types';
15
- import { CircularProgress, Typography } from '@mui/material';
15
+ import { Avatar, CircularProgress, Typography } from '@mui/material';
16
16
  import { useLocalStorageState } from 'ahooks';
17
17
  import { useEffect, useState } from 'react';
18
18
  import { Link } from 'react-router-dom';
@@ -73,21 +73,6 @@ const getListKey = (props: ListProps) => {
73
73
  return 'invoices';
74
74
  };
75
75
 
76
- InvoiceList.defaultProps = {
77
- features: {
78
- customer: true,
79
- filter: true,
80
- },
81
- customer_id: '',
82
- subscription_id: '',
83
- status: '',
84
- include_staking: false,
85
- include_return_staking: false,
86
- ignore_zero: false,
87
-
88
- mode: 'admin',
89
- };
90
-
91
76
  const getInvoiceLink = (invoice: TInvoiceExpanded) => {
92
77
  if (invoice.id.startsWith('in_')) {
93
78
  return {
@@ -116,14 +101,17 @@ function InvoiceLink({ invoice, children }: { invoice: TInvoiceExpanded; childre
116
101
  }
117
102
 
118
103
  export default function InvoiceList({
119
- customer_id,
120
- subscription_id,
121
- features,
122
- status,
123
- include_staking,
124
- include_return_staking,
125
- ignore_zero,
126
- mode,
104
+ customer_id = '',
105
+ subscription_id = '',
106
+ features = {
107
+ customer: true,
108
+ filter: true,
109
+ },
110
+ status = '',
111
+ include_staking = false,
112
+ include_return_staking = false,
113
+ ignore_zero = false,
114
+ mode = 'admin',
127
115
  }: ListProps) {
128
116
  const listKey = getListKey({ customer_id, subscription_id });
129
117
 
@@ -176,8 +164,10 @@ export default function InvoiceList({
176
164
  <InvoiceLink invoice={item}>
177
165
  <Typography
178
166
  component="strong"
179
- fontWeight={600}
180
- sx={{ textDecoration: item.status === 'void' ? 'line-through' : 'none' }}>
167
+ sx={{
168
+ fontWeight: 600,
169
+ textDecoration: item.status === 'void' ? 'line-through' : 'none',
170
+ }}>
181
171
  {formatBNStr(item?.total, item?.paymentCurrency.decimal)}&nbsp;
182
172
  {item?.paymentCurrency.symbol}
183
173
  </Typography>
@@ -186,6 +176,24 @@ export default function InvoiceList({
186
176
  },
187
177
  },
188
178
  },
179
+ {
180
+ label: t('common.paymentMethod'),
181
+ name: 'paymentMethod',
182
+ width: 120,
183
+ options: {
184
+ customBodyRenderLite: (_: string, index: number) => {
185
+ const invoice = data?.list[index] as TInvoiceExpanded;
186
+ return (
187
+ <InvoiceLink invoice={invoice}>
188
+ <Typography sx={{ display: 'flex', alignItems: 'center', whiteSpace: 'nowrap' }}>
189
+ <Avatar src={invoice.paymentMethod.logo} sx={{ width: 18, height: 18, mr: 1 }} />
190
+ {invoice.paymentMethod.name}
191
+ </Typography>
192
+ </InvoiceLink>
193
+ );
194
+ },
195
+ },
196
+ },
189
197
  {
190
198
  label: t('common.status'),
191
199
  name: 'status',
@@ -77,16 +77,14 @@ const getListKey = (props: ListProps) => {
77
77
  return 'invoices';
78
78
  };
79
79
 
80
- RechargeList.defaultProps = {
81
- features: {
80
+ export default function RechargeList({
81
+ currency_id = '',
82
+ subscription_id = '',
83
+ features = {
82
84
  customer: true,
83
85
  filter: true,
84
86
  },
85
- currency_id: '',
86
- subscription_id: '',
87
- };
88
-
89
- export default function RechargeList({ currency_id, subscription_id, features }: ListProps) {
87
+ }: ListProps) {
90
88
  const listKey = getListKey({ currency_id, subscription_id });
91
89
 
92
90
  const { t, locale } = useLocaleContext();
@@ -119,7 +119,7 @@ export function getInvoiceRows(invoice: TInvoiceExpanded) {
119
119
  };
120
120
  }
121
121
 
122
- export default function InvoiceTable({ invoice, simple, emptyNodeText }: Props) {
122
+ export default function InvoiceTable({ invoice, simple = false, emptyNodeText = '' }: Props) {
123
123
  const { t, locale } = useLocaleContext();
124
124
  const { detail, summary } = getInvoiceRows(invoice);
125
125
  const [state, setState] = useSetState({
@@ -163,15 +163,16 @@ export default function InvoiceTable({ invoice, simple, emptyNodeText }: Props)
163
163
  <Stack
164
164
  direction="row"
165
165
  spacing={0.5}
166
- alignItems="center"
166
+ onClick={() => onOpenUsageRecords(item)}
167
167
  sx={{
168
+ alignItems: 'center',
168
169
  cursor: 'pointer',
170
+
169
171
  justifyContent: {
170
172
  xs: 'flex-start',
171
173
  md: 'flex-end',
172
174
  },
173
- }}
174
- onClick={() => onOpenUsageRecords(item)}>
175
+ }}>
175
176
  <Typography component="span">{item.quantity}</Typography>
176
177
  {!!item.rawQuantity && (
177
178
  <Tooltip
@@ -268,17 +269,26 @@ export default function InvoiceTable({ invoice, simple, emptyNodeText }: Props)
268
269
  }}>
269
270
  {summary.map((line) => (
270
271
  <Box key={line.key}>
271
- <Typography component="span" variant="body1" color="text.secondary">
272
+ <Typography
273
+ component="span"
274
+ variant="body1"
275
+ sx={{
276
+ color: 'text.secondary',
277
+ }}>
272
278
  {t(line.key)}:&nbsp;
273
279
  </Typography>
274
- <Typography component="span" variant="body1" color="text.primary">
280
+ <Typography
281
+ component="span"
282
+ variant="body1"
283
+ sx={{
284
+ color: 'text.primary',
285
+ }}>
275
286
  {line.value}
276
287
  </Typography>
277
288
  </Box>
278
289
  ))}
279
290
  </Stack>
280
291
  )}
281
-
282
292
  {state.subscriptionId && state.subscriptionItemId && (
283
293
  <UsageRecordDialog
284
294
  subscriptionId={state.subscriptionId}
@@ -294,11 +304,6 @@ export default function InvoiceTable({ invoice, simple, emptyNodeText }: Props)
294
304
  );
295
305
  }
296
306
 
297
- InvoiceTable.defaultProps = {
298
- simple: false,
299
- emptyNodeText: '',
300
- };
301
-
302
307
  const Root = styled(Box)`
303
308
  .invoice-summary {
304
309
  padding-right: 16px;
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import { PaymentProvider } from '@blocklet/payment-react';
3
- import { UserCenter } from '@blocklet/ui-react';
3
+ import { UserCenter } from '@blocklet/ui-react/lib/UserCenter';
4
4
  import { useEffect } from 'react';
5
5
 
6
6
  import { useSearchParams } from 'react-router-dom';