payment-kit 1.25.8 → 1.26.0

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 (115) hide show
  1. package/api/src/crons/index.ts +24 -0
  2. package/api/src/libs/archive/config.ts +254 -0
  3. package/api/src/libs/archive/executor.ts +729 -0
  4. package/api/src/libs/archive/index.ts +7 -0
  5. package/api/src/libs/archive/lock.ts +50 -0
  6. package/api/src/libs/archive/policy.ts +55 -0
  7. package/api/src/libs/archive/query.ts +136 -0
  8. package/api/src/libs/archive/snapshot.ts +291 -0
  9. package/api/src/libs/archive/store.ts +200 -0
  10. package/api/src/libs/session.ts +43 -25
  11. package/api/src/queues/archive.ts +32 -0
  12. package/api/src/queues/subscription.ts +3 -1
  13. package/api/src/routes/archive.ts +176 -0
  14. package/api/src/routes/checkout-sessions.ts +50 -34
  15. package/api/src/routes/index.ts +2 -0
  16. package/api/src/routes/meters.ts +28 -0
  17. package/api/src/routes/payment-stats.ts +167 -20
  18. package/api/src/store/migrations/20260203-archive.ts +12 -0
  19. package/api/src/store/migrations/20260204-revenue-snapshot.ts +19 -0
  20. package/api/src/store/models/archive-lock.ts +55 -0
  21. package/api/src/store/models/archive-metadata.ts +132 -0
  22. package/api/src/store/models/index.ts +9 -0
  23. package/api/src/store/models/revenue-snapshot.ts +110 -0
  24. package/api/tests/libs/archive-config.spec.ts +185 -0
  25. package/api/tests/libs/archive-executor.spec.ts +678 -0
  26. package/api/tests/libs/archive-lock.spec.ts +130 -0
  27. package/api/tests/libs/archive-policy.spec.ts +255 -0
  28. package/api/tests/libs/archive-query.spec.ts +267 -0
  29. package/api/tests/libs/archive-store.spec.ts +159 -0
  30. package/blocklet.prefs.json +187 -0
  31. package/blocklet.yml +2 -1
  32. package/package.json +10 -10
  33. package/src/components/customer/actions.tsx +1 -1
  34. package/src/components/customer/credit-overview.tsx +3 -1
  35. package/src/components/customer/overdraft-protection.tsx +1 -1
  36. package/src/components/event/list.tsx +1 -1
  37. package/src/components/filter-toolbar.tsx +2 -2
  38. package/src/components/invoice/action.tsx +3 -3
  39. package/src/components/invoice/list.tsx +1 -1
  40. package/src/components/invoice/recharge.tsx +2 -2
  41. package/src/components/meter/add-usage-dialog.tsx +1 -1
  42. package/src/components/passport/actions.tsx +1 -1
  43. package/src/components/passport/assign.tsx +1 -1
  44. package/src/components/payment-currency/add.tsx +1 -1
  45. package/src/components/payment-currency/edit.tsx +1 -1
  46. package/src/components/payment-intent/actions.tsx +4 -4
  47. package/src/components/payment-intent/list.tsx +1 -1
  48. package/src/components/payment-link/actions.tsx +4 -4
  49. package/src/components/payment-link/item.tsx +1 -1
  50. package/src/components/payouts/list.tsx +1 -1
  51. package/src/components/payouts/portal/list.tsx +1 -1
  52. package/src/components/price/upsell-select.tsx +1 -1
  53. package/src/components/price/upsell.tsx +2 -2
  54. package/src/components/pricing-table/actions.tsx +3 -3
  55. package/src/components/pricing-table/product-item.tsx +1 -1
  56. package/src/components/product/actions.tsx +3 -3
  57. package/src/components/product/create.tsx +1 -1
  58. package/src/components/product/cross-sell.tsx +2 -2
  59. package/src/components/promotion/active-redemptions.tsx +1 -1
  60. package/src/components/refund/list.tsx +1 -1
  61. package/src/components/subscription/actions/index.tsx +1 -1
  62. package/src/components/subscription/items/usage-records.tsx +4 -2
  63. package/src/components/subscription/list.tsx +1 -1
  64. package/src/components/subscription/metrics.tsx +3 -3
  65. package/src/components/subscription/portal/actions.tsx +15 -12
  66. package/src/components/subscription/portal/list.tsx +1 -1
  67. package/src/components/webhook/attempts.tsx +4 -4
  68. package/src/hooks/subscription.ts +2 -2
  69. package/src/locales/en.tsx +4 -0
  70. package/src/locales/zh.tsx +4 -0
  71. package/src/pages/admin/billing/meter-events/index.tsx +3 -3
  72. package/src/pages/admin/billing/meters/index.tsx +1 -1
  73. package/src/pages/admin/billing/overdue/index.tsx +2 -2
  74. package/src/pages/admin/billing/subscriptions/detail.tsx +2 -2
  75. package/src/pages/admin/customers/customers/credit-grant/detail.tsx +1 -1
  76. package/src/pages/admin/customers/customers/credit-transaction/detail.tsx +1 -1
  77. package/src/pages/admin/customers/customers/detail.tsx +4 -4
  78. package/src/pages/admin/developers/events/detail.tsx +1 -1
  79. package/src/pages/admin/developers/webhooks/detail.tsx +1 -1
  80. package/src/pages/admin/developers/webhooks/index.tsx +1 -1
  81. package/src/pages/admin/overview.tsx +2 -0
  82. package/src/pages/admin/payments/intents/detail.tsx +2 -2
  83. package/src/pages/admin/payments/payouts/detail.tsx +2 -2
  84. package/src/pages/admin/payments/refunds/detail.tsx +2 -2
  85. package/src/pages/admin/products/coupons/detail.tsx +1 -1
  86. package/src/pages/admin/products/coupons/index.tsx +1 -1
  87. package/src/pages/admin/products/exchange-rate-providers/index.tsx +1 -1
  88. package/src/pages/admin/products/links/create.tsx +1 -1
  89. package/src/pages/admin/products/links/detail.tsx +2 -2
  90. package/src/pages/admin/products/links/index.tsx +1 -1
  91. package/src/pages/admin/products/passports/index.tsx +1 -1
  92. package/src/pages/admin/products/prices/actions.tsx +4 -4
  93. package/src/pages/admin/products/prices/detail.tsx +2 -2
  94. package/src/pages/admin/products/pricing-tables/create.tsx +1 -1
  95. package/src/pages/admin/products/pricing-tables/detail.tsx +2 -2
  96. package/src/pages/admin/products/pricing-tables/index.tsx +1 -1
  97. package/src/pages/admin/products/products/index.tsx +1 -1
  98. package/src/pages/admin/products/promotion-codes/actions.tsx +2 -2
  99. package/src/pages/admin/products/promotion-codes/detail.tsx +2 -2
  100. package/src/pages/admin/products/promotion-codes/list.tsx +1 -1
  101. package/src/pages/admin/settings/payment-methods/create.tsx +1 -1
  102. package/src/pages/admin/settings/payment-methods/edit.tsx +1 -1
  103. package/src/pages/admin/settings/payment-methods/index.tsx +2 -2
  104. package/src/pages/admin/tax/detail.tsx +2 -2
  105. package/src/pages/admin/tax/list.tsx +1 -1
  106. package/src/pages/checkout/pay.tsx +2 -2
  107. package/src/pages/customer/index.tsx +1 -1
  108. package/src/pages/customer/invoice/past-due.tsx +1 -1
  109. package/src/pages/customer/payout/detail.tsx +1 -1
  110. package/src/pages/customer/refund/list.tsx +1 -1
  111. package/src/pages/customer/subscription/change-payment.tsx +2 -2
  112. package/src/pages/customer/subscription/change-plan.tsx +3 -3
  113. package/src/pages/customer/subscription/detail.tsx +3 -3
  114. package/src/pages/integrations/donations/index.tsx +1 -1
  115. package/vite.config.ts +3 -1
