@blocklet/payment-react 1.14.21 → 1.14.23
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/README.md +77 -0
- package/es/checkout/donate.d.ts +4 -2
- package/es/checkout/donate.js +13 -10
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +50 -4
- package/es/checkout/table.d.ts +1 -1
- package/es/checkout/table.js +11 -1
- package/es/components/blockchain/tx.js +2 -1
- package/es/components/country-select.d.ts +16 -0
- package/es/components/country-select.js +82 -0
- package/es/components/input.d.ts +21 -21
- package/es/components/input.js +43 -42
- package/es/components/livemode.js +1 -0
- package/es/components/pricing-table.js +0 -2
- package/es/components/status.js +2 -3
- package/es/components/table.d.ts +2 -0
- package/es/components/table.js +186 -0
- package/es/contexts/payment.d.ts +2 -0
- package/es/contexts/payment.js +5 -2
- package/es/history/invoice/list.d.ts +3 -1
- package/es/history/invoice/list.js +215 -48
- package/es/hooks/mobile.d.ts +4 -0
- package/es/hooks/mobile.js +10 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +7 -1
- package/es/libs/util.d.ts +21 -8
- package/es/libs/util.js +92 -28
- package/es/locales/en.js +22 -7
- package/es/locales/index.d.ts +0 -1
- package/es/locales/index.js +10 -1
- package/es/locales/zh.js +21 -6
- package/es/payment/error.js +2 -2
- package/es/payment/footer.js +1 -1
- package/es/payment/form/address.d.ts +9 -2
- package/es/payment/form/address.js +69 -69
- package/es/payment/form/currency.js +39 -25
- package/es/payment/form/index.d.ts +1 -1
- package/es/payment/form/index.js +83 -81
- package/es/payment/form/phone.js +15 -51
- package/es/payment/index.d.ts +3 -10
- package/es/payment/index.js +295 -224
- package/es/payment/product-card.js +4 -4
- package/es/payment/product-donation.js +9 -3
- package/es/payment/product-item.d.ts +2 -2
- package/es/payment/product-item.js +120 -81
- package/es/payment/summary.js +188 -118
- package/es/theme/index.css +240 -0
- package/es/theme/index.d.ts +14 -0
- package/es/theme/index.js +256 -0
- package/es/theme/typography.d.ts +2 -0
- package/es/theme/typography.js +53 -0
- package/es/types/index.d.ts +16 -0
- package/lib/checkout/donate.d.ts +4 -2
- package/lib/checkout/donate.js +23 -2
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +60 -15
- package/lib/checkout/table.d.ts +1 -1
- package/lib/checkout/table.js +22 -1
- package/lib/components/blockchain/tx.js +4 -1
- package/lib/components/country-select.d.ts +16 -0
- package/lib/components/country-select.js +115 -0
- package/lib/components/input.d.ts +21 -21
- package/lib/components/input.js +21 -12
- package/lib/components/livemode.js +1 -0
- package/lib/components/pricing-table.js +0 -2
- package/lib/components/status.js +2 -3
- package/lib/components/table.d.ts +2 -0
- package/lib/components/table.js +220 -0
- package/lib/contexts/payment.d.ts +2 -0
- package/lib/contexts/payment.js +4 -1
- package/lib/history/invoice/list.d.ts +3 -1
- package/lib/history/invoice/list.js +290 -62
- package/lib/hooks/mobile.d.ts +4 -0
- package/lib/hooks/mobile.js +17 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +36 -0
- package/lib/libs/util.d.ts +21 -8
- package/lib/libs/util.js +115 -37
- package/lib/locales/en.js +22 -7
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/index.js +14 -3
- package/lib/locales/zh.js +21 -6
- package/lib/payment/error.js +5 -1
- package/lib/payment/footer.js +1 -1
- package/lib/payment/form/address.d.ts +9 -2
- package/lib/payment/form/address.js +67 -59
- package/lib/payment/form/currency.js +31 -24
- package/lib/payment/form/index.d.ts +1 -1
- package/lib/payment/form/index.js +92 -93
- package/lib/payment/form/phone.js +11 -59
- package/lib/payment/index.d.ts +3 -10
- package/lib/payment/index.js +302 -225
- package/lib/payment/product-card.js +5 -4
- package/lib/payment/product-donation.js +11 -7
- package/lib/payment/product-item.d.ts +2 -2
- package/lib/payment/product-item.js +38 -19
- package/lib/payment/summary.js +219 -127
- package/lib/theme/index.css +240 -0
- package/lib/theme/index.d.ts +14 -0
- package/lib/theme/index.js +273 -0
- package/lib/theme/typography.d.ts +2 -0
- package/lib/theme/typography.js +59 -0
- package/lib/types/index.d.ts +16 -0
- package/package.json +14 -11
- package/src/checkout/donate.tsx +25 -11
- package/src/checkout/form.tsx +63 -15
- package/src/checkout/table.tsx +20 -1
- package/src/components/blockchain/tx.tsx +2 -1
- package/src/components/country-select.tsx +93 -0
- package/src/components/input.tsx +49 -46
- package/src/components/livemode.tsx +1 -0
- package/src/components/pricing-table.tsx +0 -2
- package/src/components/status.tsx +1 -2
- package/src/components/table.tsx +200 -0
- package/src/contexts/payment.tsx +6 -1
- package/src/history/invoice/list.tsx +254 -49
- package/src/hooks/mobile.ts +13 -0
- package/src/index.ts +7 -0
- package/src/libs/util.ts +120 -31
- package/src/locales/en.tsx +18 -4
- package/src/locales/index.tsx +10 -3
- package/src/locales/zh.tsx +17 -3
- package/src/payment/error.tsx +2 -2
- package/src/payment/footer.tsx +1 -1
- package/src/payment/form/address.tsx +56 -47
- package/src/payment/form/currency.tsx +29 -23
- package/src/payment/form/index.tsx +89 -76
- package/src/payment/form/phone.tsx +14 -51
- package/src/payment/index.tsx +298 -231
- package/src/payment/product-card.tsx +4 -4
- package/src/payment/product-donation.tsx +9 -4
- package/src/payment/product-item.tsx +49 -20
- package/src/payment/summary.tsx +191 -108
- package/src/theme/index.css +240 -0
- package/src/theme/index.tsx +271 -0
- package/src/theme/typography.ts +56 -0
- package/src/types/index.ts +17 -0
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
|
-
import { Fade,
|
|
3
|
+
import { Fade, FormLabel, InputAdornment, Stack } from "@mui/material";
|
|
4
4
|
import { Controller, useFormContext } from "react-hook-form";
|
|
5
|
-
import { CountrySelector } from "react-international-phone";
|
|
6
5
|
import FormInput from "../../components/input.js";
|
|
7
|
-
|
|
6
|
+
import CountrySelect from "../../components/country-select.js";
|
|
7
|
+
AddressForm.defaultProps = {
|
|
8
|
+
sx: {}
|
|
9
|
+
};
|
|
10
|
+
export default function AddressForm({ mode, stripe, sx = {} }) {
|
|
8
11
|
const { t } = useLocaleContext();
|
|
9
|
-
const { control
|
|
12
|
+
const { control } = useFormContext();
|
|
10
13
|
if (mode === "required") {
|
|
11
|
-
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-address cko-payment-form", children: [
|
|
12
|
-
/* @__PURE__ */ jsx(
|
|
14
|
+
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-address cko-payment-form", sx, children: [
|
|
15
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t(`payment.checkout.billing.${mode}`) }),
|
|
13
16
|
/* @__PURE__ */ jsxs(Stack, { direction: "column", className: "cko-payment-form", spacing: 0, children: [
|
|
14
|
-
/* @__PURE__ */
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
/* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 0, children: /* @__PURE__ */ jsx(
|
|
18
|
+
FormInput,
|
|
19
|
+
{
|
|
20
|
+
name: "billing_address.postal_code",
|
|
21
|
+
rules: { required: t("payment.checkout.required") },
|
|
22
|
+
errorPosition: "right",
|
|
23
|
+
variant: "outlined",
|
|
24
|
+
placeholder: t("payment.checkout.billing.postal_code"),
|
|
25
|
+
InputProps: {
|
|
26
|
+
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(
|
|
27
|
+
Controller,
|
|
22
28
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
name: "billing_address.country",
|
|
30
|
+
control,
|
|
31
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
32
|
+
CountrySelect,
|
|
33
|
+
{
|
|
34
|
+
...field,
|
|
35
|
+
sx: {
|
|
36
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
37
|
+
borderColor: "transparent"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
)
|
|
32
42
|
}
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
),
|
|
36
|
-
/* @__PURE__ */ jsx(
|
|
37
|
-
FormInput,
|
|
38
|
-
{
|
|
39
|
-
name: "billing_address.postal_code",
|
|
40
|
-
rules: { required: t("payment.checkout.required") },
|
|
41
|
-
errorPosition: "right",
|
|
42
|
-
variant: "outlined",
|
|
43
|
-
placeholder: t("payment.checkout.billing.postal_code")
|
|
43
|
+
) })
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
}
|
|
46
|
+
) }),
|
|
47
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.state") }),
|
|
47
48
|
/* @__PURE__ */ jsx(
|
|
48
49
|
FormInput,
|
|
49
50
|
{
|
|
@@ -54,6 +55,7 @@ export default function AddressForm({ mode, stripe }) {
|
|
|
54
55
|
placeholder: t("payment.checkout.billing.state")
|
|
55
56
|
}
|
|
56
57
|
),
|
|
58
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.line1") }),
|
|
57
59
|
/* @__PURE__ */ jsx(
|
|
58
60
|
FormInput,
|
|
59
61
|
{
|
|
@@ -64,6 +66,7 @@ export default function AddressForm({ mode, stripe }) {
|
|
|
64
66
|
placeholder: t("payment.checkout.billing.line1")
|
|
65
67
|
}
|
|
66
68
|
),
|
|
69
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.city") }),
|
|
67
70
|
/* @__PURE__ */ jsx(
|
|
68
71
|
FormInput,
|
|
69
72
|
{
|
|
@@ -78,42 +81,39 @@ export default function AddressForm({ mode, stripe }) {
|
|
|
78
81
|
] }) });
|
|
79
82
|
}
|
|
80
83
|
if (stripe) {
|
|
81
|
-
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-address cko-payment-form", children: [
|
|
82
|
-
/* @__PURE__ */ jsx(
|
|
83
|
-
/* @__PURE__ */ jsx(Stack, { direction: "column", className: "cko-payment-form", spacing: 0, children: /* @__PURE__ */
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-address cko-payment-form", sx, children: [
|
|
85
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t(`payment.checkout.billing.${mode}`) }),
|
|
86
|
+
/* @__PURE__ */ jsx(Stack, { direction: "column", className: "cko-payment-form", spacing: 0, children: /* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 0, children: /* @__PURE__ */ jsx(
|
|
87
|
+
FormInput,
|
|
88
|
+
{
|
|
89
|
+
name: "billing_address.postal_code",
|
|
90
|
+
rules: { required: t("payment.checkout.required") },
|
|
91
|
+
errorPosition: "right",
|
|
92
|
+
variant: "outlined",
|
|
93
|
+
placeholder: t("payment.checkout.billing.postal_code"),
|
|
94
|
+
wrapperStyle: { height: "40px" },
|
|
95
|
+
InputProps: {
|
|
96
|
+
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(
|
|
97
|
+
Controller,
|
|
91
98
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
name: "billing_address.country",
|
|
100
|
+
control,
|
|
101
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
102
|
+
CountrySelect,
|
|
103
|
+
{
|
|
104
|
+
...field,
|
|
105
|
+
sx: {
|
|
106
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
107
|
+
borderColor: "transparent"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
)
|
|
101
112
|
}
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
),
|
|
105
|
-
/* @__PURE__ */ jsx(
|
|
106
|
-
FormInput,
|
|
107
|
-
{
|
|
108
|
-
name: "billing_address.postal_code",
|
|
109
|
-
rules: { required: t("payment.checkout.required") },
|
|
110
|
-
errorPosition: "right",
|
|
111
|
-
variant: "outlined",
|
|
112
|
-
placeholder: t("payment.checkout.billing.postal_code"),
|
|
113
|
-
wrapperStyle: { height: "40px" }
|
|
113
|
+
) })
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
}
|
|
116
|
+
) }) })
|
|
117
117
|
] }) });
|
|
118
118
|
}
|
|
119
119
|
return null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Avatar, Card, Stack, Typography } from "@mui/material";
|
|
2
|
+
import { Avatar, Card, Radio, Stack, Typography } from "@mui/material";
|
|
3
3
|
import { styled } from "@mui/system";
|
|
4
4
|
export default function CurrencySelector({ value, currencies, onChange }) {
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
@@ -8,8 +8,9 @@ export default function CurrencySelector({ value, currencies, onChange }) {
|
|
|
8
8
|
count: currencies.length,
|
|
9
9
|
style: {
|
|
10
10
|
display: currencies.length > 1 ? "grid" : "block",
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
width: "100%",
|
|
12
|
+
gap: 12,
|
|
13
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))"
|
|
13
14
|
},
|
|
14
15
|
children: currencies.map((x, i) => {
|
|
15
16
|
const selected = i === value;
|
|
@@ -19,12 +20,30 @@ export default function CurrencySelector({ value, currencies, onChange }) {
|
|
|
19
20
|
variant: "outlined",
|
|
20
21
|
onClick: () => onChange(i),
|
|
21
22
|
className: selected ? "cko-payment-card" : "cko-payment-card-unselect",
|
|
22
|
-
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", children: [
|
|
23
|
-
/* @__PURE__ */ jsx(Avatar, { src: x.logo, alt: x.name, sx: { width:
|
|
23
|
+
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", sx: { position: "relative" }, children: [
|
|
24
|
+
/* @__PURE__ */ jsx(Avatar, { src: x.logo, alt: x.name, sx: { width: 40, height: 40, marginRight: "12px" } }),
|
|
24
25
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
25
|
-
/* @__PURE__ */ jsx(
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
Typography,
|
|
28
|
+
{
|
|
29
|
+
variant: "h5",
|
|
30
|
+
component: "div",
|
|
31
|
+
sx: { fontSize: "16px", color: "text.primary", fontWeight: "500" },
|
|
32
|
+
children: x.symbol
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
/* @__PURE__ */ jsx(Typography, { sx: { fontSize: 14 }, color: "text.lighter", gutterBottom: true, children: x.method.name })
|
|
36
|
+
] }),
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
Radio,
|
|
39
|
+
{
|
|
40
|
+
checked: selected,
|
|
41
|
+
sx: {
|
|
42
|
+
position: "absolute",
|
|
43
|
+
right: 0
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
)
|
|
28
47
|
] })
|
|
29
48
|
},
|
|
30
49
|
x.id
|
|
@@ -36,32 +55,27 @@ export default function CurrencySelector({ value, currencies, onChange }) {
|
|
|
36
55
|
const Root = styled("section")`
|
|
37
56
|
.cko-payment-card {
|
|
38
57
|
position: relative;
|
|
39
|
-
border: 1px solid
|
|
58
|
+
border: 1px solid var(--stroke-border-interactive, #0086ff);
|
|
40
59
|
padding: 4px 8px;
|
|
41
|
-
margin: 8px 0 0;
|
|
42
60
|
cursor: pointer;
|
|
61
|
+
background: var(--backgrounds-bg-field, #f9fafb);
|
|
43
62
|
}
|
|
44
63
|
|
|
45
|
-
.cko-payment-card::before {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
64
|
+
// .cko-payment-card::before {
|
|
65
|
+
// content: '';
|
|
66
|
+
// position: absolute;
|
|
67
|
+
// right: 0;
|
|
68
|
+
// bottom: 0;
|
|
69
|
+
// border: 12px solid ${(props) => props.theme.palette.primary.main};
|
|
70
|
+
// border-top-color: transparent;
|
|
71
|
+
// border-left-color: transparent;
|
|
72
|
+
// }
|
|
54
73
|
|
|
55
74
|
.cko-payment-card-unselect {
|
|
56
75
|
border: 1px solid #ddd;
|
|
57
76
|
padding: 4px 8px;
|
|
58
|
-
margin: 8px 0 0;
|
|
59
77
|
cursor: pointer;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.cko-payment-card:nth-child(odd),
|
|
63
|
-
.cko-payment-card-unselect:nth-child(odd) {
|
|
64
|
-
margin-right: ${(props) => props.count > 1 ? 8 : 0}px;
|
|
78
|
+
background: var(--backgrounds-bg-field, #f9fafb);
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
.cko-payment-card::after {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import 'react-international-phone/style.css';
|
|
3
3
|
import { CheckoutCallbacks, CheckoutContext } from '../../types';
|
|
4
4
|
type PageData = CheckoutContext & CheckoutCallbacks;
|
|
5
|
-
declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError,
|
|
5
|
+
declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, }: PageData): import("react").JSX.Element;
|
|
6
6
|
declare namespace PaymentForm {
|
|
7
7
|
var defaultProps: {};
|
|
8
8
|
}
|
package/es/payment/form/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "react-international-phone/style.css";
|
|
3
3
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
4
|
-
import { useTheme } from "@arcblock/ux/lib/Theme";
|
|
5
4
|
import Toast from "@arcblock/ux/lib/Toast";
|
|
6
5
|
import { LoadingButton } from "@mui/lab";
|
|
7
|
-
import { Fade,
|
|
8
|
-
import {
|
|
6
|
+
import { Divider, Fade, FormLabel, Stack, Typography } from "@mui/material";
|
|
7
|
+
import { useMemoizedFn, useSetState } from "ahooks";
|
|
9
8
|
import { PhoneNumberUtil } from "google-libphonenumber";
|
|
10
9
|
import pWaitFor from "p-wait-for";
|
|
11
10
|
import { useEffect, useMemo, useState } from "react";
|
|
@@ -26,7 +25,6 @@ import {
|
|
|
26
25
|
getQueryParams,
|
|
27
26
|
getStatementDescriptor
|
|
28
27
|
} from "../../libs/util.js";
|
|
29
|
-
import UserButtons from "./addon.js";
|
|
30
28
|
import AddressForm from "./address.js";
|
|
31
29
|
import CurrencySelector from "./currency.js";
|
|
32
30
|
import PhoneInput from "./phone.js";
|
|
@@ -60,12 +58,11 @@ export default function PaymentForm({
|
|
|
60
58
|
customer,
|
|
61
59
|
onPaid,
|
|
62
60
|
onError,
|
|
63
|
-
mode,
|
|
61
|
+
// mode,
|
|
64
62
|
action
|
|
65
63
|
}) {
|
|
66
|
-
const theme = useTheme();
|
|
67
64
|
const { t } = useLocaleContext();
|
|
68
|
-
const { session, connect } = usePaymentContext();
|
|
65
|
+
const { session, connect, payable } = usePaymentContext();
|
|
69
66
|
const subscription = useSubscription("events");
|
|
70
67
|
const { control, getValues, setValue, handleSubmit } = useFormContext();
|
|
71
68
|
const quantityInventoryStatus = useMemo(() => {
|
|
@@ -129,15 +126,6 @@ export default function PaymentForm({
|
|
|
129
126
|
setValue("payment_currency", currencies[paymentCurrencyIndex]?.id);
|
|
130
127
|
}, [paymentCurrencyIndex, currencies, setValue]);
|
|
131
128
|
const paymentMethod = useWatch({ control, name: "payment_method" });
|
|
132
|
-
const domSize = useSize(document.body);
|
|
133
|
-
const isColumnLayout = useCreation(() => {
|
|
134
|
-
if (domSize) {
|
|
135
|
-
if (domSize?.width <= theme.breakpoints.values.md) {
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
}, [domSize, theme]);
|
|
141
129
|
const afterUserLoggedIn = useMemoizedFn(() => {
|
|
142
130
|
if (hasDidWallet(session.user)) {
|
|
143
131
|
handleSubmit(onFormSubmit, onFormError)();
|
|
@@ -308,11 +296,55 @@ export default function PaymentForm({
|
|
|
308
296
|
};
|
|
309
297
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
310
298
|
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-contact", children: [
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
299
|
+
/* @__PURE__ */ jsx(
|
|
300
|
+
Typography,
|
|
301
|
+
{
|
|
302
|
+
title: t("payment.checkout.paymentDetails"),
|
|
303
|
+
sx: {
|
|
304
|
+
color: "text.primary",
|
|
305
|
+
fontSize: {
|
|
306
|
+
xs: "18px",
|
|
307
|
+
md: "24px"
|
|
308
|
+
},
|
|
309
|
+
fontWeight: "700",
|
|
310
|
+
lineHeight: "32px",
|
|
311
|
+
mb: 2.5
|
|
312
|
+
},
|
|
313
|
+
children: t("payment.checkout.paymentDetails")
|
|
314
|
+
}
|
|
315
|
+
),
|
|
316
|
+
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", className: "cko-payment-methods", children: [
|
|
317
|
+
/* @__PURE__ */ jsx(Stack, { direction: "row", sx: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
318
|
+
Controller,
|
|
319
|
+
{
|
|
320
|
+
name: "payment_currency",
|
|
321
|
+
control,
|
|
322
|
+
render: () => /* @__PURE__ */ jsx(
|
|
323
|
+
CurrencySelector,
|
|
324
|
+
{
|
|
325
|
+
value: paymentCurrencyIndex,
|
|
326
|
+
currencies,
|
|
327
|
+
onChange: setPaymentCurrencyIndex
|
|
328
|
+
}
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
) }),
|
|
332
|
+
state.stripePaying && state.stripeContext && /* @__PURE__ */ jsx(
|
|
333
|
+
StripeCheckout,
|
|
334
|
+
{
|
|
335
|
+
clientSecret: state.stripeContext.client_secret,
|
|
336
|
+
intentType: state.stripeContext.intent_type,
|
|
337
|
+
publicKey: method.settings.stripe?.publishable_key,
|
|
338
|
+
customer: state.customer,
|
|
339
|
+
mode: checkoutSession.mode,
|
|
340
|
+
onConfirm: onStripeConfirm,
|
|
341
|
+
onCancel: onStripeCancel
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
] }) }),
|
|
345
|
+
/* @__PURE__ */ jsx(Stack, { direction: "row", sx: { mb: 1 }, alignItems: "center", justifyContent: "space-between" }),
|
|
346
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "column", className: "cko-payment-form", spacing: 0, sx: { flex: 1, overflow: "auto" }, children: [
|
|
347
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.customer.name") }),
|
|
316
348
|
/* @__PURE__ */ jsx(
|
|
317
349
|
FormInput,
|
|
318
350
|
{
|
|
@@ -321,12 +353,10 @@ export default function PaymentForm({
|
|
|
321
353
|
errorPosition: "right",
|
|
322
354
|
rules: {
|
|
323
355
|
required: t("payment.checkout.required")
|
|
324
|
-
},
|
|
325
|
-
InputProps: {
|
|
326
|
-
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: t("payment.checkout.customer.name") })
|
|
327
356
|
}
|
|
328
357
|
}
|
|
329
358
|
),
|
|
359
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.customer.email") }),
|
|
330
360
|
/* @__PURE__ */ jsx(
|
|
331
361
|
FormInput,
|
|
332
362
|
{
|
|
@@ -336,65 +366,43 @@ export default function PaymentForm({
|
|
|
336
366
|
rules: {
|
|
337
367
|
required: t("payment.checkout.required"),
|
|
338
368
|
validate: (x) => isEmail(x) ? true : t("payment.checkout.invalid")
|
|
339
|
-
},
|
|
340
|
-
InputProps: {
|
|
341
|
-
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: t("payment.checkout.customer.email") })
|
|
342
369
|
}
|
|
343
370
|
}
|
|
344
371
|
),
|
|
345
|
-
checkoutSession.phone_number_collection?.enabled && /* @__PURE__ */
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
372
|
+
checkoutSession.phone_number_collection?.enabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
373
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.customer.phone") }),
|
|
374
|
+
/* @__PURE__ */ jsx(
|
|
375
|
+
PhoneInput,
|
|
376
|
+
{
|
|
377
|
+
name: "customer_phone",
|
|
378
|
+
variant: "outlined",
|
|
379
|
+
errorPosition: "right",
|
|
380
|
+
placeholder: "Phone number",
|
|
381
|
+
rules: {
|
|
382
|
+
required: t("payment.checkout.required"),
|
|
383
|
+
validate: (x) => {
|
|
384
|
+
try {
|
|
385
|
+
const parsed = phoneUtil.parseAndKeepRawInput(x);
|
|
386
|
+
return phoneUtil.isValidNumber(parsed) ? true : t("payment.checkout.invalid");
|
|
387
|
+
} catch {
|
|
388
|
+
return t("payment.checkout.invalid");
|
|
389
|
+
}
|
|
360
390
|
}
|
|
361
391
|
}
|
|
362
392
|
}
|
|
393
|
+
)
|
|
394
|
+
] }),
|
|
395
|
+
/* @__PURE__ */ jsx(
|
|
396
|
+
AddressForm,
|
|
397
|
+
{
|
|
398
|
+
mode: checkoutSession.billing_address_collection,
|
|
399
|
+
stripe: method?.type === "stripe",
|
|
400
|
+
sx: { marginTop: "0 !important" }
|
|
363
401
|
}
|
|
364
402
|
)
|
|
365
403
|
] })
|
|
366
404
|
] }) }),
|
|
367
|
-
/* @__PURE__ */ jsx(
|
|
368
|
-
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", className: "cko-payment-methods", children: [
|
|
369
|
-
/* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary", fontWeight: 600 }, children: t("payment.checkout.method") }),
|
|
370
|
-
/* @__PURE__ */ jsx(Stack, { direction: "row", sx: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
371
|
-
Controller,
|
|
372
|
-
{
|
|
373
|
-
name: "payment_currency",
|
|
374
|
-
control,
|
|
375
|
-
render: () => /* @__PURE__ */ jsx(
|
|
376
|
-
CurrencySelector,
|
|
377
|
-
{
|
|
378
|
-
value: paymentCurrencyIndex,
|
|
379
|
-
currencies,
|
|
380
|
-
onChange: setPaymentCurrencyIndex
|
|
381
|
-
}
|
|
382
|
-
)
|
|
383
|
-
}
|
|
384
|
-
) }),
|
|
385
|
-
state.stripePaying && state.stripeContext && /* @__PURE__ */ jsx(
|
|
386
|
-
StripeCheckout,
|
|
387
|
-
{
|
|
388
|
-
clientSecret: state.stripeContext.client_secret,
|
|
389
|
-
intentType: state.stripeContext.intent_type,
|
|
390
|
-
publicKey: method.settings.stripe?.publishable_key,
|
|
391
|
-
customer: state.customer,
|
|
392
|
-
mode: checkoutSession.mode,
|
|
393
|
-
onConfirm: onStripeConfirm,
|
|
394
|
-
onCancel: onStripeCancel
|
|
395
|
-
}
|
|
396
|
-
)
|
|
397
|
-
] }) }),
|
|
405
|
+
/* @__PURE__ */ jsx(Divider, { sx: { mt: 2.5, mb: 2.5 } }),
|
|
398
406
|
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-submit", children: [
|
|
399
407
|
/* @__PURE__ */ jsx(
|
|
400
408
|
LoadingButton,
|
|
@@ -405,18 +413,12 @@ export default function PaymentForm({
|
|
|
405
413
|
className: "cko-submit-button",
|
|
406
414
|
onClick: onAction,
|
|
407
415
|
fullWidth: true,
|
|
408
|
-
disabled: state.submitting || state.paying || state.stripePaying || !quantityInventoryStatus,
|
|
416
|
+
disabled: state.submitting || state.paying || state.stripePaying || !quantityInventoryStatus || !payable,
|
|
409
417
|
loading: state.submitting || state.paying,
|
|
410
418
|
children: state.submitting || state.paying ? t("payment.checkout.processing") : buttonText
|
|
411
419
|
}
|
|
412
420
|
),
|
|
413
|
-
["subscription", "setup"].includes(checkoutSession.mode) && /* @__PURE__ */ jsx(
|
|
414
|
-
Typography,
|
|
415
|
-
{
|
|
416
|
-
sx: { mt: 1, color: "text.secondary", fontSize: "0.9rem", lineHeight: "1.1rem", textAlign: "center" },
|
|
417
|
-
children: t("payment.checkout.confirm", { payee })
|
|
418
|
-
}
|
|
419
|
-
)
|
|
421
|
+
["subscription", "setup"].includes(checkoutSession.mode) && /* @__PURE__ */ jsx(Typography, { sx: { mt: 2.5, color: "text.lighter", fontSize: "0.9rem", lineHeight: "1.1rem" }, children: t("payment.checkout.confirm", { payee }) })
|
|
420
422
|
] }) }),
|
|
421
423
|
state.customerLimited && /* @__PURE__ */ jsx(
|
|
422
424
|
ConfirmDialog,
|
package/es/payment/form/phone.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { InputAdornment
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
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
7
|
import FormInput from "../../components/input.js";
|
|
8
8
|
import { isValidCountry } from "../../libs/util.js";
|
|
9
|
+
import CountrySelect from "../../components/country-select.js";
|
|
9
10
|
export default function PhoneInput({ ...props }) {
|
|
10
11
|
const countryFieldName = props.countryFieldName || "billing_address.country";
|
|
11
12
|
const { control, getValues, setValue } = useFormContext();
|
|
@@ -16,6 +17,7 @@ export default function PhoneInput({ ...props }) {
|
|
|
16
17
|
countries: defaultCountries,
|
|
17
18
|
onChange: (data) => {
|
|
18
19
|
setValue(props.name, data.phone);
|
|
20
|
+
setValue(countryFieldName, data.country);
|
|
19
21
|
}
|
|
20
22
|
});
|
|
21
23
|
const userCountry = useWatch({ control, name: countryFieldName });
|
|
@@ -24,9 +26,9 @@ export default function PhoneInput({ ...props }) {
|
|
|
24
26
|
setCountry(userCountry);
|
|
25
27
|
}
|
|
26
28
|
}, [userCountry]);
|
|
27
|
-
const onCountryChange = (
|
|
28
|
-
setCountry(
|
|
29
|
-
setValue(countryFieldName,
|
|
29
|
+
const onCountryChange = (v) => {
|
|
30
|
+
setCountry(v);
|
|
31
|
+
setValue(countryFieldName, v);
|
|
30
32
|
};
|
|
31
33
|
return (
|
|
32
34
|
// @ts-ignore
|
|
@@ -39,54 +41,16 @@ export default function PhoneInput({ ...props }) {
|
|
|
39
41
|
inputRef,
|
|
40
42
|
InputProps: {
|
|
41
43
|
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", style: { marginRight: "2px", marginLeft: "-8px" }, children: /* @__PURE__ */ jsx(
|
|
42
|
-
|
|
44
|
+
CountrySelect,
|
|
43
45
|
{
|
|
44
|
-
MenuProps: {
|
|
45
|
-
style: {
|
|
46
|
-
height: "300px",
|
|
47
|
-
width: "360px",
|
|
48
|
-
top: "10px",
|
|
49
|
-
left: "-34px"
|
|
50
|
-
},
|
|
51
|
-
transformOrigin: {
|
|
52
|
-
vertical: "top",
|
|
53
|
-
horizontal: "left"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
sx: {
|
|
57
|
-
width: "max-content",
|
|
58
|
-
// Remove default outline (display only on focus)
|
|
59
|
-
fieldset: {
|
|
60
|
-
display: "none"
|
|
61
|
-
},
|
|
62
|
-
'&.Mui-focused:has(div[aria-expanded="false"])': {
|
|
63
|
-
fieldset: {
|
|
64
|
-
display: "block"
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
// Update default spacing
|
|
68
|
-
".MuiSelect-select": {
|
|
69
|
-
padding: "8px",
|
|
70
|
-
paddingRight: "24px !important"
|
|
71
|
-
},
|
|
72
|
-
svg: {
|
|
73
|
-
right: 0
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
46
|
value: country,
|
|
77
47
|
onChange: onCountryChange,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/* @__PURE__ */ jsxs(Typography, { color: "gray", children: [
|
|
85
|
-
"+",
|
|
86
|
-
parsed.dialCode
|
|
87
|
-
] })
|
|
88
|
-
] }, parsed.iso2);
|
|
89
|
-
})
|
|
48
|
+
name: countryFieldName,
|
|
49
|
+
sx: {
|
|
50
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
51
|
+
borderColor: "transparent"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
90
54
|
}
|
|
91
55
|
) })
|
|
92
56
|
},
|
package/es/payment/index.d.ts
CHANGED
|
@@ -4,24 +4,17 @@ import { CheckoutCallbacks, CheckoutContext } from '../types';
|
|
|
4
4
|
type Props = CheckoutContext & CheckoutCallbacks & {
|
|
5
5
|
completed?: boolean;
|
|
6
6
|
error?: any;
|
|
7
|
+
showCheckoutSummary?: boolean;
|
|
7
8
|
};
|
|
8
|
-
declare function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed,
|
|
9
|
+
declare function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, mode, onPaid, onError, onChange, goBack, action, showCheckoutSummary, }: Props): import("react").JSX.Element;
|
|
9
10
|
declare namespace Payment {
|
|
10
11
|
var defaultProps: {
|
|
11
12
|
completed: boolean;
|
|
12
13
|
error: null;
|
|
14
|
+
showCheckoutSummary: boolean;
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
export default Payment;
|
|
16
|
-
type MainProps = CheckoutContext & CheckoutCallbacks & {
|
|
17
|
-
completed?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare function PaymentInner({ checkoutSession, paymentMethods, paymentLink, paymentIntent, customer, completed, mode, onPaid, onError, onChange, goBack, action, }: MainProps): import("react").JSX.Element;
|
|
20
|
-
export declare namespace PaymentInner {
|
|
21
|
-
var defaultProps: {
|
|
22
|
-
completed: boolean;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
18
|
export declare const Root: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
26
19
|
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
27
20
|
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme> & {
|