@blocklet/payment-react 1.18.33 → 1.18.34
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/components/over-due-invoice-payment.js +7 -1
- package/es/history/invoice/list.js +2 -1
- package/es/locales/en.js +31 -5
- package/es/locales/zh.js +31 -5
- package/es/payment/form/index.js +132 -33
- package/lib/components/over-due-invoice-payment.js +8 -1
- package/lib/history/invoice/list.js +3 -1
- package/lib/locales/en.js +31 -5
- package/lib/locales/zh.js +31 -5
- package/lib/payment/form/index.js +194 -52
- package/package.json +6 -6
- package/src/components/over-due-invoice-payment.tsx +7 -1
- package/src/history/invoice/list.tsx +2 -1
- package/src/locales/en.tsx +30 -1
- package/src/locales/zh.tsx +28 -1
- package/src/payment/form/index.tsx +161 -31
|
@@ -17,12 +17,15 @@ var _reactHookForm = require("react-hook-form");
|
|
|
17
17
|
var _ufo = require("ufo");
|
|
18
18
|
var _useBus = require("use-bus");
|
|
19
19
|
var _isEmail = _interopRequireDefault(require("validator/es/lib/isEmail"));
|
|
20
|
+
var _util = require("@ocap/util");
|
|
21
|
+
var _DID = _interopRequireDefault(require("@arcblock/ux/lib/DID"));
|
|
20
22
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
23
|
+
var _iconsMaterial = require("@mui/icons-material");
|
|
21
24
|
var _input = _interopRequireDefault(require("../../components/input"));
|
|
22
25
|
var _payment = require("../../contexts/payment");
|
|
23
26
|
var _subscription = require("../../hooks/subscription");
|
|
24
27
|
var _api = _interopRequireDefault(require("../../libs/api"));
|
|
25
|
-
var
|
|
28
|
+
var _util2 = require("../../libs/util");
|
|
26
29
|
var _address = _interopRequireDefault(require("./address"));
|
|
27
30
|
var _currency = _interopRequireDefault(require("./currency"));
|
|
28
31
|
var _phone = _interopRequireDefault(require("./phone"));
|
|
@@ -32,6 +35,7 @@ var _phoneValidator = require("../../libs/phone-validator");
|
|
|
32
35
|
var _loadingButton = _interopRequireDefault(require("../../components/loading-button"));
|
|
33
36
|
var _overDueInvoicePayment = _interopRequireDefault(require("../../components/over-due-invoice-payment"));
|
|
34
37
|
var _currency2 = require("../../libs/currency");
|
|
38
|
+
var _confirm = _interopRequireDefault(require("../../components/confirm"));
|
|
35
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
40
|
const waitForCheckoutComplete = async sessionId => {
|
|
37
41
|
let result;
|
|
@@ -107,7 +111,8 @@ function PaymentForm({
|
|
|
107
111
|
isDonation = false
|
|
108
112
|
}) {
|
|
109
113
|
const {
|
|
110
|
-
t
|
|
114
|
+
t,
|
|
115
|
+
locale
|
|
111
116
|
} = (0, _context.useLocaleContext)();
|
|
112
117
|
const {
|
|
113
118
|
isMobile
|
|
@@ -131,7 +136,7 @@ function PaymentForm({
|
|
|
131
136
|
const quantityInventoryStatus = (0, _react.useMemo)(() => {
|
|
132
137
|
let status = true;
|
|
133
138
|
for (const item of checkoutSession.line_items) {
|
|
134
|
-
if ((0,
|
|
139
|
+
if ((0, _util2.formatQuantityInventory)(item.price, item.quantity)) {
|
|
135
140
|
status = false;
|
|
136
141
|
break;
|
|
137
142
|
}
|
|
@@ -146,9 +151,10 @@ function PaymentForm({
|
|
|
146
151
|
stripeContext: void 0,
|
|
147
152
|
customer,
|
|
148
153
|
customerLimited: false,
|
|
149
|
-
stripePaying: false
|
|
154
|
+
stripePaying: false,
|
|
155
|
+
fastCheckoutInfo: null
|
|
150
156
|
});
|
|
151
|
-
const currencies = (0,
|
|
157
|
+
const currencies = (0, _util2.flattenPaymentMethods)(paymentMethods);
|
|
152
158
|
const onCheckoutComplete = (0, _ahooks.useMemoizedFn)(async ({
|
|
153
159
|
response
|
|
154
160
|
}) => {
|
|
@@ -229,6 +235,10 @@ function PaymentForm({
|
|
|
229
235
|
control,
|
|
230
236
|
name: "payment_method"
|
|
231
237
|
});
|
|
238
|
+
const paymentCurrencyId = (0, _reactHookForm.useWatch)({
|
|
239
|
+
control,
|
|
240
|
+
name: "payment_currency"
|
|
241
|
+
});
|
|
232
242
|
const afterUserLoggedIn = (0, _ahooks.useMemoizedFn)(() => {
|
|
233
243
|
if (hasDidWallet(session.user) || skipBindWallet) {
|
|
234
244
|
handleSubmit(onFormSubmit, onFormError)();
|
|
@@ -240,7 +250,7 @@ function PaymentForm({
|
|
|
240
250
|
});
|
|
241
251
|
}
|
|
242
252
|
});
|
|
243
|
-
const payee = (0,
|
|
253
|
+
const payee = (0, _util2.getStatementDescriptor)(checkoutSession.line_items);
|
|
244
254
|
let buttonText = "";
|
|
245
255
|
if (paymentLink?.donation_settings) {
|
|
246
256
|
if (action) {
|
|
@@ -255,6 +265,8 @@ function PaymentForm({
|
|
|
255
265
|
action: buttonText
|
|
256
266
|
});
|
|
257
267
|
const method = paymentMethods.find(x => x.id === paymentMethod);
|
|
268
|
+
const paymentCurrency = currencies.find(x => x.id === paymentCurrencyId);
|
|
269
|
+
const showStake = method.type === "arcblock" && !checkoutSession.subscription_data?.no_stake;
|
|
258
270
|
const isDonationMode = checkoutSession?.submit_type === "donate" && isDonation;
|
|
259
271
|
const showForm = !!session?.user;
|
|
260
272
|
const skipBindWallet = method.type === "stripe";
|
|
@@ -272,7 +284,7 @@ function PaymentForm({
|
|
|
272
284
|
onPaid(result);
|
|
273
285
|
}
|
|
274
286
|
} catch (err) {
|
|
275
|
-
_Toast.default.error((0,
|
|
287
|
+
_Toast.default.error((0, _util2.formatError)(err));
|
|
276
288
|
} finally {
|
|
277
289
|
setState({
|
|
278
290
|
paying: false
|
|
@@ -299,6 +311,94 @@ function PaymentForm({
|
|
|
299
311
|
});
|
|
300
312
|
}
|
|
301
313
|
};
|
|
314
|
+
const handleFastCheckoutConfirm = async () => {
|
|
315
|
+
if (!state.fastCheckoutInfo) return;
|
|
316
|
+
setState({
|
|
317
|
+
fastCheckoutInfo: {
|
|
318
|
+
...state.fastCheckoutInfo,
|
|
319
|
+
loading: true
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
try {
|
|
323
|
+
const result = await _api.default.post(`/api/checkout-sessions/${checkoutSession.id}/fast-checkout-confirm`);
|
|
324
|
+
if (result.data.fastPaid) {
|
|
325
|
+
setState({
|
|
326
|
+
fastCheckoutInfo: null,
|
|
327
|
+
paying: true
|
|
328
|
+
});
|
|
329
|
+
await handleConnected();
|
|
330
|
+
} else {
|
|
331
|
+
_Toast.default.error(t("payment.checkout.fastPay.failed"));
|
|
332
|
+
setState({
|
|
333
|
+
fastCheckoutInfo: null,
|
|
334
|
+
paying: true
|
|
335
|
+
});
|
|
336
|
+
openConnect();
|
|
337
|
+
}
|
|
338
|
+
} catch (err) {
|
|
339
|
+
console.error(err);
|
|
340
|
+
_Toast.default.error((0, _util2.formatError)(err));
|
|
341
|
+
setState({
|
|
342
|
+
fastCheckoutInfo: null
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const handleFastCheckoutCancel = () => {
|
|
347
|
+
setState({
|
|
348
|
+
fastCheckoutInfo: null
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
const openConnect = () => {
|
|
352
|
+
try {
|
|
353
|
+
if (!["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
setState({
|
|
357
|
+
paying: true
|
|
358
|
+
});
|
|
359
|
+
connect.open({
|
|
360
|
+
locale,
|
|
361
|
+
containerEl: void 0,
|
|
362
|
+
action: checkoutSession.mode,
|
|
363
|
+
prefix: (0, _ufo.joinURL)((0, _util2.getPrefix)(), "/api/did"),
|
|
364
|
+
saveConnect: false,
|
|
365
|
+
useSocket: (0, _util2.isCrossOrigin)() === false,
|
|
366
|
+
extraParams: {
|
|
367
|
+
checkoutSessionId: checkoutSession.id,
|
|
368
|
+
sessionUserDid: session?.user?.did
|
|
369
|
+
},
|
|
370
|
+
onSuccess: async () => {
|
|
371
|
+
connect.close();
|
|
372
|
+
await handleConnected();
|
|
373
|
+
},
|
|
374
|
+
onClose: () => {
|
|
375
|
+
connect.close();
|
|
376
|
+
setState({
|
|
377
|
+
submitting: false,
|
|
378
|
+
paying: false
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
onError: err => {
|
|
382
|
+
console.error(err);
|
|
383
|
+
setState({
|
|
384
|
+
submitting: false,
|
|
385
|
+
paying: false
|
|
386
|
+
});
|
|
387
|
+
onError(err);
|
|
388
|
+
},
|
|
389
|
+
messages: {
|
|
390
|
+
title: t("payment.checkout.connectModal.title", {
|
|
391
|
+
action: buttonText
|
|
392
|
+
}),
|
|
393
|
+
scan: t("payment.checkout.connectModal.scan"),
|
|
394
|
+
confirm: t("payment.checkout.connectModal.confirm"),
|
|
395
|
+
cancel: t("payment.checkout.connectModal.cancel")
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
} catch (err) {
|
|
399
|
+
_Toast.default.error((0, _util2.formatError)(err));
|
|
400
|
+
}
|
|
401
|
+
};
|
|
302
402
|
const onFormSubmit = async data => {
|
|
303
403
|
setState({
|
|
304
404
|
submitting: true
|
|
@@ -318,47 +418,18 @@ function PaymentForm({
|
|
|
318
418
|
customerLimited: false
|
|
319
419
|
});
|
|
320
420
|
if (["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
action: checkoutSession.mode,
|
|
330
|
-
prefix: (0, _ufo.joinURL)((0, _util.getPrefix)(), "/api/did"),
|
|
331
|
-
saveConnect: false,
|
|
332
|
-
useSocket: (0, _util.isCrossOrigin)() === false,
|
|
333
|
-
extraParams: {
|
|
334
|
-
checkoutSessionId: checkoutSession.id,
|
|
335
|
-
sessionUserDid: session?.user?.did
|
|
336
|
-
},
|
|
337
|
-
onSuccess: async () => {
|
|
338
|
-
connect.close();
|
|
339
|
-
await handleConnected();
|
|
340
|
-
},
|
|
341
|
-
onClose: () => {
|
|
342
|
-
connect.close();
|
|
343
|
-
setState({
|
|
344
|
-
submitting: false,
|
|
345
|
-
paying: false
|
|
346
|
-
});
|
|
347
|
-
},
|
|
348
|
-
onError: err => {
|
|
349
|
-
console.error(err);
|
|
350
|
-
setState({
|
|
351
|
-
submitting: false,
|
|
352
|
-
paying: false
|
|
353
|
-
});
|
|
354
|
-
onError(err);
|
|
355
|
-
},
|
|
356
|
-
messages: {
|
|
357
|
-
title: "DID Connect",
|
|
358
|
-
scan: "Use following methods to complete this payment",
|
|
359
|
-
confirm: "Confirm"
|
|
421
|
+
if ((result.data.balance?.sufficient || result.data.delegation?.sufficient) && !isDonationMode && result.data.fastPayInfo) {
|
|
422
|
+
setState({
|
|
423
|
+
fastCheckoutInfo: {
|
|
424
|
+
open: true,
|
|
425
|
+
loading: false,
|
|
426
|
+
sourceType: result.data.fastPayInfo.type,
|
|
427
|
+
amount: result.data.fastPayInfo.amount,
|
|
428
|
+
payer: result.data.fastPayInfo.payer
|
|
360
429
|
}
|
|
361
430
|
});
|
|
431
|
+
} else {
|
|
432
|
+
openConnect();
|
|
362
433
|
}
|
|
363
434
|
}
|
|
364
435
|
if (["stripe"].includes(method.type)) {
|
|
@@ -387,7 +458,7 @@ function PaymentForm({
|
|
|
387
458
|
}
|
|
388
459
|
}
|
|
389
460
|
if (shouldToast) {
|
|
390
|
-
_Toast.default.error((0,
|
|
461
|
+
_Toast.default.error((0, _util2.formatError)(err));
|
|
391
462
|
}
|
|
392
463
|
} finally {
|
|
393
464
|
setState({
|
|
@@ -464,6 +535,55 @@ function PaymentForm({
|
|
|
464
535
|
window.removeEventListener("keydown", handleKeyDown);
|
|
465
536
|
};
|
|
466
537
|
}, [state.submitting, state.paying, state.stripePaying, quantityInventoryStatus, payable]);
|
|
538
|
+
const FastCheckoutConfirmDialog = state.fastCheckoutInfo && /* @__PURE__ */(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
539
|
+
onConfirm: handleFastCheckoutConfirm,
|
|
540
|
+
onCancel: handleFastCheckoutCancel,
|
|
541
|
+
title: t("payment.checkout.fastPay.title"),
|
|
542
|
+
message: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
543
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
544
|
+
children: t("payment.checkout.fastPay.autoPaymentReason")
|
|
545
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
546
|
+
children: t("payment.checkout.fastPay.confirmPrompt")
|
|
547
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {
|
|
548
|
+
sx: {
|
|
549
|
+
mt: 1.5,
|
|
550
|
+
mb: 1.5
|
|
551
|
+
}
|
|
552
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
553
|
+
spacing: 1,
|
|
554
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
555
|
+
flexDirection: "row",
|
|
556
|
+
alignItems: "center",
|
|
557
|
+
justifyContent: "space-between",
|
|
558
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
559
|
+
color: "text.primary",
|
|
560
|
+
sx: {
|
|
561
|
+
whiteSpace: "nowrap"
|
|
562
|
+
},
|
|
563
|
+
children: t("payment.checkout.fastPay.payer")
|
|
564
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
565
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_DID.default, {
|
|
566
|
+
did: state.fastCheckoutInfo.payer || "",
|
|
567
|
+
compact: true,
|
|
568
|
+
responsive: false
|
|
569
|
+
})
|
|
570
|
+
})]
|
|
571
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
572
|
+
flexDirection: "row",
|
|
573
|
+
alignItems: "center",
|
|
574
|
+
justifyContent: "space-between",
|
|
575
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
576
|
+
color: "text.primary",
|
|
577
|
+
children: t("payment.checkout.fastPay.amount")
|
|
578
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
579
|
+
children: [(0, _util.fromUnitToToken)(state.fastCheckoutInfo.amount, paymentCurrency?.decimal || 18).toString(), " ", paymentCurrency?.symbol]
|
|
580
|
+
})]
|
|
581
|
+
})]
|
|
582
|
+
})]
|
|
583
|
+
}),
|
|
584
|
+
loading: state.fastCheckoutInfo.loading,
|
|
585
|
+
color: "primary"
|
|
586
|
+
});
|
|
467
587
|
if (onlyShowBtn) {
|
|
468
588
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
469
589
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
@@ -504,7 +624,7 @@ function PaymentForm({
|
|
|
504
624
|
setState({
|
|
505
625
|
customerLimited: false
|
|
506
626
|
});
|
|
507
|
-
window.open((0, _ufo.joinURL)((0,
|
|
627
|
+
window.open((0, _ufo.joinURL)((0, _util2.getPrefix)(), `/customer/invoice/past-due?referer=${encodeURIComponent(window.location.href)}`), "_self");
|
|
508
628
|
}
|
|
509
629
|
},
|
|
510
630
|
dialogProps: {
|
|
@@ -514,7 +634,7 @@ function PaymentForm({
|
|
|
514
634
|
}),
|
|
515
635
|
title: t("payment.customer.pastDue.alert.title")
|
|
516
636
|
}
|
|
517
|
-
})]
|
|
637
|
+
}), FastCheckoutConfirmDialog]
|
|
518
638
|
});
|
|
519
639
|
}
|
|
520
640
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
@@ -661,9 +781,31 @@ function PaymentForm({
|
|
|
661
781
|
fontSize: "0.7875rem",
|
|
662
782
|
lineHeight: "0.9625rem"
|
|
663
783
|
},
|
|
664
|
-
children: t("payment.checkout.confirm", {
|
|
784
|
+
children: showStake ? t("payment.checkout.confirm.withStake", {
|
|
785
|
+
payee
|
|
786
|
+
}) : t("payment.checkout.confirm.withoutStake", {
|
|
665
787
|
payee
|
|
666
788
|
})
|
|
789
|
+
}), checkoutSession.metadata?.page_info?.form_purpose_description && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
790
|
+
sx: {
|
|
791
|
+
mt: 1,
|
|
792
|
+
display: "flex",
|
|
793
|
+
alignItems: "center",
|
|
794
|
+
gap: 0.5
|
|
795
|
+
},
|
|
796
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.HelpOutline, {
|
|
797
|
+
sx: {
|
|
798
|
+
color: "text.lighter",
|
|
799
|
+
fontSize: "0.75rem"
|
|
800
|
+
}
|
|
801
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
802
|
+
variant: "body2",
|
|
803
|
+
sx: {
|
|
804
|
+
fontSize: "0.75rem",
|
|
805
|
+
color: "text.lighter"
|
|
806
|
+
},
|
|
807
|
+
children: locale === "zh" ? checkoutSession.metadata.page_info.form_purpose_description.zh : checkoutSession.metadata.page_info.form_purpose_description.en
|
|
808
|
+
})]
|
|
667
809
|
})]
|
|
668
810
|
})
|
|
669
811
|
}), state.customerLimited && /* @__PURE__ */(0, _jsxRuntime.jsx)(_overDueInvoicePayment.default, {
|
|
@@ -681,7 +823,7 @@ function PaymentForm({
|
|
|
681
823
|
setState({
|
|
682
824
|
customerLimited: false
|
|
683
825
|
});
|
|
684
|
-
window.open((0, _ufo.joinURL)((0,
|
|
826
|
+
window.open((0, _ufo.joinURL)((0, _util2.getPrefix)(), `/customer/invoice/past-due?referer=${encodeURIComponent(window.location.href)}`), "_self");
|
|
685
827
|
}
|
|
686
828
|
},
|
|
687
829
|
dialogProps: {
|
|
@@ -691,6 +833,6 @@ function PaymentForm({
|
|
|
691
833
|
}),
|
|
692
834
|
title: t("payment.customer.pastDue.alert.title")
|
|
693
835
|
}
|
|
694
|
-
})]
|
|
836
|
+
}), FastCheckoutConfirmDialog]
|
|
695
837
|
});
|
|
696
838
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.34",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/did-connect": "^2.13.
|
|
58
|
-
"@arcblock/ux": "^2.13.
|
|
57
|
+
"@arcblock/did-connect": "^2.13.12",
|
|
58
|
+
"@arcblock/ux": "^2.13.12",
|
|
59
59
|
"@arcblock/ws": "^1.20.2",
|
|
60
|
-
"@blocklet/ui-react": "^2.13.
|
|
60
|
+
"@blocklet/ui-react": "^2.13.12",
|
|
61
61
|
"@mui/icons-material": "^5.16.6",
|
|
62
62
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
63
63
|
"@mui/material": "^5.16.6",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@babel/core": "^7.25.2",
|
|
94
94
|
"@babel/preset-env": "^7.25.2",
|
|
95
95
|
"@babel/preset-react": "^7.24.7",
|
|
96
|
-
"@blocklet/payment-types": "1.18.
|
|
96
|
+
"@blocklet/payment-types": "1.18.34",
|
|
97
97
|
"@storybook/addon-essentials": "^7.6.20",
|
|
98
98
|
"@storybook/addon-interactions": "^7.6.20",
|
|
99
99
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"vite-plugin-babel": "^1.2.0",
|
|
125
125
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "0ddb7c08956891409919c8027b56b77eba1726d4"
|
|
128
128
|
}
|
|
@@ -103,7 +103,7 @@ function OverdueInvoicePayment({
|
|
|
103
103
|
alertMessage = '',
|
|
104
104
|
authToken,
|
|
105
105
|
}: Props) {
|
|
106
|
-
const { t } = useLocaleContext();
|
|
106
|
+
const { t, locale } = useLocaleContext();
|
|
107
107
|
const { connect, session } = usePaymentContext();
|
|
108
108
|
const [selectCurrencyId, setSelectCurrencyId] = useState('');
|
|
109
109
|
const [payLoading, setPayLoading] = useState(false);
|
|
@@ -251,12 +251,18 @@ function OverdueInvoicePayment({
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
connect.open({
|
|
254
|
+
locale: locale as 'en' | 'zh',
|
|
254
255
|
containerEl: undefined as unknown as Element,
|
|
255
256
|
saveConnect: false,
|
|
256
257
|
action: 'collect-batch',
|
|
257
258
|
prefix: joinURL(getPrefix(), '/api/did'),
|
|
258
259
|
useSocket: !isCrossOriginRequest,
|
|
259
260
|
extraParams,
|
|
261
|
+
messages: {
|
|
262
|
+
scan: t('common.connect.defaultScan'),
|
|
263
|
+
title: t('payment.customer.invoice.payBatch'),
|
|
264
|
+
confirm: t('common.connect.confirm'),
|
|
265
|
+
} as any,
|
|
260
266
|
onSuccess: () => {
|
|
261
267
|
connect.close();
|
|
262
268
|
handleConnected();
|
|
@@ -605,7 +605,7 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
605
605
|
|
|
606
606
|
export default function CustomerInvoiceList(props: Props) {
|
|
607
607
|
const { action, type } = props;
|
|
608
|
-
const { t } = useLocaleContext();
|
|
608
|
+
const { t, locale } = useLocaleContext();
|
|
609
609
|
const { connect } = usePaymentContext();
|
|
610
610
|
const [state, setState] = useSetState({ paying: '' });
|
|
611
611
|
|
|
@@ -618,6 +618,7 @@ export default function CustomerInvoiceList(props: Props) {
|
|
|
618
618
|
connect.open({
|
|
619
619
|
action: 'collect',
|
|
620
620
|
saveConnect: false,
|
|
621
|
+
locale: locale as 'en' | 'zh',
|
|
621
622
|
useSocket: isCrossOrigin() === false,
|
|
622
623
|
messages: {
|
|
623
624
|
scan: '',
|
package/src/locales/en.tsx
CHANGED
|
@@ -97,6 +97,12 @@ export default flat({
|
|
|
97
97
|
slashStakeAmount: 'Slash Stake Amount',
|
|
98
98
|
know: 'I know',
|
|
99
99
|
relatedSubscription: 'Subscription',
|
|
100
|
+
connect: {
|
|
101
|
+
defaultScan: 'Use following methods to complete this action',
|
|
102
|
+
scan: 'Use following methods to complete this {action}',
|
|
103
|
+
confirm: 'Confirm',
|
|
104
|
+
cancel: 'Cancel',
|
|
105
|
+
},
|
|
100
106
|
},
|
|
101
107
|
payment: {
|
|
102
108
|
checkout: {
|
|
@@ -169,7 +175,12 @@ export default flat({
|
|
|
169
175
|
donate: 'Thanks for your tip',
|
|
170
176
|
tip: 'A payment to {payee} has been completed. You can view the details of this payment in your account.',
|
|
171
177
|
},
|
|
172
|
-
confirm:
|
|
178
|
+
confirm: {
|
|
179
|
+
withStake:
|
|
180
|
+
'By confirming, you allow {payee} to charge your account for future payments and, if necessary, slash your stake. You can cancel your subscription or withdraw your stake at any time.',
|
|
181
|
+
withoutStake:
|
|
182
|
+
'By confirming, you allow {payee} to charge your account for future payments. You can cancel your subscription at any time.',
|
|
183
|
+
},
|
|
173
184
|
required: 'Required',
|
|
174
185
|
invalid: 'Invalid',
|
|
175
186
|
billing: {
|
|
@@ -215,6 +226,22 @@ export default flat({
|
|
|
215
226
|
orderSummary: 'Order Summary',
|
|
216
227
|
paymentDetails: 'Payment Details',
|
|
217
228
|
productListTotal: 'Includes {total} items',
|
|
229
|
+
connectModal: {
|
|
230
|
+
title: '{action}',
|
|
231
|
+
scan: 'Use following methods to complete this payment',
|
|
232
|
+
confirm: 'Confirm',
|
|
233
|
+
cancel: 'Cancel',
|
|
234
|
+
},
|
|
235
|
+
fastPay: {
|
|
236
|
+
title: 'Confirm Payment',
|
|
237
|
+
confirmMessage: 'You will pay {amount} {symbol} from {sourceType}.',
|
|
238
|
+
autoPaymentReason:
|
|
239
|
+
'This payment will be processed automatically due to prior delegation or sufficient balance.',
|
|
240
|
+
confirmPrompt: 'Please confirm the details before proceeding.',
|
|
241
|
+
payer: 'Account',
|
|
242
|
+
amount: 'Amount',
|
|
243
|
+
failed: 'Account changed, please pay manually.',
|
|
244
|
+
},
|
|
218
245
|
},
|
|
219
246
|
customer: {
|
|
220
247
|
payments: 'Payment History',
|
|
@@ -287,6 +314,7 @@ export default flat({
|
|
|
287
314
|
'By confirming this change, you allow {payee} to charge {symbol} from your account for future payments in accordance with their terms. You can always change your payment method.',
|
|
288
315
|
completed:
|
|
289
316
|
'Your payment method has been successfully updated, all future payments will use the new payment method unless you change it again.',
|
|
317
|
+
title: 'Payment Method Change',
|
|
290
318
|
},
|
|
291
319
|
invoice: {
|
|
292
320
|
summary: 'Summary',
|
|
@@ -308,6 +336,7 @@ export default flat({
|
|
|
308
336
|
invoiceNumber: 'Invoice Number',
|
|
309
337
|
emptyList: 'No Invoice',
|
|
310
338
|
noPaymentRequired: 'No Payment Required',
|
|
339
|
+
payBatch: 'Pay Due Invoices',
|
|
311
340
|
},
|
|
312
341
|
payment: {
|
|
313
342
|
empty: 'There are no payments',
|
package/src/locales/zh.tsx
CHANGED
|
@@ -97,6 +97,12 @@ export default flat({
|
|
|
97
97
|
slashStakeAmount: '罚没金额',
|
|
98
98
|
know: '我知道了',
|
|
99
99
|
relatedSubscription: '订阅',
|
|
100
|
+
connect: {
|
|
101
|
+
defaultScan: '使用以下方式完成本次操作',
|
|
102
|
+
scan: '使用以下方式完成本次{action}',
|
|
103
|
+
confirm: '确认',
|
|
104
|
+
cancel: '取消',
|
|
105
|
+
},
|
|
100
106
|
},
|
|
101
107
|
payment: {
|
|
102
108
|
checkout: {
|
|
@@ -168,7 +174,11 @@ export default flat({
|
|
|
168
174
|
donate: '感谢您的支持',
|
|
169
175
|
tip: '向{payee}的付款已完成。您可以在您的账户中查看此付款的详细信息。',
|
|
170
176
|
},
|
|
171
|
-
confirm:
|
|
177
|
+
confirm: {
|
|
178
|
+
withStake:
|
|
179
|
+
'确认订阅,即表示您授权 {payee} 从您的账户扣取未来款项,并在必要时罚没质押。您可随时取消订阅或撤销质押。',
|
|
180
|
+
withoutStake: '确认订阅,即表示您授权 {payee} 从您的账户扣取未来款项。您可随时取消订阅。',
|
|
181
|
+
},
|
|
172
182
|
required: '必填项',
|
|
173
183
|
invalid: '无效',
|
|
174
184
|
billing: {
|
|
@@ -212,6 +222,21 @@ export default flat({
|
|
|
212
222
|
orderSummary: '订单概览',
|
|
213
223
|
paymentDetails: '支付信息',
|
|
214
224
|
productListTotal: '包括 {total} 项',
|
|
225
|
+
connectModal: {
|
|
226
|
+
title: '{action}',
|
|
227
|
+
scan: '使用以下方式完成本次支付',
|
|
228
|
+
confirm: '确认',
|
|
229
|
+
cancel: '取消',
|
|
230
|
+
},
|
|
231
|
+
fastPay: {
|
|
232
|
+
title: '确认支付',
|
|
233
|
+
confirmMessage: '您将支付 {amount} {symbol},从{sourceType}扣除。',
|
|
234
|
+
autoPaymentReason: '由于授权或余额充足,系统将无需钱包确认自动完成支付。',
|
|
235
|
+
confirmPrompt: '请确认支付信息无误后继续。',
|
|
236
|
+
payer: '账户地址',
|
|
237
|
+
amount: '支付金额',
|
|
238
|
+
failed: '账户发生变化,无法自动完成支付,请手动支付。',
|
|
239
|
+
},
|
|
215
240
|
},
|
|
216
241
|
customer: {
|
|
217
242
|
payments: '支付历史',
|
|
@@ -280,6 +305,7 @@ export default flat({
|
|
|
280
305
|
submit: '确认变更',
|
|
281
306
|
confirm: '确认变更方式意味着你允许 {payee} 使用新的支付方式支付你的未来账单。你可以随时再次变更支付方式。',
|
|
282
307
|
completed: '你的支付方式 已经更新成功。你可以在你的账户中查看此支付方式的详细信息。',
|
|
308
|
+
title: '支付方式变更',
|
|
283
309
|
},
|
|
284
310
|
invoice: {
|
|
285
311
|
summary: '摘要',
|
|
@@ -301,6 +327,7 @@ export default flat({
|
|
|
301
327
|
invoiceNumber: '账单编号',
|
|
302
328
|
emptyList: '没有账单',
|
|
303
329
|
noPaymentRequired: '无需支付',
|
|
330
|
+
payBatch: '支付欠款',
|
|
304
331
|
},
|
|
305
332
|
payment: {
|
|
306
333
|
empty: '没有支付记录',
|