@blocklet/payment-react 1.13.210 → 1.13.211

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 (74) hide show
  1. package/es/checkout/donate.d.ts +20 -0
  2. package/es/checkout/donate.js +199 -0
  3. package/es/checkout/form.d.ts +2 -1
  4. package/es/checkout/form.js +13 -2
  5. package/es/components/blockchain/tx.d.ts +2 -0
  6. package/es/components/blockchain/tx.js +16 -5
  7. package/es/index.d.ts +2 -1
  8. package/es/index.js +2 -0
  9. package/es/locales/en.js +8 -0
  10. package/es/locales/zh.js +8 -0
  11. package/es/payment/error.d.ts +3 -1
  12. package/es/payment/error.js +4 -3
  13. package/es/payment/form/currency.js +10 -12
  14. package/es/payment/form/index.d.ts +1 -1
  15. package/es/payment/form/index.js +15 -3
  16. package/es/payment/index.d.ts +3 -3
  17. package/es/payment/index.js +38 -13
  18. package/es/payment/product-donation.d.ts +7 -0
  19. package/es/payment/product-donation.js +99 -0
  20. package/es/payment/skeleton/overview.js +2 -2
  21. package/es/payment/skeleton/payment.js +2 -5
  22. package/es/payment/success.d.ts +2 -1
  23. package/es/payment/success.js +21 -12
  24. package/es/payment/summary.d.ts +8 -2
  25. package/es/payment/summary.js +46 -29
  26. package/es/types/index.d.ts +2 -0
  27. package/es/util.d.ts +1 -0
  28. package/es/util.js +44 -3
  29. package/lib/checkout/donate.d.ts +20 -0
  30. package/lib/checkout/donate.js +284 -0
  31. package/lib/checkout/form.d.ts +2 -1
  32. package/lib/checkout/form.js +5 -2
  33. package/lib/components/blockchain/tx.d.ts +2 -0
  34. package/lib/components/blockchain/tx.js +3 -1
  35. package/lib/index.d.ts +2 -1
  36. package/lib/index.js +8 -0
  37. package/lib/locales/en.js +8 -0
  38. package/lib/locales/zh.js +8 -0
  39. package/lib/payment/error.d.ts +3 -1
  40. package/lib/payment/error.js +5 -3
  41. package/lib/payment/form/currency.js +10 -12
  42. package/lib/payment/form/index.d.ts +1 -1
  43. package/lib/payment/form/index.js +16 -4
  44. package/lib/payment/index.d.ts +3 -3
  45. package/lib/payment/index.js +56 -24
  46. package/lib/payment/product-donation.d.ts +7 -0
  47. package/lib/payment/product-donation.js +169 -0
  48. package/lib/payment/skeleton/overview.js +2 -2
  49. package/lib/payment/skeleton/payment.js +4 -8
  50. package/lib/payment/success.d.ts +2 -1
  51. package/lib/payment/success.js +3 -2
  52. package/lib/payment/summary.d.ts +8 -2
  53. package/lib/payment/summary.js +30 -7
  54. package/lib/types/index.d.ts +2 -0
  55. package/lib/util.d.ts +1 -0
  56. package/lib/util.js +39 -4
  57. package/package.json +6 -6
  58. package/src/checkout/donate.tsx +256 -0
  59. package/src/checkout/form.tsx +13 -4
  60. package/src/components/blockchain/tx.tsx +8 -1
  61. package/src/index.ts +2 -0
  62. package/src/locales/en.tsx +8 -0
  63. package/src/locales/zh.tsx +8 -0
  64. package/src/payment/error.tsx +4 -2
  65. package/src/payment/form/currency.tsx +11 -13
  66. package/src/payment/form/index.tsx +14 -4
  67. package/src/payment/index.tsx +40 -14
  68. package/src/payment/product-donation.tsx +118 -0
  69. package/src/payment/skeleton/overview.tsx +2 -2
  70. package/src/payment/skeleton/payment.tsx +1 -4
  71. package/src/payment/success.tsx +7 -2
  72. package/src/payment/summary.tsx +47 -28
  73. package/src/types/index.ts +2 -0
  74. package/src/util.ts +50 -3
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ import type { DonationSettings, TCheckoutSessionExpanded, TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
3
+ import { CheckoutProps } from '../types';
4
+ export type DonateHistory = {
5
+ supporters: TCheckoutSessionExpanded[];
6
+ currency: TPaymentCurrency;
7
+ method: TPaymentMethod;
8
+ total: number;
9
+ };
10
+ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
11
+ settings: DonationSettings;
12
+ livemode?: boolean;
13
+ };
14
+ declare function CheckoutDonate({ settings, livemode, onPaid, onError }: DonateProps): import("react").JSX.Element;
15
+ declare namespace CheckoutDonate {
16
+ var defaultProps: {
17
+ livemode: boolean;
18
+ };
19
+ }
20
+ export default CheckoutDonate;
@@ -0,0 +1,199 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import Dialog from "@arcblock/ux/lib/Dialog";
3
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
4
+ import {
5
+ Alert,
6
+ Avatar,
7
+ AvatarGroup,
8
+ Box,
9
+ Button,
10
+ CircularProgress,
11
+ Hidden,
12
+ Stack,
13
+ Table,
14
+ TableCell,
15
+ TableRow,
16
+ Typography
17
+ } from "@mui/material";
18
+ import { useRequest, useSetState } from "ahooks";
19
+ import omit from "lodash/omit";
20
+ import uniqBy from "lodash/unionBy";
21
+ import { useEffect } from "react";
22
+ import api from "../api.js";
23
+ import TxLink from "../components/blockchain/tx.js";
24
+ import { formatAmount, formatDateTime, formatError } from "../util.js";
25
+ import CheckoutForm from "./form.js";
26
+ const donationCache = {};
27
+ const createOrUpdateDonation = (settings, livemode = true) => {
28
+ if (!donationCache[settings.target]) {
29
+ donationCache[settings.target] = api.post(`/api/donations?livemode=${livemode}`, omit(settings, ["appearance"])).then((res) => res.data).finally(() => {
30
+ setTimeout(() => {
31
+ delete donationCache[settings.target];
32
+ }, 3e3);
33
+ });
34
+ }
35
+ return donationCache[settings.target];
36
+ };
37
+ const supporterCache = {};
38
+ const fetchSupporters = (target) => {
39
+ if (!supporterCache[target]) {
40
+ supporterCache[target] = api.get(`/api/donations?&target=${target}`).then((res) => res.data).finally(() => {
41
+ setTimeout(() => {
42
+ delete supporterCache[target];
43
+ }, 3e3);
44
+ });
45
+ }
46
+ return supporterCache[target];
47
+ };
48
+ function SupporterAvatar({ supporters = [], total, currency, method }) {
49
+ const { t } = useLocaleContext();
50
+ const customers = uniqBy(supporters, "customer_did");
51
+ return /* @__PURE__ */ jsxs(
52
+ Box,
53
+ {
54
+ display: "flex",
55
+ flexDirection: "column",
56
+ alignItems: "center",
57
+ sx: {
58
+ ".MuiAvatar-root": {
59
+ width: "32px",
60
+ height: "32px"
61
+ }
62
+ },
63
+ gap: {
64
+ xs: 0.5,
65
+ sm: 1
66
+ },
67
+ children: [
68
+ /* @__PURE__ */ jsx(Typography, { component: "p", color: "text.secondary", children: t("payment.checkout.donation.summary", { total }) }),
69
+ /* @__PURE__ */ jsx(AvatarGroup, { total, max: 20, children: customers.map((x) => /* @__PURE__ */ jsx(
70
+ Avatar,
71
+ {
72
+ title: x.customer?.name,
73
+ src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
74
+ variant: "circular",
75
+ sx: { width: 32, height: 32 }
76
+ },
77
+ x.id
78
+ )) })
79
+ ]
80
+ }
81
+ );
82
+ }
83
+ function SupporterTable({ supporters = [], total, currency, method }) {
84
+ const { t } = useLocaleContext();
85
+ return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", sx: { width: "100%" }, gap: { xs: 0.5, sm: 1 }, children: [
86
+ /* @__PURE__ */ jsx(Typography, { component: "p", color: "text.secondary", children: t("payment.checkout.donation.summary", { total }) }),
87
+ /* @__PURE__ */ jsx(Table, { size: "small", sx: { width: "100%", overflow: "hidden" }, children: supporters.map((x) => /* @__PURE__ */ jsxs(
88
+ TableRow,
89
+ {
90
+ sx: {
91
+ "> td": { padding: "8px 16px 8px 0", borderTop: "1px solid #e0e0e0", borderBottom: "1px solid #e0e0e0" }
92
+ },
93
+ children: [
94
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
95
+ /* @__PURE__ */ jsx(
96
+ Avatar,
97
+ {
98
+ src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
99
+ variant: "circular",
100
+ sx: { width: 24, height: 24 }
101
+ },
102
+ x.id
103
+ ),
104
+ /* @__PURE__ */ jsx(Hidden, { smDown: true, children: /* @__PURE__ */ jsx(Typography, { children: x.customer?.name }) })
105
+ ] }) }),
106
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 0.5, children: [
107
+ /* @__PURE__ */ jsx(Typography, { fontWeight: 500, component: "strong", children: formatAmount(x.amount_total, currency.decimal) }),
108
+ /* @__PURE__ */ jsx(Typography, { component: "span", children: currency.symbol })
109
+ ] }) }),
110
+ /* @__PURE__ */ jsx(Hidden, { smDown: true, children: /* @__PURE__ */ jsx(TableCell, { align: "right", children: /* @__PURE__ */ jsx(Typography, { children: formatDateTime(x.created_at) }) }) }),
111
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: /* @__PURE__ */ jsx(TxLink, { method, details: x.payment_details, mode: "customer", align: "right" }) })
112
+ ]
113
+ },
114
+ x.id
115
+ )) })
116
+ ] });
117
+ }
118
+ export default function CheckoutDonate({ settings, livemode, onPaid, onError }) {
119
+ const [state, setState] = useSetState({
120
+ open: false,
121
+ supporterLoaded: false,
122
+ exist: false
123
+ });
124
+ const donation = useRequest(() => createOrUpdateDonation(settings, livemode));
125
+ const supporters = useRequest(() => donation.data ? fetchSupporters(donation.data.id) : Promise.resolve({}));
126
+ useEffect(() => {
127
+ if (donation.data && state.supporterLoaded === false) {
128
+ setState({ supporterLoaded: true });
129
+ supporters.runAsync().catch(console.error);
130
+ }
131
+ }, [donation.data]);
132
+ const handlePaid = (...args) => {
133
+ if (onPaid) {
134
+ onPaid(...args);
135
+ }
136
+ supporters.runAsync().catch(console.error);
137
+ setTimeout(() => {
138
+ setState({ open: false });
139
+ }, 3e3);
140
+ };
141
+ if (donation.error) {
142
+ return /* @__PURE__ */ jsx(Alert, { severity: "error", children: formatError(donation.error) });
143
+ }
144
+ if (donation.loading || !donation.data) {
145
+ return /* @__PURE__ */ jsx(CircularProgress, {});
146
+ }
147
+ return /* @__PURE__ */ jsxs(
148
+ Box,
149
+ {
150
+ sx: { width: "100%", minWidth: 300, maxWidth: 720 },
151
+ display: "flex",
152
+ flexDirection: "column",
153
+ alignItems: "center",
154
+ gap: { xs: 1, sm: 2 },
155
+ children: [
156
+ /* @__PURE__ */ jsx(
157
+ Button,
158
+ {
159
+ size: settings.appearance?.button?.size || "medium",
160
+ color: settings.appearance?.button?.color || "primary",
161
+ variant: settings.appearance?.button?.variant || "contained",
162
+ onClick: () => setState({ open: true }),
163
+ children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
164
+ settings.appearance.button.icon,
165
+ typeof settings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { children: settings.appearance.button.text }) : settings.appearance.button.text
166
+ ] })
167
+ }
168
+ ),
169
+ supporters.data && settings.appearance.history.variant === "avatar" && /* @__PURE__ */ jsx(SupporterAvatar, { ...supporters.data }),
170
+ supporters.data && settings.appearance.history.variant === "table" && /* @__PURE__ */ jsx(SupporterTable, { ...supporters.data }),
171
+ /* @__PURE__ */ jsx(
172
+ Dialog,
173
+ {
174
+ open: state.open,
175
+ title: settings.title,
176
+ maxWidth: "md",
177
+ showCloseButton: true,
178
+ disableBackdropClick: true,
179
+ disableEscapeKeyDown: true,
180
+ onClose: (e, reason) => setState({ open: reason === "backdropClick" }),
181
+ children: /* @__PURE__ */ jsx(Box, { sx: { mb: 1, mt: -2 }, children: /* @__PURE__ */ jsx(
182
+ CheckoutForm,
183
+ {
184
+ id: donation.data.id,
185
+ onPaid: handlePaid,
186
+ onError,
187
+ action: settings.appearance?.button?.text,
188
+ mode: "inline"
189
+ }
190
+ ) })
191
+ }
192
+ )
193
+ ]
194
+ }
195
+ );
196
+ }
197
+ CheckoutDonate.defaultProps = {
198
+ livemode: true
199
+ };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { CheckoutProps } from '../types';
3
- declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams }: CheckoutProps): import("react").JSX.Element;
3
+ declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, }: CheckoutProps): import("react").JSX.Element;
4
4
  declare namespace CheckoutForm {
5
5
  var defaultProps: {
6
6
  onPaid: any;
@@ -9,6 +9,7 @@ declare namespace CheckoutForm {
9
9
  (message?: any, ...optionalParams: any[]): void;
10
10
  };
11
11
  mode: string;
12
+ action: string;
12
13
  extraParams: {};
13
14
  };
14
15
  }