@@ -34,7 +34,7 @@ export default function LineItem({ prefix, product, valid, onUpdate, onRemove }:
34
34
  const onSave = async (updates: TProduct) => {
35
35
  try {
36
36
  setState({ loading: true });
37
- await api.put(`/api/products/${product.id}`, updates).then((res) => res.data);
37
+ await api.put(`/api/products/${product.id}`, updates).then((res: any) => res.data);
38
38
  Toast.success(t('common.saved'));
39
39
  onUpdate();
40
40
  } catch (err) {
@@ -34,7 +34,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: TPayoutExp
34
34
  }
35
35
  search.set(key, String(v));
36
36
  });
37
- return api.get(`/api/payouts?${search.toString()}`).then((res) => res.data);
37
+ return api.get(`/api/payouts?${search.toString()}`).then((res: any) => res.data);
38
38
  };
39
39
 
40
40
  type SearchProps = {
@@ -31,7 +31,7 @@ const fetchData = (
31
31
  }
32
32
  search.set(key, String(v));
33
33
  });
34
- return api.get(`/api/payouts/mine?${search.toString()}`).then((res) => res.data);
34
+ return api.get(`/api/payouts/mine?${search.toString()}`).then((res: any) => res.data);
35
35
  };
36
36
 
37
37
  type SearchProps = {
@@ -16,7 +16,7 @@ type Props = {
16
16
  };
17
17
 
18
18
  const fetchData = (id: string): Promise<TPriceExpanded[]> => {
19
- return api.get(`/api/prices/${id}/upsell`).then((res) => res.data);
19
+ return api.get(`/api/prices/${id}/upsell`).then((res: any) => res.data);
20
20
  };
21
21
 
22
22
  export default function UpsellSelect({ price, onSelect, onAdd }: Props) {
@@ -17,7 +17,7 @@ export function UpsellForm({ data, onChange }: { data: TPriceExpanded; onChange:
17
17
  const onRemoveUpsell = async () => {
18
18
  try {
19
19
  setState({ loading: true });
20
- await api.put(`/api/prices/${data.id}`, { upsell: { upsells_to_id: '' } }).then((res) => res.data);
20
+ await api.put(`/api/prices/${data.id}`, { upsell: { upsells_to_id: '' } }).then((res: any) => res.data);
21
21
  setState({ loading: false });
22
22
  onChange();
23
23
  } catch (err) {
@@ -30,7 +30,7 @@ export function UpsellForm({ data, onChange }: { data: TPriceExpanded; onChange:
30
30
  const onSelectUpsell = async (id: string) => {
31
31
  try {
32
32
  setState({ loading: true });
33
- await api.put(`/api/prices/${data.id}`, { upsell: { upsells_to_id: id } }).then((res) => res.data);
33
+ await api.put(`/api/prices/${data.id}`, { upsell: { upsells_to_id: id } }).then((res: any) => res.data);
34
34
  setState({ loading: false });
35
35
  onChange();
36
36
  } catch (err) {
@@ -28,7 +28,7 @@ export default function PricingTableActions({ data, variant = 'compact', onChang
28
28
  const onUpdate = async (updates: TPricingTableExpanded) => {
29
29
  try {
30
30
  setState({ loading: true });
31
- await api.put(`/api/pricing-tables/${data.id}`, updates).then((res) => res.data);
31
+ await api.put(`/api/pricing-tables/${data.id}`, updates).then((res: any) => res.data);
32
32
  Toast.success(t('common.saved'));
33
33
  onChange(state.action);
34
34
  } catch (err) {
@@ -41,7 +41,7 @@ export default function PricingTableActions({ data, variant = 'compact', onChang
41
41
  const onArchive = async () => {
42
42
  try {
43
43
  setState({ loading: true });
44
- await api.put(`/api/pricing-tables/${data.id}/archive`).then((res) => res.data);
44
+ await api.put(`/api/pricing-tables/${data.id}/archive`).then((res: any) => res.data);
45
45
  Toast.success(t('common.saved'));
46
46
  onChange(state.action);
47
47
  } catch (err) {
@@ -54,7 +54,7 @@ export default function PricingTableActions({ data, variant = 'compact', onChang
54
54
  const onRemove = async () => {
55
55
  try {
56
56
  setState({ loading: true });
57
- await api.delete(`/api/pricing-tables/${data.id}`).then((res) => res.data);
57
+ await api.delete(`/api/pricing-tables/${data.id}`).then((res: any) => res.data);
58
58
  Toast.success(t('common.removed'));
59
59
  onChange(state.action);
60
60
  } catch (err) {
@@ -30,7 +30,7 @@ export default function ProductItem({ product, prices, valid, onUpdate, onRemove
30
30
  const onSave = async (updates: TProduct) => {
31
31
  try {
32
32
  setState({ loading: true });
33
- await api.put(`/api/products/${product.id}`, updates).then((res) => res.data);
33
+ await api.put(`/api/products/${product.id}`, updates).then((res: any) => res.data);
34
34
  Toast.success(t('common.saved'));
35
35
  onUpdate();
36
36
  } catch (err) {
@@ -28,7 +28,7 @@ export default function ProductActions({ data, variant = 'compact', onChange }:
28
28
  const onUpdate = async (updates: TProduct) => {
29
29
  try {
30
30
  setState({ loading: true });
31
- await api.put(`/api/products/${data.id}`, updates).then((res) => res.data);
31
+ await api.put(`/api/products/${data.id}`, updates).then((res: any) => res.data);
32
32
  Toast.success(t('common.saved'));
33
33
  onChange(state.action);
34
34
  } catch (err) {
@@ -41,7 +41,7 @@ export default function ProductActions({ data, variant = 'compact', onChange }:
41
41
  const onArchive = async () => {
42
42
  try {
43
43
  setState({ loading: true });
44
- await api.put(`/api/products/${data.id}/archive`).then((res) => res.data);
44
+ await api.put(`/api/products/${data.id}/archive`).then((res: any) => res.data);
45
45
  Toast.success(t('common.saved'));
46
46
  onChange(state.action);
47
47
  } catch (err) {
@@ -54,7 +54,7 @@ export default function ProductActions({ data, variant = 'compact', onChange }:
54
54
  const onRemove = async () => {
55
55
  try {
56
56
  setState({ loading: true });
57
- await api.delete(`/api/products/${data.id}`).then((res) => res.data);
57
+ await api.delete(`/api/products/${data.id}`).then((res: any) => res.data);
58
58
  Toast.success(t('common.removed'));
59
59
  onChange(state.action);
60
60
  } catch (err) {
@@ -53,7 +53,7 @@ export default function CreateProduct({
53
53
  .then(() => {
54
54
  Toast.success(t('admin.product.saved'));
55
55
  })
56
- .catch((err) => {
56
+ .catch((err: any) => {
57
57
  console.error(err);
58
58
  Toast.error(formatError(err));
59
59
  })
@@ -23,7 +23,7 @@ export function CrossSellForm({ data, onChange }: { data: TProductExpanded; onCh
23
23
  const onRemoveUpsell = async () => {
24
24
  try {
25
25
  setState({ loading: true });
26
- await api.put(`/api/products/${data.id}`, { cross_sell: { cross_sells_to_id: '' } }).then((res) => res.data);
26
+ await api.put(`/api/products/${data.id}`, { cross_sell: { cross_sells_to_id: '' } }).then((res: any) => res.data);
27
27
  setState({ loading: false });
28
28
  onChange();
29
29
  } catch (err) {
@@ -44,7 +44,7 @@ export function CrossSellForm({ data, onChange }: { data: TProductExpanded; onCh
44
44
  return;
45
45
  }
46
46
  setState({ loading: true });
47
- await api.put(`/api/products/${data.id}`, { cross_sell: { cross_sells_to_id: id } }).then((res) => res.data);
47
+ await api.put(`/api/products/${data.id}`, { cross_sell: { cross_sells_to_id: id } }).then((res: any) => res.data);
48
48
  setState({ loading: false });
49
49
  onChange();
50
50
  } catch (err) {
@@ -43,7 +43,7 @@ const fetchActiveRedemptions = (
43
43
 
44
44
  const endpoint =
45
45
  entityType === 'coupon' ? `/api/coupons/${id}/redemptions` : `/api/promotion-codes/${id}/redemptions`;
46
- return api.get(`${endpoint}?${query}`).then((res) => res.data);
46
+ return api.get(`${endpoint}?${query}`).then((res: any) => res.data);
47
47
  };
48
48
 
49
49
  export default function ActiveRedemptions({ couponId = '', promotionCodeId = '' }: Props) {
@@ -31,7 +31,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: TRefundExp
31
31
  }
32
32
  search.set(key, String(v));
33
33
  });
34
- return api.get(`/api/refunds?${search.toString()}`).then((res) => res.data);
34
+ return api.get(`/api/refunds?${search.toString()}`).then((res: any) => res.data);
35
35
  };
36
36
 
37
37
  type SearchProps = {
@@ -75,7 +75,7 @@ function SubscriptionActionsInner({ data, variant = 'compact', onChange }: Props
75
75
  try {
76
76
  setState({ loading: true });
77
77
  const key = action === 'slash-stake' ? 'slashStake' : action;
78
- await api.put(`/api/subscriptions/${data.id}/${action}`, values[key] || {}).then((res) => res.data);
78
+ await api.put(`/api/subscriptions/${data.id}/${action}`, values[key] || {}).then((res: any) => res.data);
79
79
  Toast.success(t('common.saved'));
80
80
  onChange(state.action);
81
81
  } catch (err) {
@@ -28,7 +28,7 @@ const fetchData = (
28
28
  end,
29
29
  })
30
30
  )
31
- .then((res) => res.data);
31
+ .then((res: any) => res.data);
32
32
  };
33
33
 
34
34
  const colors = {
@@ -43,7 +43,9 @@ function addUsageQuantity({
43
43
  subscriptionItemId: string;
44
44
  params: import('stripe').Stripe.UsageRecordCreateParams;
45
45
  }) {
46
- return api.post(`api/subscription-items/${subscriptionItemId}/add-usage-quantity`, params).then((res) => res.data);
46
+ return api
47
+ .post(`api/subscription-items/${subscriptionItemId}/add-usage-quantity`, params)
48
+ .then((res: any) => res.data);
47
49
  }
48
50
 
49
51
  export function UsageRecordDialog({
@@ -24,7 +24,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: TSubscript
24
24
  }
25
25
  search.set(key, String(v));
26
26
  });
27
- return api.get(`/api/subscriptions?${search.toString()}`).then((res) => res.data);
27
+ return api.get(`/api/subscriptions?${search.toString()}`).then((res: any) => res.data);
28
28
  };
29
29
 
30
30
  type SearchProps = {
@@ -17,11 +17,11 @@ type Props = {
17
17
  };
18
18
 
19
19
  const fetchUpcoming = (id: string): Promise<{ amount: string }> => {
20
- return api.get(`/api/subscriptions/${id}/upcoming`).then((res) => res.data);
20
+ return api.get(`/api/subscriptions/${id}/upcoming`).then((res: any) => res.data);
21
21
  };
22
22
 
23
23
  const fetchPayer = (id: string): Promise<{ token: string; paymentAddress: string }> => {
24
- return api.get(`/api/subscriptions/${id}/payer-token`).then((res) => res.data);
24
+ return api.get(`/api/subscriptions/${id}/payer-token`).then((res: any) => res.data);
25
25
  };
26
26
 
27
27
  const fetchCreditBalance = ({
@@ -33,7 +33,7 @@ const fetchCreditBalance = ({
33
33
  }): Promise<{ [key: string]: CreditGrantSummary }> => {
34
34
  return api
35
35
  .get(`/api/credit-grants/summary?customer_id=${customerId}&subscription_id=${subscriptionId}`)
36
- .then((res) => res.data);
36
+ .then((res: any) => res.data);
37
37
  };
38
38
 
39
39
  export default function SubscriptionMetrics({ subscription, showBalance = true, mode = 'portal' }: Props) {
@@ -168,15 +168,15 @@ export function SubscriptionActionsInner({
168
168
  ready: !!showExtra,
169
169
  });
170
170
 
171
- const { data: upcoming = {} } = useRequest(
172
- () => api.get(`/api/subscriptions/${subscription.id}/upcoming`).then((res) => res.data),
171
+ const { data: upcoming = {} } = useRequest<any, any[]>(
172
+ () => api.get(`/api/subscriptions/${subscription.id}/upcoming`).then((res: any) => res.data),
173
173
  {
174
174
  ready: showAction('recharge') && !!(showRecharge && supportRecharge(subscription)) && showBalanceInfo,
175
175
  }
176
176
  );
177
177
 
178
- const { data: payerValue = {} } = useRequest(
179
- () => api.get(`/api/subscriptions/${subscription.id}/payer-token`).then((res) => res.data),
178
+ const { data: payerValue = {} } = useRequest<any, any[]>(
179
+ () => api.get(`/api/subscriptions/${subscription.id}/payer-token`).then((res: any) => res.data),
180
180
  {
181
181
  ready: showAction('recharge') && !!(showRecharge && supportRecharge(subscription)) && showBalanceInfo,
182
182
  }
@@ -203,8 +203,8 @@ export function SubscriptionActionsInner({
203
203
  ['active', 'trialing', 'past_due'].includes(subscription?.status) &&
204
204
  showAction('protection');
205
205
 
206
- const { data: delegation = { sufficient: true }, refresh: refreshDelegation } = useRequest(
207
- () => api.get(`/api/subscriptions/${subscription.id}/delegation`).then((res) => res.data),
206
+ const { data: delegation = { sufficient: true }, refresh: refreshDelegation } = useRequest<any, any[]>(
207
+ () => api.get(`/api/subscriptions/${subscription.id}/delegation`).then((res: any) => res.data),
208
208
  {
209
209
  ready: showAction('delegation') && shouldFetchDelegation,
210
210
  refreshDeps: [subscription.id, shouldFetchDelegation],
@@ -213,10 +213,13 @@ export function SubscriptionActionsInner({
213
213
  const noDelegation = delegation && typeof delegation === 'object' && !delegation.sufficient;
214
214
 
215
215
  const { data: overdraftProtection = { enabled: false, remaining: '0' }, refresh: refreshOverdraftProtection } =
216
- useRequest(() => api.get(`/api/subscriptions/${subscription.id}/overdraft-protection`).then((res) => res.data), {
217
- ready: shouldFetchOverdraftProtection,
218
- refreshDeps: [subscription.id, shouldFetchOverdraftProtection],
219
- });
216
+ useRequest<any, any[]>(
217
+ () => api.get(`/api/subscriptions/${subscription.id}/overdraft-protection`).then((res: any) => res.data),
218
+ {
219
+ ready: shouldFetchOverdraftProtection,
220
+ refreshDeps: [subscription.id, shouldFetchOverdraftProtection],
221
+ }
222
+ );
220
223
 
221
224
  useEffect(() => {
222
225
  if (setUp) {
@@ -245,7 +248,7 @@ export function SubscriptionActionsInner({
245
248
  ...getValues().cancel,
246
249
  cancel_from: 'customer',
247
250
  })
248
- .then((res) => res.data);
251
+ .then((res: any) => res.data);
249
252
  setSubscription(sub);
250
253
  Toast.success(t('common.saved'));
251
254
  if (onChange) onChange(state.action);
@@ -297,7 +300,7 @@ export function SubscriptionActionsInner({
297
300
  setState({ protectionLoading: true });
298
301
  const result = await api
299
302
  .post(`/api/subscriptions/${subscription.id}/overdraft-protection`, formData)
300
- .then((res) => res.data);
303
+ .then((res: any) => res.data);
301
304
 
302
305
  const { open, amount } = result;
303
306
 
@@ -35,7 +35,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<SubscriptionListRe
35
35
  Object.keys(params).forEach((key) => {
36
36
  search.set(key, String(params[key]));
37
37
  });
38
- return api.get(`/api/subscriptions?${search.toString()}`).then((res) => res.data);
38
+ return api.get(`/api/subscriptions?${search.toString()}`).then((res: any) => res.data);
39
39
  };
40
40
 
41
41
  const TAG_COUNT = 2;
@@ -31,7 +31,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<Paginated<TWebhook
31
31
  Object.keys(params).forEach((key) => {
32
32
  search.set(key, String(params[key]));
33
33
  });
34
- return api.get(`/api/webhook-attempts?${search.toString()}`).then((res) => res.data);
34
+ return api.get(`/api/webhook-attempts?${search.toString()}`).then((res: any) => res.data);
35
35
  };
36
36
 
37
37
  const groupAttemptsByDate = (attempts: TWebhookAttemptExpanded[]) => {
@@ -78,11 +78,11 @@ export default function WebhookAttempts({ event_id = '', webhook_endpoint_id = '
78
78
 
79
79
  const groupedAttempts = groupAttemptsByDate(attempts);
80
80
 
81
- const { loading: retrying, run: retryWebhook } = useRequest(
82
- (eventId: string) => api.post(`/api/events/${eventId}/retry-webhooks`).then((res) => res.data),
81
+ const { loading: retrying, run: retryWebhook } = useRequest<any, any[]>(
82
+ (eventId: string) => api.post(`/api/events/${eventId}/retry-webhooks`).then((res: any) => res.data),
83
83
  {
84
84
  manual: true,
85
- onSuccess: (result) => {
85
+ onSuccess: (result: any) => {
86
86
  Toast.success(result.message || t('admin.event.retryOptions.success'));
87
87
  reload();
88
88
  },
@@ -8,8 +8,8 @@ import type { TPaymentCurrency } from '@blocklet/payment-types';
8
8
  export function useUnpaidInvoicesCheckForSubscription(subscriptionId: string, manualCheck: boolean = false) {
9
9
  const { t } = useLocaleContext();
10
10
 
11
- const { data = { count: 0 }, runAsync } = useRequest(
12
- () => api.get(`/api/subscriptions/${subscriptionId}/unpaid-invoices`).then((res) => res.data),
11
+ const { data = { count: 0 }, runAsync } = useRequest<any, any[]>(
12
+ () => api.get(`/api/subscriptions/${subscriptionId}/unpaid-invoices`).then((res: any) => res.data),
13
13
  {
14
14
  manual: manualCheck,
15
15
  }
@@ -164,6 +164,10 @@ export default flat({
164
164
  title: 'Total Income',
165
165
  subtitle: "User's actual payment",
166
166
  },
167
+ refundAmount: {
168
+ title: 'Refund Amount',
169
+ subtitle: 'Total refunds issued',
170
+ },
167
171
  costOfGoods: {
168
172
  title: 'Cost of Goods',
169
173
  subtitle: 'Supplier share',
@@ -162,6 +162,10 @@ export default flat({
162
162
  title: '总收入',
163
163
  subtitle: '用户实际支付',
164
164
  },
165
+ refundAmount: {
166
+ title: '退款金额',
167
+ subtitle: '已退款总额',
168
+ },
165
169
  costOfGoods: {
166
170
  title: '进货成本',
167
171
  subtitle: '供应商分成',
@@ -38,7 +38,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: TMeterEven
38
38
  }
39
39
  }
40
40
  });
41
- return api.get(`/api/meter-events?${search.toString()}`).then((res) => res.data);
41
+ return api.get(`/api/meter-events?${search.toString()}`).then((res: any) => res.data);
42
42
  };
43
43
 
44
44
  const fetchCustomers = (params: Record<string, any> = {}): Promise<{ list: TCustomer[]; count: number }> => {
@@ -52,11 +52,11 @@ const fetchCustomers = (params: Record<string, any> = {}): Promise<{ list: TCust
52
52
  }
53
53
  search.set(key, String(v));
54
54
  });
55
- return api.get(`/api/customers?${search.toString()}`).then((res) => res.data);
55
+ return api.get(`/api/customers?${search.toString()}`).then((res: any) => res.data);
56
56
  };
57
57
 
58
58
  const fetchMeters = (): Promise<{ list: TMeter[]; count: number }> => {
59
- return api.get('/api/meters?pageSize=100').then((res) => res.data);
59
+ return api.get('/api/meters?pageSize=100').then((res: any) => res.data);
60
60
  };
61
61
 
62
62
  type SearchProps = {
@@ -22,7 +22,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: TMeter[];
22
22
  }
23
23
  search.set(key, String(v));
24
24
  });
25
- return api.get(`/api/meters?${search.toString()}`).then((res) => res.data);
25
+ return api.get(`/api/meters?${search.toString()}`).then((res: any) => res.data);
26
26
  };
27
27
 
28
28
  type SearchProps = {
@@ -36,11 +36,11 @@ const fetchData = (params: Record<string, any> = {}): Promise<ApiResponse> => {
36
36
  search.set(key, String(v));
37
37
  }
38
38
  });
39
- return api.get(`/api/meter-events/overdue-customers?${search.toString()}`).then((res) => res.data);
39
+ return api.get(`/api/meter-events/overdue-customers?${search.toString()}`).then((res: any) => res.data);
40
40
  };
41
41
 
42
42
  const fetchCreditCurrencies = (): Promise<TPaymentCurrency[]> => {
43
- return api.get('/api/payment-currencies?credit=true').then((res) => {
43
+ return api.get('/api/payment-currencies?credit=true').then((res: any) => {
44
44
  // Filter to only return credit type currencies
45
45
  return (res.data || []).filter((c: TPaymentCurrency) => c.type === 'credit');
46
46
  });
@@ -39,7 +39,7 @@ import { useSessionContext } from '../../../../contexts/session';
39
39
  import PaymentMethodInfo from '../../../../components/subscription/payment-method-info';
40
40
 
41
41
  const fetchData = (id: string): Promise<TSubscriptionExpanded> => {
42
- return api.get(`/api/subscriptions/${id}`).then((res) => res.data);
42
+ return api.get(`/api/subscriptions/${id}`).then((res: any) => res.data);
43
43
  };
44
44
 
45
45
  export default function SubscriptionDetail(props: { id: string }) {
@@ -74,7 +74,7 @@ export default function SubscriptionDetail(props: { id: string }) {
74
74
  const createUpdater = (key: string) => async (updates: TProduct) => {
75
75
  try {
76
76
  setState((prev) => ({ loading: { ...prev.loading, [key]: true } }));
77
- await api.put(`/api/subscriptions/${props.id}`, updates).then((res) => res.data);
77
+ await api.put(`/api/subscriptions/${props.id}`, updates).then((res: any) => res.data);
78
78
  Toast.success(t('common.saved'));
79
79
  runAsync();
80
80
  } catch (err) {
@@ -32,7 +32,7 @@ import { goBackOrFallback } from '../../../../../libs/util';
32
32
  import EventList from '../../../../../components/event/list';
33
33
 
34
34
  const fetchData = (id: string | undefined): Promise<TCreditGrantExpanded> => {
35
- return api.get(`/api/credit-grants/${id}`).then((res) => res.data);
35
+ return api.get(`/api/credit-grants/${id}`).then((res: any) => res.data);
36
36
  };
37
37
 
38
38
  export default function AdminCreditGrantDetail({ id }: { id: string }) {
@@ -27,7 +27,7 @@ import { goBackOrFallback } from '../../../../../libs/util';
27
27
  import EventList from '../../../../../components/event/list';
28
28
 
29
29
  const fetchData = (id: string | undefined): Promise<TCreditTransactionExpanded> => {
30
- return api.get(`/api/credit-transactions/${id}`).then((res) => res.data);
30
+ return api.get(`/api/credit-transactions/${id}`).then((res: any) => res.data);
31
31
  };
32
32
 
33
33
  export default function AdminCreditTransactionDetail({ id }: { id: string }) {
@@ -44,8 +44,8 @@ const fetchData = async (
44
44
  summary: { [key: string]: GroupedBN };
45
45
  }> => {
46
46
  const [customer, summary] = await Promise.all([
47
- api.get(`/api/customers/${id}`).then((res) => res.data),
48
- api.get(`/api/customers/${id}/summary`).then((res) => res.data),
47
+ api.get(`/api/customers/${id}`).then((res: any) => res.data),
48
+ api.get(`/api/customers/${id}/summary`).then((res: any) => res.data),
49
49
  ]);
50
50
 
51
51
  return {
@@ -121,7 +121,7 @@ export default function CustomerDetail(props: { id: string }) {
121
121
  const onUpdateMetadata = async (updates: TCustomerExpanded) => {
122
122
  try {
123
123
  setState((prev) => ({ loading: { ...prev.loading, metadata: true } }));
124
- await api.put(`/api/customers/${props.id}`, updates).then((res) => res.data);
124
+ await api.put(`/api/customers/${props.id}`, updates).then((res: any) => res.data);
125
125
  Toast.success(t('common.saved'));
126
126
  runAsync();
127
127
  } catch (err) {
@@ -135,7 +135,7 @@ export default function CustomerDetail(props: { id: string }) {
135
135
  const onUpdateInfo = async (updates: TCustomerExpanded) => {
136
136
  try {
137
137
  setState((prev) => ({ loading: { ...prev.loading, customer: true } }));
138
- await api.put(`/api/customers/${props.id}`, updates).then((res) => res.data);
138
+ await api.put(`/api/customers/${props.id}`, updates).then((res: any) => res.data);
139
139
  Toast.success(t('common.saved'));
140
140
  runAsync();
141
141
  } catch (err) {
@@ -14,7 +14,7 @@ import WebhookAttempts from '../../../../components/webhook/attempts';
14
14
  import { goBackOrFallback } from '../../../../libs/util';
15
15
 
16
16
  const fetchData = (id: string): Promise<TEventExpanded> => {
17
- return api.get(`/api/events/${id}`).then((res) => res.data);
17
+ return api.get(`/api/events/${id}`).then((res: any) => res.data);
18
18
  };
19
19
 
20
20
  export default function EventDetail(props: { id: string }) {
@@ -14,7 +14,7 @@ import WebhookAttempts from '../../../../components/webhook/attempts';
14
14
  import { getWebhookStatusColor, goBackOrFallback } from '../../../../libs/util';
15
15
 
16
16
  const fetchData = (id: string): Promise<TWebhookEndpointExpanded> => {
17
- return api.get(`/api/webhook-endpoints/${id}`).then((res) => res.data);
17
+ return api.get(`/api/webhook-endpoints/${id}`).then((res: any) => res.data);
18
18
  };
19
19
 
20
20
  export default function WebhookDetail(props: { id: string }) {
@@ -16,7 +16,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: TWebhookEn
16
16
  Object.keys(params).forEach((key) => {
17
17
  search.set(key, String(params[key]));
18
18
  });
19
- return api.get(`/api/webhook-endpoints?${search.toString()}`).then((res) => res.data);
19
+ return api.get(`/api/webhook-endpoints?${search.toString()}`).then((res: any) => res.data);
20
20
  };
21
21
 
22
22
  export default function WebhooksList() {
@@ -47,7 +47,9 @@ import DateRangePicker from '../../components/date-range-picker';
47
47
 
48
48
  type TRevenueStat = {
49
49
  totalRevenue: string;
50
+ refundAmount: string;
50
51
  promotionCost: string;
52
+ creditGrantCost: string;
51
53
  vendorCost: string;
52
54
  taxedRevenue: string;
53
55
  netRevenue: string;
@@ -38,7 +38,7 @@ import RefundList from '../../../../components/refund/list';
38
38
  import InfoRowGroup from '../../../../components/info-row-group';
39
39
 
40
40
  const fetchData = (id: string): Promise<TPaymentIntentExpanded> => {
41
- return api.get(`/api/payment-intents/${id}`).then((res) => res.data);
41
+ return api.get(`/api/payment-intents/${id}`).then((res: any) => res.data);
42
42
  };
43
43
 
44
44
  const InfoDirection = 'column';
@@ -75,7 +75,7 @@ export default function PaymentIntentDetail(props: { id: string }) {
75
75
  const createUpdater = (key: string) => async (updates: TPaymentIntentExpanded) => {
76
76
  try {
77
77
  setState((prev) => ({ loading: { ...prev.loading, [key]: true } }));
78
- await api.put(`/api/payment-intents/${props.id}`, updates).then((res) => res.data);
78
+ await api.put(`/api/payment-intents/${props.id}`, updates).then((res: any) => res.data);
79
79
  Toast.success(t('common.saved'));
80
80
  runAsync();
81
81
  } catch (err) {
@@ -43,7 +43,7 @@ const fetchData = (
43
43
  paymentIntent?: { customer: TCustomer };
44
44
  }
45
45
  > => {
46
- return api.get(`/api/payouts/${id}`).then((res) => res.data);
46
+ return api.get(`/api/payouts/${id}`).then((res: any) => res.data);
47
47
  };
48
48
 
49
49
  const InfoDirection = 'column';
@@ -80,7 +80,7 @@ export default function PayoutDetail(props: { id: string }) {
80
80
  const createUpdater = (key: string) => async (updates: TPayoutExpanded) => {
81
81
  try {
82
82
  setState((prev) => ({ loading: { ...prev.loading, [key]: true } }));
83
- await api.put(`/api/payouts/${props.id}`, updates).then((res) => res.data);
83
+ await api.put(`/api/payouts/${props.id}`, updates).then((res: any) => res.data);
84
84
  Toast.success(t('common.saved'));
85
85
  runAsync();
86
86
  } catch (err) {
@@ -34,7 +34,7 @@ import { goBackOrFallback } from '../../../../libs/util';
34
34
  import InfoRowGroup from '../../../../components/info-row-group';
35
35
 
36
36
  const fetchData = (id: string): Promise<TRefundExpanded> => {
37
- return api.get(`/api/refunds/${id}`).then((res) => res.data);
37
+ return api.get(`/api/refunds/${id}`).then((res: any) => res.data);
38
38
  };
39
39
 
40
40
  const InfoDirection = 'column';
@@ -71,7 +71,7 @@ export default function RefundDetail(props: { id: string }) {
71
71
  const createUpdater = (key: string) => async (updates: TRefundExpanded) => {
72
72
  try {
73
73
  setState((prev) => ({ loading: { ...prev.loading, [key]: true } }));
74
- await api.put(`/api/refunds/${props.id}`, updates).then((res) => res.data);
74
+ await api.put(`/api/refunds/${props.id}`, updates).then((res: any) => res.data);
75
75
  Toast.success(t('common.saved'));
76
76
  runAsync();
77
77
  } catch (err) {
@@ -36,7 +36,7 @@ import ApplicableProductsList from './applicable-products';
36
36
  import CurrencyRestrictions from '../../../../components/promotion/currency-restrictions';
37
37
 
38
38
  const getCoupon = (id: string): Promise<any> => {
39
- return api.get(`/api/coupons/${id}`).then((res) => res.data);
39
+ return api.get(`/api/coupons/${id}`).then((res: any) => res.data);
40
40
  };
41
41
 
42
42
  export default function CouponDetail(props: { id: string }) {
@@ -24,7 +24,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: any[]; cou
24
24
  }
25
25
  search.set(key, String(v));
26
26
  });
27
- return api.get(`/api/coupons?${search.toString()}`).then((res) => res.data);
27
+ return api.get(`/api/coupons?${search.toString()}`).then((res: any) => res.data);
28
28
  };
29
29
 
30
30
  type SearchProps = {
@@ -34,7 +34,7 @@ const DEFAULT_BASE_URLS = {
34
34
  } as const;
35
35
 
36
36
  const fetchProviders = (): Promise<{ data: ExchangeRateProvider[] }> => {
37
- return api.get('/api/exchange-rate-providers').then((res) => res.data);
37
+ return api.get('/api/exchange-rate-providers').then((res: any) => res.data);
38
38
  };
39
39
 
40
40
  const getStatusColor = (status: string) => {
@@ -133,7 +133,7 @@ export default function CreatePaymentLink() {
133
133
  dispatch('drawer.submitted');
134
134
  dispatch('paymentLink.created');
135
135
  })
136
- .catch((err) => {
136
+ .catch((err: any) => {
137
137
  console.error(err);
138
138
  Toast.error(formatError(err));
139
139
  });