payment-kit 1.22.14 → 1.22.16

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.
@@ -52,7 +52,7 @@ export default {
52
52
  const claims: { [key: string]: object } = {
53
53
  prepareTx: {
54
54
  type: 'TransferV3Tx',
55
- description: `Pay all past due invoices for subscription ${subscription?.description}`,
55
+ description: `Pay all past due invoices ${subscriptionId ? `for subscription ${subscription?.description}` : ''}`,
56
56
  partialTx: { from: userDid, pk: userPk, itx },
57
57
  requirement: { tokens },
58
58
  chainInfo: {
@@ -4,7 +4,7 @@ import Joi from 'joi';
4
4
  import pick from 'lodash/pick';
5
5
  import isEmail from 'validator/es/lib/isEmail';
6
6
 
7
- import { Op } from 'sequelize';
7
+ import { Op, type WhereOptions } from 'sequelize';
8
8
  import { BN } from '@ocap/util';
9
9
  import { getStakeSummaryByDid, getTokenSummaryByDid, getTokenByAddress } from '../integrations/arcblock/stake';
10
10
  import { createListParamSchema, getOrder, getWhereFromKvQuery, getWhereFromQuery, MetadataSchema } from '../libs/api';
@@ -224,12 +224,16 @@ router.get('/:id/overdue/invoices', authPortal, async (req, res) => {
224
224
  if (!doc) {
225
225
  return res.status(404).json({ error: 'Customer not found' });
226
226
  }
227
+ const where: WhereOptions<Invoice> = {
228
+ customer_id: doc.id,
229
+ status: ['uncollectible'],
230
+ amount_remaining: { [Op.gt]: '0' },
231
+ };
232
+ if (typeof req.livemode === 'boolean') {
233
+ where.livemode = !!req.livemode;
234
+ }
227
235
  const { rows: invoices, count } = await Invoice.findAndCountAll({
228
- where: {
229
- customer_id: doc.id,
230
- status: ['uncollectible'],
231
- amount_remaining: { [Op.gt]: '0' },
232
- },
236
+ where,
233
237
  include: [
234
238
  { model: PaymentCurrency, as: 'paymentCurrency' },
235
239
  { model: PaymentMethod, as: 'paymentMethod' },
@@ -2,9 +2,12 @@ import dayjs from 'dayjs';
2
2
  import { Router } from 'express';
3
3
  import Joi from 'joi';
4
4
 
5
+ import { getUrl } from '@blocklet/sdk';
6
+ import { joinURL } from 'ufo';
5
7
  import { authenticate } from '../libs/security';
6
8
  import { formatToShortUrl } from '../libs/url';
7
9
  import { CheckoutSession } from '../store/models';
10
+ import logger from '../libs/logger';
8
11
 
9
12
  const loginAuth = authenticate<CheckoutSession>({ component: false, ensureLogin: true, mine: true });
10
13
 
@@ -14,7 +17,7 @@ const shortUrlSchema = Joi.object({
14
17
  url: Joi.string().uri().required(),
15
18
  timeoutMin: Joi.number().optional(),
16
19
  maxVisits: Joi.number().optional(),
17
- });
20
+ }).unknown(true);
18
21
 
19
22
  router.get('/short-url', loginAuth, async (req, res) => {
20
23
  const { error } = shortUrlSchema.validate(req.query);
@@ -32,4 +35,31 @@ router.get('/short-url', loginAuth, async (req, res) => {
32
35
  return res.json({ url: shortUrl });
33
36
  });
34
37
 
38
+ router.get('/short-connect-url', async (req, res) => {
39
+ const { error } = shortUrlSchema.validate(req.query);
40
+ if (error) {
41
+ return res.status(400).json({ error: 'Invalid parameters', message: error.message });
42
+ }
43
+
44
+ const { url, timeoutMin = 60, maxVisits = 5 } = req.query;
45
+ const serverUrl = getUrl();
46
+
47
+ const allowedEndpoint = joinURL(new URL(serverUrl).origin, '.well-known/service/gen-simple-access-key');
48
+
49
+ if (!url?.toString().startsWith(allowedEndpoint)) {
50
+ logger.error('Client try to generate short connect url from invalid service', { url });
51
+ return res
52
+ .status(400)
53
+ .json({ error: 'Just support generate short connect url from gen-simple-access-key service' });
54
+ }
55
+
56
+ const timeoutMinNumber = Number(timeoutMin);
57
+ const validUntil = dayjs()
58
+ .add(timeoutMinNumber > 60 ? 60 : timeoutMinNumber, 'minutes')
59
+ .format('YYYY-MM-DDTHH:mm:ss+00:00');
60
+
61
+ const shortUrl = await formatToShortUrl({ url: url as string, validUntil, maxVisits: Number(maxVisits) });
62
+ return res.json({ url: shortUrl });
63
+ });
64
+
35
65
  export default router;
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.22.14
17
+ version: 1.22.16
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.22.14",
3
+ "version": "1.22.16",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
@@ -45,34 +45,34 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@abtnode/cron": "^1.17.2",
48
- "@arcblock/did": "^1.27.6",
49
- "@arcblock/did-connect-react": "^3.2.6",
48
+ "@arcblock/did": "^1.27.11",
49
+ "@arcblock/did-connect-react": "^3.2.7",
50
50
  "@arcblock/did-connect-storage-nedb": "^1.8.0",
51
- "@arcblock/did-util": "^1.27.6",
52
- "@arcblock/jwt": "^1.27.6",
53
- "@arcblock/react-hooks": "^3.2.6",
54
- "@arcblock/ux": "^3.2.6",
55
- "@arcblock/validator": "^1.27.6",
56
- "@blocklet/did-space-js": "^1.2.3",
57
- "@blocklet/error": "^0.3.2",
51
+ "@arcblock/did-util": "^1.27.11",
52
+ "@arcblock/jwt": "^1.27.11",
53
+ "@arcblock/react-hooks": "^3.2.7",
54
+ "@arcblock/ux": "^3.2.7",
55
+ "@arcblock/validator": "^1.27.11",
56
+ "@blocklet/did-space-js": "^1.2.4",
57
+ "@blocklet/error": "^0.3.3",
58
58
  "@blocklet/js-sdk": "^1.17.2",
59
59
  "@blocklet/logger": "^1.17.2",
60
- "@blocklet/payment-broker-client": "1.22.14",
61
- "@blocklet/payment-react": "1.22.14",
62
- "@blocklet/payment-vendor": "1.22.14",
60
+ "@blocklet/payment-broker-client": "1.22.16",
61
+ "@blocklet/payment-react": "1.22.16",
62
+ "@blocklet/payment-vendor": "1.22.16",
63
63
  "@blocklet/sdk": "^1.17.2",
64
- "@blocklet/ui-react": "^3.2.6",
64
+ "@blocklet/ui-react": "^3.2.7",
65
65
  "@blocklet/uploader": "^0.3.11",
66
66
  "@blocklet/xss": "^0.3.9",
67
67
  "@mui/icons-material": "^7.1.2",
68
68
  "@mui/lab": "7.0.0-beta.14",
69
69
  "@mui/material": "^7.1.2",
70
70
  "@mui/system": "^7.1.1",
71
- "@ocap/asset": "^1.27.6",
72
- "@ocap/client": "^1.27.6",
73
- "@ocap/mcrypto": "^1.27.6",
74
- "@ocap/util": "^1.27.6",
75
- "@ocap/wallet": "^1.27.6",
71
+ "@ocap/asset": "^1.27.11",
72
+ "@ocap/client": "^1.27.11",
73
+ "@ocap/mcrypto": "^1.27.11",
74
+ "@ocap/util": "^1.27.11",
75
+ "@ocap/wallet": "^1.27.11",
76
76
  "@stripe/react-stripe-js": "^2.9.0",
77
77
  "@stripe/stripe-js": "^2.4.0",
78
78
  "ahooks": "^3.8.5",
@@ -129,7 +129,7 @@
129
129
  "devDependencies": {
130
130
  "@abtnode/types": "^1.17.2",
131
131
  "@arcblock/eslint-config-ts": "^0.3.3",
132
- "@blocklet/payment-types": "1.22.14",
132
+ "@blocklet/payment-types": "1.22.16",
133
133
  "@types/cookie-parser": "^1.4.9",
134
134
  "@types/cors": "^2.8.19",
135
135
  "@types/debug": "^4.1.12",
@@ -160,7 +160,7 @@
160
160
  "vite": "^7.0.0",
161
161
  "vite-node": "^3.2.4",
162
162
  "vite-plugin-babel-import": "^2.0.5",
163
- "vite-plugin-blocklet": "^0.12.2",
163
+ "vite-plugin-blocklet": "^0.12.3",
164
164
  "vite-plugin-node-polyfills": "^0.23.0",
165
165
  "vite-plugin-svgr": "^4.3.0",
166
166
  "vite-tsconfig-paths": "^5.1.4",
@@ -176,5 +176,5 @@
176
176
  "parser": "typescript"
177
177
  }
178
178
  },
179
- "gitHead": "fc9395e0eaf4472b42192835fb4933da469939c6"
179
+ "gitHead": "68ff7bcdc9f185a8d885d9af189d2e2c1cc5fbf6"
180
180
  }
@@ -592,7 +592,10 @@ export default function CustomerHome() {
592
592
  }}
593
593
  dialogProps={{
594
594
  open: showOverduePayment,
595
- onClose: () => setShowOverduePayment(false),
595
+ onClose: () => {
596
+ setShowOverduePayment(false);
597
+ runAsync();
598
+ },
596
599
  title: t('customer.pastDue.title'),
597
600
  }}
598
601
  />