@blocklet/payment-react 1.18.29 → 1.18.31

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.
Files changed (49) hide show
  1. package/es/checkout/donate.js +51 -23
  2. package/es/components/country-select.js +1 -0
  3. package/es/components/over-due-invoice-payment.js +44 -5
  4. package/es/history/invoice/list.js +3 -1
  5. package/es/libs/util.d.ts +2 -0
  6. package/es/libs/util.js +25 -2
  7. package/es/locales/en.js +2 -1
  8. package/es/locales/zh.js +2 -1
  9. package/es/payment/form/currency.d.ts +1 -1
  10. package/es/payment/form/currency.js +3 -3
  11. package/es/payment/form/index.d.ts +1 -1
  12. package/es/payment/form/index.js +22 -36
  13. package/es/payment/form/stripe/form.js +4 -2
  14. package/es/payment/index.js +10 -1
  15. package/es/payment/product-donation.js +4 -3
  16. package/es/payment/success.d.ts +3 -1
  17. package/es/payment/success.js +78 -6
  18. package/lib/checkout/donate.js +19 -11
  19. package/lib/components/country-select.js +1 -0
  20. package/lib/components/over-due-invoice-payment.js +42 -3
  21. package/lib/history/invoice/list.js +1 -0
  22. package/lib/libs/util.d.ts +2 -0
  23. package/lib/libs/util.js +27 -2
  24. package/lib/locales/en.js +2 -1
  25. package/lib/locales/zh.js +2 -1
  26. package/lib/payment/form/currency.d.ts +1 -1
  27. package/lib/payment/form/currency.js +3 -3
  28. package/lib/payment/form/index.d.ts +1 -1
  29. package/lib/payment/form/index.js +21 -35
  30. package/lib/payment/form/stripe/form.js +4 -2
  31. package/lib/payment/index.js +10 -1
  32. package/lib/payment/product-donation.js +4 -3
  33. package/lib/payment/success.d.ts +3 -1
  34. package/lib/payment/success.js +68 -15
  35. package/package.json +8 -8
  36. package/src/checkout/donate.tsx +23 -5
  37. package/src/components/country-select.tsx +1 -0
  38. package/src/components/over-due-invoice-payment.tsx +47 -4
  39. package/src/history/invoice/list.tsx +2 -0
  40. package/src/libs/util.ts +28 -2
  41. package/src/locales/en.tsx +1 -0
  42. package/src/locales/zh.tsx +1 -0
  43. package/src/payment/form/currency.tsx +4 -4
  44. package/src/payment/form/index.tsx +23 -47
  45. package/src/payment/form/stripe/form.tsx +4 -2
  46. package/src/payment/index.tsx +12 -1
  47. package/src/payment/product-donation.tsx +4 -3
  48. package/src/payment/success.tsx +73 -11
  49. package/src/payment/summary.tsx +1 -0
@@ -1,8 +1,9 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
- import { Grow, Link, Stack, Typography } from '@mui/material';
2
+ import { Grow, Link, Stack, Typography, Box, Paper } from '@mui/material';
3
3
  import { styled } from '@mui/system';
4
4
  import { joinURL } from 'ufo';
5
5
 
6
+ import { Button } from '@arcblock/ux';
6
7
  import { usePaymentContext } from '../contexts/payment';
7
8
 
