@blocklet/payment-react 1.13.209 → 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,284 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = CheckoutDonate;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
9
+ var _context = require("@arcblock/ux/lib/Locale/context");
10
+ var _material = require("@mui/material");
11
+ var _ahooks = require("ahooks");
12
+ var _omit = _interopRequireDefault(require("lodash/omit"));
13
+ var _unionBy = _interopRequireDefault(require("lodash/unionBy"));
14
+ var _react = require("react");
15
+ var _api = _interopRequireDefault(require("../api"));
16
+ var _tx = _interopRequireDefault(require("../components/blockchain/tx"));
17
+ var _util = require("../util");
18
+ var _form = _interopRequireDefault(require("./form"));
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ const donationCache = {};
21
+ const createOrUpdateDonation = (settings, livemode = true) => {
22
+ if (!donationCache[settings.target]) {
23
+ donationCache[settings.target] = _api.default.post(`/api/donations?livemode=${livemode}`, (0, _omit.default)(settings, ["appearance"])).then(res => res.data).finally(() => {
24
+ setTimeout(() => {
25
+ delete donationCache[settings.target];
26
+ }, 3e3);
27
+ });
28
+ }
29
+ return donationCache[settings.target];
30
+ };
31
+ const supporterCache = {};
32
+ const fetchSupporters = target => {
33
+ if (!supporterCache[target]) {
34
+ supporterCache[target] = _api.default.get(`/api/donations?&target=${target}`).then(res => res.data).finally(() => {
35
+ setTimeout(() => {
36
+ delete supporterCache[target];
37
+ }, 3e3);
38
+ });
39
+ }
40
+ return supporterCache[target];
41
+ };
42
+ function SupporterAvatar({
43
+ supporters = [],
44
+ total,
45
+ currency,
46
+ method
47
+ }) {
48
+ const {
49
+ t
50
+ } = (0, _context.useLocaleContext)();
51
+ const customers = (0, _unionBy.default)(supporters, "customer_did");
52
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
53
+ display: "flex",
54
+ flexDirection: "column",
55
+ alignItems: "center",
56
+ sx: {
57
+ ".MuiAvatar-root": {
58
+ width: "32px",
59
+ height: "32px"
60
+ }
61
+ },
62
+ gap: {
63
+ xs: 0.5,
64
+ sm: 1
65
+ },
66
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
67
+ component: "p",
68
+ color: "text.secondary",
69
+ children: t("payment.checkout.donation.summary", {
70
+ total
71
+ })
72
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.AvatarGroup, {
73
+ total,
74
+ max: 20,
75
+ children: customers.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
76
+ title: x.customer?.name,
77
+ src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
78
+ variant: "circular",
79
+ sx: {
80
+ width: 32,
81
+ height: 32
82
+ }
83
+ }, x.id))
84
+ })]
85
+ });
86
+ }
87
+ function SupporterTable({
88
+ supporters = [],
89
+ total,
90
+ currency,
91
+ method
92
+ }) {
93
+ const {
94
+ t
95
+ } = (0, _context.useLocaleContext)();
96
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
97
+ display: "flex",
98
+ flexDirection: "column",
99
+ alignItems: "center",
100
+ sx: {
101
+ width: "100%"
102
+ },
103
+ gap: {
104
+ xs: 0.5,
105
+ sm: 1
106
+ },
107
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
108
+ component: "p",
109
+ color: "text.secondary",
110
+ children: t("payment.checkout.donation.summary", {
111
+ total
112
+ })
113
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Table, {
114
+ size: "small",
115
+ sx: {
116
+ width: "100%",
117
+ overflow: "hidden"
118
+ },
119
+ children: supporters.map(x => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.TableRow, {
120
+ sx: {
121
+ "> td": {
122
+ padding: "8px 16px 8px 0",
123
+ borderTop: "1px solid #e0e0e0",
124
+ borderBottom: "1px solid #e0e0e0"
125
+ }
126
+ },
127
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
128
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
129
+ direction: "row",
130
+ alignItems: "center",
131
+ spacing: 0.5,
132
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
133
+ src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
134
+ variant: "circular",
135
+ sx: {
136
+ width: 24,
137
+ height: 24
138
+ }
139
+ }, x.id), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Hidden, {
140
+ smDown: true,
141
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
142
+ children: x.customer?.name
143
+ })
144
+ })]
145
+ })
146
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
147
+ align: "right",
148
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
149
+ direction: "row",
150
+ alignItems: "center",
151
+ justifyContent: "flex-end",
152
+ spacing: 0.5,
153
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
154
+ fontWeight: 500,
155
+ component: "strong",
156
+ children: (0, _util.formatAmount)(x.amount_total, currency.decimal)
157
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
158
+ component: "span",
159
+ children: currency.symbol
160
+ })]
161
+ })
162
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Hidden, {
163
+ smDown: true,
164
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
165
+ align: "right",
166
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
167
+ children: (0, _util.formatDateTime)(x.created_at)
168
+ })
169
+ })
170
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
171
+ align: "right",
172
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_tx.default, {
173
+ method,
174
+ details: x.payment_details,
175
+ mode: "customer",
176
+ align: "right"
177
+ })
178
+ })]
179
+ }, x.id))
180
+ })]
181
+ });
182
+ }
183
+ function CheckoutDonate({
184
+ settings,
185
+ livemode,
186
+ onPaid,
187
+ onError
188
+ }) {
189
+ const [state, setState] = (0, _ahooks.useSetState)({
190
+ open: false,
191
+ supporterLoaded: false,
192
+ exist: false
193
+ });
194
+ const donation = (0, _ahooks.useRequest)(() => createOrUpdateDonation(settings, livemode));
195
+ const supporters = (0, _ahooks.useRequest)(() => donation.data ? fetchSupporters(donation.data.id) : Promise.resolve({}));
196
+ (0, _react.useEffect)(() => {
197
+ if (donation.data && state.supporterLoaded === false) {
198
+ setState({
199
+ supporterLoaded: true
200
+ });
201
+ supporters.runAsync().catch(console.error);
202
+ }
203
+ }, [donation.data]);
204
+ const handlePaid = (...args) => {
205
+ if (onPaid) {
206
+ onPaid(...args);
207
+ }
208
+ supporters.runAsync().catch(console.error);
209
+ setTimeout(() => {
210
+ setState({
211
+ open: false
212
+ });
213
+ }, 3e3);
214
+ };
215
+ if (donation.error) {
216
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Alert, {
217
+ severity: "error",
218
+ children: (0, _util.formatError)(donation.error)
219
+ });
220
+ }
221
+ if (donation.loading || !donation.data) {
222
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {});
223
+ }
224
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
225
+ sx: {
226
+ width: "100%",
227
+ minWidth: 300,
228
+ maxWidth: 720
229
+ },
230
+ display: "flex",
231
+ flexDirection: "column",
232
+ alignItems: "center",
233
+ gap: {
234
+ xs: 1,
235
+ sm: 2
236
+ },
237
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
238
+ size: settings.appearance?.button?.size || "medium",
239
+ color: settings.appearance?.button?.color || "primary",
240
+ variant: settings.appearance?.button?.variant || "contained",
241
+ onClick: () => setState({
242
+ open: true
243
+ }),
244
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
245
+ direction: "row",
246
+ alignItems: "center",
247
+ spacing: 0.5,
248
+ children: [settings.appearance.button.icon, typeof settings.appearance.button.text === "string" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
249
+ children: settings.appearance.button.text
250
+ }) : settings.appearance.button.text]
251
+ })
252
+ }), supporters.data && settings.appearance.history.variant === "avatar" && /* @__PURE__ */(0, _jsxRuntime.jsx)(SupporterAvatar, {
253
+ ...supporters.data
254
+ }), supporters.data && settings.appearance.history.variant === "table" && /* @__PURE__ */(0, _jsxRuntime.jsx)(SupporterTable, {
255
+ ...supporters.data
256
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_Dialog.default, {
257
+ open: state.open,
258
+ title: settings.title,
259
+ maxWidth: "md",
260
+ showCloseButton: true,
261
+ disableBackdropClick: true,
262
+ disableEscapeKeyDown: true,
263
+ onClose: (e, reason) => setState({
264
+ open: reason === "backdropClick"
265
+ }),
266
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
267
+ sx: {
268
+ mb: 1,
269
+ mt: -2
270
+ },
271
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_form.default, {
272
+ id: donation.data.id,
273
+ onPaid: handlePaid,
274
+ onError,
275
+ action: settings.appearance?.button?.text,
276
+ mode: "inline"
277
+ })
278
+ })
279
+ })]
280
+ });
281
+ }
282
+ CheckoutDonate.defaultProps = {
283
+ livemode: true
284
+ };
@@ -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
  }