@@ -21,7 +21,16 @@ const fetchCheckoutSession = async (id) => {
21
21
  const { data } = await api.get(`/api/checkout-sessions/retrieve/${id}`);
22
22
  return data;
23
23
  };
24
- export default function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams }) {
24
+ export default function CheckoutForm({
25
+ id,
26
+ mode,
27
+ onPaid,
28
+ onError,
29
+ onChange,
30
+ goBack,
31
+ extraParams,
32
+ action
33
+ }) {
25
34
  if (!id.startsWith("plink_") && !id.startsWith("cs_")) {
26
35
  throw new Error("Either a checkoutSession or a paymentLink id is required.");
27
36
  }
@@ -62,7 +71,8 @@ export default function CheckoutForm({ id, mode, onPaid, onError, onChange, goBa
62
71
  onError: handleError,
63
72
  onChange,
64
73
  goBack,
65
- mode
74
+ mode,
75
+ action
66
76
  }
67
77
  );
68
78
  }
@@ -70,5 +80,6 @@ CheckoutForm.defaultProps = {
70
80
  onPaid: noop,
71
81
  onError: console.error,
72
82
  mode: "inline",
83
+ action: "",
73
84
  extraParams: {}
74
85
  };
@@ -4,10 +4,12 @@ declare function TxLink(props: {
4
4
  details: PaymentDetails;
5
5
  method: TPaymentMethod;
6
6
  mode?: 'customer' | 'dashboard';
7
+ align?: 'left' | 'right';
7
8
  }): import("react").JSX.Element;
8
9
  declare namespace TxLink {
9
10
  var defaultProps: {
10
11
  mode: string;
12
+ align: string;
11
13
  };
12
14
  }
13
15
  export default TxLink;
@@ -4,7 +4,8 @@ import { OpenInNewOutlined } from "@mui/icons-material";
4
4
  import { Link, Stack, Typography } from "@mui/material";
5
5
  import { getTxLink } from "../../util.js";
6
6
  TxLink.defaultProps = {
7
- mode: "dashboard"
7
+ mode: "dashboard",
8
+ align: "left"
8
9
  };
9
10
  export default function TxLink(props) {
10
11
  const { t } = useLocaleContext();
@@ -13,10 +14,20 @@ export default function TxLink(props) {
13
14
  }
14
15
  const { text, link } = getTxLink(props.method, props.details);
15
16
  if (link) {
16
- return /* @__PURE__ */ jsx(Link, { href: link, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ jsxs(Stack, { component: "span", direction: "row", alignItems: "center", spacing: 1, children: [
17
- /* @__PURE__ */ jsx(Typography, { component: "span", color: "primary", children: text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join("...") : text }),
18
- /* @__PURE__ */ jsx(OpenInNewOutlined, { fontSize: "small" })
19
- ] }) });
17
+ return /* @__PURE__ */ jsx(Link, { href: link, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ jsxs(
18
+ Stack,
19
+ {
20
+ component: "span",
21
+ direction: "row",
22
+ alignItems: "center",
23
+ justifyContent: props.align === "left" ? "flex-start" : "flex-end",
24
+ spacing: 1,
25
+ children: [
26
+ /* @__PURE__ */ jsx(Typography, { component: "span", color: "primary", children: text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join("...") : text }),
27
+ /* @__PURE__ */ jsx(OpenInNewOutlined, { fontSize: "small" })
28
+ ]
29
+ }
30
+ ) });
20
31
  }
21
32
  return /* @__PURE__ */ jsx(Typography, { component: "small", color: "text.secondary", children: t("common.none") });
22
33
  }
package/es/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import api from './api';
2
+ import CheckoutDonate from './checkout/donate';
2
3
  import CheckoutForm from './checkout/form';
3
4
  import CheckoutTable from './checkout/table';
4
5
  import TxLink from './components/blockchain/tx';
@@ -23,4 +24,4 @@ import PaymentSummary from './payment/summary';
23
24
  export * from './util';
24
25
  export * from './contexts/payment';
25
26
  export { translations, createTranslator } from './locales';
26
- export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, };
27
+ export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, };
package/es/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import api from "./api.js";
2
+ import CheckoutDonate from "./checkout/donate.js";
2
3
  import CheckoutForm from "./checkout/form.js";
