payment-kit 1.13.110 → 1.13.112

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.
@@ -13,7 +13,7 @@ import { replace } from '../locales';
13
13
  import { createPaymentLink } from '../routes/payment-links';
14
14
  import { createPrice } from '../routes/prices';
15
15
  import { createProductAndPrices } from '../routes/products';
16
- import { PaymentCurrency, Price, Product, nextPriceId } from '../store/models';
16
+ import { PaymentCurrency, PaymentLink, Price, Product, nextPriceId } from '../store/models';
17
17
 
18
18
  export async function getPackResource(type: string) {
19
19
  const resources = await getPackResources({
@@ -85,22 +85,22 @@ export async function initPaywallResources() {
85
85
  continue;
86
86
  }
87
87
 
88
- const exist = await Product.findOne({
88
+ const existProduct = await Product.findOne({
89
89
  where: { 'metadata.source': resource.did },
90
90
  include: [{ model: Price, as: 'prices', order: [['created_at', 'DESC']] }],
91
91
  });
92
- if (exist) {
92
+ if (existProduct) {
93
93
  console.warn(`paywall resource already imported from path: ${configPath}`);
94
94
 
95
95
  // @ts-ignore
96
- const monthPrice = exist.prices.find(
96
+ const monthPrice = existProduct.prices.find(
97
97
  // @ts-ignore
98
98
  (price) =>
99
99
  price.nickname === 'monthly-member-price' &&
100
100
  price.unit_amount === fromTokenToUnit(config.product.price.month, currency.decimal).toString()
101
101
  );
102
102
  // @ts-ignore
103
- const yearPrice = exist.prices.find(
103
+ const yearPrice = existProduct.prices.find(
104
104
  // @ts-ignore
105
105
  (price) =>
106
106
  price.nickname === 'yearly-member-price' &&
@@ -112,7 +112,7 @@ export async function initPaywallResources() {
112
112
  newMonthPriceId = nextPriceId();
113
113
  await createPrice({
114
114
  id: newMonthPriceId,
115
- product_id: exist.id,
115
+ product_id: existProduct.id,
116
116
  type: 'recurring',
117
117
  model: 'standard',
118
118
  nickname: 'monthly-member-price',
@@ -133,7 +133,7 @@ export async function initPaywallResources() {
133
133
  newYearPriceId = nextPriceId();
134
134
  await createPrice({
135
135
  id: newYearPriceId,
136
- product_id: exist.id,
136
+ product_id: existProduct.id,
137
137
  type: 'recurring',
138
138
  model: 'standard',
139
139
  nickname: 'yearly-member-price',
@@ -161,7 +161,7 @@ export async function initPaywallResources() {
161
161
 
162
162
  // Create another payment link and redo updatePassportExtra
163
163
  if (newMonthPriceId) {
164
- await Product.update({ default_price_id: newMonthPriceId }, { where: { id: exist.id }, limit: 1 });
164
+ await Product.update({ default_price_id: newMonthPriceId }, { where: { id: existProduct.id }, limit: 1 });
165
165
 
166
166
  const link = await createPaymentLink({
167
167
  name: `Paywall for membership of ${config.product.name}`,
@@ -180,12 +180,25 @@ export async function initPaywallResources() {
180
180
  await Promise.all(
181
181
  config.passports.map((x: string) =>
182
182
  updatePassportExtra(x, {
183
- payment: { product: exist.id },
183
+ payment: { product: existProduct.id },
184
184
  acquire: { pay: link.id },
185
185
  })
186
186
  )
187
187
  );
188
188
  console.info('product and payment link reassociated with passport');
189
+ } else {
190
+ const existLink = await PaymentLink.findOne({ where: { 'metadata.source': resource.did } });
191
+ if (existLink) {
192
+ await Promise.all(
193
+ config.passports.map((x: string) =>
194
+ updatePassportExtra(x, {
195
+ payment: { product: existProduct.id },
196
+ acquire: { pay: existLink.id },
197
+ })
198
+ )
199
+ );
200
+ }
201
+ console.info('product and payment link associated with passport again');
189
202
  }
190
203
  } else {
191
204
  const monthPriceId = nextPriceId();
@@ -155,6 +155,7 @@ router.get('/', auth, async (req, res) => {
155
155
  offset: (page - 1) * pageSize,
156
156
  limit: pageSize,
157
157
  include: [{ model: Price, as: 'prices' }],
158
+ distinct: true,
158
159
  });
159
160
 
160
161
  res.json({ count, list });
@@ -124,6 +124,8 @@ router.get('/', authMine, async (req, res) => {
124
124
  { model: SubscriptionItem, as: 'items' },
125
125
  { model: Customer, as: 'customer' },
126
126
  ],
127
+ // https://github.com/sequelize/sequelize/issues/9481
128
+ distinct: true,
127
129
  });
128
130
 
129
131
  const products = (await Product.findAll()).map((x) => x.toJSON());
@@ -283,8 +285,7 @@ router.put('/:id/recover', authPortal, async (req, res) => {
283
285
 
284
286
  await updateStripeSubscription(doc, { cancel_at_period_end: false, cancel_at: null, canceled_at: null });
285
287
 
286
- // @ts-ignore
287
- await doc.update({ cancel_at_period_end: false, cancel_at: null, canceled_at: null });
288
+ await doc.update({ cancel_at_period_end: false, cancel_at: 0, canceled_at: 0 });
288
289
 
289
290
  // reschedule jobs
290
291
  subscriptionQueue
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.110
17
+ version: 1.13.112
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.110",
3
+ "version": "1.13.112",
4
4
  "scripts": {
5
5
  "dev": "cross-env COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev",
6
6
  "eject": "vite eject",
@@ -42,22 +42,22 @@
42
42
  ]
43
43
  },
44
44
  "dependencies": {
45
- "@abtnode/cron": "1.16.22",
45
+ "@abtnode/cron": "1.16.23-beta-aeb9f5bd",
46
46
  "@arcblock/did": "^1.18.108",
47
47
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
48
- "@arcblock/did-connect": "^2.9.13",
48
+ "@arcblock/did-connect": "^2.9.15",
49
49
  "@arcblock/did-util": "^1.18.108",
50
50
  "@arcblock/jwt": "^1.18.108",
51
- "@arcblock/ux": "^2.9.13",
52
- "@blocklet/logger": "1.16.22",
53
- "@blocklet/sdk": "1.16.22",
54
- "@blocklet/ui-react": "^2.9.13",
55
- "@blocklet/uploader": "^0.0.64",
56
- "@mui/icons-material": "^5.14.19",
57
- "@mui/lab": "^5.0.0-alpha.155",
58
- "@mui/material": "^5.14.20",
59
- "@mui/styles": "^5.14.20",
60
- "@mui/system": "^5.14.20",
51
+ "@arcblock/ux": "^2.9.15",
52
+ "@blocklet/logger": "1.16.23-beta-aeb9f5bd",
53
+ "@blocklet/sdk": "1.16.23-beta-aeb9f5bd",
54
+ "@blocklet/ui-react": "^2.9.15",
55
+ "@blocklet/uploader": "^0.0.65",
56
+ "@mui/icons-material": "^5.15.6",
57
+ "@mui/lab": "^5.0.0-alpha.162",
58
+ "@mui/material": "^5.15.6",
59
+ "@mui/styles": "^5.15.6",
60
+ "@mui/system": "^5.15.6",
61
61
  "@ocap/asset": "^1.18.108",
62
62
  "@ocap/client": "^1.18.108",
63
63
  "@ocap/mcrypto": "^1.18.108",
@@ -107,10 +107,10 @@
107
107
  "validator": "^13.11.0"
108
108
  },
109
109
  "devDependencies": {
110
- "@abtnode/types": "1.16.22",
110
+ "@abtnode/types": "1.16.23-beta-aeb9f5bd",
111
111
  "@arcblock/eslint-config": "^0.2.4",
112
112
  "@arcblock/eslint-config-ts": "^0.2.4",
113
- "@did-pay/types": "1.13.110",
113
+ "@did-pay/types": "1.13.112",
114
114
  "@types/cookie-parser": "^1.4.6",
115
115
  "@types/cors": "^2.8.17",
116
116
  "@types/dotenv-flow": "^3.3.3",
@@ -149,5 +149,5 @@
149
149
  "parser": "typescript"
150
150
  }
151
151
  },
152
- "gitHead": "d62b501d4c5ea402b0b6bfd989a301f9b6b7bea3"
152
+ "gitHead": "5db3e4ba2c5126a2ff6b8962b58d585b0eb0f01e"
153
153
  }
@@ -1,7 +1,7 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import Tabs from '@arcblock/ux/lib/Tabs';
3
3
  import { Typography } from '@mui/material';
4
- import React, { isValidElement } from 'react';
4
+ import React, { isValidElement, startTransition } from 'react';
5
5
  import { useNavigate, useParams } from 'react-router-dom';
6
6
 
7
7
  const SubscriptionDetail = React.lazy(() => import('./subscriptions/detail'));
@@ -26,7 +26,9 @@ export default function BillingIndex() {
26
26
  }
27
27
 
28
28
  const onTabChange = (newTab: string) => {
29
- navigate(`/admin/billing/${newTab}`);
29
+ startTransition(() => {
30
+ navigate(`/admin/billing/${newTab}`);
31
+ });
30
32
  };
31
33
 
32
34
  // @ts-ignore
@@ -1,7 +1,7 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import Tabs from '@arcblock/ux/lib/Tabs';
3
3
  import { Typography } from '@mui/material';
4
- import React, { isValidElement } from 'react';
4
+ import React, { isValidElement, startTransition } from 'react';
5
5
  import { useNavigate, useParams } from 'react-router-dom';
6
6
 
7
7
  const CustomerDetail = React.lazy(() => import('./customers/detail'));
@@ -20,7 +20,9 @@ export default function CustomerIndex() {
20
20
  }
21
21
 
22
22
  const onTabChange = (newTab: string) => {
23
- navigate(`/admin/customers/${newTab}`);
23
+ startTransition(() => {
24
+ navigate(`/admin/customers/${newTab}`);
25
+ });
24
26
  };
25
27
 
26
28
  // @ts-ignore
@@ -1,7 +1,7 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import Tabs from '@arcblock/ux/lib/Tabs';
3
3
  import { Typography } from '@mui/material';
4
- import React, { isValidElement } from 'react';
4
+ import React, { isValidElement, startTransition } from 'react';
5
5
  import { useNavigate, useParams } from 'react-router-dom';
6
6
 
7
7
  const EventDetail = React.lazy(() => import('./events/detail'));
@@ -28,7 +28,9 @@ export default function DevelopersIndex() {
28
28
  }
29
29
 
30
30
  const onTabChange = (newTab: string) => {
31
- navigate(`/admin/developers/${newTab}`);
31
+ startTransition(() => {
32
+ navigate(`/admin/developers/${newTab}`);
33
+ });
32
34
  };
33
35
 
34
36
  // @ts-ignore
@@ -1,6 +1,6 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import { Box, Chip, Stack } from '@mui/material';
3
- import React, { isValidElement } from 'react';
3
+ import React, { isValidElement, startTransition } from 'react';
4
4
  import { useNavigate, useParams } from 'react-router-dom';
5
5
 
6
6
  import Layout from '../../components/layout/admin';
@@ -50,7 +50,9 @@ function Admin() {
50
50
  };
51
51
 
52
52
  const onTabChange = (newTab: string) => {
53
- navigate(`/admin/${newTab}`);
53
+ startTransition(() => {
54
+ navigate(`/admin/${newTab}`);
55
+ });
54
56
  };
55
57
 
56
58
  // @ts-ignore
@@ -1,7 +1,7 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import Tabs from '@arcblock/ux/lib/Tabs';
3
3
  import { Stack, Typography } from '@mui/material';
4
- import React, { isValidElement } from 'react';
4
+ import React, { isValidElement, startTransition } from 'react';
5
5
  import { useNavigate, useParams } from 'react-router-dom';
6
6
 
7
7
  const PaymentLinkCreate = React.lazy(() => import('./links/create'));
@@ -27,7 +27,9 @@ export default function PaymentIndex() {
27
27
  }
28
28
 
29
29
  const onTabChange = (newTab: string) => {
30
- navigate(`/admin/payments/${newTab}`);
30
+ startTransition(() => {
31
+ navigate(`/admin/payments/${newTab}`);
32
+ });
31
33
  };
32
34
 
33
35
  // @ts-ignore
@@ -1,7 +1,7 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import Tabs from '@arcblock/ux/lib/Tabs';
3
3
  import { Stack, Typography } from '@mui/material';
4
- import React, { isValidElement } from 'react';
4
+ import React, { isValidElement, startTransition } from 'react';
5
5
  import { useNavigate, useParams } from 'react-router-dom';
6
6
 
7
7
  const PaymentMethodCreate = React.lazy(() => import('./payment-methods/create'));
@@ -18,7 +18,9 @@ export default function SettingsIndex() {
18
18
  const { page = 'payment-methods' } = useParams();
19
19
 
20
20
  const onTabChange = (newTab: string) => {
21
- navigate(`/admin/settings/${newTab}`);
21
+ startTransition(() => {
22
+ navigate(`/admin/settings/${newTab}`);
23
+ });
22
24
  };
23
25
 
24
26
  // @ts-ignore
@@ -57,14 +57,14 @@ export default function Payment({ id }: Props) {
57
57
  setTimeout(() => {
58
58
  const tmp = new URL(data.checkoutSession.success_url as string, window.location.origin);
59
59
  tmp.searchParams.set('checkout_session_id', data.checkoutSession.id);
60
- window.location.href = tmp.href;
60
+ window.location.replace(tmp.href);
61
61
  }, 1000);
62
62
  } else if (data?.paymentLink) {
63
63
  if (data.paymentLink.after_completion?.type === 'redirect' && data.paymentLink.after_completion?.redirect?.url) {
64
64
  setTimeout(() => {
65
65
  const tmp = new URL(data.paymentLink?.after_completion?.redirect?.url as string, window.location.origin);
66
66
  tmp.searchParams.set('checkout_session_id', data.checkoutSession.id);
67
- window.location.href = tmp.href;
67
+ window.location.replace(tmp.href);
68
68
  }, 1000);
69
69
  }
70
70
  }
@@ -37,7 +37,13 @@ export default function PricingTablePage({ id }: Props) {
37
37
  display: 'flex',
38
38
  flexDirection: 'column',
39
39
  }}>
40
- <Header />
40
+ <Header
41
+ meta={undefined}
42
+ addons={undefined}
43
+ sessionManagerProps={undefined}
44
+ homeLink={undefined}
45
+ theme={undefined}
46
+ />
41
47
  <Center relative="parent">
42
48
  <Alert severity="error">{error.message}</Alert>
43
49
  </Center>
@@ -55,7 +61,13 @@ export default function PricingTablePage({ id }: Props) {
55
61
  display: 'flex',
56
62
  flexDirection: 'column',
57
63
  }}>
58
- <Header />
64
+ <Header
65
+ meta={undefined}
66
+ addons={undefined}
67
+ sessionManagerProps={undefined}
68
+ homeLink={undefined}
69
+ theme={undefined}
70
+ />
59
71
  <Center>
60
72
  <Stack direction="column" alignItems="center" spacing={4}>
61
73
  <Typography component="div" variant="h3" sx={{ width: '40%' }}>
@@ -85,7 +97,13 @@ export default function PricingTablePage({ id }: Props) {
85
97
  display: 'flex',
86
98
  flexDirection: 'column',
87
99
  }}>
88
- <Header />
100
+ <Header
101
+ meta={undefined}
102
+ addons={undefined}
103
+ sessionManagerProps={undefined}
104
+ homeLink={undefined}
105
+ theme={undefined}
106
+ />
89
107
  <Center relative="parent">
90
108
  <Alert severity="warning">{t('checkout.noPricing')}</Alert>
91
109
  </Center>
@@ -117,7 +135,13 @@ export default function PricingTablePage({ id }: Props) {
117
135
  },
118
136
  flexDirection: 'column',
119
137
  }}>
120
- <Header />
138
+ <Header
139
+ meta={undefined}
140
+ addons={undefined}
141
+ sessionManagerProps={undefined}
142
+ homeLink={undefined}
143
+ theme={undefined}
144
+ />
121
145
  <Center relative="parent">
122
146
  <Stack direction="column" alignItems="center" spacing={4}>
123
147
  <Typography variant="h4" color="text.primary" fontWeight={600}>
@@ -6,7 +6,13 @@ import Typewriter from 'typewriter-effect';
6
6
  function Home() {
7
7
  return (
8
8
  <div>
9
- <Header />
9
+ <Header
10
+ meta={undefined}
11
+ addons={undefined}
12
+ sessionManagerProps={undefined}
13
+ homeLink={undefined}
14
+ theme={undefined}
15
+ />
10
16
  <Stack alignItems="center" justifyContent="center" sx={{ height: '60vh', width: '100vw' }}>
11
17
  <Stack maxWidth="sm" direction="column" alignItems="center" spacing={3}>
12
18
  <Avatar src={window.blocklet.appLogo} sx={{ width: 80, height: 80 }} />