@blocklet/payment-react 1.18.0 → 1.18.1
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.js +40 -10
- package/es/checkout/form.d.ts +2 -1
- package/es/checkout/form.js +32 -45
- package/es/components/payment-beneficiaries.d.ts +24 -0
- package/es/components/payment-beneficiaries.js +70 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/locales/en.js +13 -1
- package/es/locales/zh.js +13 -1
- package/es/payment/donation-form.d.ts +24 -0
- package/es/payment/donation-form.js +603 -0
- package/es/payment/error.d.ts +1 -1
- package/es/payment/error.js +11 -1
- package/es/payment/form/index.d.ts +9 -3
- package/es/payment/form/index.js +39 -4
- package/es/payment/product-donation.js +98 -57
- package/es/payment/skeleton/donation.d.ts +1 -0
- package/es/payment/skeleton/donation.js +30 -0
- package/es/theme/index.js +3 -0
- package/es/types/index.d.ts +2 -0
- package/lib/checkout/donate.js +76 -10
- package/lib/checkout/form.d.ts +2 -1
- package/lib/checkout/form.js +39 -49
- package/lib/components/payment-beneficiaries.d.ts +24 -0
- package/lib/components/payment-beneficiaries.js +113 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +8 -0
- package/lib/locales/en.js +13 -1
- package/lib/locales/zh.js +13 -1
- package/lib/payment/donation-form.d.ts +24 -0
- package/lib/payment/donation-form.js +644 -0
- package/lib/payment/error.d.ts +1 -1
- package/lib/payment/error.js +2 -2
- package/lib/payment/form/index.d.ts +9 -3
- package/lib/payment/form/index.js +35 -2
- package/lib/payment/product-donation.js +140 -73
- package/lib/payment/skeleton/donation.d.ts +1 -0
- package/lib/payment/skeleton/donation.js +66 -0
- package/lib/theme/index.js +3 -0
- package/lib/types/index.d.ts +2 -0
- package/package.json +3 -3
- package/src/checkout/donate.tsx +54 -11
- package/src/checkout/form.tsx +17 -31
- package/src/components/payment-beneficiaries.tsx +97 -0
- package/src/index.ts +2 -0
- package/src/locales/en.tsx +12 -0
- package/src/locales/zh.tsx +12 -0
- package/src/payment/donation-form.tsx +646 -0
- package/src/payment/error.tsx +13 -4
- package/src/payment/form/index.tsx +46 -4
- package/src/payment/product-donation.tsx +91 -40
- package/src/payment/skeleton/donation.tsx +35 -0
- package/src/theme/index.tsx +3 -0
- package/src/types/index.ts +2 -0
package/es/payment/form/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import PhoneInput from "./phone.js";
|
|
|
31
31
|
import StripeCheckout from "./stripe/index.js";
|
|
32
32
|
import { useMobile } from "../../hooks/mobile.js";
|
|
33
33
|
import { validatePhoneNumber } from "../../libs/phone-validator.js";
|
|
34
|
-
const waitForCheckoutComplete = async (sessionId) => {
|
|
34
|
+
export const waitForCheckoutComplete = async (sessionId) => {
|
|
35
35
|
let result;
|
|
36
36
|
await pWaitFor(
|
|
37
37
|
async () => {
|
|
@@ -49,11 +49,13 @@ const waitForCheckoutComplete = async (sessionId) => {
|
|
|
49
49
|
);
|
|
50
50
|
return result;
|
|
51
51
|
};
|
|
52
|
-
const hasDidWallet = (user) => {
|
|
52
|
+
export const hasDidWallet = (user) => {
|
|
53
53
|
const connected = user?.connectedAccounts || user?.extraConfigs?.connectedAccounts || [];
|
|
54
54
|
return connected.some((x) => x.provider === "wallet");
|
|
55
55
|
};
|
|
56
|
-
PaymentForm.defaultProps = {
|
|
56
|
+
PaymentForm.defaultProps = {
|
|
57
|
+
onlyShowBtn: false
|
|
58
|
+
};
|
|
57
59
|
export default function PaymentForm({
|
|
58
60
|
checkoutSession,
|
|
59
61
|
paymentMethods,
|
|
@@ -64,7 +66,8 @@ export default function PaymentForm({
|
|
|
64
66
|
onError,
|
|
65
67
|
// mode,
|
|
66
68
|
action,
|
|
67
|
-
currencyId
|
|
69
|
+
currencyId,
|
|
70
|
+
onlyShowBtn
|
|
68
71
|
}) {
|
|
69
72
|
const { t } = useLocaleContext();
|
|
70
73
|
const { isMobile } = useMobile();
|
|
@@ -316,6 +319,38 @@ export default function PaymentForm({
|
|
|
316
319
|
const onStripeCancel = () => {
|
|
317
320
|
setState({ stripePaying: false });
|
|
318
321
|
};
|
|
322
|
+
if (onlyShowBtn) {
|
|
323
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
324
|
+
/* @__PURE__ */ jsx(Box, { className: "cko-payment-submit-btn", children: /* @__PURE__ */ jsx(
|
|
325
|
+
LoadingButton,
|
|
326
|
+
{
|
|
327
|
+
variant: "contained",
|
|
328
|
+
color: "primary",
|
|
329
|
+
size: "large",
|
|
330
|
+
className: "cko-submit-button",
|
|
331
|
+
onClick: onAction,
|
|
332
|
+
fullWidth: true,
|
|
333
|
+
disabled: state.submitting || state.paying || state.stripePaying || !quantityInventoryStatus || !payable,
|
|
334
|
+
loading: state.submitting || state.paying,
|
|
335
|
+
children: state.submitting || state.paying ? t("payment.checkout.processing") : buttonText
|
|
336
|
+
}
|
|
337
|
+
) }),
|
|
338
|
+
state.customerLimited && /* @__PURE__ */ jsx(
|
|
339
|
+
ConfirmDialog,
|
|
340
|
+
{
|
|
341
|
+
onConfirm: () => window.open(
|
|
342
|
+
joinURL(getPrefix(), `/customer/invoice/past-due?referer=${encodeURIComponent(window.location.href)}`),
|
|
343
|
+
"_self"
|
|
344
|
+
),
|
|
345
|
+
onCancel: () => setState({ customerLimited: false }),
|
|
346
|
+
confirm: t("payment.customer.pastDue.alert.confirm"),
|
|
347
|
+
title: t("payment.customer.pastDue.alert.title"),
|
|
348
|
+
message: t("payment.customer.pastDue.alert.description"),
|
|
349
|
+
color: "primary"
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
] });
|
|
353
|
+
}
|
|
319
354
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
320
355
|
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-contact", children: [
|
|
321
356
|
/* @__PURE__ */ jsx(
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
|
-
import { Box, Card, CardActionArea,
|
|
3
|
+
import { Avatar, Box, Card, CardActionArea, Grid, Stack, TextField, Typography } from "@mui/material";
|
|
4
4
|
import { useSetState } from "ahooks";
|
|
5
|
-
import { useEffect } from "react";
|
|
6
|
-
import Switch from "../components/switch-button.js";
|
|
5
|
+
import { useEffect, useRef } from "react";
|
|
7
6
|
import { formatAmountPrecisionLimit } from "../libs/util.js";
|
|
8
7
|
import { usePaymentContext } from "../contexts/payment.js";
|
|
9
8
|
import { usePreventWheel } from "../hooks/scroll.js";
|
|
@@ -16,13 +15,17 @@ export default function ProductDonation({
|
|
|
16
15
|
const { t, locale } = useLocaleContext();
|
|
17
16
|
const { setPayable } = usePaymentContext();
|
|
18
17
|
usePreventWheel();
|
|
19
|
-
const
|
|
18
|
+
const presets = settings?.amount?.presets || [];
|
|
19
|
+
const preset = settings?.amount?.preset || presets?.[0] || "0";
|
|
20
|
+
const supportPreset = presets.length > 0;
|
|
21
|
+
const supportCustom = !!settings?.amount?.custom;
|
|
20
22
|
const [state, setState] = useSetState({
|
|
21
23
|
selected: preset,
|
|
22
24
|
input: "",
|
|
23
|
-
custom:
|
|
25
|
+
custom: !supportPreset,
|
|
24
26
|
error: ""
|
|
25
27
|
});
|
|
28
|
+
const customInputRef = useRef(null);
|
|
26
29
|
useEffect(() => {
|
|
27
30
|
if (settings.amount.preset) {
|
|
28
31
|
setState({ selected: settings.amount.preset, custom: false });
|
|
@@ -32,6 +35,13 @@ export default function ProductDonation({
|
|
|
32
35
|
onChange({ priceId: item.price_id, amount: settings.amount.presets[0] });
|
|
33
36
|
}
|
|
34
37
|
}, [settings.amount.preset, settings.amount.presets]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (state.custom) {
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
customInputRef.current?.focus();
|
|
42
|
+
}, 0);
|
|
43
|
+
}
|
|
44
|
+
}, [state.custom]);
|
|
35
45
|
const handleSelect = (amount) => {
|
|
36
46
|
setState({ selected: amount, custom: false, error: "" });
|
|
37
47
|
onChange({ priceId: item.price_id, amount });
|
|
@@ -55,71 +65,102 @@ export default function ProductDonation({
|
|
|
55
65
|
setState({ error: "", input: value });
|
|
56
66
|
onChange({ priceId: item.price_id, amount: value });
|
|
57
67
|
};
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
setState({ custom: true, input: state.selected, error: "" });
|
|
61
|
-
} else {
|
|
62
|
-
setPayable(true);
|
|
63
|
-
handleSelect(preset);
|
|
64
|
-
}
|
|
68
|
+
const handleCustomSelect = () => {
|
|
69
|
+
setState({ custom: true, error: "" });
|
|
65
70
|
};
|
|
66
71
|
return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 1.5, children: [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
supportPreset && /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
|
|
73
|
+
settings.amount.presets && settings.amount.presets.length > 0 && settings.amount.presets.map((amount) => /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, sm: 3, children: /* @__PURE__ */ jsx(
|
|
74
|
+
Card,
|
|
75
|
+
{
|
|
76
|
+
variant: "outlined",
|
|
77
|
+
sx: {
|
|
78
|
+
minWidth: 115,
|
|
79
|
+
textAlign: "center",
|
|
80
|
+
transition: "all 0.3s",
|
|
81
|
+
cursor: "pointer",
|
|
82
|
+
"&:hover": {
|
|
83
|
+
transform: "translateY(-4px)",
|
|
84
|
+
boxShadow: 3
|
|
85
|
+
},
|
|
86
|
+
height: "42px",
|
|
87
|
+
...state.selected === amount && !state.custom ? { borderColor: "primary.main", borderWidth: 1 } : {}
|
|
88
|
+
},
|
|
89
|
+
children: /* @__PURE__ */ jsx(CardActionArea, { onClick: () => handleSelect(amount), children: /* @__PURE__ */ jsxs(
|
|
90
|
+
Stack,
|
|
91
|
+
{
|
|
92
|
+
direction: "row",
|
|
93
|
+
sx: { py: 1.5, px: 1.5 },
|
|
94
|
+
spacing: 0.5,
|
|
95
|
+
alignItems: "center",
|
|
96
|
+
justifyContent: "center",
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsx(Avatar, { src: currency?.logo, sx: { width: 16, height: 16, mr: 0.5 }, alt: currency?.symbol }),
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
Typography,
|
|
101
|
+
{
|
|
102
|
+
component: "strong",
|
|
103
|
+
lineHeight: 1,
|
|
104
|
+
variant: "h3",
|
|
105
|
+
sx: { fontVariantNumeric: "tabular-nums", fontWeight: 400 },
|
|
106
|
+
children: amount
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
/* @__PURE__ */ jsx(Typography, { lineHeight: 1, fontSize: 14, color: "text.secondary", children: currency?.symbol })
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
) })
|
|
83
113
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
amount
|
|
115
|
+
) }, amount)),
|
|
116
|
+
supportCustom && /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, sm: 3, children: /* @__PURE__ */ jsx(
|
|
117
|
+
Card,
|
|
118
|
+
{
|
|
119
|
+
variant: "outlined",
|
|
120
|
+
sx: {
|
|
121
|
+
textAlign: "center",
|
|
122
|
+
transition: "all 0.3s",
|
|
123
|
+
cursor: "pointer",
|
|
124
|
+
"&:hover": {
|
|
125
|
+
transform: "translateY(-4px)",
|
|
126
|
+
boxShadow: 3
|
|
127
|
+
},
|
|
128
|
+
height: "42px",
|
|
129
|
+
...state.custom ? { borderColor: "primary.main", borderWidth: 1 } : {}
|
|
130
|
+
},
|
|
131
|
+
children: /* @__PURE__ */ jsx(CardActionArea, { onClick: () => handleCustomSelect(), children: /* @__PURE__ */ jsx(
|
|
132
|
+
Stack,
|
|
133
|
+
{
|
|
134
|
+
direction: "row",
|
|
135
|
+
sx: { py: 1.5, px: 1.5 },
|
|
136
|
+
spacing: 0.5,
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
justifyContent: "center",
|
|
139
|
+
children: /* @__PURE__ */ jsx(Typography, { variant: "h3", lineHeight: 1, sx: { fontWeight: 400 }, children: t("common.custom") })
|
|
140
|
+
}
|
|
141
|
+
) })
|
|
142
|
+
},
|
|
143
|
+
"custom"
|
|
144
|
+
) }, "custom")
|
|
145
|
+
] }),
|
|
111
146
|
state.custom && /* @__PURE__ */ jsx(
|
|
112
147
|
TextField,
|
|
113
148
|
{
|
|
114
|
-
label: preset !== "0" ? null : t("payment.checkout.donation.custom"),
|
|
115
149
|
type: "number",
|
|
116
150
|
value: state.input,
|
|
117
151
|
onChange: handleInput,
|
|
118
|
-
inputProps: { min: settings.amount.minimum, max: settings.amount.maximum },
|
|
119
152
|
margin: "none",
|
|
120
153
|
fullWidth: true,
|
|
121
154
|
error: !!state.error,
|
|
122
155
|
helperText: state.error,
|
|
156
|
+
inputRef: customInputRef,
|
|
157
|
+
InputProps: {
|
|
158
|
+
endAdornment: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 0.5, alignItems: "center", sx: { ml: 1 }, children: [
|
|
159
|
+
/* @__PURE__ */ jsx(Avatar, { src: currency?.logo, sx: { width: 16, height: 16 }, alt: currency?.symbol }),
|
|
160
|
+
/* @__PURE__ */ jsx(Typography, { children: currency?.symbol })
|
|
161
|
+
] }),
|
|
162
|
+
autoComplete: "off"
|
|
163
|
+
},
|
|
123
164
|
sx: {
|
|
124
165
|
mt: preset !== "0" ? 0 : 1
|
|
125
166
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function DonationSkeleton(): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Divider, Fade, Skeleton, Stack } from "@mui/material";
|
|
3
|
+
export default function DonationSkeleton() {
|
|
4
|
+
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", children: [
|
|
5
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "text", sx: { fontSize: "2rem", width: "40%" } }),
|
|
6
|
+
/* @__PURE__ */ jsx(Skeleton, { sx: { mt: 2 }, variant: "rounded", height: 80 }),
|
|
7
|
+
/* @__PURE__ */ jsx(
|
|
8
|
+
Divider,
|
|
9
|
+
{
|
|
10
|
+
sx: {
|
|
11
|
+
mt: {
|
|
12
|
+
xs: "16px",
|
|
13
|
+
md: "16px"
|
|
14
|
+
},
|
|
15
|
+
mb: {
|
|
16
|
+
xs: "16px",
|
|
17
|
+
md: "16px"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
),
|
|
22
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", spacing: 2, children: [
|
|
23
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "text", sx: { fontSize: "1.5rem", width: "40%" } }),
|
|
24
|
+
/* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", gap: 2, children: [
|
|
25
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 80 }) }),
|
|
26
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 120 }) })
|
|
27
|
+
] })
|
|
28
|
+
] })
|
|
29
|
+
] }) });
|
|
30
|
+
}
|
package/es/theme/index.js
CHANGED
package/es/types/index.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type CheckoutProps = Partial<CheckoutCallbacks> & {
|
|
|
36
36
|
action?: string;
|
|
37
37
|
mode?: LiteralUnion<'standalone' | 'inline' | 'popup' | 'inline-minimal' | 'popup-minimal', string>;
|
|
38
38
|
theme?: 'default' | 'inherit' | PaymentThemeOptions;
|
|
39
|
+
formType?: 'donation' | 'payment';
|
|
40
|
+
formRender?: Record<string, any>;
|
|
39
41
|
};
|
|
40
42
|
export type CheckoutCallbacks = {
|
|
41
43
|
onPaid: (res: CheckoutContext) => void;
|
package/lib/checkout/donate.js
CHANGED
|
@@ -18,6 +18,8 @@ var _util = require("../libs/util");
|
|
|
18
18
|
var _form = _interopRequireDefault(require("./form"));
|
|
19
19
|
var _theme = require("../theme");
|
|
20
20
|
var _payment = require("../contexts/payment");
|
|
21
|
+
var _livemode = _interopRequireDefault(require("../components/livemode"));
|
|
22
|
+
var _mobile = require("../hooks/mobile");
|
|
21
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
24
|
const donationCache = {};
|
|
23
25
|
const createOrUpdateDonation = (settings, livemode = true) => {
|
|
@@ -308,8 +310,15 @@ function CheckoutDonateInner({
|
|
|
308
310
|
donation,
|
|
309
311
|
supporters
|
|
310
312
|
} = useDonation(settings, livemode, mode);
|
|
313
|
+
const customers = (0, _unionBy.default)(supporters?.data?.supporters || [], "customer_did");
|
|
314
|
+
const {
|
|
315
|
+
t
|
|
316
|
+
} = (0, _context.useLocaleContext)();
|
|
311
317
|
const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
|
|
312
318
|
const [popoverOpen, setPopoverOpen] = (0, _react.useState)(false);
|
|
319
|
+
const {
|
|
320
|
+
isMobile
|
|
321
|
+
} = (0, _mobile.useMobile)();
|
|
313
322
|
const handlePaid = (...args) => {
|
|
314
323
|
if (onPaid) {
|
|
315
324
|
onPaid(...args);
|
|
@@ -467,21 +476,64 @@ function CheckoutDonateInner({
|
|
|
467
476
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
468
477
|
children: [renderInnerView(), donation.data && /* @__PURE__ */(0, _jsxRuntime.jsx)(_Dialog.default, {
|
|
469
478
|
open: state.open,
|
|
470
|
-
title:
|
|
479
|
+
title: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
480
|
+
display: "flex",
|
|
481
|
+
alignItems: "center",
|
|
482
|
+
gap: 0.5,
|
|
483
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
484
|
+
variant: "h3",
|
|
485
|
+
sx: {
|
|
486
|
+
maxWidth: 320,
|
|
487
|
+
textOverflow: "ellipsis",
|
|
488
|
+
overflow: "hidden"
|
|
489
|
+
},
|
|
490
|
+
children: settings.title
|
|
491
|
+
}), !donation.data.livemode && /* @__PURE__ */(0, _jsxRuntime.jsx)(_livemode.default, {
|
|
492
|
+
sx: {
|
|
493
|
+
width: "fit-content"
|
|
494
|
+
}
|
|
495
|
+
})]
|
|
496
|
+
}),
|
|
471
497
|
maxWidth: "md",
|
|
472
|
-
|
|
498
|
+
toolbar: isMobile ? null : /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
499
|
+
display: "flex",
|
|
500
|
+
alignItems: "center",
|
|
501
|
+
gap: 1,
|
|
502
|
+
sx: {
|
|
503
|
+
color: "text.secondary"
|
|
504
|
+
},
|
|
505
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.AvatarGroup, {
|
|
506
|
+
total: customers?.length,
|
|
507
|
+
max: 5,
|
|
508
|
+
children: customers.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
|
|
509
|
+
title: x.customer?.name,
|
|
510
|
+
src: (0, _util.getCustomerAvatar)(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 18),
|
|
511
|
+
variant: "circular",
|
|
512
|
+
sx: {
|
|
513
|
+
width: 18,
|
|
514
|
+
height: 18
|
|
515
|
+
}
|
|
516
|
+
}, x.id))
|
|
517
|
+
}), customers?.length > 0 && t("payment.checkout.donation.gaveTips", {
|
|
518
|
+
count: customers?.length
|
|
519
|
+
})]
|
|
520
|
+
}),
|
|
521
|
+
showCloseButton: false,
|
|
473
522
|
disableEscapeKeyDown: true,
|
|
474
523
|
sx: {
|
|
475
524
|
".MuiDialogContent-root": {
|
|
476
|
-
padding:
|
|
477
|
-
xs: 0,
|
|
478
|
-
md: "0 16px 0"
|
|
479
|
-
},
|
|
525
|
+
padding: "16px 24px",
|
|
480
526
|
borderTop: "1px solid var(--stroke-border-base, #EFF1F5)",
|
|
481
|
-
width:
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
527
|
+
width: "100%"
|
|
528
|
+
},
|
|
529
|
+
".ux-dialog_header": {
|
|
530
|
+
gap: 5
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
PaperProps: {
|
|
534
|
+
style: {
|
|
535
|
+
minHeight: "auto",
|
|
536
|
+
width: 680
|
|
485
537
|
}
|
|
486
538
|
},
|
|
487
539
|
onClose: (e, reason) => setState({
|
|
@@ -499,8 +551,22 @@ function CheckoutDonateInner({
|
|
|
499
551
|
action: settings.appearance?.button?.text,
|
|
500
552
|
mode: "inline",
|
|
501
553
|
theme,
|
|
554
|
+
formType: "donation",
|
|
502
555
|
extraParams: {
|
|
503
556
|
livemode
|
|
557
|
+
},
|
|
558
|
+
formRender: {
|
|
559
|
+
cancel: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
560
|
+
variant: "outlined",
|
|
561
|
+
size: "large",
|
|
562
|
+
onClick: () => setState({
|
|
563
|
+
open: false
|
|
564
|
+
}),
|
|
565
|
+
children: t("common.cancel")
|
|
566
|
+
}),
|
|
567
|
+
onCancel: () => setState({
|
|
568
|
+
open: false
|
|
569
|
+
})
|
|
504
570
|
}
|
|
505
571
|
})
|
|
506
572
|
})
|
package/lib/checkout/form.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CheckoutProps } from '../types';
|
|
2
|
-
declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, theme, ...restProps }: CheckoutProps): import("react").JSX.Element;
|
|
2
|
+
declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, theme, formType, ...restProps }: CheckoutProps): import("react").JSX.Element;
|
|
3
3
|
declare namespace CheckoutForm {
|
|
4
4
|
var defaultProps: {
|
|
5
5
|
onPaid: any;
|
|
@@ -10,6 +10,7 @@ declare namespace CheckoutForm {
|
|
|
10
10
|
mode: string;
|
|
11
11
|
action: string;
|
|
12
12
|
extraParams: {};
|
|
13
|
+
formType: string;
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
export default CheckoutForm;
|
package/lib/checkout/form.js
CHANGED
|
@@ -13,6 +13,7 @@ var _api = _interopRequireDefault(require("../libs/api"));
|
|
|
13
13
|
var _util = require("../libs/util");
|
|
14
14
|
var _payment = _interopRequireDefault(require("../payment"));
|
|
15
15
|
var _theme = require("../theme");
|
|
16
|
+
var _donationForm = _interopRequireDefault(require("../payment/donation-form"));
|
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
18
|
const promises = {};
|
|
18
19
|
const startFromPaymentLink = (id, params) => {
|
|
@@ -41,6 +42,7 @@ function CheckoutForm({
|
|
|
41
42
|
extraParams,
|
|
42
43
|
action,
|
|
43
44
|
theme = "default",
|
|
45
|
+
formType = "payment",
|
|
44
46
|
...restProps
|
|
45
47
|
}) {
|
|
46
48
|
if (!id.startsWith("plink_") && !id.startsWith("cs_")) {
|
|
@@ -73,62 +75,49 @@ function CheckoutForm({
|
|
|
73
75
|
});
|
|
74
76
|
onError?.(err);
|
|
75
77
|
};
|
|
78
|
+
const Checkout = formType === "donation" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_donationForm.default, {
|
|
79
|
+
checkoutSession: data?.checkoutSession,
|
|
80
|
+
paymentMethods: data?.paymentMethods,
|
|
81
|
+
paymentIntent: data?.paymentIntent,
|
|
82
|
+
paymentLink: data?.paymentLink,
|
|
83
|
+
customer: data?.customer,
|
|
84
|
+
completed: state.completed,
|
|
85
|
+
error: apiError,
|
|
86
|
+
onPaid: handlePaid,
|
|
87
|
+
onError: handleError,
|
|
88
|
+
onChange,
|
|
89
|
+
goBack,
|
|
90
|
+
mode,
|
|
91
|
+
action,
|
|
92
|
+
id,
|
|
93
|
+
...restProps
|
|
94
|
+
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment.default, {
|
|
95
|
+
checkoutSession: data?.checkoutSession,
|
|
96
|
+
paymentMethods: data?.paymentMethods,
|
|
97
|
+
paymentIntent: data?.paymentIntent,
|
|
98
|
+
paymentLink: data?.paymentLink,
|
|
99
|
+
customer: data?.customer,
|
|
100
|
+
completed: state.completed,
|
|
101
|
+
error: apiError,
|
|
102
|
+
onPaid: handlePaid,
|
|
103
|
+
onError: handleError,
|
|
104
|
+
onChange,
|
|
105
|
+
goBack,
|
|
106
|
+
mode,
|
|
107
|
+
action,
|
|
108
|
+
...restProps
|
|
109
|
+
});
|
|
76
110
|
if (theme === "inherit") {
|
|
77
|
-
return
|
|
78
|
-
checkoutSession: data?.checkoutSession,
|
|
79
|
-
paymentMethods: data?.paymentMethods,
|
|
80
|
-
paymentIntent: data?.paymentIntent,
|
|
81
|
-
paymentLink: data?.paymentLink,
|
|
82
|
-
customer: data?.customer,
|
|
83
|
-
completed: state.completed,
|
|
84
|
-
error: apiError,
|
|
85
|
-
onPaid: handlePaid,
|
|
86
|
-
onError: handleError,
|
|
87
|
-
onChange,
|
|
88
|
-
goBack,
|
|
89
|
-
mode,
|
|
90
|
-
action,
|
|
91
|
-
...restProps
|
|
92
|
-
});
|
|
111
|
+
return Checkout;
|
|
93
112
|
}
|
|
94
113
|
if (theme && typeof theme === "object") {
|
|
95
114
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
96
115
|
theme,
|
|
97
|
-
children:
|
|
98
|
-
checkoutSession: data?.checkoutSession,
|
|
99
|
-
paymentMethods: data?.paymentMethods,
|
|
100
|
-
paymentIntent: data?.paymentIntent,
|
|
101
|
-
paymentLink: data?.paymentLink,
|
|
102
|
-
customer: data?.customer,
|
|
103
|
-
completed: state.completed,
|
|
104
|
-
error: apiError,
|
|
105
|
-
onPaid: handlePaid,
|
|
106
|
-
onError: handleError,
|
|
107
|
-
onChange,
|
|
108
|
-
goBack,
|
|
109
|
-
mode,
|
|
110
|
-
action,
|
|
111
|
-
...restProps
|
|
112
|
-
})
|
|
116
|
+
children: Checkout
|
|
113
117
|
});
|
|
114
118
|
}
|
|
115
119
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
116
|
-
children:
|
|
117
|
-
checkoutSession: data?.checkoutSession,
|
|
118
|
-
paymentMethods: data?.paymentMethods,
|
|
119
|
-
paymentIntent: data?.paymentIntent,
|
|
120
|
-
paymentLink: data?.paymentLink,
|
|
121
|
-
customer: data?.customer,
|
|
122
|
-
completed: state.completed,
|
|
123
|
-
error: apiError,
|
|
124
|
-
onPaid: handlePaid,
|
|
125
|
-
onError: handleError,
|
|
126
|
-
onChange,
|
|
127
|
-
goBack,
|
|
128
|
-
mode,
|
|
129
|
-
action,
|
|
130
|
-
...restProps
|
|
131
|
-
})
|
|
120
|
+
children: Checkout
|
|
132
121
|
});
|
|
133
122
|
}
|
|
134
123
|
CheckoutForm.defaultProps = {
|
|
@@ -136,5 +125,6 @@ CheckoutForm.defaultProps = {
|
|
|
136
125
|
onError: console.error,
|
|
137
126
|
mode: "inline",
|
|
138
127
|
action: "",
|
|
139
|
-
extraParams: {}
|
|
128
|
+
extraParams: {},
|
|
129
|
+
formType: "payment"
|
|
140
130
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface TBeneficiary {
|
|
2
|
+
name: string;
|
|
3
|
+
address: string;
|
|
4
|
+
avatar?: string;
|
|
5
|
+
percent: number;
|
|
6
|
+
amount?: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
type?: 'user' | 'dapp';
|
|
9
|
+
}
|
|
10
|
+
interface BenefitsProps {
|
|
11
|
+
data: TBeneficiary[];
|
|
12
|
+
currency: {
|
|
13
|
+
symbol: string;
|
|
14
|
+
decimal: number;
|
|
15
|
+
};
|
|
16
|
+
totalAmount?: string;
|
|
17
|
+
}
|
|
18
|
+
declare function PaymentBeneficiaries({ data, currency, totalAmount }: BenefitsProps): import("react").JSX.Element;
|
|
19
|
+
declare namespace PaymentBeneficiaries {
|
|
20
|
+
var defaultProps: {
|
|
21
|
+
totalAmount: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export default PaymentBeneficiaries;
|