payment-kit 1.13.285 → 1.13.287

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.
package/.eslintrc.js CHANGED
@@ -13,5 +13,6 @@ module.exports = {
13
13
  'import/prefer-default-export': 'off',
14
14
  'react-hooks/exhaustive-deps': 'off',
15
15
  'jsx-a11y/no-noninteractive-element-interactions': 'off',
16
+ '@typescript-eslint/indent': 'off',
16
17
  },
17
18
  };
@@ -44,7 +44,7 @@ export async function ensureStripeProduct(internal: Product, method: PaymentMeth
44
44
  attrs.unit_label = internal.unit_label;
45
45
  }
46
46
  if (internal.statement_descriptor) {
47
- attrs.statement_descriptor = internal.statement_descriptor;
47
+ attrs.statement_descriptor_suffix = internal.statement_descriptor;
48
48
  }
49
49
 
50
50
  const product = await client.products.create(attrs);
@@ -175,7 +175,7 @@ export async function ensureStripePaymentIntent(
175
175
  enabled: true,
176
176
  allow_redirects: 'never',
177
177
  },
178
- statement_descriptor: internal.statement_descriptor,
178
+ statement_descriptor_suffix: internal.statement_descriptor,
179
179
  metadata: {
180
180
  appPid: env.appPid,
181
181
  id: internal.id,
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.285
17
+ version: 1.13.287
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.285",
3
+ "version": "1.13.287",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "eject": "vite eject",
@@ -43,29 +43,29 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@abtnode/cron": "1.16.28",
46
- "@arcblock/did": "^1.18.123",
46
+ "@arcblock/did": "^1.18.124",
47
47
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
48
- "@arcblock/did-connect": "^2.10.1",
49
- "@arcblock/did-util": "^1.18.123",
50
- "@arcblock/jwt": "^1.18.123",
51
- "@arcblock/ux": "^2.10.1",
52
- "@arcblock/validator": "^1.18.123",
48
+ "@arcblock/did-connect": "^2.10.3",
49
+ "@arcblock/did-util": "^1.18.124",
50
+ "@arcblock/jwt": "^1.18.124",
51
+ "@arcblock/ux": "^2.10.3",
52
+ "@arcblock/validator": "^1.18.124",
53
53
  "@blocklet/js-sdk": "1.16.28",
54
54
  "@blocklet/logger": "1.16.28",
55
- "@blocklet/payment-react": "1.13.285",
55
+ "@blocklet/payment-react": "1.13.287",
56
56
  "@blocklet/sdk": "1.16.28",
57
- "@blocklet/ui-react": "^2.10.1",
58
- "@blocklet/uploader": "^0.1.11",
57
+ "@blocklet/ui-react": "^2.10.3",
58
+ "@blocklet/uploader": "^0.1.18",
59
59
  "@mui/icons-material": "^5.15.19",
60
60
  "@mui/lab": "^5.0.0-alpha.170",
61
61
  "@mui/material": "^5.15.19",
62
62
  "@mui/styles": "^5.15.19",
63
63
  "@mui/system": "^5.15.15",
64
- "@ocap/asset": "^1.18.123",
65
- "@ocap/client": "^1.18.123",
66
- "@ocap/mcrypto": "^1.18.123",
67
- "@ocap/util": "^1.18.123",
68
- "@ocap/wallet": "^1.18.123",
64
+ "@ocap/asset": "^1.18.124",
65
+ "@ocap/client": "^1.18.124",
66
+ "@ocap/mcrypto": "^1.18.124",
67
+ "@ocap/util": "^1.18.124",
68
+ "@ocap/wallet": "^1.18.124",
69
69
  "@react-pdf/renderer": "^3.4.4",
70
70
  "@stripe/react-stripe-js": "^2.7.1",
71
71
  "@stripe/stripe-js": "^2.4.0",
@@ -118,7 +118,7 @@
118
118
  "devDependencies": {
119
119
  "@abtnode/types": "1.16.28",
120
120
  "@arcblock/eslint-config-ts": "^0.3.2",
121
- "@blocklet/payment-types": "1.13.285",
121
+ "@blocklet/payment-types": "1.13.287",
122
122
  "@types/cookie-parser": "^1.4.7",
123
123
  "@types/cors": "^2.8.17",
124
124
  "@types/debug": "^4.1.12",
@@ -143,7 +143,7 @@
143
143
  "type-fest": "^4.19.0",
144
144
  "typescript": "^4.9.5",
145
145
  "vite": "^5.2.12",
146
- "vite-plugin-blocklet": "^0.7.9",
146
+ "vite-plugin-blocklet": "^0.8.1",
147
147
  "vite-plugin-node-polyfills": "^0.21.0",
148
148
  "vite-plugin-svgr": "^4.2.0",
149
149
  "zx": "^7.2.3"
@@ -158,5 +158,5 @@
158
158
  "parser": "typescript"
159
159
  }
160
160
  },
