@blocklet/payment-react 1.16.13 → 1.16.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.
- package/es/checkout/donate.d.ts +2 -3
- package/es/checkout/donate.js +2 -2
- package/es/checkout/form.d.ts +1 -2
- package/es/checkout/form.js +1 -1
- package/es/checkout/table.d.ts +1 -2
- package/es/components/blockchain/gas.d.ts +0 -1
- package/es/components/blockchain/tx.d.ts +0 -1
- package/es/components/country-select.d.ts +2 -3
- package/es/components/input.d.ts +13 -14
- package/es/components/livemode.d.ts +1 -2
- package/es/components/over-due-invoice-payment.d.ts +0 -1
- package/es/components/pricing-item.d.ts +1 -2
- package/es/components/pricing-item.js +1 -1
- package/es/components/pricing-table.d.ts +0 -1
- package/es/components/status.d.ts +1 -2
- package/es/components/switch-button.d.ts +5 -4
- package/es/components/switch-button.js +40 -37
- package/es/components/truncated-text.d.ts +0 -1
- package/es/contexts/payment.d.ts +0 -1
- package/es/history/invoice/list.d.ts +0 -1
- package/es/history/payment/list.d.ts +0 -1
- package/es/libs/util.d.ts +2 -5
- package/es/libs/util.js +1 -1
- package/es/locales/index.d.ts +1 -1
- package/es/payment/amount.d.ts +1 -2
- package/es/payment/error.d.ts +0 -1
- package/es/payment/footer.d.ts +0 -1
- package/es/payment/form/addon.d.ts +0 -1
- package/es/payment/form/address.d.ts +1 -2
- package/es/payment/form/currency.d.ts +0 -1
- package/es/payment/form/index.d.ts +1 -2
- package/es/payment/form/index.js +4 -1
- package/es/payment/form/phone.d.ts +0 -1
- package/es/payment/form/stripe/form.d.ts +0 -1
- package/es/payment/form/stripe/index.d.ts +0 -1
- package/es/payment/header.d.ts +0 -1
- package/es/payment/index.d.ts +5 -6
- package/es/payment/product-card.d.ts +0 -1
- package/es/payment/product-donation.d.ts +0 -1
- package/es/payment/product-skeleton.d.ts +0 -1
- package/es/payment/skeleton/overview.d.ts +0 -1
- package/es/payment/skeleton/payment.d.ts +0 -1
- package/es/payment/success.d.ts +0 -1
- package/es/payment/summary.d.ts +0 -1
- package/es/payment/summary.js +1 -11
- package/es/theme/index.d.ts +1 -1
- package/es/types/index.d.ts +2 -2
- package/lib/checkout/donate.d.ts +2 -3
- package/lib/checkout/donate.js +2 -2
- package/lib/checkout/form.d.ts +1 -2
- package/lib/checkout/form.js +1 -1
- package/lib/checkout/table.d.ts +1 -2
- package/lib/components/blockchain/gas.d.ts +0 -1
- package/lib/components/blockchain/tx.d.ts +0 -1
- package/lib/components/country-select.d.ts +2 -3
- package/lib/components/input.d.ts +13 -14
- package/lib/components/livemode.d.ts +1 -2
- package/lib/components/over-due-invoice-payment.d.ts +0 -1
- package/lib/components/pricing-item.d.ts +1 -2
- package/lib/components/pricing-item.js +1 -1
- package/lib/components/pricing-table.d.ts +0 -1
- package/lib/components/status.d.ts +1 -2
- package/lib/components/switch-button.d.ts +5 -4
- package/lib/components/switch-button.js +3 -2
- package/lib/components/truncated-text.d.ts +0 -1
- package/lib/contexts/payment.d.ts +0 -1
- package/lib/history/invoice/list.d.ts +0 -1
- package/lib/history/payment/list.d.ts +0 -1
- package/lib/libs/util.d.ts +2 -5
- package/lib/libs/util.js +1 -1
- package/lib/locales/index.d.ts +1 -1
- package/lib/payment/amount.d.ts +1 -2
- package/lib/payment/error.d.ts +0 -1
- package/lib/payment/footer.d.ts +0 -1
- package/lib/payment/form/addon.d.ts +0 -1
- package/lib/payment/form/address.d.ts +1 -2
- package/lib/payment/form/currency.d.ts +0 -1
- package/lib/payment/form/index.d.ts +1 -2
- package/lib/payment/form/index.js +4 -1
- package/lib/payment/form/phone.d.ts +0 -1
- package/lib/payment/form/stripe/form.d.ts +0 -1
- package/lib/payment/form/stripe/index.d.ts +0 -1
- package/lib/payment/header.d.ts +0 -1
- package/lib/payment/index.d.ts +5 -6
- package/lib/payment/product-card.d.ts +0 -1
- package/lib/payment/product-donation.d.ts +0 -1
- package/lib/payment/product-skeleton.d.ts +0 -1
- package/lib/payment/skeleton/overview.d.ts +0 -1
- package/lib/payment/skeleton/payment.d.ts +0 -1
- package/lib/payment/success.d.ts +0 -1
- package/lib/payment/summary.d.ts +0 -1
- package/lib/theme/index.d.ts +1 -1
- package/lib/types/index.d.ts +2 -2
- package/package.json +16 -15
- package/src/checkout/donate.tsx +4 -4
- package/src/checkout/form.tsx +2 -2
- package/src/checkout/table.tsx +3 -3
- package/src/components/country-select.tsx +5 -3
- package/src/components/input.tsx +4 -2
- package/src/components/livemode.tsx +2 -1
- package/src/components/pricing-item.tsx +2 -2
- package/src/components/status.tsx +2 -1
- package/src/components/switch-button.tsx +44 -39
- package/src/components/truncated-text.tsx +2 -1
- package/src/contexts/payment.tsx +2 -2
- package/src/libs/api.ts +2 -2
- package/src/libs/util.ts +4 -5
- package/src/payment/amount.tsx +2 -1
- package/src/payment/form/address.tsx +2 -1
- package/src/payment/form/index.tsx +2 -1
- package/src/payment/form/phone.tsx +3 -2
- package/src/payment/index.tsx +4 -3
- package/src/payment/summary.tsx +2 -12
- package/src/theme/index.tsx +1 -1
- package/src/types/index.ts +2 -2
|
@@ -1,48 +1,53 @@
|
|
|
1
1
|
import { Switch } from '@mui/material';
|
|
2
2
|
import { styled } from '@mui/system';
|
|
3
3
|
import type { LiteralUnion } from 'type-fest';
|
|
4
|
+
import type { SwitchProps as MuiSwitchProps } from '@mui/material';
|
|
4
5
|
|
|
5
|
-
type
|
|
6
|
+
type CustomSwitchProps = {
|
|
6
7
|
variant?: LiteralUnion<'success' | 'error' | 'warning' | 'info' | 'primary' | 'secondary', string>;
|
|
7
|
-
};
|
|
8
|
+
} & MuiSwitchProps;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
const SwitchButton: React.FC<CustomSwitchProps> = styled(Switch)<CustomSwitchProps>(
|
|
11
|
+
({ variant = 'success', theme }) => ({
|
|
12
|
+
width: 28,
|
|
13
|
+
height: 16,
|
|
14
|
+
padding: 0,
|
|
15
|
+
display: 'inline-flex',
|
|
16
|
+
'&:active': {
|
|
17
|
+
'& .MuiSwitch-thumb': {
|
|
18
|
+
width: 15,
|
|
19
|
+
},
|
|
20
|
+
'& .MuiSwitch-switchBase.Mui-checked': {
|
|
21
|
+
transform: 'translateX(9px)',
|
|
22
|
+
},
|
|
20
23
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
'& .MuiSwitch-switchBase': {
|
|
25
|
+
padding: 2,
|
|
26
|
+
'&.Mui-checked': {
|
|
27
|
+
transform: 'translateX(12px)',
|
|
28
|
+
color: '#fff',
|
|
29
|
+
'& + .MuiSwitch-track': {
|
|
30
|
+
opacity: 1,
|
|
31
|
+
backgroundColor: theme.palette[variant]?.light,
|
|
32
|
+
},
|
|
30
33
|
},
|
|
31
34
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
35
|
+
'& .MuiSwitch-thumb': {
|
|
36
|
+
boxShadow: '0 2px 4px 0 rgb(0 35 11 / 20%)',
|
|
37
|
+
width: 12,
|
|
38
|
+
height: 12,
|
|
39
|
+
borderRadius: 6,
|
|
40
|
+
transition: (theme.transitions as any)?.create(['width'], {
|
|
41
|
+
duration: 200,
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
'& .MuiSwitch-track': {
|
|
45
|
+
borderRadius: 16 / 2,
|
|
46
|
+
opacity: 1,
|
|
47
|
+
backgroundColor: theme.palette.mode === 'dark' ? 'rgba(255,255,255,.35)' : 'rgba(0,0,0,.25)',
|
|
48
|
+
boxSizing: 'border-box',
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export default SwitchButton;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Tooltip
|
|
1
|
+
import { Tooltip } from '@mui/material';
|
|
2
|
+
import type { TooltipProps } from '@mui/material';
|
|
2
3
|
import { tooltipClasses } from '@mui/material/Tooltip';
|
|
3
4
|
import { styled } from '@mui/system';
|
|
4
5
|
import { truncateText } from '../libs/util';
|
package/src/contexts/payment.tsx
CHANGED
|
@@ -50,11 +50,11 @@ const getSettings = () => {
|
|
|
50
50
|
if (!settingsPromise) {
|
|
51
51
|
settingsPromise = api
|
|
52
52
|
.get('/api/settings', { params: { livemode } })
|
|
53
|
-
.then(({ data }) => {
|
|
53
|
+
.then(({ data }: any) => {
|
|
54
54
|
sessionStorage.setItem(cacheKey, JSON.stringify(data));
|
|
55
55
|
return data;
|
|
56
56
|
})
|
|
57
|
-
.catch((error) => {
|
|
57
|
+
.catch((error: any) => {
|
|
58
58
|
throw error;
|
|
59
59
|
})
|
|
60
60
|
.finally(() => {
|
package/src/libs/api.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { getPrefix } from './util';
|
|
|
8
8
|
const api = createAxios();
|
|
9
9
|
|
|
10
10
|
api.interceptors.request.use(
|
|
11
|
-
(config) => {
|
|
11
|
+
(config: any) => {
|
|
12
12
|
const prefix = getPrefix();
|
|
13
13
|
config.baseURL = prefix || '';
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ api.interceptors.request.use(
|
|
|
23
23
|
|
|
24
24
|
return config;
|
|
25
25
|
},
|
|
26
|
-
(err) => Promise.reject(err)
|
|
26
|
+
(err: any) => Promise.reject(err)
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
export default api;
|
package/src/libs/util.ts
CHANGED
|
@@ -15,7 +15,6 @@ import type {
|
|
|
15
15
|
TSubscriptionExpanded,
|
|
16
16
|
TSubscriptionItemExpanded,
|
|
17
17
|
} from '@blocklet/payment-types';
|
|
18
|
-
import type { TComponent } from '@blocklet/sdk/lib/config';
|
|
19
18
|
import { BN, fromUnitToToken } from '@ocap/util';
|
|
20
19
|
import omit from 'lodash/omit';
|
|
21
20
|
import trimEnd from 'lodash/trimEnd';
|
|
@@ -27,7 +26,7 @@ import { joinURL } from 'ufo';
|
|
|
27
26
|
|
|
28
27
|
import { t } from '../locales';
|
|
29
28
|
import dayjs from './dayjs';
|
|
30
|
-
import { ActionProps, PricingRenderProps } from '../types';
|
|
29
|
+
import type { ActionProps, PricingRenderProps } from '../types';
|
|
31
30
|
|
|
32
31
|
export const PAYMENT_KIT_DID = 'z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk';
|
|
33
32
|
|
|
@@ -54,7 +53,7 @@ export const getPrefix = (): string => {
|
|
|
54
53
|
if (componentId === PAYMENT_KIT_DID) {
|
|
55
54
|
return joinURL(baseUrl, prefix);
|
|
56
55
|
}
|
|
57
|
-
const component = (window.blocklet?.componentMountPoints || []).find((x:
|
|
56
|
+
const component = (window.blocklet?.componentMountPoints || []).find((x: any) => x?.did === PAYMENT_KIT_DID);
|
|
58
57
|
if (component) {
|
|
59
58
|
return joinURL(baseUrl, component.mountPoint);
|
|
60
59
|
}
|
|
@@ -774,7 +773,7 @@ export function findCurrency(methods: TPaymentMethodExpanded[], currencyId: stri
|
|
|
774
773
|
}
|
|
775
774
|
|
|
776
775
|
export function isValidCountry(code: string) {
|
|
777
|
-
return defaultCountries.some((x) => x[1] === code);
|
|
776
|
+
return defaultCountries.some((x: any) => x[1] === code);
|
|
778
777
|
}
|
|
779
778
|
|
|
780
779
|
export function stopEvent(e: React.SyntheticEvent<any>) {
|
|
@@ -874,7 +873,7 @@ export const mergeExtraParams = (extra: Record<string, any> = {}) => {
|
|
|
874
873
|
return params.toString();
|
|
875
874
|
};
|
|
876
875
|
|
|
877
|
-
export const flattenPaymentMethods = (methods: TPaymentMethodExpanded[] = []) => {
|
|
876
|
+
export const flattenPaymentMethods = (methods: TPaymentMethodExpanded[] = []): TPaymentCurrency[] => {
|
|
878
877
|
const out: TPaymentCurrency[] = [];
|
|
879
878
|
|
|
880
879
|
methods.forEach((method: any) => {
|
package/src/payment/amount.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
-
import { Fade, FormLabel, InputAdornment, Stack
|
|
2
|
+
import { Fade, FormLabel, InputAdornment, Stack } from '@mui/material';
|
|
3
|
+
import type { SxProps } from '@mui/material';
|
|
3
4
|
import { Controller, useFormContext } from 'react-hook-form';
|
|
4
5
|
import FormInput from '../../components/input';
|
|
5
6
|
import CountrySelect from '../../components/country-select';
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
getQueryParams,
|
|
35
35
|
getStatementDescriptor,
|
|
36
36
|
} from '../../libs/util';
|
|
37
|
-
import { CheckoutCallbacks, CheckoutContext } from '../../types';
|
|
37
|
+
import type { CheckoutCallbacks, CheckoutContext } from '../../types';
|
|
38
38
|
import AddressForm from './address';
|
|
39
39
|
import CurrencySelector from './currency';
|
|
40
40
|
import PhoneInput from './phone';
|
|
@@ -59,6 +59,7 @@ const waitForCheckoutComplete = async (sessionId: string) => {
|
|
|
59
59
|
result = data;
|
|
60
60
|
|
|
61
61
|
return (
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/return-await
|
|
62
63
|
data.checkoutSession?.status === 'complete' &&
|
|
63
64
|
['paid', 'no_payment_required'].includes(data.checkoutSession?.payment_status)
|
|
64
65
|
);
|
|
@@ -3,7 +3,8 @@ import { InputAdornment } from '@mui/material';
|
|
|
3
3
|
import omit from 'lodash/omit';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
import { useFormContext, useWatch } from 'react-hook-form';
|
|
6
|
-
import {
|
|
6
|
+
import { defaultCountries, usePhoneInput } from 'react-international-phone';
|
|
7
|
+
import type { CountryIso2 } from 'react-international-phone';
|
|
7
8
|
|
|
8
9
|
import FormInput from '../../components/input';
|
|
9
10
|
import { isValidCountry } from '../../libs/util';
|
|
@@ -18,7 +19,7 @@ export default function PhoneInput({ ...props }) {
|
|
|
18
19
|
defaultCountry: isValidCountry(values[countryFieldName]) ? values[countryFieldName] : 'us',
|
|
19
20
|
value: values[props.name] || '',
|
|
20
21
|
countries: defaultCountries,
|
|
21
|
-
onChange: (data) => {
|
|
22
|
+
onChange: (data: any) => {
|
|
22
23
|
setValue(props.name, data.phone);
|
|
23
24
|
setValue(countryFieldName, data.country);
|
|
24
25
|
},
|
package/src/payment/index.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
TPaymentMethodExpanded,
|
|
13
13
|
} from '@blocklet/payment-types';
|
|
14
14
|
import { ArrowBackOutlined } from '@mui/icons-material';
|
|
15
|
-
import { Box, Fade, Stack } from '@mui/material';
|
|
15
|
+
import { Box, Fade, Stack, type BoxProps } from '@mui/material';
|
|
16
16
|
import { styled } from '@mui/system';
|
|
17
17
|
import { fromTokenToUnit } from '@ocap/util';
|
|
18
18
|
import { useSetState } from 'ahooks';
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
isMobileSafari,
|
|
32
32
|
isValidCountry,
|
|
33
33
|
} from '../libs/util';
|
|
34
|
-
import { CheckoutCallbacks, CheckoutContext, CheckoutFormData } from '../types';
|
|
34
|
+
import type { CheckoutCallbacks, CheckoutContext, CheckoutFormData } from '../types';
|
|
35
35
|
import PaymentError from './error';
|
|
36
36
|
import CheckoutFooter from './footer';
|
|
37
37
|
import PaymentForm from './form';
|
|
@@ -470,7 +470,8 @@ export default function Payment({
|
|
|
470
470
|
|
|
471
471
|
type MainProps = CheckoutContext & CheckoutCallbacks & { completed?: boolean; showCheckoutSummary?: boolean };
|
|
472
472
|
|
|
473
|
-
|
|
473
|
+
type RootProps = { mode: LiteralUnion<'standalone' | 'inline' | 'popup', string> } & BoxProps;
|
|
474
|
+
export const Root: React.FC<RootProps> = styled(Box)<RootProps>`
|
|
474
475
|
box-sizing: border-box;
|
|
475
476
|
display: flex;
|
|
476
477
|
flex-direction: column;
|
package/src/payment/summary.tsx
CHANGED
|
@@ -2,18 +2,8 @@ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
|
2
2
|
import type { DonationSettings, TLineItemExpanded, TPaymentCurrency } from '@blocklet/payment-types';
|
|
3
3
|
import { HelpOutline } from '@mui/icons-material';
|
|
4
4
|
import { LoadingButton } from '@mui/lab';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
Divider,
|
|
8
|
-
Fade,
|
|
9
|
-
Grow,
|
|
10
|
-
Stack,
|
|
11
|
-
Tooltip,
|
|
12
|
-
Typography,
|
|
13
|
-
Collapse,
|
|
14
|
-
IconButton,
|
|
15
|
-
IconButtonProps,
|
|
16
|
-
} from '@mui/material';
|
|
5
|
+
import { Box, Divider, Fade, Grow, Stack, Tooltip, Typography, Collapse, IconButton } from '@mui/material';
|
|
6
|
+
import type { IconButtonProps } from '@mui/material';
|
|
17
7
|
import { BN, fromTokenToUnit, fromUnitToToken } from '@ocap/util';
|
|
18
8
|
import { useRequest, useSetState } from 'ahooks';
|
|
19
9
|
import noop from 'lodash/noop';
|
package/src/theme/index.tsx
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -6,8 +6,8 @@ import type {
|
|
|
6
6
|
TPaymentLink,
|
|
7
7
|
TPaymentMethodExpanded,
|
|
8
8
|
} from '@blocklet/payment-types';
|
|
9
|
-
import { SxProps, ThemeOptions } from '@mui/material';
|
|
10
|
-
import { LiteralUnion } from 'type-fest';
|
|
9
|
+
import type { SxProps, ThemeOptions } from '@mui/material';
|
|
10
|
+
import type { LiteralUnion } from 'type-fest';
|
|
11
11
|
|
|
12
12
|
export type CheckoutContext = {
|
|
13
13
|
checkoutSession: TCheckoutSessionExpanded;
|