3
4
  import CheckoutTable from "./checkout/table.js";
4
5
  import TxLink from "./components/blockchain/tx.js";
@@ -36,6 +37,7 @@ export {
36
37
  ConfirmDialog,
37
38
  CheckoutForm,
38
39
  CheckoutTable,
40
+ CheckoutDonate,
39
41
  CurrencySelector,
40
42
  Payment,
41
43
  PaymentSummary,
package/es/locales/en.js CHANGED
@@ -87,6 +87,7 @@ export default flat({
87
87
  try: "Try for free",
88
88
  include: "This includes:",
89
89
  subscription: "Subscribe",
90
+ donate: "Donate",
90
91
  select: "Select",
91
92
  selected: "Selected",
92
93
  noPricing: "No items to purchase",
@@ -102,6 +103,12 @@ export default flat({
102
103
  title: "Staking Required",
103
104
  tooltip: "Staking is used to ensure that future invoices can be paid normally. Revoking the staking from DID Wallet means canceling the subscription."
104
105
  },
106
+ donation: {
107
+ between: "Please enter an amount between {min} and {max}.",
108
+ custom: "Custom Amount",
109
+ select: "Select Amount",
110
+ summary: "{total} supporters"
111
+ },
105
112
  cardPay: "{action} with card",
106
113
  empty: "No thing to pay",
107
114
  per: "per",
@@ -117,6 +124,7 @@ export default flat({
117
124
  payment: "Thanks for your purchase",
118
125
  subscription: "Thanks for your subscribing",
119
126
  setup: "Thanks for your subscribing",
127
+ donate: "Thanks for your support",
120
128
  tip: "A payment to {payee} has been completed. You can view the details of this payment in your account."
121
129
  },
122
130
  confirm: "By confirming your subscription, you allow {payee} to charge your account or slashing your staking for this and future payments in accordance with their terms. You can always cancel your subscription, or revoking your staking from DID Wallet.",
package/es/locales/zh.js CHANGED
@@ -87,6 +87,7 @@ export default flat({
87
87
  try: "\u514D\u8D39\u8BD5\u7528",
88
88
  include: "\u5305\u62EC\uFF1A",
89
89
  subscription: "\u8BA2\u9605",
90
+ donate: "\u6350\u8D60",
90
91
  select: "\u9009\u62E9",
91
92
  selected: "\u5DF2\u9009",
92
93
  noPricing: "\u6CA1\u6709\u53EF\u8D2D\u4E70\u7684\u7269\u54C1",
@@ -102,6 +103,12 @@ export default flat({
102
103
  title: "\u8D28\u62BC\u6570\u91CF",
103
104
  tooltip: "\u8D28\u62BC\u76F8\u5F53\u4E8E\u4FDD\u8BC1\u91D1\uFF0C\u7528\u4E8E\u786E\u4FDD\u672A\u6765\u7684\u8D26\u5355\u80FD\u591F\u6B63\u5E38\u6263\u6B3E\uFF0C\u5982\u679C\u4F60\u4ECE DID Wallet \u64A4\u9500\u8D28\u62BC\uFF0C\u8BA2\u9605\u4E5F\u4F1A\u88AB\u53D6\u6D88\u3002"
104
105
  },
106
+ donation: {
107
+ between: "\u91D1\u989D\u5FC5\u987B\u5927\u4E8E {min} \u4E14\u5C0F\u4E8E {max}",
108
+ custom: "\u8F93\u5165\u91D1\u989D",
109
+ select: "\u9009\u62E9\u91D1\u989D",
110
+ summary: "\u5DF2\u7ECF\u6709 {total} \u4EBA\u652F\u6301"
111
+ },
105
112
  cardPay: "\u4F7F\u7528\u5361\u7247{action}",
106
113
  empty: "\u6CA1\u6709\u53EF\u652F\u4ED8\u7684\u9879\u76EE",
107
114
  per: "\u6BCF",
@@ -117,6 +124,7 @@ export default flat({
117
124
  payment: "\u611F\u8C22\u60A8\u7684\u8D2D\u4E70",
118
125
  subscription: "\u611F\u8C22\u60A8\u7684\u8BA2\u9605",
119
126
  setup: "\u611F\u8C22\u60A8\u7684\u8BA2\u9605",
127
+ donate: "\u611F\u8C22\u60A8\u7684\u652F\u6301",
120
128
  tip: "\u5411{payee}\u7684\u4ED8\u6B3E\u5DF2\u5B8C\u6210\u3002\u60A8\u53EF\u4EE5\u5728\u60A8\u7684\u8D26\u6237\u4E2D\u67E5\u770B\u6B64\u4ED8\u6B3E\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002"
121
129
  },
122
130
  confirm: "\u901A\u8FC7\u786E\u8BA4\u60A8\u7684\u8BA2\u9605\uFF0C\u60A8\u5141\u8BB8{payee}\u6309\u7167\u5176\u6761\u6B3E\u5BF9\u60A8\u7684\u8D26\u6237\u8FDB\u884C\u4ED8\u6B3E\u6216\u8005\u7F5A\u6CA1\u60A8\u7684\u8D28\u62BC\u3002\u60A8\u968F\u65F6\u53EF\u4EE5\u53D6\u6D88\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u8005\u64A4\u9500\u8D28\u62BC\u3002",
@@ -3,11 +3,13 @@ type Props = {
3
3
  title: string;
4
4
  description: string;
5
5
  button?: string;
6
+ mode?: string;
6
7
  };
7
- declare function PaymentError({ title, description, button }: Props): import("react").JSX.Element;
8
+ declare function PaymentError({ title, description, button, mode }: Props): import("react").JSX.Element;
8
9
  declare namespace PaymentError {
9
10
  var defaultProps: {
10
11
  button: string;
12
+ mode: string;
11
13
  };
12
14
  }
13
15
  export default PaymentError;
@@ -1,12 +1,13 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Button, Link, Stack, Typography } from "@mui/material";
3
- export default function PaymentError({ title, description, button }) {
4
- return /* @__PURE__ */ jsx(Stack, { sx: { height: "100vh" }, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs(Stack, { sx: { width: "280px" }, direction: "column", alignItems: "center", justifyContent: "center", children: [
3
+ export default function PaymentError({ title, description, button, mode }) {
4
+ return /* @__PURE__ */ jsx(Stack, { sx: { height: mode === "inline" ? "auto" : "100vh" }, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs(Stack, { sx: { width: "280px" }, direction: "column", alignItems: "center", justifyContent: "center", children: [
5
5
  /* @__PURE__ */ jsx(Typography, { variant: "h5", sx: { mb: 2 }, children: title }),
6
6
  /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { mb: 2, textAlign: "center" }, children: description }),
7
7
  /* @__PURE__ */ jsx(Button, { variant: "text", size: "small", component: Link, href: window.blocklet?.appUrl, children: button })
8
8
  ] }) });
9
9
  }
10
10
  PaymentError.defaultProps = {
11
- button: "Back"
11
+ button: "Back",
12
+ mode: "standalone"
12
13
  };
@@ -5,6 +5,7 @@ export default function CurrencySelector({ value, currencies, onChange }) {
5
5
  return /* @__PURE__ */ jsx(
6
6
  Root,
7
7
  {
8
+ count: currencies.length,
8
9
  style: {
9
10
  display: currencies.length > 1 ? "grid" : "block",
10
11
  gridTemplateColumns: "50% 50%",
@@ -35,9 +36,9 @@ export default function CurrencySelector({ value, currencies, onChange }) {
35
36
  const Root = styled("section")`
36
37
  .cko-payment-card {
37
38
  position: relative;
38
- border: 2px solid ${(props) => props.theme.palette.primary.main};
39
- padding: 5px 10px;
40
- margin: 5px 0;
39
+ border: 1px solid ${(props) => props.theme.palette.primary.main};
40
+ padding: 4px 8px;
41
+ margin: 8px 0 0;
41
42
  cursor: pointer;
42
43
  }
43
44
 
@@ -52,18 +53,15 @@ const Root = styled("section")`
52
53
  }
53
54
 
54
55
  .cko-payment-card-unselect {
55
- border: 2px solid #ddd;
56
- padding: 5px 10px;
57
- margin: 5px 0;
56
+ border: 1px solid #ddd;
57
+ padding: 4px 8px;
58
+ margin: 8px 0 0;
58
59
  cursor: pointer;
59
60
  }
60
61
 
61
- .cko-payment-card:nth-child(odd) {
62
- margin-right: 8px;
63
- }
64
-
62
+ .cko-payment-card:nth-child(odd),
65
63
  .cko-payment-card-unselect:nth-child(odd) {
66
- margin-right: 8px;
64
+ margin-right: ${(props) => props.count > 1 ? 8 : 0}px;
67
65
  }
68
66
 
69
67
  .cko-payment-card::after {
@@ -73,7 +71,7 @@ const Root = styled("section")`
73
71
  position: absolute;
74
72
  right: 3px;
75
73
  bottom: 3px;
76
- border: 2px solid #fff;
74
+ border: 1px solid #fff;
77
75
  border-top-color: transparent;
78
76
  border-left-color: transparent;
79
77
  transform: rotate(35deg);
@@ -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, customer, onPaid, onError, mode, }: PageData): import("react").JSX.Element;
5
+ declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, mode, action, }: PageData): import("react").JSX.Element;
6
6
  declare namespace PaymentForm {
7
7
  var defaultProps: {};
8
8
  }
@@ -44,10 +44,12 @@ export default function PaymentForm({
44
44
  checkoutSession,
45
45
  paymentMethods,
46
46
  paymentIntent,
47
+ paymentLink,
47
48
  customer,
48
49
  onPaid,
49
50
  onError,
50
- mode
51
+ mode,
52
+ action
51
53
  }) {
52
54
  const theme = useTheme();
53
55
  const { t } = useLocaleContext();
@@ -94,7 +96,17 @@ export default function PaymentForm({
94
96
  return false;
95
97
  }, [domSize, theme]);
96
98
  const payee = getStatementDescriptor(checkoutSession.line_items);
97
- const buttonText = session?.user ? t(`payment.checkout.${checkoutSession.mode}`) : t("payment.checkout.connect", { action: t(`payment.checkout.${checkoutSession.mode}`) });
99
+ let buttonText = "";
100
+ if (paymentLink?.donation_settings) {
101
+ if (action) {
102
+ buttonText = action;
103
+ } else {
104
+ buttonText = t("payment.checkout.donate");
105
+ }
106
+ } else {
107
+ buttonText = t(`payment.checkout.${checkoutSession.mode}`);
108
+ }
109
+ buttonText = session?.user ? buttonText : t("payment.checkout.connect", { action: buttonText });
98
110
  const method = paymentMethods.find((x) => x.id === paymentMethod);
99
111
  const handleConnected = async () => {
100
112
  try {
@@ -287,7 +299,7 @@ export default function PaymentForm({
287
299
  ] }) }),
288
300
  /* @__PURE__ */ jsx(AddressForm, { mode: checkoutSession.billing_address_collection, stripe: method?.type === "stripe" }),
289
301
  /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", className: "cko-payment-methods", children: [
290
- /* @__PURE__ */ jsx(Typography, { sx: { mb: 2, color: "text.primary", fontWeight: 600 }, children: t("payment.checkout.method") }),
302
+ /* @__PURE__ */ jsx(Typography, { sx: { mb: 1, color: "text.primary", fontWeight: 600 }, children: t("payment.checkout.method") }),
291
303
  /* @__PURE__ */ jsx(Stack, { direction: "row", sx: { width: "100%" }, children: /* @__PURE__ */ jsx(
292
304
  Controller,
293
305
  {
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { LiteralUnion } from 'type-fest';
2
+ import type { LiteralUnion } from 'type-fest';
3
3
  import { CheckoutCallbacks, CheckoutContext } from '../types';
4
4
  type Props = CheckoutContext & CheckoutCallbacks & {
5
5
  completed?: boolean;
6
6
  error?: any;
7
7
  };
8
- declare function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, error, mode, onPaid, onError, onChange, goBack, }: Props): import("react").JSX.Element;
8
+ declare function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, error, mode, onPaid, onError, onChange, goBack, action, }: Props): import("react").JSX.Element;
9
9
  declare namespace Payment {
10
10
  var defaultProps: {
11
11
  completed: boolean;
@@ -16,7 +16,7 @@ export default Payment;
16
16
  type MainProps = CheckoutContext & CheckoutCallbacks & {
17
17
  completed?: boolean;
18
18
  };
19
- export declare function PaymentInner({ checkoutSession, paymentMethods, paymentLink, paymentIntent, customer, completed, mode, onPaid, onError, onChange, goBack, }: MainProps): import("react").JSX.Element;
19
+ export declare function PaymentInner({ checkoutSession, paymentMethods, paymentLink, paymentIntent, customer, completed, mode, onPaid, onError, onChange, goBack, action, }: MainProps): import("react").JSX.Element;
20
20
  export declare namespace PaymentInner {
21
21
  var defaultProps: {
22
22
  completed: boolean;