8
9
  type Props = {
@@ -12,20 +13,80 @@ type Props = {
12
13
  payee: string;
13
14
  invoiceId?: string;
14
15
  subscriptionId?: string;
16
+ subscriptions?: any[];
15
17
  };
16
18
 
17
- export default function PaymentSuccess({ mode, message, action, payee, invoiceId, subscriptionId }: Props) {
19
+ export default function PaymentSuccess({
20
+ mode,
21
+ message,
22
+ action,
23
+ payee,
24
+ invoiceId,
25
+ subscriptionId,
26
+ subscriptions,
27
+ }: Props) {
18
28
  const { t } = useLocaleContext();
19
29
  const { prefix } = usePaymentContext();
20
30
  let next: any = null;
21
- if (['subscription', 'setup'].includes(action) && subscriptionId) {
22
- next = (
23
- <Typography textAlign="center" sx={{ mt: 2 }}>
24
- <Link href={joinURL(prefix, `/customer/subscription/${subscriptionId}`)}>
25
- {t('payment.checkout.next.subscription', { payee })}
26
- </Link>
27
- </Typography>
28
- );
31
+ if (['subscription', 'setup'].includes(action)) {
32
+ if (subscriptions && subscriptions.length > 1) {
33
+ next = (
34
+ <Paper
35
+ elevation={0}
36
+ sx={{
37
+ p: 3,
38
+ backgroundColor: 'grey.50',
39
+ borderRadius: 2,
40
+ width: '100%',
41
+ mt: 2,
42
+ display: 'flex',
43
+ flexDirection: 'column',
44
+ gap: 2,
45
+ }}>
46
+ {subscriptions.map((subscription) => (
47
+ <Box
48
+ key={subscription.id}
49
+ sx={{
50
+ display: 'flex',
51
+ alignItems: 'center',
52
+ justifyContent: 'space-between',
53
+ }}>
54
+ <Typography
55
+ variant="body2"
56
+ sx={{
57
+ color: 'text.secondary',
58
+ fontWeight: 500,
59
+ }}>
60
+ {subscription.description}
61
+ </Typography>
62
+ <Box
63
+ sx={{
64
+ flex: 1,
65
+ borderBottom: '1px dashed',
66
+ borderColor: 'grey.300',
67
+ mx: 2,
68
+ }}
69
+ />
70
+ <Button variant="text" color="primary" size="small">
71
+ <Link
72
+ href={joinURL(prefix, `/customer/subscription/${subscription.id}`)}
73
+ sx={{ color: 'text.secondary' }}>
74
+ {t('payment.checkout.next.view')}
75
+ </Link>
76
+ </Button>
77
+ </Box>
78
+ ))}
79
+ </Paper>
80
+ );
81
+ } else if (subscriptionId) {
82
+ next = (
83
+ <Button variant="outlined" color="primary" sx={{ mt: 2 }}>
84
+ <Link href={joinURL(prefix, `/customer/subscription/${subscriptionId}`)}>
85
+ {t('payment.checkout.next.subscription', { payee })}
86
+ </Link>
87
+ </Button>
88
+ );
89
+ }
29
90
  } else if (invoiceId) {
30
91
  next = (
31
92
  <Typography textAlign="center" sx={{ mt: 2 }}>
@@ -42,7 +103,7 @@ export default function PaymentSuccess({ mode, message, action, payee, invoiceId
42
103
  direction="column"
43
104
  alignItems="center"
44
105
  justifyContent={mode === 'standalone' ? 'center' : 'flex-start'}
45
- sx={{ height: mode === 'standalone' ? 360 : 300 }}>
106
+ sx={{ height: mode === 'standalone' ? 'fit-content' : 300 }}>
46
107
  <Div>
47
108
  <div className="check-icon">
48
109
  <span className="icon-line line-tip" />
@@ -66,6 +127,7 @@ export default function PaymentSuccess({ mode, message, action, payee, invoiceId
66
127
  PaymentSuccess.defaultProps = {
67
128
  invoiceId: '',
68
129
  subscriptionId: '',
130
+ subscriptions: [],
69
131
  };
70
132
 
71
133
  const Div = styled('div')`
@@ -160,6 +160,7 @@ export default function PaymentSummary({
160
160
  );
161
161
  const headlines = formatCheckoutHeadlines(items, currency, { trialEnd, trialInDays }, locale);
162
162
  const staking = showStaking ? getStakingSetup(items, currency, billingThreshold) : '0';
163
+
163
164
  const totalAmount = fromUnitToToken(
164
165
  new BN(fromTokenToUnit(headlines.actualAmount, currency?.decimal)).add(new BN(staking)).toString(),
165
166
  currency?.decimal