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
@@ -60,12 +60,21 @@ export default function PayoutDetail() {
60
60
  return (
61
61
  <Root direction="column" spacing={2.5} mb={4}>
62
62
  <Box>
63
- <Stack className="page-header" direction="row" justifyContent="space-between" alignItems="center">
63
+ <Stack
64
+ className="page-header"
65
+ direction="row"
66
+ sx={{
67
+ justifyContent: 'space-between',
68
+ alignItems: 'center',
69
+ }}>
64
70
  <Stack
65
71
  direction="row"
66
- alignItems="center"
67
- sx={{ fontWeight: 'normal', cursor: 'pointer' }}
68
- onClick={() => goBackOrFallback('/customer/payouts')}>
72
+ onClick={() => goBackOrFallback('/customer/payouts')}
73
+ sx={{
74
+ alignItems: 'center',
75
+ fontWeight: 'normal',
76
+ cursor: 'pointer',
77
+ }}>
69
78
  <ArrowBackOutlined fontSize="small" sx={{ mr: 0.5, color: 'text.secondary' }} />
70
79
  <Typography variant="h6" sx={{ color: 'text.secondary', fontWeight: 'normal' }}>
71
80
  {t('common.previous')}
@@ -82,37 +91,60 @@ export default function PayoutDetail() {
82
91
  )}
83
92
  </Stack>
84
93
  <Box
85
- mt={4}
86
- mb={3}
87
94
  sx={{
95
+ mt: 4,
96
+ mb: 3,
88
97
  display: 'flex',
98
+
89
99
  gap: {
90
100
  xs: 2,
91
101
  sm: 2,
92
102
  md: 5,
93
103
  },
104
+
94
105
  flexWrap: 'wrap',
106
+
95
107
  flexDirection: {
96
108
  xs: 'column',
97
109
  sm: 'column',
98
110
  md: 'row',
99
111
  },
112
+
100
113
  alignItems: {
101
114
  xs: 'flex-start',
102
115
  sm: 'flex-start',
103
116
  md: 'center',
104
117
  },
105
118
  }}>
106
- <Stack direction="row" justifyContent="space-between" alignItems="center">
107
- <Stack direction="row" alignItems="center">
108
- <Stack direction="row" alignItems="center" spacing={1}>
119
+ <Stack
120
+ direction="row"
121
+ sx={{
122
+ justifyContent: 'space-between',
123
+ alignItems: 'center',
124
+ }}>
125
+ <Stack
126
+ direction="row"
127
+ sx={{
128
+ alignItems: 'center',
129
+ }}>
130
+ <Stack
131
+ direction="row"
132
+ spacing={1}
133
+ sx={{
134
+ alignItems: 'center',
135
+ }}>
109
136
  <Avatar
110
137
  src={data.paymentCurrency.logo}
111
138
  alt={data.paymentCurrency.symbol}
112
139
  variant="square"
113
140
  sx={{ width: '52px', height: '52px', borderRadius: 0.5 }}
114
141
  />
115
- <Stack direction="column" alignItems="flex-start" justifyContent="space-around">
142
+ <Stack
143
+ direction="column"
144
+ sx={{
145
+ alignItems: 'flex-start',
146
+ justifyContent: 'space-around',
147
+ }}>
116
148
  <Amount amount={total} sx={{ my: 0, fontSize: '1.75rem', lineHeight: '32px' }} />
117
149
  </Stack>
118
150
  </Stack>
@@ -120,18 +152,22 @@ export default function PayoutDetail() {
120
152
  </Stack>
121
153
  <Stack
122
154
  className="section-body"
123
- justifyContent="flex-start"
124
- flexWrap="wrap"
125
155
  sx={{
156
+ justifyContent: 'flex-start',
157
+ flexWrap: 'wrap',
158
+
126
159
  'hr.MuiDivider-root:last-child': {
127
160
  display: 'none',
128
161
  },
162
+
129
163
  flexDirection: {
130
164
  xs: 'column',
131
165
  sm: 'column',
132
166
  md: 'row',
133
167
  },
168
+
134
169
  alignItems: 'flex-start',
170
+
135
171
  gap: {
136
172
  xs: 1,
137
173
  sm: 1,
@@ -218,7 +254,14 @@ export default function PayoutDetail() {
218
254
  },
219
255
  },
220
256
  }}>
221
- <Box flex={1} className="payment-link-column-1" sx={{ gap: 2.5, display: 'flex', flexDirection: 'column' }}>
257
+ <Box
258
+ className="payment-link-column-1"
259
+ sx={{
260
+ flex: 1,
261
+ gap: 2.5,
262
+ display: 'flex',
263
+ flexDirection: 'column',
264
+ }}>
222
265
  <Box className="section">
223
266
  <SectionHeader title={t('common.detail')} />
224
267
  <InfoRowGroup
@@ -322,7 +322,13 @@ export default function BalanceRechargePage() {
322
322
 
323
323
  return (
324
324
  <Root>
325
- <Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ position: 'relative' }}>
325
+ <Stack
326
+ direction="row"
327
+ sx={{
328
+ justifyContent: 'space-between',
329
+ alignItems: 'center',
330
+ position: 'relative',
331
+ }}>
326
332
  <Button
327
333
  startIcon={<ArrowBackOutlined />}
328
334
  variant="text"
@@ -332,19 +338,27 @@ export default function BalanceRechargePage() {
332
338
  {t('common.previous')}
333
339
  </Button>
334
340
  </Stack>
335
-
336
341
  <Typography variant="h2" gutterBottom>
337
342
  {currency?.symbol} {t('customer.recharge.title')}
338
343
  </Typography>
339
-
340
344
  {currency && (
341
345
  <Box ref={rechargeRef}>
342
346
  <Stack sx={{ maxWidth: '760px' }}>
343
347
  <Box sx={{ mb: 4 }}>
344
348
  <BalanceCard elevation={0}>
345
- <Stack direction="row" justifyContent="space-between" alignItems="center" spacing={2}>
349
+ <Stack
350
+ direction="row"
351
+ spacing={2}
352
+ sx={{
353
+ justifyContent: 'space-between',
354
+ alignItems: 'center',
355
+ }}>
346
356
  <Stack spacing={0.5}>
347
- <Typography variant="body2" color="text.secondary">
357
+ <Typography
358
+ variant="body2"
359
+ sx={{
360
+ color: 'text.secondary',
361
+ }}>
348
362
  {t('customer.recharge.receiveAddress')}
349
363
  </Typography>
350
364
  <Typography variant="body1" sx={{ wordBreak: 'break-all', fontFamily: 'monospace' }}>
@@ -388,7 +402,12 @@ export default function BalanceRechargePage() {
388
402
  }
389
403
  : undefined,
390
404
  }}>
391
- <Stack direction="row" alignItems="center" justifyContent="space-between">
405
+ <Stack
406
+ direction="row"
407
+ sx={{
408
+ alignItems: 'center',
409
+ justifyContent: 'space-between',
410
+ }}>
392
411
  <Stack>
393
412
  <Typography
394
413
  variant="body1"
@@ -420,7 +439,12 @@ export default function BalanceRechargePage() {
420
439
  <Stack sx={{ mb: 3, backgroundColor: 'background.default', borderRadius: '16px' }}>
421
440
  <Grid container spacing={2}>
422
441
  {presetAmounts.map(({ amount: presetAmount, label, multiplier }) => (
423
- <Grid item xs={6} sm={3} key={presetAmount}>
442
+ <Grid
443
+ key={presetAmount}
444
+ size={{
445
+ xs: 6,
446
+ sm: 3,
447
+ }}>
424
448
  <Card
425
449
  variant="outlined"
426
450
  sx={{
@@ -456,7 +480,12 @@ export default function BalanceRechargePage() {
456
480
  {formatNumber(presetAmount)} {currency.symbol}
457
481
  </Typography>
458
482
  {multiplier > 0 && label && (
459
- <Typography variant="caption" align="center" color="text.secondary">
483
+ <Typography
484
+ variant="caption"
485
+ align="center"
486
+ sx={{
487
+ color: 'text.secondary',
488
+ }}>
460
489
  {label}
461
490
  </Typography>
462
491
  )}
@@ -464,7 +493,11 @@ export default function BalanceRechargePage() {
464
493
  </Card>
465
494
  </Grid>
466
495
  ))}
467
- <Grid item xs={6} sm={3}>
496
+ <Grid
497
+ size={{
498
+ xs: 6,
499
+ sm: 3,
500
+ }}>
468
501
  <Card
469
502
  variant="outlined"
470
503
  sx={{
@@ -488,7 +521,13 @@ export default function BalanceRechargePage() {
488
521
  : {}),
489
522
  }}>
490
523
  <CardActionArea onClick={handleCustomSelect} sx={{ height: '100%', p: 1 }}>
491
- <Stack direction="row" spacing={1} justifyContent="center" alignItems="center">
524
+ <Stack
525
+ direction="row"
526
+ spacing={1}
527
+ sx={{
528
+ justifyContent: 'center',
529
+ alignItems: 'center',
530
+ }}>
492
531
  <Typography
493
532
  variant="h6"
494
533
  align="center"
@@ -513,18 +552,26 @@ export default function BalanceRechargePage() {
513
552
  error={!!amountError}
514
553
  helperText={amountError}
515
554
  onChange={handleAmountChange}
516
- InputProps={{
517
- endAdornment: <Typography>{currency.symbol}</Typography>,
518
- autoComplete: 'off',
519
- inputProps: {
555
+ inputRef={customInputRef}
556
+ autoComplete="off"
557
+ slotProps={{
558
+ input: {
559
+ endAdornment: <Typography>{currency.symbol}</Typography>,
560
+ },
561
+ htmlInput: {
520
562
  min: 0,
521
563
  max: MAX_SAFE_AMOUNT,
522
564
  },
523
565
  }}
524
- inputRef={customInputRef}
525
566
  />
526
567
  {amount && Number(amount) > 0 && Number(unitCycle.amount) > 0 && !amountError && (
527
- <Typography variant="body2" sx={{ color: 'text.lighter', mt: 1 }} fontSize={12}>
568
+ <Typography
569
+ variant="body2"
570
+ sx={{
571
+ fontSize: 12,
572
+ color: 'text.lighter',
573
+ mt: 1,
574
+ }}>
528
575
  {t('common.estimatedDuration', {
529
576
  duration: formatSmartDuration(
530
577
  Math.floor(Number(amount) / Number(unitCycle.amount)) < 1
@@ -568,12 +615,25 @@ export default function BalanceRechargePage() {
568
615
 
569
616
  <Grid container spacing={2}>
570
617
  {relatedSubscriptions.map((subscription) => (
571
- <Grid item xs={12} sm={6} md={4} lg={3} key={subscription.id}>
618
+ <Grid
619
+ key={subscription.id}
620
+ size={{
621
+ xs: 12,
622
+ sm: 6,
623
+ md: 4,
624
+ lg: 3,
625
+ }}>
572
626
  <Stack
573
627
  onClick={() => handleSubscriptionClick(subscription.id)}
574
628
  className="base-card"
575
629
  sx={{ height: '100%' }}>
576
- <Stack direction="row" alignItems="center" spacing={1.5} sx={{ mb: 1 }}>
630
+ <Stack
631
+ direction="row"
632
+ spacing={1.5}
633
+ sx={{
634
+ alignItems: 'center',
635
+ mb: 1,
636
+ }}>
577
637
  <Typography
578
638
  variant="subtitle1"
579
639
  sx={{
@@ -254,12 +254,21 @@ export default function RechargePage() {
254
254
 
255
255
  return (
256
256
  <Root>
257
- <Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ position: 'relative' }}>
257
+ <Stack
258
+ direction="row"
259
+ sx={{
260
+ justifyContent: 'space-between',
261
+ alignItems: 'center',
262
+ position: 'relative',
263
+ }}>
258
264
  <Stack
259
265
  direction="row"
260
266
  onClick={() => goBackOrFallback('/customer')}
261
- alignItems="center"
262
- sx={{ fontWeight: 'normal', cursor: 'pointer' }}>
267
+ sx={{
268
+ alignItems: 'center',
269
+ fontWeight: 'normal',
270
+ cursor: 'pointer',
271
+ }}>
263
272
  <ArrowBackOutlined fontSize="small" sx={{ mr: 0.5, color: 'text.secondary' }} />
264
273
  <Typography variant="h6" sx={{ color: 'text.secondary', fontWeight: 'normal' }}>
265
274
  {t('common.previous')}
@@ -269,7 +278,6 @@ export default function RechargePage() {
269
278
  {t('customer.recharge.view')}
270
279
  </Button>
271
280
  </Stack>
272
-
273
281
  <Box>
274
282
  <Box
275
283
  sx={{
@@ -279,15 +287,26 @@ export default function RechargePage() {
279
287
  flexDirection: { xs: 'column', sm: 'column', md: 'row' },
280
288
  alignItems: { xs: 'flex-start', sm: 'flex-start', md: 'center' },
281
289
  }}>
282
- <Stack direction="row" justifyContent="space-between" alignItems="center">
283
- <Stack direction="row" alignItems="center" flexWrap="wrap" gap={1}>
290
+ <Stack
291
+ direction="row"
292
+ sx={{
293
+ justifyContent: 'space-between',
294
+ alignItems: 'center',
295
+ }}>
296
+ <Stack
297
+ direction="row"
298
+ sx={{
299
+ alignItems: 'center',
300
+ flexWrap: 'wrap',
301
+ gap: 1,
302
+ }}>
284
303
  <SubscriptionDescription subscription={subscription} variant="h1" />
285
304
  </Stack>
286
305
  </Stack>
287
306
  <Stack
288
- justifyContent="flex-start"
289
- flexWrap="wrap"
290
307
  sx={{
308
+ justifyContent: 'flex-start',
309
+ flexWrap: 'wrap',
291
310
  flexDirection: { xs: 'column', sm: 'column', md: 'row' },
292
311
  alignItems: { xs: 'flex-start', sm: 'flex-start', md: 'center' },
293
312
  gap: { xs: 1, sm: 1, md: 3 },
@@ -341,7 +360,6 @@ export default function RechargePage() {
341
360
  </Box>
342
361
  </Box>
343
362
  <Divider />
344
-
345
363
  <Box sx={{ maxWidth: 600 }} ref={rechargeRef}>
346
364
  <Typography variant="h4" gutterBottom>
347
365
  {t('customer.recharge.title')}
@@ -373,8 +391,16 @@ export default function RechargePage() {
373
391
  }
374
392
  : undefined,
375
393
  }}>
376
- <Stack direction="row" alignItems="center" spacing={1}>
377
- <Stack flex={1}>
394
+ <Stack
395
+ direction="row"
396
+ spacing={1}
397
+ sx={{
398
+ alignItems: 'center',
399
+ }}>
400
+ <Stack
401
+ sx={{
402
+ flex: 1,
403
+ }}>
378
404
  <Typography
379
405
  variant="body1"
380
406
  color="inherit"
@@ -402,7 +428,12 @@ export default function RechargePage() {
402
428
  <Stack sx={{ mb: 2, mt: 2, backgroundColor: 'background.default' }}>
403
429
  <Grid container spacing={2}>
404
430
  {presetAmounts.map(({ amount: presetAmount, cycles }) => (
405
- <Grid item xs={6} sm={4} key={presetAmount}>
431
+ <Grid
432
+ key={presetAmount}
433
+ size={{
434
+ xs: 6,
435
+ sm: 4,
436
+ }}>
406
437
  <Card
407
438
  variant="outlined"
408
439
  sx={{
@@ -421,7 +452,14 @@ export default function RechargePage() {
421
452
  : {}),
422
453
  }}>
423
454
  <CardActionArea onClick={() => handleSelect(presetAmount)} sx={{ height: '100%' }}>
424
- <Stack direction="column" sx={{ p: 1 }} spacing={1} alignItems="center" justifyContent="center">
455
+ <Stack
456
+ direction="column"
457
+ spacing={1}
458
+ sx={{
459
+ alignItems: 'center',
460
+ justifyContent: 'center',
461
+ p: 1,
462
+ }}>
425
463
  <Typography
426
464
  variant="h6"
427
465
  sx={{
@@ -430,7 +468,11 @@ export default function RechargePage() {
430
468
  }}>
431
469
  {presetAmount} {subscription.paymentCurrency.symbol}
432
470
  </Typography>
433
- <Typography variant="caption" color="text.secondary">
471
+ <Typography
472
+ variant="caption"
473
+ sx={{
474
+ color: 'text.secondary',
475
+ }}>
434
476
  {formatEstimatedDuration(cycles)}
435
477
  </Typography>
436
478
  </Stack>
@@ -438,7 +480,11 @@ export default function RechargePage() {
438
480
  </Card>
439
481
  </Grid>
440
482
  ))}
441
- <Grid item xs={6} sm={4}>
483
+ <Grid
484
+ size={{
485
+ xs: 6,
486
+ sm: 4,
487
+ }}>
442
488
  <Card
443
489
  variant="outlined"
444
490
  sx={{
@@ -455,7 +501,14 @@ export default function RechargePage() {
455
501
  ...(customAmount ? { borderColor: 'primary.main', borderWidth: 1 } : {}),
456
502
  }}>
457
503
  <CardActionArea onClick={handleCustomSelect} sx={{ height: '100%' }}>
458
- <Stack direction="column" sx={{ p: 1 }} spacing={1} alignItems="center" justifyContent="center">
504
+ <Stack
505
+ direction="column"
506
+ spacing={1}
507
+ sx={{
508
+ alignItems: 'center',
509
+ justifyContent: 'center',
510
+ p: 1,
511
+ }}>
459
512
  <Typography
460
513
  variant="h6"
461
514
  sx={{ fontWeight: 600, color: customAmount ? 'primary.main' : 'text.primary' }}>
@@ -479,19 +532,27 @@ export default function RechargePage() {
479
532
  error={!!amountError}
480
533
  helperText={amountError}
481
534
  onChange={handleAmountChange}
482
- InputProps={{
483
- endAdornment: <Typography>{subscription.paymentCurrency.symbol}</Typography>,
484
- autoComplete: 'off',
485
- inputProps: {
486
- min: 0,
487
- max: MAX_SAFE_AMOUNT,
488
- },
489
- }}
490
535
  sx={{ mt: 1 }}
491
536
  inputRef={customInputRef}
537
+ slotProps={{
538
+ input: {
539
+ endAdornment: <Typography>{subscription.paymentCurrency.symbol}</Typography>,
540
+ autoComplete: 'off',
541
+ inputProps: {
542
+ min: 0,
543
+ max: MAX_SAFE_AMOUNT,
544
+ },
545
+ },
546
+ }}
492
547
  />
493
548
  {amount && Number(amount) > 0 && Number(cycleAmount) > 0 && !amountError && (
494
- <Typography variant="body2" sx={{ color: 'text.lighter', mt: '8px !important' }} fontSize={12}>
549
+ <Typography
550
+ variant="body2"
551
+ sx={{
552
+ fontSize: 12,
553
+ color: 'text.lighter',
554
+ mt: '8px !important',
555
+ }}>
495
556
  {formatEstimatedDuration(
496
557
  Math.floor(Number(amount) / Number(cycleAmount)) < 1
497
558
  ? parseFloat((Number(amount) / Number(cycleAmount)).toFixed(1))
@@ -72,8 +72,12 @@ const RefundTable = memo(({ invoice_id }: Props) => {
72
72
  customBodyRenderLite: (_: string, index: number) => {
73
73
  const item = data.list[index] as TRefundExpanded;
74
74
  return (
75
- <Typography component="strong" fontWeight={600}>
76
- {formatBNStr(item?.amount, item?.paymentCurrency.decimal)}&nbsp;
75
+ <Typography
76
+ component="strong"
77
+ sx={{
78
+ fontWeight: 600,
79
+ }}>
80
+ {formatBNStr(item?.amount, item?.paymentCurrency.decimal)}
77
81
  {item?.paymentCurrency.symbol}
78
82
  </Typography>
79
83
  );
@@ -228,7 +232,14 @@ const RefundList = memo(({ invoice_id }: Props) => {
228
232
  }
229
233
 
230
234
  if (data && data.list.length === 0) {
231
- return <Typography color="text.secondary">{t('payment.customer.refund.empty')}</Typography>;
235
+ return (
236
+ <Typography
237
+ sx={{
238
+ color: 'text.secondary',
239
+ }}>
240
+ {t('payment.customer.refund.empty')}
241
+ </Typography>
242
+ );
232
243
  }
233
244
 
234
245
  const hasMore = data && data.list.length < data.count;
@@ -236,7 +247,12 @@ const RefundList = memo(({ invoice_id }: Props) => {
236
247
  const grouped = groupByDate(data.list);
237
248
 
238
249
  return (
239
- <Stack direction="column" gap={1} sx={{ mt: 1 }}>
250
+ <Stack
251
+ direction="column"
252
+ sx={{
253
+ gap: 1,
254
+ mt: 1,
255
+ }}>
240
256
  {Object.entries(grouped).map(([date, payments]) => (
241
257
  <Box key={date}>
242
258
  <Typography sx={{ fontWeight: 'bold', color: 'text.secondary', mt: 2, mb: 1 }}>{date}</Typography>
@@ -248,31 +264,53 @@ const RefundList = memo(({ invoice_id }: Props) => {
248
264
  xs: 'column',
249
265
  sm: 'row',
250
266
  }}
251
- sx={{ my: 1 }}
252
- gap={{
253
- xs: 0.5,
254
- sm: 1.5,
255
- md: 3,
256
- }}
257
- flexWrap="nowrap">
258
- <Box flex={3}>
267
+ sx={{
268
+ gap: {
269
+ xs: 0.5,
270
+ sm: 1.5,
271
+ md: 3,
272
+ },
273
+
274
+ flexWrap: 'nowrap',
275
+ my: 1,
276
+ }}>
277
+ <Box
278
+ sx={{
279
+ flex: 3,
280
+ }}>
259
281
  <Typography>{formatToDate(item.created_at)}</Typography>
260
282
  </Box>
261
- <Box flex={2}>
262
- <Typography textAlign="right">
283
+ <Box
284
+ sx={{
285
+ flex: 2,
286
+ }}>
287
+ <Typography
288
+ sx={{
289
+ textAlign: 'right',
290
+ }}>
263
291
  {formatBNStr(item.amount, item.paymentCurrency.decimal)}&nbsp;
264
292
  {item.paymentCurrency.symbol}
265
293
  </Typography>
266
294
  </Box>
267
- <Box flex={3}>
295
+ <Box
296
+ sx={{
297
+ flex: 3,
298
+ }}>
268
299
  <Status label={item.status} color={getPaymentIntentStatusColor(item.status)} />
269
300
  </Box>
270
- <Box flex={3}>
301
+ <Box
302
+ sx={{
303
+ flex: 3,
304
+ }}>
271
305
  <Typography>
272
306
  {item.description ? capitalize(toLower(item.description.replace(/_/g, ' '))) : '-'}
273
307
  </Typography>
274
308
  </Box>
275
- <Box flex={3} sx={{ minWidth: '220px' }}>
309
+ <Box
310
+ sx={{
311
+ flex: 3,
312
+ minWidth: '220px',
313
+ }}>
276
314
  {(item.payment_details?.arcblock?.tx_hash ||
277
315
  item.payment_details?.ethereum?.tx_hash ||
278
316
  item.payment_details?.base?.tx_hash) && (
@@ -293,7 +331,10 @@ const RefundList = memo(({ invoice_id }: Props) => {
293
331
  </Button>
294
332
  )}
295
333
  {!hasMore && data.count > pageSize && (
296
- <Typography color="text.secondary">
334
+ <Typography
335
+ sx={{
336
+ color: 'text.secondary',
337
+ }}>
297
338
  {t('common.noMore', { resource: t('payment.customer.payments') })}
298
339
  </Typography>
299
340
  )}
@@ -302,14 +343,9 @@ const RefundList = memo(({ invoice_id }: Props) => {
302
343
  );
303
344
  });
304
345
 
305
- export default function CustomerRefundList(props: Props & { type?: 'table' | 'list' }) {
306
- const { type, ...restProps } = props;
346
+ export default function CustomerRefundList({ type = 'list', ...restProps }: Props & { type?: 'table' | 'list' }) {
307
347
  if (type === 'table') {
308
348
  return <RefundTable {...restProps} />;
309
349
  }
310
350
  return <RefundList {...restProps} />;
311
351
  }
312
-
313
- CustomerRefundList.defaultProps = {
314
- type: 'list',
315
- };