payment-kit 1.13.21 → 1.13.22

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.
@@ -43,14 +43,14 @@ const handleEvent = async (req: Request, res: Response) => {
43
43
 
44
44
  if (STRIPE_EVENTS.includes(stripeEvent.type) === false) {
45
45
  logger.debug('webhook event not interested', { id: stripeEvent.id, type: stripeEvent.type });
46
- return res.status(400).json({ error: 'Not implemented' });
46
+ return res.json({ skipped: true });
47
47
  }
48
48
 
49
49
  // only events from this app should be processed
50
50
  const appPid = get(stripeEvent, 'data.object.metadata.appPid');
51
51
  if (appPid && appPid !== env.appPid) {
52
52
  logger.debug('webhook event for other app', { id: stripeEvent.id, type: stripeEvent.type });
53
- return res.json({ received: true });
53
+ return res.json({ skipped: true });
54
54
  }
55
55
 
56
56
  logger.debug('webhook received event', { id: stripeEvent.id, type: stripeEvent.type });
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.21
17
+ version: 1.13.22
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.21",
3
+ "version": "1.13.22",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev",
6
6
  "eject": "vite eject",
@@ -100,7 +100,7 @@
100
100
  "devDependencies": {
101
101
  "@arcblock/eslint-config": "^0.2.4",
102
102
  "@arcblock/eslint-config-ts": "^0.2.4",
103
- "@did-pay/types": "1.13.21",
103
+ "@did-pay/types": "1.13.22",
104
104
  "@types/cookie-parser": "^1.4.4",
105
105
  "@types/cors": "^2.8.14",
106
106
  "@types/dotenv-flow": "^3.3.1",
@@ -137,5 +137,5 @@
137
137
  "parser": "typescript"
138
138
  }
139
139
  },
140
- "gitHead": "9a767485dd2e712fdaf1e636d73556c90f20e2bd"
140
+ "gitHead": "c8b53669ddb7118a2e43596548f031547b2d3da3"
141
141
  }
@@ -5,10 +5,9 @@ import { useEffect } from 'react';
5
5
  import { useFormContext, useWatch } from 'react-hook-form';
6
6
  import { CountryIso2, FlagEmoji, defaultCountries, parseCountry, usePhoneInput } from 'react-international-phone';
7
7
 
8
+ import { isValidCountry } from '../../../libs/util';
8
9
  import FormInput from '../../input';
9
10
 
10
- const isValidCountry = (code: string) => defaultCountries.some((x) => x[1] === code);
11
-
12
11
  export default function PhoneInput({ ...props }) {
13
12
  const countryFieldName = props.countryFieldName || 'billing_address.country';
14
13
 
@@ -14,7 +14,7 @@ import { FormProvider, useForm } from 'react-hook-form';
14
14
 
15
15
  import { useSessionContext } from '../../contexts/session';
16
16
  import { useSettingsContext } from '../../contexts/settings';
17
- import { findCurrency, formatError, getStatementDescriptor } from '../../libs/util';
17
+ import { findCurrency, formatError, getStatementDescriptor, isValidCountry } from '../../libs/util';
18
18
  import PaymentError from './error';
19
19
  import CheckoutFooter from './footer';
20
20
  import PaymentForm from './form';
@@ -175,7 +175,7 @@ export function CheckoutPayMain({
175
175
  postal_code: '',
176
176
  },
177
177
  customer?.address || {},
178
- { country: customer?.address?.country || 'us' }
178
+ { country: isValidCountry(customer?.address?.country || '') ? customer?.address?.country : 'us' }
179
179
  ),
180
180
  },
181
181
  });
@@ -5,6 +5,7 @@ import { Button, CircularProgress, Stack } from '@mui/material';
5
5
  import type { EventHandler } from 'react';
6
6
  import { FormProvider, useForm } from 'react-hook-form';
7
7
 
8
+ import { isValidCountry } from '../../libs/util';
8
9
  import CustomerForm from './form';
9
10
 
10
11
  export default function EditCustomer({
@@ -34,7 +35,7 @@ export default function EditCustomer({
34
35
  postal_code: '',
35
36
  },
36
37
  data.address || {},
37
- { country: data.address?.country || 'us' }
38
+ { country: isValidCountry(data.address?.country || '') ? data.address?.country : 'us' }
38
39
  ),
39
40
  },
40
41
  });
@@ -1,7 +1,9 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
2
  import { AddOutlined, DeleteOutlineOutlined } from '@mui/icons-material';
3
- import { Box, Button, IconButton, Stack, TextField, Typography } from '@mui/material';
4
- import { Controller, useFieldArray, useFormContext } from 'react-hook-form';
3
+ import { Box, Button, IconButton, Stack, Typography } from '@mui/material';
4
+ import { useFieldArray, useFormContext } from 'react-hook-form';
5
+
6
+ import FormInput from '../input';
5
7
 
6
8
  export default function MetadataForm({ title, actions }: { title?: string; actions?: React.ReactNode }) {
7
9
  const { t } = useLocaleContext();
@@ -13,15 +15,19 @@ export default function MetadataForm({ title, actions }: { title?: string; actio
13
15
  {metadata.fields.map((meta, index) => (
14
16
  <Stack key={meta.id} mt={2} spacing={2} direction="row" alignItems="center">
15
17
  <Stack direction="row" spacing={2}>
16
- <Controller
17
- render={({ field }) => <TextField {...field} sx={{ flex: 1 }} placeholder="Key" size="small" />}
18
+ <FormInput
19
+ sx={{ flex: 1 }}
20
+ size="small"
18
21
  name={`metadata.${index}.key`}
19
- control={control}
22
+ rules={{ required: t('checkout.required') }}
23
+ placeholder="Key"
20
24
  />
21
- <Controller
22
- render={({ field }) => <TextField {...field} sx={{ flex: 2 }} placeholder="Value" size="small" />}
25
+ <FormInput
26
+ sx={{ flex: 2 }}
27
+ size="small"
23
28
  name={`metadata.${index}.value`}
24
- control={control}
29
+ placeholder="Value"
30
+ rules={{ required: t('checkout.required') }}
25
31
  />
26
32
  </Stack>
27
33
  <IconButton size="small" onClick={() => metadata.remove(index)}>
package/src/libs/util.ts CHANGED
@@ -15,6 +15,7 @@ import type {
15
15
  import { BN, fromUnitToToken } from '@ocap/util';
16
16
  import cloneDeep from 'lodash/cloneDeep';
17
17
  import isEqual from 'lodash/isEqual';
18
+ import { defaultCountries } from 'react-international-phone';
18
19
 
19
20
  import dayjs from './dayjs';
20
21
 
@@ -567,3 +568,7 @@ export function getSupportedPaymentCurrencies(items: TLineItemExpanded[]) {
567
568
  }, []);
568
569
  return Array.from(new Set(currencies));
569
570
  }
571
+
572
+ export function isValidCountry(code: string) {
573
+ return defaultCountries.some((x) => x[1] === code);
574
+ }