161
- "gitHead": "d95d4a86102a7394461680849860140aa372ab06"
161
+ "gitHead": "a0dac51aff70028e5996af607181e285ea2bb770"
162
162
  }
@@ -1,8 +1,10 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import { Button, CircularProgress, Stack } from '@mui/material';
3
+ import { isObject } from 'lodash';
3
4
  import type { EventHandler } from 'react';
4
5
  import { FormProvider, useForm } from 'react-hook-form';
5
6
 
7
+ import { isObjectContent } from '../../libs/util';
6
8
  import MetadataForm from './form';
7
9
 
8
10
  export default function MetadataEditor({
@@ -20,7 +22,10 @@ export default function MetadataEditor({
20
22
  const metadata = data.metadata || {};
21
23
  const methods = useForm<any>({
22
24
  defaultValues: {
23
- metadata: Object.keys(metadata).map((key: string) => ({ key, value: metadata[key] })),
25
+ metadata: Object.keys(metadata).map((key: string) => ({
26
+ key,
27
+ value: isObject(metadata[key]) ? JSON.stringify(metadata[key]) : metadata[key],
28
+ })),
24
29
  },
25
30
  });
26
31
 
@@ -31,7 +36,16 @@ export default function MetadataEditor({
31
36
  };
32
37
  const onSubmit = () => {
33
38
  handleSubmit(async (formData: any) => {
34
- await onSave(formData);
39
+ const payload = {
40
+ ...(formData || {}),
41
+ metadata: Array.isArray(formData.metadata)
42
+ ? formData.metadata.reduce((acc: any, x: any) => {
43
+ acc[x.key] = isObjectContent(x.value) ? JSON.parse(x.value) : x.value;
44
+ return acc;
45
+ }, {})
46
+ : [],
47
+ };
48
+ await onSave(payload);
35
49
  reset();
36
50
  onCancel(null);
37
51
  })();
@@ -3,6 +3,7 @@ import { Typography } from '@mui/material';
3
3
  import isEmpty from 'lodash/isEmpty';
4
4
  import isObject from 'lodash/isObject';
5
5
 
6
+ import { isObjectContent } from '../../libs/util';
6
7
  import InfoRow from '../info-row';
7
8
 
8
9
  export default function MetadataList({ data }: { data: any }) {
@@ -12,14 +13,22 @@ export default function MetadataList({ data }: { data: any }) {
12
13
  return <Typography color="text.secondary">{t('common.metadata.empty')}</Typography>;
13
14
  }
14
15
 
16
+ const formatValue = (value: any) => {
17
+ if (isObjectContent(value)) {
18
+ return <pre>{JSON.stringify(JSON.parse(value), null, 2)}</pre>;
19
+ }
20
+ if (isObject(value)) {
21
+ return <pre>{JSON.stringify(value, null, 2)}</pre>;
22
+ }
23
+ return value;
24
+ };
25
+
15
26
  // skip non-string values
16
27
  return (
17
28
  <>
18
- {Object.keys(data || {})
19
- .filter((key) => isObject(data[key]) === false)
20
- .map((key) => (
21
- <InfoRow key={key} label={key} value={data[key]} />
22
- ))}
29
+ {Object.keys(data || {}).map((key) => (
30
+ <InfoRow key={key} label={key} value={formatValue(data[key])} />
31
+ ))}
23
32
  </>
24
33
  );
25
34
  }
package/src/libs/util.ts CHANGED
@@ -14,6 +14,7 @@ import type {
14
14
  } from '@blocklet/payment-types';
15
15
  import { Hasher } from '@ocap/mcrypto';
16
16
  import { hexToNumber } from '@ocap/util';
17
+ import { isObject } from 'lodash';
17
18
  import cloneDeep from 'lodash/cloneDeep';
18
19
  import isEqual from 'lodash/isEqual';
19
20
  import { joinURL } from 'ufo';
@@ -224,3 +225,11 @@ export function goBackOrFallback(fallback: string) {
224
225
  }
225
226
  }, 500);
226
227
  }
228
+
229
+ export function isObjectContent(value: string) {
230
+ try {
231
+ return isObject(JSON.parse(value));
232
+ } catch (err) {
233
+ return false;
234
+ }
235
+ }