@@ -37,7 +37,8 @@ function CheckoutForm({
37
37
  onError,
38
38
  onChange,
39
39
  goBack,
40
- extraParams
40
+ extraParams,
41
+ action
41
42
  }) {
42
43
  if (!id.startsWith("plink_") && !id.startsWith("cs_")) {
43
44
  throw new Error("Either a checkoutSession or a paymentLink id is required.");
@@ -81,12 +82,14 @@ function CheckoutForm({
81
82
  onError: handleError,
82
83
  onChange,
83
84
  goBack,
84
- mode
85
+ mode,
86
+ action
85
87
  });
86
88
  }
87
89
  CheckoutForm.defaultProps = {
88
90
  onPaid: _noop.default,
89
91
  onError: console.error,
90
92
  mode: "inline",
93
+ action: "",
91
94
  extraParams: {}
92
95
  };
@@ -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;
@@ -10,7 +10,8 @@ var _iconsMaterial = require("@mui/icons-material");
10
10
  var _material = require("@mui/material");
11
11
  var _util = require("../../util");
12
12
  TxLink.defaultProps = {
13
- mode: "dashboard"
13
+ mode: "dashboard",
14
+ align: "left"
14
15
  };
15
16
  function TxLink(props) {
16
17
  const {
@@ -36,6 +37,7 @@ function TxLink(props) {
36
37
  component: "span",
37
38
  direction: "row",
38
39
  alignItems: "center",
40
+ justifyContent: props.align === "left" ? "flex-start" : "flex-end",
39
41
  spacing: 1,
40
42
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
41
43
  component: "span",
package/lib/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/lib/index.js CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  var _exportNames = {
7
7
  api: true,
8
+ CheckoutDonate: true,
8
9
  CheckoutForm: true,
9
10
  CheckoutTable: true,
10
11
  TxLink: true,
@@ -41,6 +42,12 @@ Object.defineProperty(exports, "Amount", {
41
42
  return _amount.default;
42
43
  }
43
44
  });
45
+ Object.defineProperty(exports, "CheckoutDonate", {
46
+ enumerable: true,
47
+ get: function () {
48
+ return _donate.default;
49
+ }
50
+ });
44
51
  Object.defineProperty(exports, "CheckoutForm", {
45
52
  enumerable: true,
46
53
  get: function () {
@@ -174,6 +181,7 @@ Object.defineProperty(exports, "translations", {
174
181
  }
175
182
  });
176
183
  var _api = _interopRequireDefault(require("./api"));
184
+ var _donate = _interopRequireDefault(require("./checkout/donate"));
177
185
  var _form = _interopRequireDefault(require("./checkout/form"));
178
186
  var _table = _interopRequireDefault(require("./checkout/table"));
179
187
  var _tx = _interopRequireDefault(require("./components/blockchain/tx"));
package/lib/locales/en.js CHANGED
@@ -94,6 +94,7 @@ module.exports = (0, _flat.default)({
94
94
  try: "Try for free",
95
95
  include: "This includes:",
96
96
  subscription: "Subscribe",
97
+ donate: "Donate",
97
98
  select: "Select",
98
99
  selected: "Selected",
99
100
  noPricing: "No items to purchase",
@@ -109,6 +110,12 @@ module.exports = (0, _flat.default)({
109
110
  title: "Staking Required",
110
111
  tooltip: "Staking is used to ensure that future invoices can be paid normally. Revoking the staking from DID Wallet means canceling the subscription."
111
112
  },
113
+ donation: {
114
+ between: "Please enter an amount between {min} and {max}.",
115
+ custom: "Custom Amount",
116
+ select: "Select Amount",
117
+ summary: "{total} supporters"
118
+ },
112
119
  cardPay: "{action} with card",
113
120
  empty: "No thing to pay",
114
121
  per: "per",
@@ -124,6 +131,7 @@ module.exports = (0, _flat.default)({
124
131
  payment: "Thanks for your purchase",
125
132
  subscription: "Thanks for your subscribing",
126
133
  setup: "Thanks for your subscribing",
134
+ donate: "Thanks for your support",
127
135
  tip: "A payment to {payee} has been completed. You can view the details of this payment in your account."
128
136
  },
129
137
  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/lib/locales/zh.js CHANGED
@@ -94,6 +94,7 @@ module.exports = (0, _flat.default)({
94
94
  try: "\u514D\u8D39\u8BD5\u7528",
95
95
  include: "\u5305\u62EC\uFF1A",
96
96
  subscription: "\u8BA2\u9605",
97
+ donate: "\u6350\u8D60",
97
98
  select: "\u9009\u62E9",
98
99
  selected: "\u5DF2\u9009",
99
100
  noPricing: "\u6CA1\u6709\u53EF\u8D2D\u4E70\u7684\u7269\u54C1",
@@ -109,6 +110,12 @@ module.exports = (0, _flat.default)({
109
110
  title: "\u8D28\u62BC\u6570\u91CF",
110
111
  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"
111
112
  },
113
+ donation: {
114
+ between: "\u91D1\u989D\u5FC5\u987B\u5927\u4E8E {min} \u4E14\u5C0F\u4E8E {max}",
115
+ custom: "\u8F93\u5165\u91D1\u989D",
116
+ select: "\u9009\u62E9\u91D1\u989D",
117
+ summary: "\u5DF2\u7ECF\u6709 {total} \u4EBA\u652F\u6301"
118
+ },
112
119
  cardPay: "\u4F7F\u7528\u5361\u7247{action}",
113
120
  empty: "\u6CA1\u6709\u53EF\u652F\u4ED8\u7684\u9879\u76EE",
114
121
  per: "\u6BCF",
@@ -124,6 +131,7 @@ module.exports = (0, _flat.default)({
124
131
  payment: "\u611F\u8C22\u60A8\u7684\u8D2D\u4E70",
125
132
  subscription: "\u611F\u8C22\u60A8\u7684\u8BA2\u9605",
126
133
  setup: "\u611F\u8C22\u60A8\u7684\u8BA2\u9605",
134
+ donate: "\u611F\u8C22\u60A8\u7684\u652F\u6301",
127
135
  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"
128
136
  },
129
137
  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;
@@ -9,11 +9,12 @@ var _material = require("@mui/material");
9
9
  function PaymentError({
10
10
  title,
11
11
  description,
12
- button
12
+ button,
13
+ mode
13
14
  }) {
14
15
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
15
16
  sx: {
16
- height: "100vh"
17
+ height: mode === "inline" ? "auto" : "100vh"
17
18
  },
18
19
  alignItems: "center",
19
20
  justifyContent: "center",
@@ -48,5 +49,6 @@ function PaymentError({
48
49
  });
49
50
  }
50
51
  PaymentError.defaultProps = {
51
- button: "Back"
52
+ button: "Back",
53
+ mode: "standalone"
52
54
  };
@@ -13,6 +13,7 @@ function CurrencySelector({
13
13
  onChange
14
14
  }) {
15
15
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(Root, {
16
+ count: currencies.length,
16
17
  style: {
17
18
  display: currencies.length > 1 ? "grid" : "block",
18
19
  gridTemplateColumns: "50% 50%",
@@ -60,9 +61,9 @@ function CurrencySelector({
60
61
  const Root = (0, _system.styled)("section")`
61
62
  .cko-payment-card {
62
63
  position: relative;
63
- border: 2px solid ${props => props.theme.palette.primary.main};
64
- padding: 5px 10px;
65
- margin: 5px 0;
64
+ border: 1px solid ${props => props.theme.palette.primary.main};
65
+ padding: 4px 8px;
66
+ margin: 8px 0 0;
66
67
  cursor: pointer;
67
68
  }
68
69
 
@@ -77,18 +78,15 @@ const Root = (0, _system.styled)("section")`
77
78
  }
78
79
 
79
80
  .cko-payment-card-unselect {
80
- border: 2px solid #ddd;
81
- padding: 5px 10px;
82
- margin: 5px 0;
81
+ border: 1px solid #ddd;
82
+ padding: 4px 8px;
83
+ margin: 8px 0 0;
83
84
  cursor: pointer;
84
85
  }
85
86
 
86
- .cko-payment-card:nth-child(odd) {
87
- margin-right: 8px;
88
- }
89
-
87
+ .cko-payment-card:nth-child(odd),
90
88
  .cko-payment-card-unselect:nth-child(odd) {
91
- margin-right: 8px;
89
+ margin-right: ${props => props.count > 1 ? 8 : 0}px;
92
90
  }
93
91
 
94
92
  .cko-payment-card::after {
@@ -98,7 +96,7 @@ const Root = (0, _system.styled)("section")`
98
96
  position: absolute;
99
97
  right: 3px;
100
98
  bottom: 3px;
101
- border: 2px solid #fff;
99
+ border: 1px solid #fff;
102
100
  border-top-color: transparent;
103
101
  border-left-color: transparent;
104
102
  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
  }
@@ -53,10 +53,12 @@ function PaymentForm({
53
53
  checkoutSession,
54
54
  paymentMethods,
55
55
  paymentIntent,
56
+ paymentLink,
56
57
  customer,
57
58
  onPaid,
58
59
  onError,
59
- mode
60
+ mode,
61
+ action
60
62
  }) {
61
63
  const theme = (0, _Theme.useTheme)();
62
64
  const {
@@ -116,8 +118,18 @@ function PaymentForm({
116
118
  return false;
117
119
  }, [domSize, theme]);
118
120
  const payee = (0, _util.getStatementDescriptor)(checkoutSession.line_items);
119
- const buttonText = session?.user ? t(`payment.checkout.${checkoutSession.mode}`) : t("payment.checkout.connect", {
120
- action: t(`payment.checkout.${checkoutSession.mode}`)
121
+ let buttonText = "";
122
+ if (paymentLink?.donation_settings) {
123
+ if (action) {
124
+ buttonText = action;
125
+ } else {
126
+ buttonText = t("payment.checkout.donate");
127
+ }
128
+ } else {
129
+ buttonText = t(`payment.checkout.${checkoutSession.mode}`);
130
+ }
131
+ buttonText = session?.user ? buttonText : t("payment.checkout.connect", {
132
+ action: buttonText
121
133
  });
122
134
  const method = paymentMethods.find(x => x.id === paymentMethod);
123
135
  const handleConnected = async () => {
@@ -369,7 +381,7 @@ function PaymentForm({
369
381
  className: "cko-payment-methods",
370
382
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
371
383
  sx: {
372
- mb: 2,
384
+ mb: 1,
373
385
  color: "text.primary",
374
386
  fontWeight: 600
375
387
  },
@@ -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;