@blocklet/payment-react 1.14.21 → 1.14.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.
- package/es/checkout/donate.d.ts +2 -1
- package/es/checkout/donate.js +9 -10
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +23 -1
- package/es/checkout/table.d.ts +1 -1
- package/es/checkout/table.js +8 -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 +15 -2
- 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 +1 -10
- package/es/payment/index.js +274 -219
- package/es/payment/product-card.js +4 -4
- package/es/payment/product-donation.js +7 -2
- 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 +9 -0
- package/es/theme/index.js +243 -0
- package/es/theme/typography.d.ts +2 -0
- package/es/theme/typography.js +53 -0
- package/es/types/index.d.ts +11 -0
- package/lib/checkout/donate.d.ts +2 -1
- package/lib/checkout/donate.js +14 -2
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +22 -1
- package/lib/checkout/table.d.ts +1 -1
- package/lib/checkout/table.js +14 -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 +15 -2
- 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 +1 -10
- package/lib/payment/index.js +291 -219
- package/lib/payment/product-card.js +5 -4
- package/lib/payment/product-donation.js +9 -2
- 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 +9 -0
- package/lib/theme/index.js +259 -0
- package/lib/theme/typography.d.ts +2 -0
- package/lib/theme/typography.js +59 -0
- package/lib/types/index.d.ts +11 -0
- package/package.json +14 -11
- package/src/checkout/donate.tsx +16 -10
- package/src/checkout/form.tsx +23 -0
- package/src/checkout/table.tsx +13 -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 +294 -242
- package/src/payment/product-card.tsx +4 -4
- package/src/payment/product-donation.tsx +7 -3
- 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 +250 -0
- package/src/theme/typography.ts +56 -0
- package/src/types/index.ts +12 -0
|
@@ -8,66 +8,70 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
8
8
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _reactHookForm = require("react-hook-form");
|
|
11
|
-
var _reactInternationalPhone = require("react-international-phone");
|
|
12
11
|
var _input = _interopRequireDefault(require("../../components/input"));
|
|
12
|
+
var _countrySelect = _interopRequireDefault(require("../../components/country-select"));
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
AddressForm.defaultProps = {
|
|
15
|
+
sx: {}
|
|
16
|
+
};
|
|
14
17
|
function AddressForm({
|
|
15
18
|
mode,
|
|
16
|
-
stripe
|
|
19
|
+
stripe,
|
|
20
|
+
sx = {}
|
|
17
21
|
}) {
|
|
18
22
|
const {
|
|
19
23
|
t
|
|
20
24
|
} = (0, _context.useLocaleContext)();
|
|
21
25
|
const {
|
|
22
|
-
control
|
|
23
|
-
setValue
|
|
26
|
+
control
|
|
24
27
|
} = (0, _reactHookForm.useFormContext)();
|
|
25
28
|
if (mode === "required") {
|
|
26
29
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
27
30
|
in: true,
|
|
28
31
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
29
32
|
className: "cko-payment-address cko-payment-form",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
color: "text.primary",
|
|
34
|
-
fontWeight: 600
|
|
35
|
-
},
|
|
33
|
+
sx,
|
|
34
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
35
|
+
className: "base-label",
|
|
36
36
|
children: t(`payment.checkout.billing.${mode}`)
|
|
37
37
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
38
38
|
direction: "column",
|
|
39
39
|
className: "cko-payment-form",
|
|
40
40
|
spacing: 0,
|
|
41
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.
|
|
41
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
42
42
|
direction: "row",
|
|
43
43
|
spacing: 0,
|
|
44
|
-
children:
|
|
45
|
-
name: "billing_address.country",
|
|
46
|
-
control,
|
|
47
|
-
render: ({
|
|
48
|
-
field
|
|
49
|
-
}) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactInternationalPhone.CountrySelector, {
|
|
50
|
-
selectedCountry: field.value,
|
|
51
|
-
onSelect: ({
|
|
52
|
-
iso2
|
|
53
|
-
}) => setValue(field.name, iso2),
|
|
54
|
-
buttonStyle: {
|
|
55
|
-
width: "64px",
|
|
56
|
-
height: "40px",
|
|
57
|
-
border: "1px solid #ccc",
|
|
58
|
-
marginLeft: -1,
|
|
59
|
-
marginTop: -1
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
44
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
63
45
|
name: "billing_address.postal_code",
|
|
64
46
|
rules: {
|
|
65
47
|
required: t("payment.checkout.required")
|
|
66
48
|
},
|
|
67
49
|
errorPosition: "right",
|
|
68
50
|
variant: "outlined",
|
|
69
|
-
placeholder: t("payment.checkout.billing.postal_code")
|
|
70
|
-
|
|
51
|
+
placeholder: t("payment.checkout.billing.postal_code"),
|
|
52
|
+
InputProps: {
|
|
53
|
+
startAdornment: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.InputAdornment, {
|
|
54
|
+
position: "start",
|
|
55
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
56
|
+
name: "billing_address.country",
|
|
57
|
+
control,
|
|
58
|
+
render: ({
|
|
59
|
+
field
|
|
60
|
+
}) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_countrySelect.default, {
|
|
61
|
+
...field,
|
|
62
|
+
sx: {
|
|
63
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
64
|
+
borderColor: "transparent"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
73
|
+
className: "base-label",
|
|
74
|
+
children: t("payment.checkout.billing.state")
|
|
71
75
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
72
76
|
name: "billing_address.state",
|
|
73
77
|
rules: {
|
|
@@ -76,6 +80,9 @@ function AddressForm({
|
|
|
76
80
|
errorPosition: "right",
|
|
77
81
|
variant: "outlined",
|
|
78
82
|
placeholder: t("payment.checkout.billing.state")
|
|
83
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
84
|
+
className: "base-label",
|
|
85
|
+
children: t("payment.checkout.billing.line1")
|
|
79
86
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
80
87
|
name: "billing_address.line1",
|
|
81
88
|
rules: {
|
|
@@ -84,6 +91,9 @@ function AddressForm({
|
|
|
84
91
|
errorPosition: "right",
|
|
85
92
|
variant: "outlined",
|
|
86
93
|
placeholder: t("payment.checkout.billing.line1")
|
|
94
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
95
|
+
className: "base-label",
|
|
96
|
+
children: t("payment.checkout.billing.city")
|
|
87
97
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
88
98
|
name: "billing_address.city",
|
|
89
99
|
rules: {
|
|
@@ -102,39 +112,18 @@ function AddressForm({
|
|
|
102
112
|
in: true,
|
|
103
113
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
104
114
|
className: "cko-payment-address cko-payment-form",
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
color: "text.primary",
|
|
109
|
-
fontWeight: 600
|
|
110
|
-
},
|
|
115
|
+
sx,
|
|
116
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
117
|
+
className: "base-label",
|
|
111
118
|
children: t(`payment.checkout.billing.${mode}`)
|
|
112
119
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
113
120
|
direction: "column",
|
|
114
121
|
className: "cko-payment-form",
|
|
115
122
|
spacing: 0,
|
|
116
|
-
children: /* @__PURE__ */(0, _jsxRuntime.
|
|
123
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
117
124
|
direction: "row",
|
|
118
125
|
spacing: 0,
|
|
119
|
-
children:
|
|
120
|
-
name: "billing_address.country",
|
|
121
|
-
control,
|
|
122
|
-
render: ({
|
|
123
|
-
field
|
|
124
|
-
}) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactInternationalPhone.CountrySelector, {
|
|
125
|
-
selectedCountry: field.value,
|
|
126
|
-
onSelect: ({
|
|
127
|
-
iso2
|
|
128
|
-
}) => setValue(field.name, iso2),
|
|
129
|
-
buttonStyle: {
|
|
130
|
-
width: "64px",
|
|
131
|
-
height: "40px",
|
|
132
|
-
border: "1px solid #ccc",
|
|
133
|
-
marginLeft: -1,
|
|
134
|
-
marginTop: -1
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
126
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
138
127
|
name: "billing_address.postal_code",
|
|
139
128
|
rules: {
|
|
140
129
|
required: t("payment.checkout.required")
|
|
@@ -144,8 +133,27 @@ function AddressForm({
|
|
|
144
133
|
placeholder: t("payment.checkout.billing.postal_code"),
|
|
145
134
|
wrapperStyle: {
|
|
146
135
|
height: "40px"
|
|
136
|
+
},
|
|
137
|
+
InputProps: {
|
|
138
|
+
startAdornment: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.InputAdornment, {
|
|
139
|
+
position: "start",
|
|
140
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
141
|
+
name: "billing_address.country",
|
|
142
|
+
control,
|
|
143
|
+
render: ({
|
|
144
|
+
field
|
|
145
|
+
}) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_countrySelect.default, {
|
|
146
|
+
...field,
|
|
147
|
+
sx: {
|
|
148
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
149
|
+
borderColor: "transparent"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
})
|
|
147
155
|
}
|
|
148
|
-
})
|
|
156
|
+
})
|
|
149
157
|
})
|
|
150
158
|
})]
|
|
151
159
|
})
|
|
@@ -16,8 +16,9 @@ function CurrencySelector({
|
|
|
16
16
|
count: currencies.length,
|
|
17
17
|
style: {
|
|
18
18
|
display: currencies.length > 1 ? "grid" : "block",
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
width: "100%",
|
|
20
|
+
gap: 12,
|
|
21
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))"
|
|
21
22
|
},
|
|
22
23
|
children: currencies.map((x, i) => {
|
|
23
24
|
const selected = i === value;
|
|
@@ -28,30 +29,41 @@ function CurrencySelector({
|
|
|
28
29
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
29
30
|
direction: "row",
|
|
30
31
|
alignItems: "center",
|
|
32
|
+
sx: {
|
|
33
|
+
position: "relative"
|
|
34
|
+
},
|
|
31
35
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
|
|
32
36
|
src: x.logo,
|
|
33
37
|
alt: x.name,
|
|
34
38
|
sx: {
|
|
35
|
-
width:
|
|
36
|
-
height:
|
|
37
|
-
marginRight: "
|
|
39
|
+
width: 40,
|
|
40
|
+
height: 40,
|
|
41
|
+
marginRight: "12px"
|
|
38
42
|
}
|
|
39
43
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)("div", {
|
|
40
44
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
41
45
|
variant: "h5",
|
|
42
46
|
component: "div",
|
|
43
47
|
sx: {
|
|
44
|
-
fontSize: "
|
|
48
|
+
fontSize: "16px",
|
|
49
|
+
color: "text.primary",
|
|
50
|
+
fontWeight: "500"
|
|
45
51
|
},
|
|
46
52
|
children: x.symbol
|
|
47
53
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
48
54
|
sx: {
|
|
49
55
|
fontSize: 14
|
|
50
56
|
},
|
|
51
|
-
color: "text.
|
|
57
|
+
color: "text.lighter",
|
|
52
58
|
gutterBottom: true,
|
|
53
59
|
children: x.method.name
|
|
54
60
|
})]
|
|
61
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Radio, {
|
|
62
|
+
checked: selected,
|
|
63
|
+
sx: {
|
|
64
|
+
position: "absolute",
|
|
65
|
+
right: 0
|
|
66
|
+
}
|
|
55
67
|
})]
|
|
56
68
|
})
|
|
57
69
|
}, x.id);
|
|
@@ -61,32 +73,27 @@ function CurrencySelector({
|
|
|
61
73
|
const Root = (0, _system.styled)("section")`
|
|
62
74
|
.cko-payment-card {
|
|
63
75
|
position: relative;
|
|
64
|
-
border: 1px solid
|
|
76
|
+
border: 1px solid var(--stroke-border-interactive, #0086ff);
|
|
65
77
|
padding: 4px 8px;
|
|
66
|
-
margin: 8px 0 0;
|
|
67
78
|
cursor: pointer;
|
|
79
|
+
background: var(--backgrounds-bg-field, #f9fafb);
|
|
68
80
|
}
|
|
69
81
|
|
|
70
|
-
.cko-payment-card::before {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
82
|
+
// .cko-payment-card::before {
|
|
83
|
+
// content: '';
|
|
84
|
+
// position: absolute;
|
|
85
|
+
// right: 0;
|
|
86
|
+
// bottom: 0;
|
|
87
|
+
// border: 12px solid ${props => props.theme.palette.primary.main};
|
|
88
|
+
// border-top-color: transparent;
|
|
89
|
+
// border-left-color: transparent;
|
|
90
|
+
// }
|
|
79
91
|
|
|
80
92
|
.cko-payment-card-unselect {
|
|
81
93
|
border: 1px solid #ddd;
|
|
82
94
|
padding: 4px 8px;
|
|
83
|
-
margin: 8px 0 0;
|
|
84
95
|
cursor: pointer;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
.cko-payment-card:nth-child(odd),
|
|
88
|
-
.cko-payment-card-unselect:nth-child(odd) {
|
|
89
|
-
margin-right: ${props => props.count > 1 ? 8 : 0}px;
|
|
96
|
+
background: var(--backgrounds-bg-field, #f9fafb);
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
.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
|
}
|
|
@@ -7,7 +7,6 @@ module.exports = PaymentForm;
|
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
8
|
require("react-international-phone/style.css");
|
|
9
9
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
10
|
-
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
11
10
|
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
12
11
|
var _lab = require("@mui/lab");
|
|
13
12
|
var _material = require("@mui/material");
|
|
@@ -25,7 +24,6 @@ var _payment = require("../../contexts/payment");
|
|
|
25
24
|
var _subscription = require("../../hooks/subscription");
|
|
26
25
|
var _api = _interopRequireDefault(require("../../libs/api"));
|
|
27
26
|
var _util = require("../../libs/util");
|
|
28
|
-
var _addon = _interopRequireDefault(require("./addon"));
|
|
29
27
|
var _address = _interopRequireDefault(require("./address"));
|
|
30
28
|
var _currency = _interopRequireDefault(require("./currency"));
|
|
31
29
|
var _phone = _interopRequireDefault(require("./phone"));
|
|
@@ -62,16 +60,16 @@ function PaymentForm({
|
|
|
62
60
|
customer,
|
|
63
61
|
onPaid,
|
|
64
62
|
onError,
|
|
65
|
-
mode,
|
|
63
|
+
// mode,
|
|
66
64
|
action
|
|
67
65
|
}) {
|
|
68
|
-
const theme = (0, _Theme.useTheme)();
|
|
69
66
|
const {
|
|
70
67
|
t
|
|
71
68
|
} = (0, _context.useLocaleContext)();
|
|
72
69
|
const {
|
|
73
70
|
session,
|
|
74
|
-
connect
|
|
71
|
+
connect,
|
|
72
|
+
payable
|
|
75
73
|
} = (0, _payment.usePaymentContext)();
|
|
76
74
|
const subscription = (0, _subscription.useSubscription)("events");
|
|
77
75
|
const {
|
|
@@ -148,15 +146,6 @@ function PaymentForm({
|
|
|
148
146
|
control,
|
|
149
147
|
name: "payment_method"
|
|
150
148
|
});
|
|
151
|
-
const domSize = (0, _ahooks.useSize)(document.body);
|
|
152
|
-
const isColumnLayout = (0, _ahooks.useCreation)(() => {
|
|
153
|
-
if (domSize) {
|
|
154
|
-
if (domSize?.width <= theme.breakpoints.values.md) {
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return false;
|
|
159
|
-
}, [domSize, theme]);
|
|
160
149
|
const afterUserLoggedIn = (0, _ahooks.useMemoizedFn)(() => {
|
|
161
150
|
if (hasDidWallet(session.user)) {
|
|
162
151
|
handleSubmit(onFormSubmit, onFormError)();
|
|
@@ -370,37 +359,77 @@ function PaymentForm({
|
|
|
370
359
|
in: true,
|
|
371
360
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
372
361
|
className: "cko-payment-contact",
|
|
373
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.
|
|
362
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
363
|
+
title: t("payment.checkout.paymentDetails"),
|
|
364
|
+
sx: {
|
|
365
|
+
color: "text.primary",
|
|
366
|
+
fontSize: {
|
|
367
|
+
xs: "18px",
|
|
368
|
+
md: "24px"
|
|
369
|
+
},
|
|
370
|
+
fontWeight: "700",
|
|
371
|
+
lineHeight: "32px",
|
|
372
|
+
mb: 2.5
|
|
373
|
+
},
|
|
374
|
+
children: t("payment.checkout.paymentDetails")
|
|
375
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
376
|
+
in: true,
|
|
377
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
378
|
+
direction: "column",
|
|
379
|
+
alignItems: "flex-start",
|
|
380
|
+
className: "cko-payment-methods",
|
|
381
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
382
|
+
direction: "row",
|
|
383
|
+
sx: {
|
|
384
|
+
width: "100%"
|
|
385
|
+
},
|
|
386
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
387
|
+
name: "payment_currency",
|
|
388
|
+
control,
|
|
389
|
+
render: () => /* @__PURE__ */(0, _jsxRuntime.jsx)(_currency.default, {
|
|
390
|
+
value: paymentCurrencyIndex,
|
|
391
|
+
currencies,
|
|
392
|
+
onChange: setPaymentCurrencyIndex
|
|
393
|
+
})
|
|
394
|
+
})
|
|
395
|
+
}), state.stripePaying && state.stripeContext && /* @__PURE__ */(0, _jsxRuntime.jsx)(_stripe.default, {
|
|
396
|
+
clientSecret: state.stripeContext.client_secret,
|
|
397
|
+
intentType: state.stripeContext.intent_type,
|
|
398
|
+
publicKey: method.settings.stripe?.publishable_key,
|
|
399
|
+
customer: state.customer,
|
|
400
|
+
mode: checkoutSession.mode,
|
|
401
|
+
onConfirm: onStripeConfirm,
|
|
402
|
+
onCancel: onStripeCancel
|
|
403
|
+
})]
|
|
404
|
+
})
|
|
405
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
374
406
|
direction: "row",
|
|
375
407
|
sx: {
|
|
376
408
|
mb: 1
|
|
377
409
|
},
|
|
378
410
|
alignItems: "center",
|
|
379
|
-
justifyContent: "space-between"
|
|
380
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
381
|
-
sx: {
|
|
382
|
-
color: "text.secondary",
|
|
383
|
-
fontWeight: 600
|
|
384
|
-
},
|
|
385
|
-
children: t("payment.checkout.contact")
|
|
386
|
-
}), isColumnLayout || mode !== "standalone" ? null : /* @__PURE__ */(0, _jsxRuntime.jsx)(_addon.default, {})]
|
|
411
|
+
justifyContent: "space-between"
|
|
387
412
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
388
413
|
direction: "column",
|
|
389
414
|
className: "cko-payment-form",
|
|
390
415
|
spacing: 0,
|
|
391
|
-
|
|
416
|
+
sx: {
|
|
417
|
+
flex: 1,
|
|
418
|
+
overflow: "auto"
|
|
419
|
+
},
|
|
420
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
421
|
+
className: "base-label",
|
|
422
|
+
children: t("payment.checkout.customer.name")
|
|
423
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
392
424
|
name: "customer_name",
|
|
393
425
|
variant: "outlined",
|
|
394
426
|
errorPosition: "right",
|
|
395
427
|
rules: {
|
|
396
428
|
required: t("payment.checkout.required")
|
|
397
|
-
},
|
|
398
|
-
InputProps: {
|
|
399
|
-
startAdornment: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.InputAdornment, {
|
|
400
|
-
position: "start",
|
|
401
|
-
children: t("payment.checkout.customer.name")
|
|
402
|
-
})
|
|
403
429
|
}
|
|
430
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
431
|
+
className: "base-label",
|
|
432
|
+
children: t("payment.checkout.customer.email")
|
|
404
433
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
405
434
|
name: "customer_email",
|
|
406
435
|
variant: "outlined",
|
|
@@ -408,71 +437,42 @@ function PaymentForm({
|
|
|
408
437
|
rules: {
|
|
409
438
|
required: t("payment.checkout.required"),
|
|
410
439
|
validate: x => (0, _isEmail.default)(x) ? true : t("payment.checkout.invalid")
|
|
411
|
-
},
|
|
412
|
-
InputProps: {
|
|
413
|
-
startAdornment: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.InputAdornment, {
|
|
414
|
-
position: "start",
|
|
415
|
-
children: t("payment.checkout.customer.email")
|
|
416
|
-
})
|
|
417
440
|
}
|
|
418
|
-
}), checkoutSession.phone_number_collection?.enabled && /* @__PURE__ */(0, _jsxRuntime.
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
441
|
+
}), checkoutSession.phone_number_collection?.enabled && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
442
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
443
|
+
className: "base-label",
|
|
444
|
+
children: t("payment.checkout.customer.phone")
|
|
445
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_phone.default, {
|
|
446
|
+
name: "customer_phone",
|
|
447
|
+
variant: "outlined",
|
|
448
|
+
errorPosition: "right",
|
|
449
|
+
placeholder: "Phone number",
|
|
450
|
+
rules: {
|
|
451
|
+
required: t("payment.checkout.required"),
|
|
452
|
+
validate: x => {
|
|
453
|
+
try {
|
|
454
|
+
const parsed = phoneUtil.parseAndKeepRawInput(x);
|
|
455
|
+
return phoneUtil.isValidNumber(parsed) ? true : t("payment.checkout.invalid");
|
|
456
|
+
} catch {
|
|
457
|
+
return t("payment.checkout.invalid");
|
|
458
|
+
}
|
|
431
459
|
}
|
|
432
460
|
}
|
|
461
|
+
})]
|
|
462
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_address.default, {
|
|
463
|
+
mode: checkoutSession.billing_address_collection,
|
|
464
|
+
stripe: method?.type === "stripe",
|
|
465
|
+
sx: {
|
|
466
|
+
marginTop: "0 !important"
|
|
433
467
|
}
|
|
434
468
|
})]
|
|
435
469
|
})]
|
|
436
470
|
})
|
|
437
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
443
|
-
direction: "column",
|
|
444
|
-
alignItems: "flex-start",
|
|
445
|
-
className: "cko-payment-methods",
|
|
446
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
447
|
-
sx: {
|
|
448
|
-
color: "text.secondary",
|
|
449
|
-
fontWeight: 600
|
|
450
|
-
},
|
|
451
|
-
children: t("payment.checkout.method")
|
|
452
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
453
|
-
direction: "row",
|
|
454
|
-
sx: {
|
|
455
|
-
width: "100%"
|
|
456
|
-
},
|
|
457
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
458
|
-
name: "payment_currency",
|
|
459
|
-
control,
|
|
460
|
-
render: () => /* @__PURE__ */(0, _jsxRuntime.jsx)(_currency.default, {
|
|
461
|
-
value: paymentCurrencyIndex,
|
|
462
|
-
currencies,
|
|
463
|
-
onChange: setPaymentCurrencyIndex
|
|
464
|
-
})
|
|
465
|
-
})
|
|
466
|
-
}), state.stripePaying && state.stripeContext && /* @__PURE__ */(0, _jsxRuntime.jsx)(_stripe.default, {
|
|
467
|
-
clientSecret: state.stripeContext.client_secret,
|
|
468
|
-
intentType: state.stripeContext.intent_type,
|
|
469
|
-
publicKey: method.settings.stripe?.publishable_key,
|
|
470
|
-
customer: state.customer,
|
|
471
|
-
mode: checkoutSession.mode,
|
|
472
|
-
onConfirm: onStripeConfirm,
|
|
473
|
-
onCancel: onStripeCancel
|
|
474
|
-
})]
|
|
475
|
-
})
|
|
471
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {
|
|
472
|
+
sx: {
|
|
473
|
+
mt: 2.5,
|
|
474
|
+
mb: 2.5
|
|
475
|
+
}
|
|
476
476
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
477
477
|
in: true,
|
|
478
478
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
@@ -484,16 +484,15 @@ function PaymentForm({
|
|
|
484
484
|
className: "cko-submit-button",
|
|
485
485
|
onClick: onAction,
|
|
486
486
|
fullWidth: true,
|
|
487
|
-
disabled: state.submitting || state.paying || state.stripePaying || !quantityInventoryStatus,
|
|
487
|
+
disabled: state.submitting || state.paying || state.stripePaying || !quantityInventoryStatus || !payable,
|
|
488
488
|
loading: state.submitting || state.paying,
|
|
489
489
|
children: state.submitting || state.paying ? t("payment.checkout.processing") : buttonText
|
|
490
490
|
}), ["subscription", "setup"].includes(checkoutSession.mode) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
491
491
|
sx: {
|
|
492
|
-
mt:
|
|
493
|
-
color: "text.
|
|
492
|
+
mt: 2.5,
|
|
493
|
+
color: "text.lighter",
|
|
494
494
|
fontSize: "0.9rem",
|
|
495
|
-
lineHeight: "1.1rem"
|
|
496
|
-
textAlign: "center"
|
|
495
|
+
lineHeight: "1.1rem"
|
|
497
496
|
},
|
|
498
497
|
children: t("payment.checkout.confirm", {
|
|
499
498
|
payee
|
|
@@ -12,6 +12,7 @@ var _reactHookForm = require("react-hook-form");
|
|
|
12
12
|
var _reactInternationalPhone = require("react-international-phone");
|
|
13
13
|
var _input = _interopRequireDefault(require("../../components/input"));
|
|
14
14
|
var _util = require("../../libs/util");
|
|
15
|
+
var _countrySelect = _interopRequireDefault(require("../../components/country-select"));
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
17
|
function PhoneInput({
|
|
17
18
|
...props
|
|
@@ -35,6 +36,7 @@ function PhoneInput({
|
|
|
35
36
|
countries: _reactInternationalPhone.defaultCountries,
|
|
36
37
|
onChange: data => {
|
|
37
38
|
setValue(props.name, data.phone);
|
|
39
|
+
setValue(countryFieldName, data.country);
|
|
38
40
|
}
|
|
39
41
|
});
|
|
40
42
|
const userCountry = (0, _reactHookForm.useWatch)({
|
|
@@ -46,9 +48,9 @@ function PhoneInput({
|
|
|
46
48
|
setCountry(userCountry);
|
|
47
49
|
}
|
|
48
50
|
}, [userCountry]);
|
|
49
|
-
const onCountryChange =
|
|
50
|
-
setCountry(
|
|
51
|
-
setValue(countryFieldName,
|
|
51
|
+
const onCountryChange = v => {
|
|
52
|
+
setCountry(v);
|
|
53
|
+
setValue(countryFieldName, v);
|
|
52
54
|
};
|
|
53
55
|
return (
|
|
54
56
|
// @ts-ignore
|
|
@@ -65,65 +67,15 @@ function PhoneInput({
|
|
|
65
67
|
marginRight: "2px",
|
|
66
68
|
marginLeft: "-8px"
|
|
67
69
|
},
|
|
68
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
69
|
-
MenuProps: {
|
|
70
|
-
style: {
|
|
71
|
-
height: "300px",
|
|
72
|
-
width: "360px",
|
|
73
|
-
top: "10px",
|
|
74
|
-
left: "-34px"
|
|
75
|
-
},
|
|
76
|
-
transformOrigin: {
|
|
77
|
-
vertical: "top",
|
|
78
|
-
horizontal: "left"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
sx: {
|
|
82
|
-
width: "max-content",
|
|
83
|
-
// Remove default outline (display only on focus)
|
|
84
|
-
fieldset: {
|
|
85
|
-
display: "none"
|
|
86
|
-
},
|
|
87
|
-
'&.Mui-focused:has(div[aria-expanded="false"])': {
|
|
88
|
-
fieldset: {
|
|
89
|
-
display: "block"
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
// Update default spacing
|
|
93
|
-
".MuiSelect-select": {
|
|
94
|
-
padding: "8px",
|
|
95
|
-
paddingRight: "24px !important"
|
|
96
|
-
},
|
|
97
|
-
svg: {
|
|
98
|
-
right: 0
|
|
99
|
-
}
|
|
100
|
-
},
|
|
70
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_countrySelect.default, {
|
|
101
71
|
value: country,
|
|
102
72
|
onChange: onCountryChange,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
73
|
+
name: countryFieldName,
|
|
74
|
+
sx: {
|
|
75
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
76
|
+
borderColor: "transparent"
|
|
107
77
|
}
|
|
108
|
-
}
|
|
109
|
-
children: _reactInternationalPhone.defaultCountries.map(c => {
|
|
110
|
-
const parsed = (0, _reactInternationalPhone.parseCountry)(c);
|
|
111
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.MenuItem, {
|
|
112
|
-
value: parsed.iso2,
|
|
113
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_reactInternationalPhone.FlagEmoji, {
|
|
114
|
-
iso2: parsed.iso2,
|
|
115
|
-
style: {
|
|
116
|
-
marginRight: "8px"
|
|
117
|
-
}
|
|
118
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
119
|
-
marginRight: "8px",
|
|
120
|
-
children: parsed.name
|
|
121
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
122
|
-
color: "gray",
|
|
123
|
-
children: ["+", parsed.dialCode]
|
|
124
|
-
})]
|
|
125
|
-
}, parsed.iso2);
|
|
126
|
-
})
|
|
78
|
+
}
|
|
127
79
|
})
|
|
128
80
|
})
|
|
129
81
|
},
|