payment-kit 1.25.10 → 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 (86) hide show
  1. package/api/src/libs/session.ts +43 -25
  2. package/api/src/queues/subscription.ts +3 -1
  3. package/api/src/routes/checkout-sessions.ts +50 -34
  4. package/api/src/routes/meters.ts +28 -0
  5. package/blocklet.yml +2 -1
  6. package/package.json +6 -6
  7. package/src/components/customer/actions.tsx +1 -1
  8. package/src/components/customer/credit-overview.tsx +3 -1
  9. package/src/components/customer/overdraft-protection.tsx +1 -1
  10. package/src/components/event/list.tsx +1 -1
  11. package/src/components/filter-toolbar.tsx +2 -2
  12. package/src/components/invoice/action.tsx +3 -3
  13. package/src/components/invoice/list.tsx +1 -1
  14. package/src/components/invoice/recharge.tsx +2 -2
  15. package/src/components/meter/add-usage-dialog.tsx +1 -1
  16. package/src/components/passport/actions.tsx +1 -1
  17. package/src/components/passport/assign.tsx +1 -1
  18. package/src/components/payment-currency/add.tsx +1 -1
  19. package/src/components/payment-currency/edit.tsx +1 -1
  20. package/src/components/payment-intent/actions.tsx +4 -4
  21. package/src/components/payment-intent/list.tsx +1 -1
  22. package/src/components/payment-link/actions.tsx +4 -4
  23. package/src/components/payment-link/item.tsx +1 -1
  24. package/src/components/payouts/list.tsx +1 -1
  25. package/src/components/payouts/portal/list.tsx +1 -1
  26. package/src/components/price/upsell-select.tsx +1 -1
  27. package/src/components/price/upsell.tsx +2 -2
  28. package/src/components/pricing-table/actions.tsx +3 -3
  29. package/src/components/pricing-table/product-item.tsx +1 -1
  30. package/src/components/product/actions.tsx +3 -3
  31. package/src/components/product/create.tsx +1 -1
  32. package/src/components/product/cross-sell.tsx +2 -2
  33. package/src/components/promotion/active-redemptions.tsx +1 -1
  34. package/src/components/refund/list.tsx +1 -1
  35. package/src/components/subscription/actions/index.tsx +1 -1
  36. package/src/components/subscription/items/usage-records.tsx +4 -2
  37. package/src/components/subscription/list.tsx +1 -1
  38. package/src/components/subscription/metrics.tsx +3 -3
  39. package/src/components/subscription/portal/actions.tsx +15 -12
  40. package/src/components/subscription/portal/list.tsx +1 -1
  41. package/src/components/webhook/attempts.tsx +4 -4
  42. package/src/hooks/subscription.ts +2 -2
  43. package/src/pages/admin/billing/meter-events/index.tsx +3 -3
  44. package/src/pages/admin/billing/meters/index.tsx +1 -1
  45. package/src/pages/admin/billing/overdue/index.tsx +2 -2
  46. package/src/pages/admin/billing/subscriptions/detail.tsx +2 -2
  47. package/src/pages/admin/customers/customers/credit-grant/detail.tsx +1 -1
  48. package/src/pages/admin/customers/customers/credit-transaction/detail.tsx +1 -1
  49. package/src/pages/admin/customers/customers/detail.tsx +4 -4
  50. package/src/pages/admin/developers/events/detail.tsx +1 -1
  51. package/src/pages/admin/developers/webhooks/detail.tsx +1 -1
  52. package/src/pages/admin/developers/webhooks/index.tsx +1 -1
  53. package/src/pages/admin/payments/intents/detail.tsx +2 -2
  54. package/src/pages/admin/payments/payouts/detail.tsx +2 -2
  55. package/src/pages/admin/payments/refunds/detail.tsx +2 -2
  56. package/src/pages/admin/products/coupons/detail.tsx +1 -1
  57. package/src/pages/admin/products/coupons/index.tsx +1 -1
  58. package/src/pages/admin/products/exchange-rate-providers/index.tsx +1 -1
  59. package/src/pages/admin/products/links/create.tsx +1 -1
  60. package/src/pages/admin/products/links/detail.tsx +2 -2
  61. package/src/pages/admin/products/links/index.tsx +1 -1
  62. package/src/pages/admin/products/passports/index.tsx +1 -1
  63. package/src/pages/admin/products/prices/actions.tsx +4 -4
  64. package/src/pages/admin/products/prices/detail.tsx +2 -2
  65. package/src/pages/admin/products/pricing-tables/create.tsx +1 -1
  66. package/src/pages/admin/products/pricing-tables/detail.tsx +2 -2
  67. package/src/pages/admin/products/pricing-tables/index.tsx +1 -1
  68. package/src/pages/admin/products/products/index.tsx +1 -1
  69. package/src/pages/admin/products/promotion-codes/actions.tsx +2 -2
  70. package/src/pages/admin/products/promotion-codes/detail.tsx +2 -2
  71. package/src/pages/admin/products/promotion-codes/list.tsx +1 -1
  72. package/src/pages/admin/settings/payment-methods/create.tsx +1 -1
  73. package/src/pages/admin/settings/payment-methods/edit.tsx +1 -1
  74. package/src/pages/admin/settings/payment-methods/index.tsx +2 -2
  75. package/src/pages/admin/tax/detail.tsx +2 -2
  76. package/src/pages/admin/tax/list.tsx +1 -1
  77. package/src/pages/checkout/pay.tsx +2 -2
  78. package/src/pages/customer/index.tsx +1 -1
  79. package/src/pages/customer/invoice/past-due.tsx +1 -1
  80. package/src/pages/customer/payout/detail.tsx +1 -1
  81. package/src/pages/customer/refund/list.tsx +1 -1
  82. package/src/pages/customer/subscription/change-payment.tsx +2 -2
  83. package/src/pages/customer/subscription/change-plan.tsx +3 -3
  84. package/src/pages/customer/subscription/detail.tsx +3 -3
  85. package/src/pages/integrations/donations/index.tsx +1 -1
  86. package/vite.config.ts +2 -1
