payment-kit 1.13.229 → 1.13.231

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.
@@ -174,7 +174,7 @@ router.get('/', auth, async (req, res) => {
174
174
  const list = await PaymentMethod.findAll({
175
175
  where,
176
176
  order: [['created_at', 'ASC']],
177
- include: [{ model: PaymentCurrency, as: 'payment_currencies' }],
177
+ include: [{ model: PaymentCurrency, as: 'payment_currencies', order: [['created_at', 'ASC']] }],
178
178
  });
179
179
 
180
180
  res.json(list);
@@ -8,13 +8,15 @@ import { PaymentMethod } from '../store/models/payment-method';
8
8
  const router = Router();
9
9
 
10
10
  router.get('/', async (req, res) => {
11
- const attributes = ['id', 'name', 'symbol', 'decimal', 'logo'];
11
+ const attributes = ['id', 'name', 'symbol', 'decimal', 'logo', 'payment_method_id'];
12
12
  const where: WhereOptions<PaymentMethod> = { livemode: req.livemode, active: true };
13
13
 
14
14
  const methods = await PaymentMethod.findAll({
15
15
  where,
16
16
  order: [['created_at', 'ASC']],
17
- include: [{ model: PaymentCurrency, as: 'payment_currencies', where: { active: true } }],
17
+ include: [
18
+ { model: PaymentCurrency, as: 'payment_currencies', where: { active: true }, order: [['created_at', 'ASC']] },
19
+ ],
18
20
  });
19
21
 
20
22
  methods.forEach((method) => {
@@ -23,7 +25,9 @@ router.get('/', async (req, res) => {
23
25
  });
24
26
 
25
27
  res.json({
26
- paymentMethods: methods.map((x) => pick(x, ['id', 'name', 'type', 'logo', 'payment_currencies'])),
28
+ paymentMethods: methods.map((x) =>
29
+ pick(x, ['id', 'name', 'type', 'logo', 'payment_currencies', 'default_currency_id'])
30
+ ),
27
31
  baseCurrency: await PaymentCurrency.findOne({
28
32
  where: { is_base_currency: true, livemode: req.livemode },
29
33
  attributes,
package/blocklet.yml CHANGED
@@ -14,7 +14,7 @@ repository:
14
14
  type: git
15
15
  url: git+https://github.com/blocklet/payment-kit.git
16
16
  specVersion: 1.2.8
17
- version: 1.13.229
17
+ version: 1.13.231
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.13.229",
3
+ "version": "1.13.231",
4
4
  "scripts": {
5
5
  "dev": "cross-env COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev --open",
6
6
  "eject": "vite eject",
@@ -51,7 +51,7 @@
51
51
  "@arcblock/ux": "^2.9.68",
52
52
  "@arcblock/validator": "^1.18.115",
53
53
  "@blocklet/logger": "1.16.25",
54
- "@blocklet/payment-react": "1.13.229",
54
+ "@blocklet/payment-react": "1.13.231",
55
55
  "@blocklet/sdk": "1.16.25",
56
56
  "@blocklet/ui-react": "^2.9.68",
57
57
  "@blocklet/uploader": "^0.0.76",
@@ -116,7 +116,7 @@
116
116
  "devDependencies": {
117
117
  "@abtnode/types": "1.16.25",
118
118
  "@arcblock/eslint-config-ts": "^0.3.0",
119
- "@blocklet/payment-types": "1.13.229",
119
+ "@blocklet/payment-types": "1.13.231",
120
120
  "@types/cookie-parser": "^1.4.7",
121
121
  "@types/cors": "^2.8.17",
122
122
  "@types/dotenv-flow": "^3.3.3",
@@ -155,5 +155,5 @@
155
155
  "parser": "typescript"
156
156
  }
157
157
  },
158
- "gitHead": "7def3178288871dff00ba89e16c5adcec6d4dfc9"
158
+ "gitHead": "256dbf9b77d59252cbb5db1832544ce5c7dfa4f4"
159
159
  }
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
+ import { PaymentProvider } from '@blocklet/payment-react';
3
4
  import Dashboard from '@blocklet/ui-react/lib/Dashboard';
4
5
  import { styled } from '@mui/system';
5
6
  import { useEffect } from 'react';
@@ -52,7 +53,7 @@ const Root = styled(Dashboard)`
52
53
 
53
54
  export default function Layout(props: any) {
54
55
  const { t } = useLocaleContext();
55
- const { session, events } = useSessionContext();
56
+ const { session, connectApi, events } = useSessionContext();
56
57
 
57
58
  useEffect(() => {
58
59
  events.once('logout', () => {
@@ -68,7 +69,11 @@ export default function Layout(props: any) {
68
69
  }, [session.initialized]);
69
70
 
70
71
  if (session.user) {
71
- return <Root {...props} footerProps={{ className: 'dashboard-footer' }} />;
72
+ return (
73
+ <PaymentProvider session={session} connect={connectApi}>
74
+ <Root {...props} footerProps={{ className: 'dashboard-footer' }} />
75
+ </PaymentProvider>
76
+ );
72
77
  }
73
78
 
74
79
  return t('common.redirecting');
@@ -152,13 +152,7 @@ export default function InvoiceDetail(props: { id: string }) {
152
152
  {!!data.paymentIntent.payment_details?.ethereum && (
153
153
  <InfoRow
154
154
  label={t('common.txGas')}
155
- value={
156
- <TxGas
157
- details={data.paymentIntent.payment_details as any}
158
- method={data.paymentMethod}
159
- currency={data.paymentCurrency}
160
- />
161
- }
155
+ value={<TxGas details={data.paymentIntent.payment_details as any} method={data.paymentMethod} />}
162
156
  />
163
157
  )}
164
158
  {data.paymentIntent && data.paymentIntent.payment_details && (
@@ -1,5 +1,5 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
- import { PaymentProvider, Switch, usePaymentContext } from '@blocklet/payment-react';
2
+ import { Switch, usePaymentContext } from '@blocklet/payment-react';
3
3
  import { Box, Chip, Stack } from '@mui/material';
4
4
  import React, { isValidElement, useEffect } from 'react';
5
5
  import { useNavigate, useParams } from 'react-router-dom';
@@ -109,7 +109,7 @@ function Admin() {
109
109
 
110
110
  export default function WrappedAdmin() {
111
111
  const navigate = useNavigate();
112
- const { session, connectApi } = useSessionContext();
112
+ const { session } = useSessionContext();
113
113
 
114
114
  useEffect(() => {
115
115
  if (session.user && ['owner', 'admin'].includes(session.user.role) === false) {
@@ -117,9 +117,5 @@ export default function WrappedAdmin() {
117
117
  }
118
118
  }, [session.user]);
119
119
 
120
- return (
121
- <PaymentProvider session={session} connect={connectApi}>
122
- <Admin />
123
- </PaymentProvider>
124
- );
120
+ return <Admin />;
125
121
  }
@@ -158,13 +158,7 @@ export default function PaymentIntentDetail(props: { id: string }) {
158
158
  {!!data.payment_details?.ethereum && (
159
159
  <InfoRow
160
160
  label={t('common.txGas')}
161
- value={
162
- <TxGas
163
- details={data.payment_details as any}
164
- method={data.paymentMethod}
165
- currency={data.paymentCurrency}
166
- />
167
- }
161
+ value={<TxGas details={data.payment_details as any} method={data.paymentMethod} />}
168
162
  />
169
163
  )}
170
164
  <InfoRow
@@ -155,13 +155,7 @@ export default function PayoutDetail(props: { id: string }) {
155
155
  {!!data.payment_details?.ethereum && (
156
156
  <InfoRow
157
157
  label={t('common.txGas')}
158
- value={
159
- <TxGas
160
- details={data.payment_details as any}
161
- method={data.paymentMethod}
162
- currency={data.paymentCurrency}
163
- />
164
- }
158
+ value={<TxGas details={data.payment_details as any} method={data.paymentMethod} />}
165
159
  />
166
160
  )}
167
161
  <InfoRow
@@ -155,13 +155,7 @@ export default function RefundDetail(props: { id: string }) {
155
155
  {!!data.payment_details?.ethereum && (
156
156
  <InfoRow
157
157
  label={t('common.txGas')}
158
- value={
159
- <TxGas
160
- details={data.payment_details as any}
161
- method={data.paymentMethod}
162
- currency={data.paymentCurrency}
163
- />
164
- }
158
+ value={<TxGas details={data.payment_details as any} method={data.paymentMethod} />}
165
159
  />
166
160
  )}
167
161
  <InfoRow
@@ -1,5 +1,4 @@
1
1
  import { PaymentProvider } from '@blocklet/payment-react';
2
- import { Box } from '@mui/material';
3
2
  import React from 'react';
4
3
  import { useParams } from 'react-router-dom';
5
4
 
@@ -16,11 +15,7 @@ function Checkout() {
16
15
  // @ts-ignore
17
16
  const TabComponent = pages[action];
18
17
 
19
- return (
20
- <Box>
21
- <TabComponent id={id} />
22
- </Box>
23
- );
18
+ return <TabComponent id={id} />;
24
19
  }
25
20
 
26
21
  export default function WrappedAdmin() {
@@ -1,7 +1,7 @@
1
1
  import DID from '@arcblock/ux/lib/DID';
2
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
3
  import Toast from '@arcblock/ux/lib/Toast';
4
- import { CustomerInvoiceList, PaymentProvider, formatError, getPrefix } from '@blocklet/payment-react';
4
+ import { CustomerInvoiceList, formatError, getPrefix } from '@blocklet/payment-react';
5
5
  import type { GroupedBN, TCustomerExpanded } from '@blocklet/payment-types';
6
6
  import { Edit } from '@mui/icons-material';
7
7
  import { Alert, Box, Button, CircularProgress, Grid, Stack, Tooltip } from '@mui/material';
@@ -31,7 +31,7 @@ const fetchData = (): Promise<Result> => {
31
31
 
32
32
  export default function CustomerHome() {
33
33
  const { t } = useLocaleContext();
34
- const { events, session, connectApi } = useSessionContext();
34
+ const { events } = useSessionContext();
35
35
  const [state, setState] = useSetState({ editing: false, loading: false });
36
36
  const navigate = useNavigate();
37
37
  const { isPending, startTransition } = useTransitionContext();
@@ -174,20 +174,18 @@ export default function CustomerHome() {
174
174
  </Box>
175
175
  <Box className="section">
176
176
  <SectionHeader title={t('payment.customer.summary')} />
177
- <PaymentProvider session={session} connect={connectApi}>
178
- <Stack
179
- className="section-body"
180
- direction="column"
181
- spacing={2}
182
- justifyContent="flex-start"
183
- sx={{ width: '100%' }}>
184
- <InfoMetric label={t('admin.customer.spent')} value={<BalanceList data={data.summary.paid} />} />
185
- <InfoMetric label={t('admin.customer.stake')} value={<BalanceList data={data.summary.stake} />} />
186
- <InfoMetric label={t('admin.customer.token')} value={<BalanceList data={data.summary.token} />} />
187
- <InfoMetric label={t('admin.customer.due')} value={<BalanceList data={data.summary.due} />} />
188
- <InfoMetric label={t('admin.customer.refund')} value={<BalanceList data={data.summary.refunded} />} />
189
- </Stack>
190
- </PaymentProvider>
177
+ <Stack
178
+ className="section-body"
179
+ direction="column"
180
+ spacing={2}
181
+ justifyContent="flex-start"
182
+ sx={{ width: '100%' }}>
183
+ <InfoMetric label={t('admin.customer.spent')} value={<BalanceList data={data.summary.paid} />} />
184
+ <InfoMetric label={t('admin.customer.stake')} value={<BalanceList data={data.summary.stake} />} />
185
+ <InfoMetric label={t('admin.customer.token')} value={<BalanceList data={data.summary.token} />} />
186
+ <InfoMetric label={t('admin.customer.due')} value={<BalanceList data={data.summary.due} />} />
187
+ <InfoMetric label={t('admin.customer.refund')} value={<BalanceList data={data.summary.refunded} />} />
188
+ </Stack>
191
189
  </Box>
192
190
  </Root>
193
191
  </Grid>
@@ -152,13 +152,7 @@ export default function CustomerInvoiceDetail() {
152
152
  {!!data.paymentIntent.payment_details?.ethereum && (
153
153
  <InfoRow
154
154
  label={t('common.txGas')}
155
- value={
156
- <TxGas
157
- details={data.paymentIntent.payment_details as any}
158
- method={data.paymentMethod}
159
- currency={data.paymentCurrency}
160
- />
161
- }
155
+ value={<TxGas details={data.paymentIntent.payment_details as any} method={data.paymentMethod} />}
162
156
  />
163
157
  )}
164
158
  {data.paymentIntent && data.paymentIntent.payment_details && (
@@ -1,12 +1,6 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import Toast from '@arcblock/ux/lib/Toast';
3
- import {
4
- CustomerInvoiceList,
5
- PaymentProvider,
6
- formatError,
7
- getPrefix,
8
- usePaymentContext,
9
- } from '@blocklet/payment-react';
3
+ import { CustomerInvoiceList, formatError, getPrefix, usePaymentContext } from '@blocklet/payment-react';
10
4
  import type { TCustomerExpanded } from '@blocklet/payment-types';
11
5
  import { ArrowBackOutlined } from '@mui/icons-material';
12
6
  import { Alert, Box, Button, CircularProgress, Stack, Typography } from '@mui/material';
@@ -24,7 +18,7 @@ const fetchData = (): Promise<TCustomerExpanded> => {
24
18
  return api.get('/api/customers/me').then((res) => res.data);
25
19
  };
26
20
 
27
- export function CustomerInvoicePastDue() {
21
+ export default function CustomerInvoicePastDue() {
28
22
  const { t } = useLocaleContext();
29
23
  const { events } = useSessionContext();
30
24
  const { connect } = usePaymentContext();
@@ -126,13 +120,3 @@ const Root = styled(Stack)`
126
120
  text-decoration: underline;
127
121
  }
128
122
  `;
129
-
130
- export default function PastDueWrapper() {
131
- const { session, connectApi } = useSessionContext();
132
-
133
- return (
134
- <PaymentProvider session={session} connect={connectApi}>
135
- <CustomerInvoicePastDue />
136
- </PaymentProvider>
137
- );
138
- }
@@ -6,7 +6,6 @@ import Toast from '@arcblock/ux/lib/Toast';
6
6
  import {
7
7
  AddressForm,
8
8
  CurrencySelector,
9
- PaymentProvider,
10
9
  PaymentSummary,
11
10
  StripeForm,
12
11
  api,
@@ -33,7 +32,6 @@ import { joinURL } from 'ufo';
33
32
 
34
33
  import SectionHeader from '../../../components/section/header';
35
34
  import SubscriptionDescription from '../../../components/subscription/description';
36
- import { useSessionContext } from '../../../contexts/session';
37
35
 
38
36
  const fetchData = async (id: string): Promise<{ subscription: TSubscriptionExpanded; customer: TCustomer }> => {
39
37
  const [subscription, customer] = await Promise.all([
@@ -311,7 +309,6 @@ export default function DataWrapper() {
311
309
  const { t } = useLocaleContext();
312
310
  const { id } = useParams() as { id: string };
313
311
  const { loading, error, data, runAsync } = useRequest(() => fetchData(id));
314
- const { session, connectApi } = useSessionContext();
315
312
 
316
313
  if (error) {
317
314
  return <Alert severity="error">{error.message}</Alert>;
@@ -325,11 +322,7 @@ export default function DataWrapper() {
325
322
  return <Alert severity="error">{t('payment.customer.changePlan.subscriptionNotFound')}</Alert>;
326
323
  }
327
324
 
328
- return (
329
- <PaymentProvider session={session} connect={connectApi}>
330
- <FormWrapper subscription={data.subscription} customer={data.customer} onComplete={runAsync} />
331
- </PaymentProvider>
332
- );
325
+ return <FormWrapper subscription={data.subscription} customer={data.customer} onComplete={runAsync} />;
333
326
  }
334
327
 
335
328
  const Root = styled(Stack)`