@blocklet/payment-react 1.18.15 → 1.18.17
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 +17 -8
- package/es/components/over-due-invoice-payment.d.ts +20 -7
- package/es/components/over-due-invoice-payment.js +223 -75
- package/es/contexts/payment.js +14 -1
- package/es/history/invoice/list.d.ts +2 -0
- package/es/history/invoice/list.js +61 -13
- package/es/locales/en.js +17 -7
- package/es/locales/zh.js +17 -7
- package/es/payment/donation-form.js +2 -1
- package/es/payment/form/address.js +63 -65
- package/es/payment/form/index.d.ts +3 -1
- package/es/payment/form/index.js +17 -5
- package/lib/checkout/donate.js +18 -9
- package/lib/components/over-due-invoice-payment.d.ts +20 -7
- package/lib/components/over-due-invoice-payment.js +218 -76
- package/lib/contexts/payment.js +14 -1
- package/lib/history/invoice/list.d.ts +2 -0
- package/lib/history/invoice/list.js +84 -24
- package/lib/locales/en.js +17 -7
- package/lib/locales/zh.js +17 -7
- package/lib/payment/donation-form.js +2 -1
- package/lib/payment/form/address.js +46 -50
- package/lib/payment/form/index.d.ts +3 -1
- package/lib/payment/form/index.js +17 -5
- package/package.json +8 -7
- package/src/checkout/donate.tsx +16 -7
- package/src/components/over-due-invoice-payment.tsx +277 -81
- package/src/contexts/payment.tsx +15 -1
- package/src/history/invoice/list.tsx +75 -16
- package/src/locales/en.tsx +14 -4
- package/src/locales/zh.tsx +14 -3
- package/src/payment/donation-form.tsx +1 -0
- package/src/payment/form/address.tsx +36 -38
- package/src/payment/form/index.tsx +16 -4
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
3
|
import Toast from "@arcblock/ux/lib/Toast";
|
|
4
4
|
import { OpenInNewOutlined } from "@mui/icons-material";
|
|
5
|
-
import { Box, Button, CircularProgress,
|
|
5
|
+
import { Box, Button, CircularProgress, Stack, Typography, Tooltip } from "@mui/material";
|
|
6
6
|
import { styled } from "@mui/system";
|
|
7
7
|
import { useInfiniteScroll, useRequest, useSetState } from "ahooks";
|
|
8
8
|
import React, { useEffect, useRef, useState } from "react";
|
|
@@ -72,7 +72,8 @@ const InvoiceTable = React.memo((props) => {
|
|
|
72
72
|
include_staking,
|
|
73
73
|
include_return_staking,
|
|
74
74
|
include_recovered_from,
|
|
75
|
-
onTableDataChange
|
|
75
|
+
onTableDataChange,
|
|
76
|
+
relatedSubscription
|
|
76
77
|
} = props;
|
|
77
78
|
const listKey = "invoice-table";
|
|
78
79
|
const { t, locale } = useLocaleContext();
|
|
@@ -135,6 +136,11 @@ const InvoiceTable = React.memo((props) => {
|
|
|
135
136
|
const { link } = getInvoiceLink(invoice, action);
|
|
136
137
|
handleNavigation(e, link, navigate, { target: link.external ? "_blank" : target });
|
|
137
138
|
};
|
|
139
|
+
const handleRelatedSubscriptionClick = (e, invoice) => {
|
|
140
|
+
if (invoice.subscription_id) {
|
|
141
|
+
handleNavigation(e, createLink(`/customer/subscription/${invoice.subscription_id}`), navigate);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
138
144
|
const columns = [
|
|
139
145
|
{
|
|
140
146
|
label: t("common.amount"),
|
|
@@ -144,7 +150,8 @@ const InvoiceTable = React.memo((props) => {
|
|
|
144
150
|
options: {
|
|
145
151
|
customBodyRenderLite: (_, index) => {
|
|
146
152
|
const invoice = data?.list[index];
|
|
147
|
-
|
|
153
|
+
const isVoid = invoice.status === "void";
|
|
154
|
+
return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: /* @__PURE__ */ jsxs(Typography, { sx: isVoid ? { textDecoration: "line-through" } : {}, children: [
|
|
148
155
|
formatBNStr(invoice.total, invoice.paymentCurrency.decimal),
|
|
149
156
|
"\xA0",
|
|
150
157
|
invoice.paymentCurrency.symbol
|
|
@@ -172,13 +179,36 @@ const InvoiceTable = React.memo((props) => {
|
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
},
|
|
182
|
+
...relatedSubscription ? [
|
|
183
|
+
{
|
|
184
|
+
label: t("common.relatedSubscription"),
|
|
185
|
+
name: "subscription",
|
|
186
|
+
options: {
|
|
187
|
+
customBodyRenderLite: (_, index) => {
|
|
188
|
+
const invoice = data?.list[index];
|
|
189
|
+
return invoice.subscription_id ? /* @__PURE__ */ jsx(
|
|
190
|
+
Box,
|
|
191
|
+
{
|
|
192
|
+
onClick: (e) => handleRelatedSubscriptionClick(e, invoice),
|
|
193
|
+
sx: { color: "text.link", cursor: "pointer" },
|
|
194
|
+
children: invoice.subscription?.description
|
|
195
|
+
}
|
|
196
|
+
) : /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: { ...linkStyle, color: "text.lighter" }, children: t("common.none") });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
] : [],
|
|
175
201
|
{
|
|
176
202
|
label: t("common.updatedAt"),
|
|
177
203
|
name: "name",
|
|
178
204
|
options: {
|
|
179
205
|
customBodyRenderLite: (val, index) => {
|
|
180
206
|
const invoice = data?.list[index];
|
|
181
|
-
return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: formatToDate(
|
|
207
|
+
return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: formatToDate(
|
|
208
|
+
invoice.created_at,
|
|
209
|
+
locale,
|
|
210
|
+
relatedSubscription ? "YYYY-MM-DD HH:mm" : "YYYY-MM-DD HH:mm:ss"
|
|
211
|
+
) });
|
|
182
212
|
}
|
|
183
213
|
}
|
|
184
214
|
},
|
|
@@ -201,6 +231,7 @@ const InvoiceTable = React.memo((props) => {
|
|
|
201
231
|
const invoice = data?.list[index];
|
|
202
232
|
const hidePay = invoice.billing_reason === "overdraft-protection";
|
|
203
233
|
const { connect } = getInvoiceLink(invoice, action);
|
|
234
|
+
const isVoid = invoice.status === "void";
|
|
204
235
|
if (action && !hidePay) {
|
|
205
236
|
return connect ? /* @__PURE__ */ jsx(Button, { variant: "text", size: "small", onClick: () => onPay(invoice.id), sx: { color: "text.link" }, children: t("payment.customer.invoice.pay") }) : /* @__PURE__ */ jsx(
|
|
206
237
|
Button,
|
|
@@ -215,7 +246,7 @@ const InvoiceTable = React.memo((props) => {
|
|
|
215
246
|
}
|
|
216
247
|
);
|
|
217
248
|
}
|
|
218
|
-
return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) });
|
|
249
|
+
return /* @__PURE__ */ jsx(Box, { onClick: (e) => handleLinkClick(e, invoice), sx: linkStyle, children: isVoid ? /* @__PURE__ */ jsx(Tooltip, { title: t("payment.customer.invoice.noPaymentRequired"), arrow: true, placement: "top", children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) }) }) : /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) });
|
|
219
250
|
}
|
|
220
251
|
}
|
|
221
252
|
}
|
|
@@ -349,6 +380,7 @@ const InvoiceList = React.memo((props) => {
|
|
|
349
380
|
/* @__PURE__ */ jsx(Typography, { sx: { fontWeight: "bold", color: "text.secondary", mt: 2, mb: 1 }, children: date }),
|
|
350
381
|
invoices.map((invoice) => {
|
|
351
382
|
const { link, connect } = getInvoiceLink(invoice, action);
|
|
383
|
+
const isVoid = invoice.status === "void";
|
|
352
384
|
return /* @__PURE__ */ jsxs(
|
|
353
385
|
Stack,
|
|
354
386
|
{
|
|
@@ -371,17 +403,35 @@ const InvoiceList = React.memo((props) => {
|
|
|
371
403
|
onClick: (e) => handleLinkClick(e, link),
|
|
372
404
|
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
373
405
|
/* @__PURE__ */ jsx(Typography, { component: "span", children: invoice.number }),
|
|
374
|
-
link.external && /* @__PURE__ */ jsx(
|
|
406
|
+
link.external && /* @__PURE__ */ jsx(
|
|
407
|
+
OpenInNewOutlined,
|
|
408
|
+
{
|
|
409
|
+
fontSize: "small",
|
|
410
|
+
sx: {
|
|
411
|
+
color: "text.secondary",
|
|
412
|
+
display: { xs: "none", md: "inline-flex" }
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
)
|
|
375
416
|
] })
|
|
376
417
|
}
|
|
377
418
|
) }),
|
|
378
|
-
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsxs(Typography, { children: [
|
|
419
|
+
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsxs(Typography, { sx: isVoid ? { textDecoration: "line-through" } : {}, children: [
|
|
379
420
|
formatBNStr(invoice.total, invoice.paymentCurrency.decimal),
|
|
380
421
|
"\xA0",
|
|
381
422
|
invoice.paymentCurrency.symbol
|
|
382
423
|
] }) }),
|
|
383
424
|
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsx(Typography, { children: formatToDate(invoice.created_at, locale, "HH:mm:ss") }) }),
|
|
384
|
-
!action && /* @__PURE__ */ jsx(
|
|
425
|
+
!action && /* @__PURE__ */ jsx(
|
|
426
|
+
Box,
|
|
427
|
+
{
|
|
428
|
+
flex: 2,
|
|
429
|
+
className: "invoice-description",
|
|
430
|
+
textAlign: "right",
|
|
431
|
+
sx: { display: { xs: "none", lg: "inline-flex" } },
|
|
432
|
+
children: /* @__PURE__ */ jsx(Typography, { children: invoice.description || invoice.id })
|
|
433
|
+
}
|
|
434
|
+
),
|
|
385
435
|
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: action ? connect ? /* @__PURE__ */ jsx(
|
|
386
436
|
Button,
|
|
387
437
|
{
|
|
@@ -403,7 +453,7 @@ const InvoiceList = React.memo((props) => {
|
|
|
403
453
|
rel: "noreferrer",
|
|
404
454
|
children: t("payment.customer.invoice.pay")
|
|
405
455
|
}
|
|
406
|
-
) : /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) })
|
|
456
|
+
) : isVoid ? /* @__PURE__ */ jsx(Tooltip, { title: t("payment.customer.invoice.noPaymentRequired"), arrow: true, placement: "top", children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) }) }) : /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) })
|
|
407
457
|
]
|
|
408
458
|
},
|
|
409
459
|
invoice.id
|
|
@@ -468,13 +518,11 @@ CustomerInvoiceList.defaultProps = {
|
|
|
468
518
|
action: "",
|
|
469
519
|
type: "list",
|
|
470
520
|
onTableDataChange: () => {
|
|
471
|
-
}
|
|
521
|
+
},
|
|
522
|
+
relatedSubscription: false
|
|
472
523
|
};
|
|
473
524
|
const Root = styled(Stack)`
|
|
474
525
|
@media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
475
|
-
.invoice-description {
|
|
476
|
-
display: none !important;
|
|
477
|
-
}
|
|
478
526
|
svg.MuiSvgIcon-root {
|
|
479
527
|
display: none !important;
|
|
480
528
|
}
|
package/es/locales/en.js
CHANGED
|
@@ -93,7 +93,8 @@ export default flat({
|
|
|
93
93
|
saveAsDefaultPriceSuccess: "Set default price successfully",
|
|
94
94
|
stakeAmount: "Stake Amount",
|
|
95
95
|
slashStakeAmount: "Slash Stake Amount",
|
|
96
|
-
know: "I know"
|
|
96
|
+
know: "I know",
|
|
97
|
+
relatedSubscription: "Subscription"
|
|
97
98
|
},
|
|
98
99
|
payment: {
|
|
99
100
|
checkout: {
|
|
@@ -237,12 +238,13 @@ export default flat({
|
|
|
237
238
|
pastDue: {
|
|
238
239
|
button: "Pay",
|
|
239
240
|
invoices: "Past Due Invoices",
|
|
240
|
-
warning: "Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore.
|
|
241
|
+
warning: "Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore.",
|
|
241
242
|
alert: {
|
|
242
243
|
title: "You have unpaid invoices",
|
|
243
244
|
description: "Seems you have unpaid invoices from previous subscriptions, new purchases are not allowed unless you have paid all past due invoices.",
|
|
244
245
|
confirm: "Pay Now"
|
|
245
|
-
}
|
|
246
|
+
},
|
|
247
|
+
view: "View Due Invoices"
|
|
246
248
|
},
|
|
247
249
|
recover: {
|
|
248
250
|
button: "Resume Subscription",
|
|
@@ -291,7 +293,8 @@ export default flat({
|
|
|
291
293
|
empty: "There are no invoices",
|
|
292
294
|
next: "No invoices yet, next invoice will be generated on {date}",
|
|
293
295
|
invoiceNumber: "Invoice Number",
|
|
294
|
-
emptyList: "No Invoice"
|
|
296
|
+
emptyList: "No Invoice",
|
|
297
|
+
noPaymentRequired: "No Payment Required"
|
|
295
298
|
},
|
|
296
299
|
payment: {
|
|
297
300
|
empty: "There are no payments",
|
|
@@ -312,6 +315,11 @@ export default flat({
|
|
|
312
315
|
changePayment: "Change payment method",
|
|
313
316
|
trialLeft: "Trail Left",
|
|
314
317
|
owner: "Subscription Owner"
|
|
318
|
+
},
|
|
319
|
+
overdue: {
|
|
320
|
+
title: "You have {count} due invoices for {subscriptionCount} subscriptions, totaling {total} {symbol}{method}. Please pay immediately to avoid service disruption.",
|
|
321
|
+
simpleTitle: "You have {count} due invoices. Please pay now to ensure uninterrupted service.",
|
|
322
|
+
empty: "Great! You have no due invoices."
|
|
315
323
|
}
|
|
316
324
|
},
|
|
317
325
|
invoice: {
|
|
@@ -342,16 +350,18 @@ export default flat({
|
|
|
342
350
|
subscription: {
|
|
343
351
|
overdue: {
|
|
344
352
|
simpleTitle: "There are {count} due invoices for your subscription {name}, you need to pay them to activate your subscription or before making new purchases.",
|
|
345
|
-
title: "There are {count} due invoices for your subscription {name}, the total due amount is {total} {symbol}, you need to pay them to activate your subscription or before making new purchases.",
|
|
353
|
+
title: "There are {count} due invoices for your subscription {name}, the total due amount is {total} {symbol}{method}, you need to pay them to activate your subscription or before making new purchases.",
|
|
346
354
|
payNow: "Pay Now",
|
|
347
355
|
notSupport: "This payment method is not supported",
|
|
348
|
-
total: "Total {total} {currency}",
|
|
356
|
+
total: "Total {total} {currency}{method}",
|
|
349
357
|
view: "View Subscription Details",
|
|
350
358
|
viewNow: "View Now",
|
|
351
359
|
pastDue: "Past Due Invoices",
|
|
352
360
|
description: "If you have any questions, you can choose ",
|
|
353
361
|
list: "Past Due Invoices:",
|
|
354
|
-
empty: "There are no overdue invoices for your subscription {name}."
|
|
362
|
+
empty: "There are no overdue invoices for your subscription {name}.",
|
|
363
|
+
retry: "Retry",
|
|
364
|
+
paid: "Paid"
|
|
355
365
|
}
|
|
356
366
|
}
|
|
357
367
|
},
|
package/es/locales/zh.js
CHANGED
|
@@ -93,7 +93,8 @@ export default flat({
|
|
|
93
93
|
saveAsDefaultPriceSuccess: "\u8BBE\u7F6E\u9ED8\u8BA4\u4EF7\u683C\u6210\u529F",
|
|
94
94
|
stakeAmount: "\u8D28\u62BC\u91D1\u989D",
|
|
95
95
|
slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D",
|
|
96
|
-
know: "\u6211\u77E5\u9053\u4E86"
|
|
96
|
+
know: "\u6211\u77E5\u9053\u4E86",
|
|
97
|
+
relatedSubscription: "\u8BA2\u9605"
|
|
97
98
|
},
|
|
98
99
|
payment: {
|
|
99
100
|
checkout: {
|
|
@@ -237,12 +238,13 @@ export default flat({
|
|
|
237
238
|
pastDue: {
|
|
238
239
|
button: "\u7EED\u8D39",
|
|
239
240
|
invoices: "\u6B20\u8D39\u5E10\u5355",
|
|
240
|
-
warning: "\u8BF7\u5C3D\u5FEB\u652F\u4ED8\u6B20\u8D39\u8D26\u5355\uFF0C\u5426\u5219\u4F60\u5C06\u65E0\u6CD5\u7EE7\u7EED\u4F7F\u7528\u670D\u52A1\u6216\u8D2D\u4E70\u65B0\u670D\u52A1\
|
|
241
|
+
warning: "\u8BF7\u5C3D\u5FEB\u652F\u4ED8\u6B20\u8D39\u8D26\u5355\uFF0C\u5426\u5219\u4F60\u5C06\u65E0\u6CD5\u7EE7\u7EED\u4F7F\u7528\u670D\u52A1\u6216\u8D2D\u4E70\u65B0\u670D\u52A1\u3002",
|
|
241
242
|
alert: {
|
|
242
243
|
title: "\u4F60\u6709\u6B20\u8D39\u8D26\u5355",
|
|
243
244
|
description: "\u770B\u8D77\u6765\u4F60\u6709\u6B20\u8D39\u7684\u8D26\u5355\uFF0C\u5728\u4F60\u652F\u4ED8\u6240\u6709\u6B20\u8D39\u8D26\u5355\u4E4B\u524D\uFF0C\u65B0\u7684\u8D2D\u4E70\u6216\u8005\u8BA2\u9605\u5C06\u88AB\u7981\u6B62\uFF0C\u8BF7\u4E0D\u8981\u8C03\u76AE\u3002",
|
|
244
245
|
confirm: "\u53BB\u652F\u4ED8"
|
|
245
|
-
}
|
|
246
|
+
},
|
|
247
|
+
view: "\u67E5\u770B\u6B20\u8D39\u660E\u7EC6"
|
|
246
248
|
},
|
|
247
249
|
recover: {
|
|
248
250
|
button: "\u6062\u590D\u8BA2\u9605",
|
|
@@ -291,7 +293,8 @@ export default flat({
|
|
|
291
293
|
empty: "\u6CA1\u6709\u4EFB\u4F55\u8D26\u5355",
|
|
292
294
|
next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210",
|
|
293
295
|
invoiceNumber: "\u8D26\u5355\u7F16\u53F7",
|
|
294
|
-
emptyList: "\u6CA1\u6709\u8D26\u5355"
|
|
296
|
+
emptyList: "\u6CA1\u6709\u8D26\u5355",
|
|
297
|
+
noPaymentRequired: "\u65E0\u9700\u652F\u4ED8"
|
|
295
298
|
},
|
|
296
299
|
payment: {
|
|
297
300
|
empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55",
|
|
@@ -312,6 +315,11 @@ export default flat({
|
|
|
312
315
|
changePayment: "\u5207\u6362\u652F\u4ED8\u65B9\u5F0F",
|
|
313
316
|
trialLeft: "\u5269\u4F59\u8BD5\u7528\u65F6\u957F",
|
|
314
317
|
owner: "\u8BA2\u9605\u62E5\u6709\u8005"
|
|
318
|
+
},
|
|
319
|
+
overdue: {
|
|
320
|
+
title: "\u60A8\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u6D89\u53CA {subscriptionCount} \u4E2A\u8BA2\u9605\uFF0C\u603B\u91D1\u989D {total} {symbol}{method}\u3002\u8BF7\u7ACB\u5373\u652F\u4ED8\uFF0C\u4EE5\u514D\u5F71\u54CD\u60A8\u7684\u4F7F\u7528\u3002",
|
|
321
|
+
simpleTitle: "\u60A8\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u8BF7\u7ACB\u5373\u652F\u4ED8\uFF0C\u4EE5\u514D\u5F71\u54CD\u60A8\u7684\u4F7F\u7528\u3002",
|
|
322
|
+
empty: "\u606D\u559C\uFF01\u60A8\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355\u3002"
|
|
315
323
|
}
|
|
316
324
|
},
|
|
317
325
|
invoice: {
|
|
@@ -341,17 +349,19 @@ export default flat({
|
|
|
341
349
|
},
|
|
342
350
|
subscription: {
|
|
343
351
|
overdue: {
|
|
344
|
-
title: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5171\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u603B\u8BA1 {total} {symbol}\uFF0C\u60A8\u9700\u8981\u652F\u4ED8\u8FD9\u4E9B\u8D26\u5355\u4EE5\u6FC0\u6D3B\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u5728\u8FDB\u884C\u65B0\u7684\u8D2D\u4E70\u4E4B\u524D\u5B8C\u6210\u652F\u4ED8\u3002",
|
|
352
|
+
title: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5171\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u603B\u8BA1 {total} {symbol}{method}\uFF0C\u60A8\u9700\u8981\u652F\u4ED8\u8FD9\u4E9B\u8D26\u5355\u4EE5\u6FC0\u6D3B\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u5728\u8FDB\u884C\u65B0\u7684\u8D2D\u4E70\u4E4B\u524D\u5B8C\u6210\u652F\u4ED8\u3002",
|
|
345
353
|
simpleTitle: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5171\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u60A8\u9700\u8981\u652F\u4ED8\u8FD9\u4E9B\u8D26\u5355\u4EE5\u6FC0\u6D3B\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u5728\u8FDB\u884C\u65B0\u7684\u8D2D\u4E70\u4E4B\u524D\u5B8C\u6210\u652F\u4ED8\u3002",
|
|
346
354
|
payNow: "\u7ACB\u5373\u652F\u4ED8",
|
|
347
355
|
notSupport: "\u6682\u4E0D\u652F\u6301\u8BE5\u652F\u4ED8\u65B9\u5F0F",
|
|
348
|
-
total: "\u603B\u8BA1 {total} {currency}",
|
|
356
|
+
total: "\u603B\u8BA1 {total} {currency}{method}",
|
|
349
357
|
view: "\u67E5\u770B\u8BA2\u9605\u8BE6\u60C5",
|
|
350
358
|
pastDue: "\u6B20\u8D39\u8D26\u5355",
|
|
351
359
|
viewNow: "\u7ACB\u5373\u67E5\u770B",
|
|
352
360
|
description: "\u5982\u679C\u60A8\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u53EF\u4EE5\u9009\u62E9 ",
|
|
353
361
|
list: "\u6B20\u8D39\u8D26\u5355\uFF1A",
|
|
354
|
-
empty: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355"
|
|
362
|
+
empty: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355",
|
|
363
|
+
retry: "\u91CD\u65B0\u652F\u4ED8",
|
|
364
|
+
paid: "\u5DF2\u652F\u4ED8"
|
|
355
365
|
}
|
|
356
366
|
}
|
|
357
367
|
},
|
|
@@ -11,74 +11,72 @@ export default function AddressForm({ mode, stripe, sx = {} }) {
|
|
|
11
11
|
const { t } = useLocaleContext();
|
|
12
12
|
const { control } = useFormContext();
|
|
13
13
|
if (mode === "required") {
|
|
14
|
-
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */
|
|
15
|
-
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t(
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsx(Stack, { className: "cko-payment-address cko-payment-form", sx, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", className: "cko-payment-form", spacing: 0, children: [
|
|
15
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.line1") }),
|
|
16
|
+
/* @__PURE__ */ jsx(
|
|
17
|
+
FormInput,
|
|
18
|
+
{
|
|
19
|
+
name: "billing_address.line1",
|
|
20
|
+
rules: { required: t("payment.checkout.required") },
|
|
21
|
+
errorPosition: "right",
|
|
22
|
+
variant: "outlined",
|
|
23
|
+
placeholder: t("payment.checkout.billing.line1")
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.city") }),
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
FormInput,
|
|
29
|
+
{
|
|
30
|
+
name: "billing_address.city",
|
|
31
|
+
rules: { required: t("payment.checkout.required") },
|
|
32
|
+
errorPosition: "right",
|
|
33
|
+
variant: "outlined",
|
|
34
|
+
placeholder: t("payment.checkout.billing.city")
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.state") }),
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
FormInput,
|
|
40
|
+
{
|
|
41
|
+
name: "billing_address.state",
|
|
42
|
+
rules: { required: t("payment.checkout.required") },
|
|
43
|
+
errorPosition: "right",
|
|
44
|
+
variant: "outlined",
|
|
45
|
+
placeholder: t("payment.checkout.billing.state")
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.postal_code") }),
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
FormInput,
|
|
51
|
+
{
|
|
52
|
+
name: "billing_address.postal_code",
|
|
53
|
+
rules: { required: t("payment.checkout.required") },
|
|
54
|
+
errorPosition: "right",
|
|
55
|
+
variant: "outlined",
|
|
56
|
+
placeholder: t("payment.checkout.billing.postal_code"),
|
|
57
|
+
InputProps: {
|
|
58
|
+
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", style: { marginRight: "2px", marginLeft: "-8px" }, children: /* @__PURE__ */ jsx(
|
|
59
|
+
Controller,
|
|
60
|
+
{
|
|
61
|
+
name: "billing_address.country",
|
|
62
|
+
control,
|
|
63
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
64
|
+
CountrySelect,
|
|
65
|
+
{
|
|
66
|
+
...field,
|
|
67
|
+
sx: {
|
|
68
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
69
|
+
borderColor: "transparent"
|
|
39
70
|
}
|
|
40
71
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
) }),
|
|
47
|
-
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.state") }),
|
|
48
|
-
/* @__PURE__ */ jsx(
|
|
49
|
-
FormInput,
|
|
50
|
-
{
|
|
51
|
-
name: "billing_address.state",
|
|
52
|
-
rules: { required: t("payment.checkout.required") },
|
|
53
|
-
errorPosition: "right",
|
|
54
|
-
variant: "outlined",
|
|
55
|
-
placeholder: t("payment.checkout.billing.state")
|
|
56
|
-
}
|
|
57
|
-
),
|
|
58
|
-
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.line1") }),
|
|
59
|
-
/* @__PURE__ */ jsx(
|
|
60
|
-
FormInput,
|
|
61
|
-
{
|
|
62
|
-
name: "billing_address.line1",
|
|
63
|
-
rules: { required: t("payment.checkout.required") },
|
|
64
|
-
errorPosition: "right",
|
|
65
|
-
variant: "outlined",
|
|
66
|
-
placeholder: t("payment.checkout.billing.line1")
|
|
67
|
-
}
|
|
68
|
-
),
|
|
69
|
-
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.city") }),
|
|
70
|
-
/* @__PURE__ */ jsx(
|
|
71
|
-
FormInput,
|
|
72
|
-
{
|
|
73
|
-
name: "billing_address.city",
|
|
74
|
-
rules: { required: t("payment.checkout.required") },
|
|
75
|
-
errorPosition: "right",
|
|
76
|
-
variant: "outlined",
|
|
77
|
-
placeholder: t("payment.checkout.billing.city")
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
) })
|
|
78
76
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
] }) });
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
] }) }) });
|
|
82
80
|
}
|
|
83
81
|
if (stripe) {
|
|
84
82
|
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-address cko-payment-form", sx, children: [
|
|
@@ -4,11 +4,13 @@ export declare const waitForCheckoutComplete: (sessionId: string) => Promise<Che
|
|
|
4
4
|
export declare const hasDidWallet: (user: any) => any;
|
|
5
5
|
type PageData = CheckoutContext & CheckoutCallbacks & {
|
|
6
6
|
onlyShowBtn?: boolean;
|
|
7
|
+
isDonation?: boolean;
|
|
7
8
|
};
|
|
8
|
-
declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, currencyId, onlyShowBtn, }: PageData): import("react").JSX.Element;
|
|
9
|
+
declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, currencyId, onlyShowBtn, isDonation, }: PageData): import("react").JSX.Element;
|
|
9
10
|
declare namespace PaymentForm {
|
|
10
11
|
var defaultProps: {
|
|
11
12
|
onlyShowBtn: boolean;
|
|
13
|
+
isDonation: boolean;
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
16
|
export default PaymentForm;
|
package/es/payment/form/index.js
CHANGED
|
@@ -54,7 +54,8 @@ export const hasDidWallet = (user) => {
|
|
|
54
54
|
return connected.some((x) => x.provider === "wallet");
|
|
55
55
|
};
|
|
56
56
|
PaymentForm.defaultProps = {
|
|
57
|
-
onlyShowBtn: false
|
|
57
|
+
onlyShowBtn: false,
|
|
58
|
+
isDonation: false
|
|
58
59
|
};
|
|
59
60
|
export default function PaymentForm({
|
|
60
61
|
checkoutSession,
|
|
@@ -67,7 +68,8 @@ export default function PaymentForm({
|
|
|
67
68
|
// mode,
|
|
68
69
|
action,
|
|
69
70
|
currencyId,
|
|
70
|
-
onlyShowBtn
|
|
71
|
+
onlyShowBtn,
|
|
72
|
+
isDonation = false
|
|
71
73
|
}) {
|
|
72
74
|
const { t } = useLocaleContext();
|
|
73
75
|
const { isMobile } = useMobile();
|
|
@@ -170,8 +172,9 @@ export default function PaymentForm({
|
|
|
170
172
|
} else {
|
|
171
173
|
buttonText = t(`payment.checkout.${checkoutSession.mode}`);
|
|
172
174
|
}
|
|
173
|
-
buttonText = session?.user ? buttonText : t("payment.checkout.connect", { action: buttonText });
|
|
175
|
+
buttonText = session?.user || isDonation ? buttonText : t("payment.checkout.connect", { action: buttonText });
|
|
174
176
|
const method = paymentMethods.find((x) => x.id === paymentMethod);
|
|
177
|
+
const isDonationMode = checkoutSession?.submit_type === "donate" && isDonation;
|
|
175
178
|
const showForm = session?.user;
|
|
176
179
|
const skipBindWallet = method.type === "stripe";
|
|
177
180
|
const handleConnected = async () => {
|
|
@@ -228,7 +231,12 @@ export default function PaymentForm({
|
|
|
228
231
|
const onFormSubmit = async (data) => {
|
|
229
232
|
setState({ submitting: true });
|
|
230
233
|
try {
|
|
231
|
-
|
|
234
|
+
let result;
|
|
235
|
+
if (isDonationMode) {
|
|
236
|
+
result = await api.put(`/api/checkout-sessions/${checkoutSession.id}/donate-submit`, data);
|
|
237
|
+
} else {
|
|
238
|
+
result = await api.put(`/api/checkout-sessions/${checkoutSession.id}/submit`, data);
|
|
239
|
+
}
|
|
232
240
|
setState({
|
|
233
241
|
paymentIntent: result.data.paymentIntent,
|
|
234
242
|
stripeContext: result.data.stripeContext,
|
|
@@ -238,7 +246,7 @@ export default function PaymentForm({
|
|
|
238
246
|
});
|
|
239
247
|
if (["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
240
248
|
setState({ paying: true });
|
|
241
|
-
if (result.data.balance?.sufficient || result.data.delegation?.sufficient) {
|
|
249
|
+
if ((result.data.balance?.sufficient || result.data.delegation?.sufficient) && !isDonationMode) {
|
|
242
250
|
await handleConnected();
|
|
243
251
|
} else {
|
|
244
252
|
connect.open({
|
|
@@ -314,6 +322,10 @@ export default function PaymentForm({
|
|
|
314
322
|
});
|
|
315
323
|
}
|
|
316
324
|
} else {
|
|
325
|
+
if (isDonationMode) {
|
|
326
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
317
329
|
session?.login(() => {
|
|
318
330
|
setState({ submitting: true });
|
|
319
331
|
onUserLoggedIn().then(afterUserLoggedIn).catch((err) => {
|
package/lib/checkout/donate.js
CHANGED
|
@@ -11,7 +11,7 @@ var _context = require("@arcblock/ux/lib/Locale/context");
|
|
|
11
11
|
var _material = require("@mui/material");
|
|
12
12
|
var _ahooks = require("ahooks");
|
|
13
13
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
14
|
-
var
|
|
14
|
+
var _uniqBy = _interopRequireDefault(require("lodash/uniqBy"));
|
|
15
15
|
var _react = require("react");
|
|
16
16
|
var _iconsMaterial = require("@mui/icons-material");
|
|
17
17
|
var _api = _interopRequireDefault(require("../libs/api"));
|
|
@@ -104,7 +104,7 @@ function DonateDetails({
|
|
|
104
104
|
},
|
|
105
105
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
|
|
106
106
|
src: (0, _util.getCustomerAvatar)(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 20),
|
|
107
|
-
alt: x.customer?.name,
|
|
107
|
+
alt: x.customer?.metadata?.anonymous ? "" : x.customer?.name,
|
|
108
108
|
variant: "circular",
|
|
109
109
|
sx: {
|
|
110
110
|
width: 20,
|
|
@@ -112,6 +112,9 @@ function DonateDetails({
|
|
|
112
112
|
},
|
|
113
113
|
onClick: e => {
|
|
114
114
|
e.stopPropagation();
|
|
115
|
+
if (x.customer?.metadata?.anonymous) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
115
118
|
if (x.customer?.did) {
|
|
116
119
|
window.open((0, _util.getUserProfileLink)(x.customer?.did, locale), "_blank");
|
|
117
120
|
}
|
|
@@ -126,6 +129,9 @@ function DonateDetails({
|
|
|
126
129
|
textOverflow: "ellipsis"
|
|
127
130
|
},
|
|
128
131
|
onClick: e => {
|
|
132
|
+
if (x.customer?.metadata?.anonymous) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
129
135
|
e.stopPropagation();
|
|
130
136
|
if (x.customer?.did) {
|
|
131
137
|
window.open((0, _util.getUserProfileLink)(x.customer?.did, locale), "_blank");
|
|
@@ -172,7 +178,7 @@ function SupporterAvatar({
|
|
|
172
178
|
showDonateDetails = false
|
|
173
179
|
}) {
|
|
174
180
|
const [open, setOpen] = (0, _react.useState)(false);
|
|
175
|
-
const customers = (0,
|
|
181
|
+
const customers = (0, _uniqBy.default)(supporters, "customer_id");
|
|
176
182
|
const customersNum = customers.length;
|
|
177
183
|
if (customersNum === 0) return null;
|
|
178
184
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
@@ -183,12 +189,15 @@ function SupporterAvatar({
|
|
|
183
189
|
max: 5,
|
|
184
190
|
sx: {
|
|
185
191
|
"& .MuiAvatar-root": {
|
|
186
|
-
backgroundColor: "background.paper"
|
|
192
|
+
backgroundColor: "background.paper",
|
|
193
|
+
"&.MuiAvatar-colorDefault": {
|
|
194
|
+
backgroundColor: "#bdbdbd"
|
|
195
|
+
}
|
|
187
196
|
}
|
|
188
197
|
},
|
|
189
198
|
children: customers.slice(0, 5).map(supporter => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
|
|
190
199
|
src: (0, _util.getCustomerAvatar)(supporter.customer?.did, supporter?.updated_at ? new Date(supporter.updated_at).toISOString() : "", 24),
|
|
191
|
-
alt: supporter.customer?.name,
|
|
200
|
+
alt: supporter.customer?.metadata?.anonymous ? "" : supporter.customer?.name,
|
|
192
201
|
sx: {
|
|
193
202
|
width: "24px",
|
|
194
203
|
height: "24px"
|
|
@@ -238,7 +247,7 @@ function SupporterTable({
|
|
|
238
247
|
currency,
|
|
239
248
|
method
|
|
240
249
|
}) {
|
|
241
|
-
const customers = (0,
|
|
250
|
+
const customers = (0, _uniqBy.default)(supporters, "customer_id");
|
|
242
251
|
const customersNum = customers.length;
|
|
243
252
|
if (customersNum === 0) return null;
|
|
244
253
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
@@ -271,7 +280,7 @@ function SupporterSimple({
|
|
|
271
280
|
const {
|
|
272
281
|
t
|
|
273
282
|
} = (0, _context.useLocaleContext)();
|
|
274
|
-
const customers = (0,
|
|
283
|
+
const customers = (0, _uniqBy.default)(supporters, "customer_id");
|
|
275
284
|
const customersNum = customers.length;
|
|
276
285
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
277
286
|
display: "flex",
|
|
@@ -297,7 +306,7 @@ function SupporterSimple({
|
|
|
297
306
|
max: 10,
|
|
298
307
|
children: customers.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
|
|
299
308
|
title: x.customer?.name,
|
|
300
|
-
alt: x.customer?.name,
|
|
309
|
+
alt: x.customer?.metadata?.anonymous ? "" : x.customer?.name,
|
|
301
310
|
src: (0, _util.getCustomerAvatar)(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
|
|
302
311
|
variant: "circular",
|
|
303
312
|
sx: {
|
|
@@ -410,7 +419,7 @@ function CheckoutDonateInner({
|
|
|
410
419
|
donateSettings,
|
|
411
420
|
supportUpdateSettings
|
|
412
421
|
} = useDonation(settings, livemode, mode);
|
|
413
|
-
const customers = (0,
|
|
422
|
+
const customers = (0, _uniqBy.default)(supporters?.data?.supporters || [], "customer_did");
|
|
414
423
|
const {
|
|
415
424
|
t
|
|
416
425
|
} = (0, _context.useLocaleContext)();
|