@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
|
@@ -73,7 +73,8 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
73
73
|
include_staking,
|
|
74
74
|
include_return_staking,
|
|
75
75
|
include_recovered_from,
|
|
76
|
-
onTableDataChange
|
|
76
|
+
onTableDataChange,
|
|
77
|
+
relatedSubscription
|
|
77
78
|
} = props;
|
|
78
79
|
const listKey = "invoice-table";
|
|
79
80
|
const {
|
|
@@ -141,6 +142,11 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
141
142
|
target: link.external ? "_blank" : target
|
|
142
143
|
});
|
|
143
144
|
};
|
|
145
|
+
const handleRelatedSubscriptionClick = (e, invoice) => {
|
|
146
|
+
if (invoice.subscription_id) {
|
|
147
|
+
(0, _navigation.handleNavigation)(e, (0, _navigation.createLink)(`/customer/subscription/${invoice.subscription_id}`), navigate);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
144
150
|
const columns = [{
|
|
145
151
|
label: t("common.amount"),
|
|
146
152
|
name: "total",
|
|
@@ -149,10 +155,14 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
149
155
|
options: {
|
|
150
156
|
customBodyRenderLite: (_, index) => {
|
|
151
157
|
const invoice = data?.list[index];
|
|
158
|
+
const isVoid = invoice.status === "void";
|
|
152
159
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
153
160
|
onClick: e => handleLinkClick(e, invoice),
|
|
154
161
|
sx: linkStyle,
|
|
155
162
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
163
|
+
sx: isVoid ? {
|
|
164
|
+
textDecoration: "line-through"
|
|
165
|
+
} : {},
|
|
156
166
|
children: [(0, _util.formatBNStr)(invoice.total, invoice.paymentCurrency.decimal), "\xA0", invoice.paymentCurrency.symbol]
|
|
157
167
|
})
|
|
158
168
|
});
|
|
@@ -186,7 +196,30 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
186
196
|
});
|
|
187
197
|
}
|
|
188
198
|
}
|
|
189
|
-
}, {
|
|
199
|
+
}, ...(relatedSubscription ? [{
|
|
200
|
+
label: t("common.relatedSubscription"),
|
|
201
|
+
name: "subscription",
|
|
202
|
+
options: {
|
|
203
|
+
customBodyRenderLite: (_, index) => {
|
|
204
|
+
const invoice = data?.list[index];
|
|
205
|
+
return invoice.subscription_id ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
206
|
+
onClick: e => handleRelatedSubscriptionClick(e, invoice),
|
|
207
|
+
sx: {
|
|
208
|
+
color: "text.link",
|
|
209
|
+
cursor: "pointer"
|
|
210
|
+
},
|
|
211
|
+
children: invoice.subscription?.description
|
|
212
|
+
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
213
|
+
onClick: e => handleLinkClick(e, invoice),
|
|
214
|
+
sx: {
|
|
215
|
+
...linkStyle,
|
|
216
|
+
color: "text.lighter"
|
|
217
|
+
},
|
|
218
|
+
children: t("common.none")
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}] : []), {
|
|
190
223
|
label: t("common.updatedAt"),
|
|
191
224
|
name: "name",
|
|
192
225
|
options: {
|
|
@@ -195,7 +228,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
195
228
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
196
229
|
onClick: e => handleLinkClick(e, invoice),
|
|
197
230
|
sx: linkStyle,
|
|
198
|
-
children: (0, _util.formatToDate)(invoice.created_at, locale, "YYYY-MM-DD HH:mm:ss")
|
|
231
|
+
children: (0, _util.formatToDate)(invoice.created_at, locale, relatedSubscription ? "YYYY-MM-DD HH:mm" : "YYYY-MM-DD HH:mm:ss")
|
|
199
232
|
});
|
|
200
233
|
}
|
|
201
234
|
}
|
|
@@ -223,6 +256,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
223
256
|
const {
|
|
224
257
|
connect
|
|
225
258
|
} = getInvoiceLink(invoice, action);
|
|
259
|
+
const isVoid = invoice.status === "void";
|
|
226
260
|
if (action && !hidePay) {
|
|
227
261
|
return connect ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
228
262
|
variant: "text",
|
|
@@ -247,7 +281,17 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
247
281
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
248
282
|
onClick: e => handleLinkClick(e, invoice),
|
|
249
283
|
sx: linkStyle,
|
|
250
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
284
|
+
children: isVoid ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
285
|
+
title: t("payment.customer.invoice.noPaymentRequired"),
|
|
286
|
+
arrow: true,
|
|
287
|
+
placement: "top",
|
|
288
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
|
|
289
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
290
|
+
label: invoice.status,
|
|
291
|
+
color: (0, _util.getInvoiceStatusColor)(invoice.status)
|
|
292
|
+
})
|
|
293
|
+
})
|
|
294
|
+
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
251
295
|
label: invoice.status,
|
|
252
296
|
color: (0, _util.getInvoiceStatusColor)(invoice.status)
|
|
253
297
|
})
|
|
@@ -432,6 +476,7 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
432
476
|
link,
|
|
433
477
|
connect
|
|
434
478
|
} = getInvoiceLink(invoice, action);
|
|
479
|
+
const isVoid = invoice.status === "void";
|
|
435
480
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
436
481
|
direction: "row",
|
|
437
482
|
sx: {
|
|
@@ -458,14 +503,15 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
458
503
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
459
504
|
component: "span",
|
|
460
505
|
children: invoice.number
|
|
461
|
-
}), link.external && /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
506
|
+
}), link.external && /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.OpenInNewOutlined, {
|
|
507
|
+
fontSize: "small",
|
|
508
|
+
sx: {
|
|
509
|
+
color: "text.secondary",
|
|
510
|
+
display: {
|
|
511
|
+
xs: "none",
|
|
512
|
+
md: "inline-flex"
|
|
467
513
|
}
|
|
468
|
-
}
|
|
514
|
+
}
|
|
469
515
|
})]
|
|
470
516
|
})
|
|
471
517
|
})
|
|
@@ -473,6 +519,9 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
473
519
|
flex: 1,
|
|
474
520
|
textAlign: "right",
|
|
475
521
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
522
|
+
sx: isVoid ? {
|
|
523
|
+
textDecoration: "line-through"
|
|
524
|
+
} : {},
|
|
476
525
|
children: [(0, _util.formatBNStr)(invoice.total, invoice.paymentCurrency.decimal), "\xA0", invoice.paymentCurrency.symbol]
|
|
477
526
|
})
|
|
478
527
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
@@ -481,15 +530,18 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
481
530
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
482
531
|
children: (0, _util.formatToDate)(invoice.created_at, locale, "HH:mm:ss")
|
|
483
532
|
})
|
|
484
|
-
}), !action && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
533
|
+
}), !action && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
534
|
+
flex: 2,
|
|
535
|
+
className: "invoice-description",
|
|
536
|
+
textAlign: "right",
|
|
537
|
+
sx: {
|
|
538
|
+
display: {
|
|
539
|
+
xs: "none",
|
|
540
|
+
lg: "inline-flex"
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
544
|
+
children: invoice.description || invoice.id
|
|
493
545
|
})
|
|
494
546
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
495
547
|
flex: 1,
|
|
@@ -513,6 +565,16 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
513
565
|
},
|
|
514
566
|
rel: "noreferrer",
|
|
515
567
|
children: t("payment.customer.invoice.pay")
|
|
568
|
+
}) : isVoid ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
569
|
+
title: t("payment.customer.invoice.noPaymentRequired"),
|
|
570
|
+
arrow: true,
|
|
571
|
+
placement: "top",
|
|
572
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
|
|
573
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
574
|
+
label: invoice.status,
|
|
575
|
+
color: (0, _util.getInvoiceStatusColor)(invoice.status)
|
|
576
|
+
})
|
|
577
|
+
})
|
|
516
578
|
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
517
579
|
label: invoice.status,
|
|
518
580
|
color: (0, _util.getInvoiceStatusColor)(invoice.status)
|
|
@@ -618,15 +680,13 @@ CustomerInvoiceList.defaultProps = {
|
|
|
618
680
|
target: "_self",
|
|
619
681
|
action: "",
|
|
620
682
|
type: "list",
|
|
621
|
-
onTableDataChange: () => {}
|
|
683
|
+
onTableDataChange: () => {},
|
|
684
|
+
relatedSubscription: false
|
|
622
685
|
};
|
|
623
686
|
const Root = (0, _system.styled)(_material.Stack)`
|
|
624
687
|
@media (max-width: ${({
|
|
625
688
|
theme
|
|
626
689
|
}) => theme.breakpoints.values.md}px) {
|
|
627
|
-
.invoice-description {
|
|
628
|
-
display: none !important;
|
|
629
|
-
}
|
|
630
690
|
svg.MuiSvgIcon-root {
|
|
631
691
|
display: none !important;
|
|
632
692
|
}
|
package/lib/locales/en.js
CHANGED
|
@@ -100,7 +100,8 @@ module.exports = (0, _flat.default)({
|
|
|
100
100
|
saveAsDefaultPriceSuccess: "Set default price successfully",
|
|
101
101
|
stakeAmount: "Stake Amount",
|
|
102
102
|
slashStakeAmount: "Slash Stake Amount",
|
|
103
|
-
know: "I know"
|
|
103
|
+
know: "I know",
|
|
104
|
+
relatedSubscription: "Subscription"
|
|
104
105
|
},
|
|
105
106
|
payment: {
|
|
106
107
|
checkout: {
|
|
@@ -244,12 +245,13 @@ module.exports = (0, _flat.default)({
|
|
|
244
245
|
pastDue: {
|
|
245
246
|
button: "Pay",
|
|
246
247
|
invoices: "Past Due Invoices",
|
|
247
|
-
warning: "Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore.
|
|
248
|
+
warning: "Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore.",
|
|
248
249
|
alert: {
|
|
249
250
|
title: "You have unpaid invoices",
|
|
250
251
|
description: "Seems you have unpaid invoices from previous subscriptions, new purchases are not allowed unless you have paid all past due invoices.",
|
|
251
252
|
confirm: "Pay Now"
|
|
252
|
-
}
|
|
253
|
+
},
|
|
254
|
+
view: "View Due Invoices"
|
|
253
255
|
},
|
|
254
256
|
recover: {
|
|
255
257
|
button: "Resume Subscription",
|
|
@@ -298,7 +300,8 @@ module.exports = (0, _flat.default)({
|
|
|
298
300
|
empty: "There are no invoices",
|
|
299
301
|
next: "No invoices yet, next invoice will be generated on {date}",
|
|
300
302
|
invoiceNumber: "Invoice Number",
|
|
301
|
-
emptyList: "No Invoice"
|
|
303
|
+
emptyList: "No Invoice",
|
|
304
|
+
noPaymentRequired: "No Payment Required"
|
|
302
305
|
},
|
|
303
306
|
payment: {
|
|
304
307
|
empty: "There are no payments",
|
|
@@ -319,6 +322,11 @@ module.exports = (0, _flat.default)({
|
|
|
319
322
|
changePayment: "Change payment method",
|
|
320
323
|
trialLeft: "Trail Left",
|
|
321
324
|
owner: "Subscription Owner"
|
|
325
|
+
},
|
|
326
|
+
overdue: {
|
|
327
|
+
title: "You have {count} due invoices for {subscriptionCount} subscriptions, totaling {total} {symbol}{method}. Please pay immediately to avoid service disruption.",
|
|
328
|
+
simpleTitle: "You have {count} due invoices. Please pay now to ensure uninterrupted service.",
|
|
329
|
+
empty: "Great! You have no due invoices."
|
|
322
330
|
}
|
|
323
331
|
},
|
|
324
332
|
invoice: {
|
|
@@ -349,16 +357,18 @@ module.exports = (0, _flat.default)({
|
|
|
349
357
|
subscription: {
|
|
350
358
|
overdue: {
|
|
351
359
|
simpleTitle: "There are {count} due invoices for your subscription {name}, you need to pay them to activate your subscription or before making new purchases.",
|
|
352
|
-
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.",
|
|
360
|
+
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.",
|
|
353
361
|
payNow: "Pay Now",
|
|
354
362
|
notSupport: "This payment method is not supported",
|
|
355
|
-
total: "Total {total} {currency}",
|
|
363
|
+
total: "Total {total} {currency}{method}",
|
|
356
364
|
view: "View Subscription Details",
|
|
357
365
|
viewNow: "View Now",
|
|
358
366
|
pastDue: "Past Due Invoices",
|
|
359
367
|
description: "If you have any questions, you can choose ",
|
|
360
368
|
list: "Past Due Invoices:",
|
|
361
|
-
empty: "There are no overdue invoices for your subscription {name}."
|
|
369
|
+
empty: "There are no overdue invoices for your subscription {name}.",
|
|
370
|
+
retry: "Retry",
|
|
371
|
+
paid: "Paid"
|
|
362
372
|
}
|
|
363
373
|
}
|
|
364
374
|
},
|
package/lib/locales/zh.js
CHANGED
|
@@ -100,7 +100,8 @@ module.exports = (0, _flat.default)({
|
|
|
100
100
|
saveAsDefaultPriceSuccess: "\u8BBE\u7F6E\u9ED8\u8BA4\u4EF7\u683C\u6210\u529F",
|
|
101
101
|
stakeAmount: "\u8D28\u62BC\u91D1\u989D",
|
|
102
102
|
slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D",
|
|
103
|
-
know: "\u6211\u77E5\u9053\u4E86"
|
|
103
|
+
know: "\u6211\u77E5\u9053\u4E86",
|
|
104
|
+
relatedSubscription: "\u8BA2\u9605"
|
|
104
105
|
},
|
|
105
106
|
payment: {
|
|
106
107
|
checkout: {
|
|
@@ -244,12 +245,13 @@ module.exports = (0, _flat.default)({
|
|
|
244
245
|
pastDue: {
|
|
245
246
|
button: "\u7EED\u8D39",
|
|
246
247
|
invoices: "\u6B20\u8D39\u5E10\u5355",
|
|
247
|
-
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\
|
|
248
|
+
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",
|
|
248
249
|
alert: {
|
|
249
250
|
title: "\u4F60\u6709\u6B20\u8D39\u8D26\u5355",
|
|
250
251
|
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",
|
|
251
252
|
confirm: "\u53BB\u652F\u4ED8"
|
|
252
|
-
}
|
|
253
|
+
},
|
|
254
|
+
view: "\u67E5\u770B\u6B20\u8D39\u660E\u7EC6"
|
|
253
255
|
},
|
|
254
256
|
recover: {
|
|
255
257
|
button: "\u6062\u590D\u8BA2\u9605",
|
|
@@ -298,7 +300,8 @@ module.exports = (0, _flat.default)({
|
|
|
298
300
|
empty: "\u6CA1\u6709\u4EFB\u4F55\u8D26\u5355",
|
|
299
301
|
next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210",
|
|
300
302
|
invoiceNumber: "\u8D26\u5355\u7F16\u53F7",
|
|
301
|
-
emptyList: "\u6CA1\u6709\u8D26\u5355"
|
|
303
|
+
emptyList: "\u6CA1\u6709\u8D26\u5355",
|
|
304
|
+
noPaymentRequired: "\u65E0\u9700\u652F\u4ED8"
|
|
302
305
|
},
|
|
303
306
|
payment: {
|
|
304
307
|
empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55",
|
|
@@ -319,6 +322,11 @@ module.exports = (0, _flat.default)({
|
|
|
319
322
|
changePayment: "\u5207\u6362\u652F\u4ED8\u65B9\u5F0F",
|
|
320
323
|
trialLeft: "\u5269\u4F59\u8BD5\u7528\u65F6\u957F",
|
|
321
324
|
owner: "\u8BA2\u9605\u62E5\u6709\u8005"
|
|
325
|
+
},
|
|
326
|
+
overdue: {
|
|
327
|
+
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",
|
|
328
|
+
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",
|
|
329
|
+
empty: "\u606D\u559C\uFF01\u60A8\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355\u3002"
|
|
322
330
|
}
|
|
323
331
|
},
|
|
324
332
|
invoice: {
|
|
@@ -348,17 +356,19 @@ module.exports = (0, _flat.default)({
|
|
|
348
356
|
},
|
|
349
357
|
subscription: {
|
|
350
358
|
overdue: {
|
|
351
|
-
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",
|
|
359
|
+
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",
|
|
352
360
|
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",
|
|
353
361
|
payNow: "\u7ACB\u5373\u652F\u4ED8",
|
|
354
362
|
notSupport: "\u6682\u4E0D\u652F\u6301\u8BE5\u652F\u4ED8\u65B9\u5F0F",
|
|
355
|
-
total: "\u603B\u8BA1 {total} {currency}",
|
|
363
|
+
total: "\u603B\u8BA1 {total} {currency}{method}",
|
|
356
364
|
view: "\u67E5\u770B\u8BA2\u9605\u8BE6\u60C5",
|
|
357
365
|
pastDue: "\u6B20\u8D39\u8D26\u5355",
|
|
358
366
|
viewNow: "\u7ACB\u5373\u67E5\u770B",
|
|
359
367
|
description: "\u5982\u679C\u60A8\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u53EF\u4EE5\u9009\u62E9 ",
|
|
360
368
|
list: "\u6B20\u8D39\u8D26\u5355\uFF1A",
|
|
361
|
-
empty: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355"
|
|
369
|
+
empty: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355",
|
|
370
|
+
retry: "\u91CD\u65B0\u652F\u4ED8",
|
|
371
|
+
paid: "\u5DF2\u652F\u4ED8"
|
|
362
372
|
}
|
|
363
373
|
}
|
|
364
374
|
},
|
|
@@ -28,86 +28,82 @@ function AddressForm({
|
|
|
28
28
|
if (mode === "required") {
|
|
29
29
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
30
30
|
in: true,
|
|
31
|
-
children: /* @__PURE__ */(0, _jsxRuntime.
|
|
31
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
32
32
|
className: "cko-payment-address cko-payment-form",
|
|
33
33
|
sx,
|
|
34
|
-
children:
|
|
35
|
-
className: "base-label",
|
|
36
|
-
children: t(`payment.checkout.billing.${mode}`)
|
|
37
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
34
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
38
35
|
direction: "column",
|
|
39
36
|
className: "cko-payment-form",
|
|
40
37
|
spacing: 0,
|
|
41
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
InputProps: {
|
|
53
|
-
startAdornment: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.InputAdornment, {
|
|
54
|
-
position: "start",
|
|
55
|
-
style: {
|
|
56
|
-
marginRight: "2px",
|
|
57
|
-
marginLeft: "-8px"
|
|
58
|
-
},
|
|
59
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
60
|
-
name: "billing_address.country",
|
|
61
|
-
control,
|
|
62
|
-
render: ({
|
|
63
|
-
field
|
|
64
|
-
}) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_countrySelect.default, {
|
|
65
|
-
...field,
|
|
66
|
-
sx: {
|
|
67
|
-
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
68
|
-
borderColor: "transparent"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
})
|
|
38
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
39
|
+
className: "base-label",
|
|
40
|
+
children: t("payment.checkout.billing.line1")
|
|
41
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
42
|
+
name: "billing_address.line1",
|
|
43
|
+
rules: {
|
|
44
|
+
required: t("payment.checkout.required")
|
|
45
|
+
},
|
|
46
|
+
errorPosition: "right",
|
|
47
|
+
variant: "outlined",
|
|
48
|
+
placeholder: t("payment.checkout.billing.line1")
|
|
76
49
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
77
50
|
className: "base-label",
|
|
78
|
-
children: t("payment.checkout.billing.
|
|
51
|
+
children: t("payment.checkout.billing.city")
|
|
79
52
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
80
|
-
name: "billing_address.
|
|
53
|
+
name: "billing_address.city",
|
|
81
54
|
rules: {
|
|
82
55
|
required: t("payment.checkout.required")
|
|
83
56
|
},
|
|
84
57
|
errorPosition: "right",
|
|
85
58
|
variant: "outlined",
|
|
86
|
-
placeholder: t("payment.checkout.billing.
|
|
59
|
+
placeholder: t("payment.checkout.billing.city")
|
|
87
60
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
88
61
|
className: "base-label",
|
|
89
|
-
children: t("payment.checkout.billing.
|
|
62
|
+
children: t("payment.checkout.billing.state")
|
|
90
63
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
91
|
-
name: "billing_address.
|
|
64
|
+
name: "billing_address.state",
|
|
92
65
|
rules: {
|
|
93
66
|
required: t("payment.checkout.required")
|
|
94
67
|
},
|
|
95
68
|
errorPosition: "right",
|
|
96
69
|
variant: "outlined",
|
|
97
|
-
placeholder: t("payment.checkout.billing.
|
|
70
|
+
placeholder: t("payment.checkout.billing.state")
|
|
98
71
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
99
72
|
className: "base-label",
|
|
100
|
-
children: t("payment.checkout.billing.
|
|
73
|
+
children: t("payment.checkout.billing.postal_code")
|
|
101
74
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
102
|
-
name: "billing_address.
|
|
75
|
+
name: "billing_address.postal_code",
|
|
103
76
|
rules: {
|
|
104
77
|
required: t("payment.checkout.required")
|
|
105
78
|
},
|
|
106
79
|
errorPosition: "right",
|
|
107
80
|
variant: "outlined",
|
|
108
|
-
placeholder: t("payment.checkout.billing.
|
|
81
|
+
placeholder: t("payment.checkout.billing.postal_code"),
|
|
82
|
+
InputProps: {
|
|
83
|
+
startAdornment: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.InputAdornment, {
|
|
84
|
+
position: "start",
|
|
85
|
+
style: {
|
|
86
|
+
marginRight: "2px",
|
|
87
|
+
marginLeft: "-8px"
|
|
88
|
+
},
|
|
89
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
90
|
+
name: "billing_address.country",
|
|
91
|
+
control,
|
|
92
|
+
render: ({
|
|
93
|
+
field
|
|
94
|
+
}) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_countrySelect.default, {
|
|
95
|
+
...field,
|
|
96
|
+
sx: {
|
|
97
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
98
|
+
borderColor: "transparent"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
}
|
|
109
105
|
})]
|
|
110
|
-
})
|
|
106
|
+
})
|
|
111
107
|
})
|
|
112
108
|
});
|
|
113
109
|
}
|
|
@@ -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;
|
|
@@ -59,7 +59,8 @@ const hasDidWallet = user => {
|
|
|
59
59
|
};
|
|
60
60
|
exports.hasDidWallet = hasDidWallet;
|
|
61
61
|
PaymentForm.defaultProps = {
|
|
62
|
-
onlyShowBtn: false
|
|
62
|
+
onlyShowBtn: false,
|
|
63
|
+
isDonation: false
|
|
63
64
|
};
|
|
64
65
|
function PaymentForm({
|
|
65
66
|
checkoutSession,
|
|
@@ -72,7 +73,8 @@ function PaymentForm({
|
|
|
72
73
|
// mode,
|
|
73
74
|
action,
|
|
74
75
|
currencyId,
|
|
75
|
-
onlyShowBtn
|
|
76
|
+
onlyShowBtn,
|
|
77
|
+
isDonation = false
|
|
76
78
|
}) {
|
|
77
79
|
const {
|
|
78
80
|
t
|
|
@@ -192,10 +194,11 @@ function PaymentForm({
|
|
|
192
194
|
} else {
|
|
193
195
|
buttonText = t(`payment.checkout.${checkoutSession.mode}`);
|
|
194
196
|
}
|
|
195
|
-
buttonText = session?.user ? buttonText : t("payment.checkout.connect", {
|
|
197
|
+
buttonText = session?.user || isDonation ? buttonText : t("payment.checkout.connect", {
|
|
196
198
|
action: buttonText
|
|
197
199
|
});
|
|
198
200
|
const method = paymentMethods.find(x => x.id === paymentMethod);
|
|
201
|
+
const isDonationMode = checkoutSession?.submit_type === "donate" && isDonation;
|
|
199
202
|
const showForm = session?.user;
|
|
200
203
|
const skipBindWallet = method.type === "stripe";
|
|
201
204
|
const handleConnected = async () => {
|
|
@@ -263,7 +266,12 @@ function PaymentForm({
|
|
|
263
266
|
submitting: true
|
|
264
267
|
});
|
|
265
268
|
try {
|
|
266
|
-
|
|
269
|
+
let result;
|
|
270
|
+
if (isDonationMode) {
|
|
271
|
+
result = await _api.default.put(`/api/checkout-sessions/${checkoutSession.id}/donate-submit`, data);
|
|
272
|
+
} else {
|
|
273
|
+
result = await _api.default.put(`/api/checkout-sessions/${checkoutSession.id}/submit`, data);
|
|
274
|
+
}
|
|
267
275
|
setState({
|
|
268
276
|
paymentIntent: result.data.paymentIntent,
|
|
269
277
|
stripeContext: result.data.stripeContext,
|
|
@@ -275,7 +283,7 @@ function PaymentForm({
|
|
|
275
283
|
setState({
|
|
276
284
|
paying: true
|
|
277
285
|
});
|
|
278
|
-
if (result.data.balance?.sufficient || result.data.delegation?.sufficient) {
|
|
286
|
+
if ((result.data.balance?.sufficient || result.data.delegation?.sufficient) && !isDonationMode) {
|
|
279
287
|
await handleConnected();
|
|
280
288
|
} else {
|
|
281
289
|
connect.open({
|
|
@@ -372,6 +380,10 @@ function PaymentForm({
|
|
|
372
380
|
});
|
|
373
381
|
}
|
|
374
382
|
} else {
|
|
383
|
+
if (isDonationMode) {
|
|
384
|
+
handleSubmit(onFormSubmit, onFormError)();
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
375
387
|
session?.login(() => {
|
|
376
388
|
setState({
|
|
377
389
|
submitting: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.17",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"lint": "tsc --noEmit && eslint src tests --ext js --ext jsx --ext ts --ext tsx",
|
|
20
20
|
"lint:fix": "pnpm run lint --fix",
|
|
21
|
-
"
|
|
21
|
+
"clean": "rm -rf es lib",
|
|
22
|
+
"build": "pnpm run clean && tsc --noEmit && unbuild && node tools/auto-exports.js && pnpm run cpfiles",
|
|
22
23
|
"watch": "CONSOLA_LEVEL=1 nodemon -e .jsx,.js,.ts,.tsx -w src -x 'yalc publish --push'",
|
|
23
24
|
"precommit": "CI=1 pnpm run lint",
|
|
24
25
|
"prepush": "CI=1 pnpm run lint",
|
|
@@ -53,10 +54,10 @@
|
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@arcblock/did-connect": "^2.12.
|
|
57
|
-
"@arcblock/ux": "^2.12.
|
|
57
|
+
"@arcblock/did-connect": "^2.12.25",
|
|
58
|
+
"@arcblock/ux": "^2.12.25",
|
|
58
59
|
"@arcblock/ws": "^1.19.15",
|
|
59
|
-
"@blocklet/ui-react": "^2.12.
|
|
60
|
+
"@blocklet/ui-react": "^2.12.25",
|
|
60
61
|
"@mui/icons-material": "^5.16.6",
|
|
61
62
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
62
63
|
"@mui/material": "^5.16.6",
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"@babel/core": "^7.25.2",
|
|
93
94
|
"@babel/preset-env": "^7.25.2",
|
|
94
95
|
"@babel/preset-react": "^7.24.7",
|
|
95
|
-
"@blocklet/payment-types": "1.18.
|
|
96
|
+
"@blocklet/payment-types": "1.18.17",
|
|
96
97
|
"@storybook/addon-essentials": "^7.6.20",
|
|
97
98
|
"@storybook/addon-interactions": "^7.6.20",
|
|
98
99
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -123,5 +124,5 @@
|
|
|
123
124
|
"vite-plugin-babel": "^1.2.0",
|
|
124
125
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
125
126
|
},
|
|
126
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "9d43381dd3744506455547260f5e621c6ad88e8f"
|
|
127
128
|
}
|