@@ -82,7 +82,7 @@ export default function CreatePricingTable() {
82
82
  dispatch('drawer.submitted');
83
83
  dispatch('pricingTable.created');
84
84
  })
85
- .catch((err) => {
85
+ .catch((err: any) => {
86
86
  console.error(err);
87
87
  Toast.error(formatError(err));
88
88
  });
@@ -24,7 +24,7 @@ import InfoMetric from '../../../../components/info-metric';
24
24
  import InfoRowGroup from '../../../../components/info-row-group';
25
25
 
26
26
  const fetchData = (id: string): Promise<TPricingTableExpanded> => {
27
- return api.get(`/api/pricing-tables/${id}`).then((res) => res.data);
27
+ return api.get(`/api/pricing-tables/${id}`).then((res: any) => res.data);
28
28
  };
29
29
 
30
30
  export default function PricingTableDetail(props: { id: string }) {
@@ -59,7 +59,7 @@ export default function PricingTableDetail(props: { id: string }) {
59
59
  const createUpdater = (key: string) => async (updates: TProduct) => {
60
60
  try {
61
61
  setState((prev) => ({ loading: { ...prev.loading, [key]: true } }));
62
- await api.put(`/api/pricing-tables/${props.id}`, updates).then((res) => res.data);
62
+ await api.put(`/api/pricing-tables/${props.id}`, updates).then((res: any) => res.data);
63
63
  Toast.success(t('common.saved'));
64
64
  runAsync();
65
65
  } catch (err) {
@@ -19,7 +19,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: TPricingTa
19
19
  Object.keys(params).forEach((key) => {
20
20
  search.set(key, String(params[key]));
21
21
  });
22
- return api.get(`/api/pricing-tables?${search.toString()}`).then((res) => res.data);
22
+ return api.get(`/api/pricing-tables?${search.toString()}`).then((res: any) => res.data);
23
23
  };
24
24
 
25
25
  function PricingTables() {
@@ -25,7 +25,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: TProductEx
25
25
  }
26
26
  search.set(key, String(v));
27
27
  });
28
- return api.get(`/api/products?${search.toString()}`).then((res) => res.data);
28
+ return api.get(`/api/products?${search.toString()}`).then((res: any) => res.data);
29
29
  };
30
30
 
31
31
  type SearchProps = {
@@ -26,7 +26,7 @@ export default function PromotionCodeActions({ data, onChange, variant = 'compac
26
26
  const onArchivePromotionCode = async () => {
27
27
  try {
28
28
  setState({ loading: true });
29
- await api.put(`/api/promotion-codes/${data.id}/archive`).then((res) => res.data);
29
+ await api.put(`/api/promotion-codes/${data.id}/archive`).then((res: any) => res.data);
30
30
  Toast.success(t('common.saved'));
31
31
  dispatch('promotion-code.updated');
32
32
  onChange(state.action);
@@ -41,7 +41,7 @@ export default function PromotionCodeActions({ data, onChange, variant = 'compac
41
41
  const onDeletePromotionCode = async () => {
42
42
  try {
43
43
  setState({ loading: true });
44
- await api.delete(`/api/promotion-codes/${data.id}`).then((res) => res.data);
44
+ await api.delete(`/api/promotion-codes/${data.id}`).then((res: any) => res.data);
45
45
  Toast.success(t('common.removed'));
46
46
  dispatch('promotion-code.deleted');
47
47
  onChange(state.action);
@@ -24,11 +24,11 @@ import CurrencyRestrictions from '../../../../components/promotion/currency-rest
24
24
  import ActiveRedemptions from '../../../../components/promotion/active-redemptions';
25
25
 
26
26
  const getPromotionCode = (id: string): Promise<any> => {
27
- return api.get(`/api/promotion-codes/${id}`).then((res) => res.data);
27
+ return api.get(`/api/promotion-codes/${id}`).then((res: any) => res.data);
28
28
  };
29
29
 
30
30
  const getCoupon = (id: string): Promise<any> => {
31
- return api.get(`/api/coupons/${id}`).then((res) => res.data);
31
+ return api.get(`/api/coupons/${id}`).then((res: any) => res.data);
32
32
  };
33
33
 
34
34
  export default function PromotionCodeDetail(props: { id: string }) {
@@ -32,7 +32,7 @@ const fetchPromotionCodes = (
32
32
  }
33
33
  }
34
34
  });
35
- return api.get(`/api/promotion-codes?${search.toString()}`).then((res) => res.data);
35
+ return api.get(`/api/promotion-codes?${search.toString()}`).then((res: any) => res.data);
36
36
  };
37
37
 
38
38
  type SearchProps = {
@@ -66,7 +66,7 @@ export default function PaymentMethodCreate() {
66
66
  dispatch('drawer.submitted');
67
67
  dispatch('paymentMethod.created');
68
68
  })
69
- .catch((err) => {
69
+ .catch((err: any) => {
70
70
  console.error(err);
71
71
  Toast.error(formatError(err));
72
72
  });
@@ -38,7 +38,7 @@ export default function PaymentMethodEdit({ onClose, value }: { onClose: () => v
38
38
  dispatch('drawer.submitted');
39
39
  dispatch('paymentMethod.updated');
40
40
  })
41
- .catch((err) => {
41
+ .catch((err: any) => {
42
42
  setState({ loading: false });
43
43
  console.error(err);
44
44
  Toast.error(formatError(err));
@@ -56,11 +56,11 @@ const getMethods = (
56
56
  Object.keys(params).forEach((key) => {
57
57
  search.set(key, String(params[key]));
58
58
  });
59
- return api.get(`/api/payment-methods?${search.toString()}`).then((res) => res.data);
59
+ return api.get(`/api/payment-methods?${search.toString()}`).then((res: any) => res.data);
60
60
  };
61
61
 
62
62
  const updateApiHost = (id: string, params: Record<string, any>) => {
63
- return api.put(`/api/payment-methods/${id}/settings`, { arcblock: params }).then((res) => res.data);
63
+ return api.put(`/api/payment-methods/${id}/settings`, { arcblock: params }).then((res: any) => res.data);
64
64
  };
65
65
 
66
66
  function EditApiHost({ method, refresh }: { method: TPaymentMethodExpanded; refresh: () => void }) {
@@ -24,7 +24,7 @@ import DrawerForm from '../../../components/drawer-form';
24
24
  import { goBackOrFallback } from '../../../libs/util';
25
25
  import { getTaxCodeInfo, getCountryInfo } from '../../../components/tax/tax-utils';
26
26
 
27
- const getTaxRate = (id: string) => api.get(`/api/tax-rates/${id}`).then((res) => res.data);
27
+ const getTaxRate = (id: string) => api.get(`/api/tax-rates/${id}`).then((res: any) => res.data);
28
28
 
29
29
  type FormData = TaxRateFormValues & {
30
30
  metadata: Array<{ key: string; value: string }>;
@@ -81,7 +81,7 @@ export default function TaxRateDetail({ id }: Props) {
81
81
  },
82
82
  });
83
83
 
84
- const { data, loading, error, runAsync } = useRequest(() => getTaxRate(id));
84
+ const { data, loading, error, runAsync } = useRequest<any, any[]>(() => getTaxRate(id));
85
85
 
86
86
  if (loading && !data) {
87
87
  return <CircularProgress />;
@@ -36,7 +36,7 @@ const fetchTaxRates = (params: Record<string, any> = {}): Promise<{ list: any[];
36
36
  search.set(key, String(value));
37
37
  });
38
38
 
39
- return api.get(`/api/tax-rates?${search.toString()}`).then((res) => res.data);
39
+ return api.get(`/api/tax-rates?${search.toString()}`).then((res: any) => res.data);
40
40
  };
41
41
 
42
42
  export default function TaxRatesList() {
@@ -1,4 +1,4 @@
1
- import { CheckoutForm } from '@blocklet/payment-react';
1
+ import { CheckoutV2 } from '@blocklet/payment-react';
2
2
  import { useSearchParams } from 'react-router-dom';
3
3
 
4
4
  type Props = {
@@ -34,5 +34,5 @@ export default function Payment({ id }: Props) {
34
34
  }
35
35
  };
36
36
 
37
- return <CheckoutForm mode="standalone" id={id} onPaid={onPaid} />;
37
+ return <CheckoutV2 mode="standalone" id={id} onPaid={onPaid} />;
38
38
  }
@@ -60,7 +60,7 @@ type Result = TCustomerExpanded & {
60
60
  };
61
61
 
62
62
  const fetchData = (): Promise<Result> => {
63
- return api.get('/api/customers/me?skipError=true&create=true').then((res) => res.data);
63
+ return api.get('/api/customers/me?skipError=true&create=true').then((res: any) => res.data);
64
64
  };
65
65
 
66
66
  const emptyObject = {};
@@ -25,7 +25,7 @@ import { goBackOrFallback } from '../../../libs/util';
25
25
  import { useArcsphere } from '../../../hooks/browser';
26
26
 
27
27
  const fetchData = (): Promise<TCustomerExpanded> => {
28
- return api.get('/api/customers/me').then((res) => res.data);
28
+ return api.get('/api/customers/me').then((res: any) => res.data);
29
29
  };
30
30
 
31
31
  export default function CustomerInvoicePastDue() {
@@ -34,7 +34,7 @@ const fetchData = (
34
34
  paymentLink: TPaymentLink;
35
35
  }
36
36
  > => {
37
- return api.get(`/api/payouts/${id}`).then((res) => res.data);
37
+ return api.get(`/api/payouts/${id}`).then((res: any) => res.data);
38
38
  };
39
39
 
40
40
  export default function PayoutDetail() {
@@ -34,7 +34,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<Paginated<TRefundE
34
34
  Object.keys(params).forEach((key) => {
35
35
  search.set(key, String(params[key]));
36
36
  });
37
- return api.get(`/api/refunds?${search.toString()}`).then((res) => res.data);
37
+ return api.get(`/api/refunds?${search.toString()}`).then((res: any) => res.data);
38
38
  };
39
39
 
40
40
  type Props = {
@@ -39,8 +39,8 @@ import { useArcsphere } from '../../../hooks/browser';
39
39
 
40
40
  const fetchData = async (id: string): Promise<{ subscription: TSubscriptionExpanded; customer: TCustomer }> => {
41
41
  const [subscription, customer] = await Promise.all([
42
- api.get(`/api/subscriptions/${id}`).then((res) => res.data),
43
- api.get('/api/customers/me').then((res) => res.data),
42
+ api.get(`/api/subscriptions/${id}`).then((res: any) => res.data),
43
+ api.get('/api/customers/me').then((res: any) => res.data),
44
44
  ]);
45
45
 
46
46
  return {
@@ -135,8 +135,8 @@ const fetchData = async (
135
135
  id: string
136
136
  ): Promise<{ subscription: TSubscriptionExpanded; table: TPricingTableExpanded }> => {
137
137
  const [subscription, table] = await Promise.all([
138
- api.get(`/api/subscriptions/${id}`).then((res) => res.data),
139
- api.get(`/api/subscriptions/${id}/change-plan`).then((res) => res.data),
138
+ api.get(`/api/subscriptions/${id}`).then((res: any) => res.data),
139
+ api.get(`/api/subscriptions/${id}/change-plan`).then((res: any) => res.data),
140
140
  ]);
141
141
 
142
142
  return {
@@ -154,7 +154,7 @@ type UpdateItem = {
154
154
  };
155
155
 
156
156
  const simulateUpdate = ({ id, items }: { id: string; items: UpdateItem[] }) => {
157
- return api.post(`/api/subscriptions/${id}/change-plan`, { items }).then((res) => res.data);
157
+ return api.post(`/api/subscriptions/${id}/change-plan`, { items }).then((res: any) => res.data);
158
158
  };
159
159
 
160
160
  export default function CustomerSubscriptionChangePlan() {
@@ -73,20 +73,20 @@ import { useArcsphere } from '../../../hooks/browser';
73
73
  const defaultSlippageConfig: SlippageConfigValue = { mode: 'percent', percent: 0.5 };
74
74
 
75
75
  const fetchData = (id: string | undefined): Promise<TSubscriptionExpanded> => {
76
- return api.get(`/api/subscriptions/${id}`).then((res) => res.data);
76
+ return api.get(`/api/subscriptions/${id}`).then((res: any) => res.data);
77
77
  };
78
78
 
79
79
  const fetchOverdraftProtection = (
80
80
  id: string
81
81
  ): Promise<{ enabled: boolean; remaining: string; unused: string; upcoming: { amount: string }; gas: string }> => {
82
- return api.get(`/api/subscriptions/${id}/overdraft-protection`).then((res) => res.data);
82
+ return api.get(`/api/subscriptions/${id}/overdraft-protection`).then((res: any) => res.data);
83
83
  };
84
84
 
85
85
  const fetchCycleAmount = (
86
86
  subscriptionId: string,
87
87
  params: { overdraftProtection: boolean }
88
88
  ): Promise<{ amount: string; gas: string; currency: TPaymentCurrency }> => {
89
- return api.get(`/api/subscriptions/${subscriptionId}/cycle-amount`, { params }).then((res) => res.data);
89
+ return api.get(`/api/subscriptions/${subscriptionId}/cycle-amount`, { params }).then((res: any) => res.data);
90
90
  };
91
91
 
92
92
  export default function CustomerSubscriptionDetail() {
@@ -52,7 +52,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<any> => {
52
52
  }
53
53
  search.set(key, String(v));
54
54
  });
55
- return api.get(`/api/settings/donate?${search.toString()}`).then((res) => res.data);
55
+ return api.get(`/api/settings/donate?${search.toString()}`).then((res: any) => res.data);
56
56
  };
57
57
 
58
58
  function CodeExample({ code }: { code: string }) {
package/vite.config.ts CHANGED
@@ -35,8 +35,9 @@ export default defineConfig(({ mode }) => {
35
35
 
36
36
  if (isDevelopment) {
37
37
  alias['@blocklet/payment-react'] = path.resolve(__dirname, '../../packages/react/src');
38
+ alias['@blocklet/payment-react-headless'] = path.resolve(__dirname, '../../packages/payment-react-headless/src');
38
39
  alias['@blocklet/payment-js'] = path.resolve(__dirname, '../../packages/client/src');
39
- exclude.push('@blocklet/payment-react', '@blocklet/payment-js');
40
+ exclude.push('@blocklet/payment-react', '@blocklet/payment-react-headless', '@blocklet/payment-js');
40
41
  }
41
42
 
42
43
  if (isProduction) {