@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
|
@@ -40,7 +40,7 @@ function OverdueInvoicePayment({
|
|
|
40
40
|
alertMessage = "",
|
|
41
41
|
authToken
|
|
42
42
|
}) {
|
|
43
|
-
const { t } = useLocaleContext();
|
|
43
|
+
const { t, locale } = useLocaleContext();
|
|
44
44
|
const { connect, session } = usePaymentContext();
|
|
45
45
|
const [selectCurrencyId, setSelectCurrencyId] = useState("");
|
|
46
46
|
const [payLoading, setPayLoading] = useState(false);
|
|
@@ -170,12 +170,18 @@ function OverdueInvoicePayment({
|
|
|
170
170
|
extraParams.customerId = effectiveCustomerId;
|
|
171
171
|
}
|
|
172
172
|
connect.open({
|
|
173
|
+
locale,
|
|
173
174
|
containerEl: void 0,
|
|
174
175
|
saveConnect: false,
|
|
175
176
|
action: "collect-batch",
|
|
176
177
|
prefix: joinURL(getPrefix(), "/api/did"),
|
|
177
178
|
useSocket: !isCrossOriginRequest,
|
|
178
179
|
extraParams,
|
|
180
|
+
messages: {
|
|
181
|
+
scan: t("common.connect.defaultScan"),
|
|
182
|
+
title: t("payment.customer.invoice.payBatch"),
|
|
183
|
+
confirm: t("common.connect.confirm")
|
|
184
|
+
},
|
|
179
185
|
onSuccess: () => {
|
|
180
186
|
connect.close();
|
|
181
187
|
handleConnected();
|
|
@@ -469,7 +469,7 @@ const InvoiceList = React.memo((props) => {
|
|
|
469
469
|
});
|
|
470
470
|
export default function CustomerInvoiceList(props) {
|
|
471
471
|
const { action, type } = props;
|
|
472
|
-
const { t } = useLocaleContext();
|
|
472
|
+
const { t, locale } = useLocaleContext();
|
|
473
473
|
const { connect } = usePaymentContext();
|
|
474
474
|
const [state, setState] = useSetState({ paying: "" });
|
|
475
475
|
const onPay = (invoiceId) => {
|
|
@@ -480,6 +480,7 @@ export default function CustomerInvoiceList(props) {
|
|
|
480
480
|
connect.open({
|
|
481
481
|
action: "collect",
|
|
482
482
|
saveConnect: false,
|
|
483
|
+
locale,
|
|
483
484
|
useSocket: isCrossOrigin() === false,
|
|
484
485
|
messages: {
|
|
485
486
|
scan: "",
|
package/es/locales/en.js
CHANGED
|
@@ -94,7 +94,13 @@ export default flat({
|
|
|
94
94
|
stakeAmount: "Stake Amount",
|
|
95
95
|
slashStakeAmount: "Slash Stake Amount",
|
|
96
96
|
know: "I know",
|
|
97
|
-
relatedSubscription: "Subscription"
|
|
97
|
+
relatedSubscription: "Subscription",
|
|
98
|
+
connect: {
|
|
99
|
+
defaultScan: "Use following methods to complete this action",
|
|
100
|
+
scan: "Use following methods to complete this {action}",
|
|
101
|
+
confirm: "Confirm",
|
|
102
|
+
cancel: "Cancel"
|
|
103
|
+
}
|
|
98
104
|
},
|
|
99
105
|
payment: {
|
|
100
106
|
checkout: {
|
|
@@ -166,7 +172,10 @@ export default flat({
|
|
|
166
172
|
donate: "Thanks for your tip",
|
|
167
173
|
tip: "A payment to {payee} has been completed. You can view the details of this payment in your account."
|
|
168
174
|
},
|
|
169
|
-
confirm:
|
|
175
|
+
confirm: {
|
|
176
|
+
withStake: "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.",
|
|
177
|
+
withoutStake: "By confirming, you allow {payee} to charge your account for future payments. You can cancel your subscription at any time."
|
|
178
|
+
},
|
|
170
179
|
required: "Required",
|
|
171
180
|
invalid: "Invalid",
|
|
172
181
|
billing: {
|
|
@@ -209,7 +218,22 @@ export default flat({
|
|
|
209
218
|
},
|
|
210
219
|
orderSummary: "Order Summary",
|
|
211
220
|
paymentDetails: "Payment Details",
|
|
212
|
-
productListTotal: "Includes {total} items"
|
|
221
|
+
productListTotal: "Includes {total} items",
|
|
222
|
+
connectModal: {
|
|
223
|
+
title: "{action}",
|
|
224
|
+
scan: "Use following methods to complete this payment",
|
|
225
|
+
confirm: "Confirm",
|
|
226
|
+
cancel: "Cancel"
|
|
227
|
+
},
|
|
228
|
+
fastPay: {
|
|
229
|
+
title: "Confirm Payment",
|
|
230
|
+
confirmMessage: "You will pay {amount} {symbol} from {sourceType}.",
|
|
231
|
+
autoPaymentReason: "This payment will be processed automatically due to prior delegation or sufficient balance.",
|
|
232
|
+
confirmPrompt: "Please confirm the details before proceeding.",
|
|
233
|
+
payer: "Account",
|
|
234
|
+
amount: "Amount",
|
|
235
|
+
failed: "Account changed, please pay manually."
|
|
236
|
+
}
|
|
213
237
|
},
|
|
214
238
|
customer: {
|
|
215
239
|
payments: "Payment History",
|
|
@@ -275,7 +299,8 @@ export default flat({
|
|
|
275
299
|
select: "Select payment method",
|
|
276
300
|
submit: "Confirm change",
|
|
277
301
|
confirm: "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.",
|
|
278
|
-
completed: "Your payment method has been successfully updated, all future payments will use the new payment method unless you change it again."
|
|
302
|
+
completed: "Your payment method has been successfully updated, all future payments will use the new payment method unless you change it again.",
|
|
303
|
+
title: "Payment Method Change"
|
|
279
304
|
},
|
|
280
305
|
invoice: {
|
|
281
306
|
summary: "Summary",
|
|
@@ -296,7 +321,8 @@ export default flat({
|
|
|
296
321
|
next: "No invoices yet, next invoice will be generated on {date}",
|
|
297
322
|
invoiceNumber: "Invoice Number",
|
|
298
323
|
emptyList: "No Invoice",
|
|
299
|
-
noPaymentRequired: "No Payment Required"
|
|
324
|
+
noPaymentRequired: "No Payment Required",
|
|
325
|
+
payBatch: "Pay Due Invoices"
|
|
300
326
|
},
|
|
301
327
|
payment: {
|
|
302
328
|
empty: "There are no payments",
|
package/es/locales/zh.js
CHANGED
|
@@ -94,7 +94,13 @@ export default flat({
|
|
|
94
94
|
stakeAmount: "\u8D28\u62BC\u91D1\u989D",
|
|
95
95
|
slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D",
|
|
96
96
|
know: "\u6211\u77E5\u9053\u4E86",
|
|
97
|
-
relatedSubscription: "\u8BA2\u9605"
|
|
97
|
+
relatedSubscription: "\u8BA2\u9605",
|
|
98
|
+
connect: {
|
|
99
|
+
defaultScan: "\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u5B8C\u6210\u672C\u6B21\u64CD\u4F5C",
|
|
100
|
+
scan: "\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u5B8C\u6210\u672C\u6B21{action}",
|
|
101
|
+
confirm: "\u786E\u8BA4",
|
|
102
|
+
cancel: "\u53D6\u6D88"
|
|
103
|
+
}
|
|
98
104
|
},
|
|
99
105
|
payment: {
|
|
100
106
|
checkout: {
|
|
@@ -166,7 +172,10 @@ export default flat({
|
|
|
166
172
|
donate: "\u611F\u8C22\u60A8\u7684\u652F\u6301",
|
|
167
173
|
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"
|
|
168
174
|
},
|
|
169
|
-
confirm:
|
|
175
|
+
confirm: {
|
|
176
|
+
withStake: "\u786E\u8BA4\u8BA2\u9605\uFF0C\u5373\u8868\u793A\u60A8\u6388\u6743 {payee} \u4ECE\u60A8\u7684\u8D26\u6237\u6263\u53D6\u672A\u6765\u6B3E\u9879\uFF0C\u5E76\u5728\u5FC5\u8981\u65F6\u7F5A\u6CA1\u8D28\u62BC\u3002\u60A8\u53EF\u968F\u65F6\u53D6\u6D88\u8BA2\u9605\u6216\u64A4\u9500\u8D28\u62BC\u3002",
|
|
177
|
+
withoutStake: "\u786E\u8BA4\u8BA2\u9605\uFF0C\u5373\u8868\u793A\u60A8\u6388\u6743 {payee} \u4ECE\u60A8\u7684\u8D26\u6237\u6263\u53D6\u672A\u6765\u6B3E\u9879\u3002\u60A8\u53EF\u968F\u65F6\u53D6\u6D88\u8BA2\u9605\u3002"
|
|
178
|
+
},
|
|
170
179
|
required: "\u5FC5\u586B\u9879",
|
|
171
180
|
invalid: "\u65E0\u6548",
|
|
172
181
|
billing: {
|
|
@@ -209,7 +218,22 @@ export default flat({
|
|
|
209
218
|
},
|
|
210
219
|
orderSummary: "\u8BA2\u5355\u6982\u89C8",
|
|
211
220
|
paymentDetails: "\u652F\u4ED8\u4FE1\u606F",
|
|
212
|
-
productListTotal: "\u5305\u62EC {total} \u9879"
|
|
221
|
+
productListTotal: "\u5305\u62EC {total} \u9879",
|
|
222
|
+
connectModal: {
|
|
223
|
+
title: "{action}",
|
|
224
|
+
scan: "\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u5B8C\u6210\u672C\u6B21\u652F\u4ED8",
|
|
225
|
+
confirm: "\u786E\u8BA4",
|
|
226
|
+
cancel: "\u53D6\u6D88"
|
|
227
|
+
},
|
|
228
|
+
fastPay: {
|
|
229
|
+
title: "\u786E\u8BA4\u652F\u4ED8",
|
|
230
|
+
confirmMessage: "\u60A8\u5C06\u652F\u4ED8 {amount} {symbol}\uFF0C\u4ECE{sourceType}\u6263\u9664\u3002",
|
|
231
|
+
autoPaymentReason: "\u7531\u4E8E\u6388\u6743\u6216\u4F59\u989D\u5145\u8DB3\uFF0C\u7CFB\u7EDF\u5C06\u65E0\u9700\u94B1\u5305\u786E\u8BA4\u81EA\u52A8\u5B8C\u6210\u652F\u4ED8\u3002",
|
|
232
|
+
confirmPrompt: "\u8BF7\u786E\u8BA4\u652F\u4ED8\u4FE1\u606F\u65E0\u8BEF\u540E\u7EE7\u7EED\u3002",
|
|
233
|
+
payer: "\u8D26\u6237\u5730\u5740",
|
|
234
|
+
amount: "\u652F\u4ED8\u91D1\u989D",
|
|
235
|
+
failed: "\u8D26\u6237\u53D1\u751F\u53D8\u5316\uFF0C\u65E0\u6CD5\u81EA\u52A8\u5B8C\u6210\u652F\u4ED8\uFF0C\u8BF7\u624B\u52A8\u652F\u4ED8\u3002"
|
|
236
|
+
}
|
|
213
237
|
},
|
|
214
238
|
customer: {
|
|
215
239
|
payments: "\u652F\u4ED8\u5386\u53F2",
|
|
@@ -276,7 +300,8 @@ export default flat({
|
|
|
276
300
|
select: "\u9009\u62E9\u652F\u4ED8\u65B9\u5F0F",
|
|
277
301
|
submit: "\u786E\u8BA4\u53D8\u66F4",
|
|
278
302
|
confirm: "\u786E\u8BA4\u53D8\u66F4\u65B9\u5F0F\u610F\u5473\u7740\u4F60\u5141\u8BB8 {payee} \u4F7F\u7528\u65B0\u7684\u652F\u4ED8\u65B9\u5F0F\u652F\u4ED8\u4F60\u7684\u672A\u6765\u8D26\u5355\u3002\u4F60\u53EF\u4EE5\u968F\u65F6\u518D\u6B21\u53D8\u66F4\u652F\u4ED8\u65B9\u5F0F\u3002",
|
|
279
|
-
completed: "\u4F60\u7684\u652F\u4ED8\u65B9\u5F0F \u5DF2\u7ECF\u66F4\u65B0\u6210\u529F\u3002\u4F60\u53EF\u4EE5\u5728\u4F60\u7684\u8D26\u6237\u4E2D\u67E5\u770B\u6B64\u652F\u4ED8\u65B9\u5F0F\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002"
|
|
303
|
+
completed: "\u4F60\u7684\u652F\u4ED8\u65B9\u5F0F \u5DF2\u7ECF\u66F4\u65B0\u6210\u529F\u3002\u4F60\u53EF\u4EE5\u5728\u4F60\u7684\u8D26\u6237\u4E2D\u67E5\u770B\u6B64\u652F\u4ED8\u65B9\u5F0F\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002",
|
|
304
|
+
title: "\u652F\u4ED8\u65B9\u5F0F\u53D8\u66F4"
|
|
280
305
|
},
|
|
281
306
|
invoice: {
|
|
282
307
|
summary: "\u6458\u8981",
|
|
@@ -297,7 +322,8 @@ export default flat({
|
|
|
297
322
|
next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210",
|
|
298
323
|
invoiceNumber: "\u8D26\u5355\u7F16\u53F7",
|
|
299
324
|
emptyList: "\u6CA1\u6709\u8D26\u5355",
|
|
300
|
-
noPaymentRequired: "\u65E0\u9700\u652F\u4ED8"
|
|
325
|
+
noPaymentRequired: "\u65E0\u9700\u652F\u4ED8",
|
|
326
|
+
payBatch: "\u652F\u4ED8\u6B20\u6B3E"
|
|
301
327
|
},
|
|
302
328
|
payment: {
|
|
303
329
|
empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55",
|
package/es/payment/form/index.js
CHANGED
|
@@ -10,7 +10,10 @@ import { Controller, useFormContext, useWatch } from "react-hook-form";
|
|
|
10
10
|
import { joinURL } from "ufo";
|
|
11
11
|
import { dispatch } from "use-bus";
|
|
12
12
|
import isEmail from "validator/es/lib/isEmail";
|
|
13
|
+
import { fromUnitToToken } from "@ocap/util";
|
|
14
|
+
import DID from "@arcblock/ux/lib/DID";
|
|
13
15
|
import isEmpty from "lodash/isEmpty";
|
|
16
|
+
import { HelpOutline } from "@mui/icons-material";
|
|
14
17
|
import FormInput from "../../components/input.js";
|
|
15
18
|
import { usePaymentContext } from "../../contexts/payment.js";
|
|
16
19
|
import { useSubscription } from "../../hooks/subscription.js";
|
|
@@ -32,6 +35,7 @@ import { formatPhone, validatePhoneNumber } from "../../libs/phone-validator.js"
|
|
|
32
35
|
import LoadingButton from "../../components/loading-button.js";
|
|
33
36
|
import OverdueInvoicePayment from "../../components/over-due-invoice-payment.js";
|
|
34
37
|
import { saveCurrencyPreference } from "../../libs/currency.js";
|
|
38
|
+
import ConfirmDialog from "../../components/confirm.js";
|
|
35
39
|
export const waitForCheckoutComplete = async (sessionId) => {
|
|
36
40
|
let result;
|
|
37
41
|
await pWaitFor(
|
|
@@ -96,7 +100,7 @@ export default function PaymentForm({
|
|
|
96
100
|
onlyShowBtn,
|
|
97
101
|
isDonation = false
|
|
98
102
|
}) {
|
|
99
|
-
const { t } = useLocaleContext();
|
|
103
|
+
const { t, locale } = useLocaleContext();
|
|
100
104
|
const { isMobile } = useMobile();
|
|
101
105
|
const { session, connect, payable } = usePaymentContext();
|
|
102
106
|
const subscription = useSubscription("events");
|
|
@@ -126,7 +130,8 @@ export default function PaymentForm({
|
|
|
126
130
|
stripeContext: void 0,
|
|
127
131
|
customer,
|
|
128
132
|
customerLimited: false,
|
|
129
|
-
stripePaying: false
|
|
133
|
+
stripePaying: false,
|
|
134
|
+
fastCheckoutInfo: null
|
|
130
135
|
});
|
|
131
136
|
const currencies = flattenPaymentMethods(paymentMethods);
|
|
132
137
|
const onCheckoutComplete = useMemoizedFn(async ({ response }) => {
|
|
@@ -204,6 +209,7 @@ export default function PaymentForm({
|
|
|
204
209
|
initUserInfo();
|
|
205
210
|
}, [session?.user, checkoutSession.phone_number_collection?.enabled]);
|
|
206
211
|
const paymentMethod = useWatch({ control, name: "payment_method" });
|
|
212
|
+
const paymentCurrencyId = useWatch({ control, name: "payment_currency" });
|
|
207
213
|
const afterUserLoggedIn = useMemoizedFn(() => {
|
|
208
214
|
if (hasDidWallet(session.user) || skipBindWallet) {
|
|
209
215
|
handleSubmit(onFormSubmit, onFormError)();
|
|
@@ -228,6 +234,8 @@ export default function PaymentForm({
|
|
|
228
234
|
}
|
|
229
235
|
buttonText = session?.user || isDonation ? buttonText : t("payment.checkout.connect", { action: buttonText });
|
|
230
236
|
const method = paymentMethods.find((x) => x.id === paymentMethod);
|
|
237
|
+
const paymentCurrency = currencies.find((x) => x.id === paymentCurrencyId);
|
|
238
|
+
const showStake = method.type === "arcblock" && !checkoutSession.subscription_data?.no_stake;
|
|
231
239
|
const isDonationMode = checkoutSession?.submit_type === "donate" && isDonation;
|
|
232
240
|
const showForm = !!session?.user;
|
|
233
241
|
const skipBindWallet = method.type === "stripe";
|
|
@@ -261,6 +269,80 @@ export default function PaymentForm({
|
|
|
261
269
|
});
|
|
262
270
|
}
|
|
263
271
|
};
|
|
272
|
+
const handleFastCheckoutConfirm = async () => {
|
|
273
|
+
if (!state.fastCheckoutInfo)
|
|
274
|
+
return;
|
|
275
|
+
setState({
|
|
276
|
+
fastCheckoutInfo: {
|
|
277
|
+
...state.fastCheckoutInfo,
|
|
278
|
+
loading: true
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
try {
|
|
282
|
+
const result = await api.post(`/api/checkout-sessions/${checkoutSession.id}/fast-checkout-confirm`);
|
|
283
|
+
if (result.data.fastPaid) {
|
|
284
|
+
setState({
|
|
285
|
+
fastCheckoutInfo: null,
|
|
286
|
+
paying: true
|
|
287
|
+
});
|
|
288
|
+
await handleConnected();
|
|
289
|
+
} else {
|
|
290
|
+
Toast.error(t("payment.checkout.fastPay.failed"));
|
|
291
|
+
setState({
|
|
292
|
+
fastCheckoutInfo: null,
|
|
293
|
+
paying: true
|
|
294
|
+
});
|
|
295
|
+
openConnect();
|
|
296
|
+
}
|
|
297
|
+
} catch (err) {
|
|
298
|
+
console.error(err);
|
|
299
|
+
Toast.error(formatError(err));
|
|
300
|
+
setState({
|
|
301
|
+
fastCheckoutInfo: null
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const handleFastCheckoutCancel = () => {
|
|
306
|
+
setState({ fastCheckoutInfo: null });
|
|
307
|
+
};
|
|
308
|
+
const openConnect = () => {
|
|
309
|
+
try {
|
|
310
|
+
if (!["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
setState({ paying: true });
|
|
314
|
+
connect.open({
|
|
315
|
+
locale,
|
|
316
|
+
containerEl: void 0,
|
|
317
|
+
action: checkoutSession.mode,
|
|
318
|
+
prefix: joinURL(getPrefix(), "/api/did"),
|
|
319
|
+
saveConnect: false,
|
|
320
|
+
useSocket: isCrossOrigin() === false,
|
|
321
|
+
extraParams: { checkoutSessionId: checkoutSession.id, sessionUserDid: session?.user?.did },
|
|
322
|
+
onSuccess: async () => {
|
|
323
|
+
connect.close();
|
|
324
|
+
await handleConnected();
|
|
325
|
+
},
|
|
326
|
+
onClose: () => {
|
|
327
|
+
connect.close();
|
|
328
|
+
setState({ submitting: false, paying: false });
|
|
329
|
+
},
|
|
330
|
+
onError: (err) => {
|
|
331
|
+
console.error(err);
|
|
332
|
+
setState({ submitting: false, paying: false });
|
|
333
|
+
onError(err);
|
|
334
|
+
},
|
|
335
|
+
messages: {
|
|
336
|
+
title: t("payment.checkout.connectModal.title", { action: buttonText }),
|
|
337
|
+
scan: t("payment.checkout.connectModal.scan"),
|
|
338
|
+
confirm: t("payment.checkout.connectModal.confirm"),
|
|
339
|
+
cancel: t("payment.checkout.connectModal.cancel")
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
} catch (err) {
|
|
343
|
+
Toast.error(formatError(err));
|
|
344
|
+
}
|
|
345
|
+
};
|
|
264
346
|
const onFormSubmit = async (data) => {
|
|
265
347
|
setState({ submitting: true });
|
|
266
348
|
try {
|
|
@@ -278,36 +360,18 @@ export default function PaymentForm({
|
|
|
278
360
|
customerLimited: false
|
|
279
361
|
});
|
|
280
362
|
if (["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
saveConnect: false,
|
|
290
|
-
useSocket: isCrossOrigin() === false,
|
|
291
|
-
extraParams: { checkoutSessionId: checkoutSession.id, sessionUserDid: session?.user?.did },
|
|
292
|
-
onSuccess: async () => {
|
|
293
|
-
connect.close();
|
|
294
|
-
await handleConnected();
|
|
295
|
-
},
|
|
296
|
-
onClose: () => {
|
|
297
|
-
connect.close();
|
|
298
|
-
setState({ submitting: false, paying: false });
|
|
299
|
-
},
|
|
300
|
-
onError: (err) => {
|
|
301
|
-
console.error(err);
|
|
302
|
-
setState({ submitting: false, paying: false });
|
|
303
|
-
onError(err);
|
|
304
|
-
},
|
|
305
|
-
messages: {
|
|
306
|
-
title: "DID Connect",
|
|
307
|
-
scan: "Use following methods to complete this payment",
|
|
308
|
-
confirm: "Confirm"
|
|
363
|
+
if ((result.data.balance?.sufficient || result.data.delegation?.sufficient) && !isDonationMode && result.data.fastPayInfo) {
|
|
364
|
+
setState({
|
|
365
|
+
fastCheckoutInfo: {
|
|
366
|
+
open: true,
|
|
367
|
+
loading: false,
|
|
368
|
+
sourceType: result.data.fastPayInfo.type,
|
|
369
|
+
amount: result.data.fastPayInfo.amount,
|
|
370
|
+
payer: result.data.fastPayInfo.payer
|
|
309
371
|
}
|
|
310
372
|
});
|
|
373
|
+
} else {
|
|
374
|
+
openConnect();
|
|
311
375
|
}
|
|
312
376
|
}
|
|
313
377
|
if (["stripe"].includes(method.type)) {
|
|
@@ -392,6 +456,35 @@ export default function PaymentForm({
|
|
|
392
456
|
window.removeEventListener("keydown", handleKeyDown);
|
|
393
457
|
};
|
|
394
458
|
}, [state.submitting, state.paying, state.stripePaying, quantityInventoryStatus, payable]);
|
|
459
|
+
const FastCheckoutConfirmDialog = state.fastCheckoutInfo && /* @__PURE__ */ jsx(
|
|
460
|
+
ConfirmDialog,
|
|
461
|
+
{
|
|
462
|
+
onConfirm: handleFastCheckoutConfirm,
|
|
463
|
+
onCancel: handleFastCheckoutCancel,
|
|
464
|
+
title: t("payment.checkout.fastPay.title"),
|
|
465
|
+
message: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
466
|
+
/* @__PURE__ */ jsx(Typography, { children: t("payment.checkout.fastPay.autoPaymentReason") }),
|
|
467
|
+
/* @__PURE__ */ jsx(Typography, { children: t("payment.checkout.fastPay.confirmPrompt") }),
|
|
468
|
+
/* @__PURE__ */ jsx(Divider, { sx: { mt: 1.5, mb: 1.5 } }),
|
|
469
|
+
/* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
|
|
470
|
+
/* @__PURE__ */ jsxs(Stack, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", children: [
|
|
471
|
+
/* @__PURE__ */ jsx(Typography, { color: "text.primary", sx: { whiteSpace: "nowrap" }, children: t("payment.checkout.fastPay.payer") }),
|
|
472
|
+
/* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(DID, { did: state.fastCheckoutInfo.payer || "", compact: true, responsive: false }) })
|
|
473
|
+
] }),
|
|
474
|
+
/* @__PURE__ */ jsxs(Stack, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", children: [
|
|
475
|
+
/* @__PURE__ */ jsx(Typography, { color: "text.primary", children: t("payment.checkout.fastPay.amount") }),
|
|
476
|
+
/* @__PURE__ */ jsxs(Typography, { children: [
|
|
477
|
+
fromUnitToToken(state.fastCheckoutInfo.amount, paymentCurrency?.decimal || 18).toString(),
|
|
478
|
+
" ",
|
|
479
|
+
paymentCurrency?.symbol
|
|
480
|
+
] })
|
|
481
|
+
] })
|
|
482
|
+
] })
|
|
483
|
+
] }),
|
|
484
|
+
loading: state.fastCheckoutInfo.loading,
|
|
485
|
+
color: "primary"
|
|
486
|
+
}
|
|
487
|
+
);
|
|
395
488
|
if (onlyShowBtn) {
|
|
396
489
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
397
490
|
/* @__PURE__ */ jsx(Box, { className: "cko-payment-submit-btn", children: /* @__PURE__ */ jsxs(
|
|
@@ -443,7 +536,8 @@ export default function PaymentForm({
|
|
|
443
536
|
title: t("payment.customer.pastDue.alert.title")
|
|
444
537
|
}
|
|
445
538
|
}
|
|
446
|
-
)
|
|
539
|
+
),
|
|
540
|
+
FastCheckoutConfirmDialog
|
|
447
541
|
] });
|
|
448
542
|
}
|
|
449
543
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -583,7 +677,11 @@ export default function PaymentForm({
|
|
|
583
677
|
children: state.submitting || state.paying ? t("payment.checkout.processing") : buttonText
|
|
584
678
|
}
|
|
585
679
|
) }),
|
|
586
|
-
["subscription", "setup"].includes(checkoutSession.mode) && /* @__PURE__ */ jsx(Typography, { sx: { mt: 2.5, color: "text.lighter", fontSize: "0.7875rem", lineHeight: "0.9625rem" }, children: t("payment.checkout.confirm", { payee }) })
|
|
680
|
+
["subscription", "setup"].includes(checkoutSession.mode) && /* @__PURE__ */ jsx(Typography, { sx: { mt: 2.5, color: "text.lighter", fontSize: "0.7875rem", lineHeight: "0.9625rem" }, children: showStake ? t("payment.checkout.confirm.withStake", { payee }) : t("payment.checkout.confirm.withoutStake", { payee }) }),
|
|
681
|
+
checkoutSession.metadata?.page_info?.form_purpose_description && /* @__PURE__ */ jsxs(Box, { sx: { mt: 1, display: "flex", alignItems: "center", gap: 0.5 }, children: [
|
|
682
|
+
/* @__PURE__ */ jsx(HelpOutline, { sx: { color: "text.lighter", fontSize: "0.75rem" } }),
|
|
683
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { fontSize: "0.75rem", color: "text.lighter" }, children: locale === "zh" ? checkoutSession.metadata.page_info.form_purpose_description.zh : checkoutSession.metadata.page_info.form_purpose_description.en })
|
|
684
|
+
] })
|
|
587
685
|
] }) }),
|
|
588
686
|
state.customerLimited && /* @__PURE__ */ jsx(
|
|
589
687
|
OverdueInvoicePayment,
|
|
@@ -610,6 +708,7 @@ export default function PaymentForm({
|
|
|
610
708
|
title: t("payment.customer.pastDue.alert.title")
|
|
611
709
|
}
|
|
612
710
|
}
|
|
613
|
-
)
|
|
711
|
+
),
|
|
712
|
+
FastCheckoutConfirmDialog
|
|
614
713
|
] });
|
|
615
714
|
}
|
|
@@ -49,7 +49,8 @@ function OverdueInvoicePayment({
|
|
|
49
49
|
authToken
|
|
50
50
|
}) {
|
|
51
51
|
const {
|
|
52
|
-
t
|
|
52
|
+
t,
|
|
53
|
+
locale
|
|
53
54
|
} = (0, _context.useLocaleContext)();
|
|
54
55
|
const {
|
|
55
56
|
connect,
|
|
@@ -193,12 +194,18 @@ function OverdueInvoicePayment({
|
|
|
193
194
|
extraParams.customerId = effectiveCustomerId;
|
|
194
195
|
}
|
|
195
196
|
connect.open({
|
|
197
|
+
locale,
|
|
196
198
|
containerEl: void 0,
|
|
197
199
|
saveConnect: false,
|
|
198
200
|
action: "collect-batch",
|
|
199
201
|
prefix: (0, _ufo.joinURL)((0, _util.getPrefix)(), "/api/did"),
|
|
200
202
|
useSocket: !isCrossOriginRequest,
|
|
201
203
|
extraParams,
|
|
204
|
+
messages: {
|
|
205
|
+
scan: t("common.connect.defaultScan"),
|
|
206
|
+
title: t("payment.customer.invoice.payBatch"),
|
|
207
|
+
confirm: t("common.connect.confirm")
|
|
208
|
+
},
|
|
202
209
|
onSuccess: () => {
|
|
203
210
|
connect.close();
|
|
204
211
|
handleConnected();
|
|
@@ -609,7 +609,8 @@ function CustomerInvoiceList(props) {
|
|
|
609
609
|
type
|
|
610
610
|
} = props;
|
|
611
611
|
const {
|
|
612
|
-
t
|
|
612
|
+
t,
|
|
613
|
+
locale
|
|
613
614
|
} = (0, _context.useLocaleContext)();
|
|
614
615
|
const {
|
|
615
616
|
connect
|
|
@@ -627,6 +628,7 @@ function CustomerInvoiceList(props) {
|
|
|
627
628
|
connect.open({
|
|
628
629
|
action: "collect",
|
|
629
630
|
saveConnect: false,
|
|
631
|
+
locale,
|
|
630
632
|
useSocket: (0, _util.isCrossOrigin)() === false,
|
|
631
633
|
messages: {
|
|
632
634
|
scan: "",
|
package/lib/locales/en.js
CHANGED
|
@@ -101,7 +101,13 @@ module.exports = (0, _flat.default)({
|
|
|
101
101
|
stakeAmount: "Stake Amount",
|
|
102
102
|
slashStakeAmount: "Slash Stake Amount",
|
|
103
103
|
know: "I know",
|
|
104
|
-
relatedSubscription: "Subscription"
|
|
104
|
+
relatedSubscription: "Subscription",
|
|
105
|
+
connect: {
|
|
106
|
+
defaultScan: "Use following methods to complete this action",
|
|
107
|
+
scan: "Use following methods to complete this {action}",
|
|
108
|
+
confirm: "Confirm",
|
|
109
|
+
cancel: "Cancel"
|
|
110
|
+
}
|
|
105
111
|
},
|
|
106
112
|
payment: {
|
|
107
113
|
checkout: {
|
|
@@ -173,7 +179,10 @@ module.exports = (0, _flat.default)({
|
|
|
173
179
|
donate: "Thanks for your tip",
|
|
174
180
|
tip: "A payment to {payee} has been completed. You can view the details of this payment in your account."
|
|
175
181
|
},
|
|
176
|
-
confirm:
|
|
182
|
+
confirm: {
|
|
183
|
+
withStake: "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.",
|
|
184
|
+
withoutStake: "By confirming, you allow {payee} to charge your account for future payments. You can cancel your subscription at any time."
|
|
185
|
+
},
|
|
177
186
|
required: "Required",
|
|
178
187
|
invalid: "Invalid",
|
|
179
188
|
billing: {
|
|
@@ -216,7 +225,22 @@ module.exports = (0, _flat.default)({
|
|
|
216
225
|
},
|
|
217
226
|
orderSummary: "Order Summary",
|
|
218
227
|
paymentDetails: "Payment Details",
|
|
219
|
-
productListTotal: "Includes {total} items"
|
|
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: "This payment will be processed automatically due to prior delegation or sufficient balance.",
|
|
239
|
+
confirmPrompt: "Please confirm the details before proceeding.",
|
|
240
|
+
payer: "Account",
|
|
241
|
+
amount: "Amount",
|
|
242
|
+
failed: "Account changed, please pay manually."
|
|
243
|
+
}
|
|
220
244
|
},
|
|
221
245
|
customer: {
|
|
222
246
|
payments: "Payment History",
|
|
@@ -282,7 +306,8 @@ module.exports = (0, _flat.default)({
|
|
|
282
306
|
select: "Select payment method",
|
|
283
307
|
submit: "Confirm change",
|
|
284
308
|
confirm: "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.",
|
|
285
|
-
completed: "Your payment method has been successfully updated, all future payments will use the new payment method unless you change it again."
|
|
309
|
+
completed: "Your payment method has been successfully updated, all future payments will use the new payment method unless you change it again.",
|
|
310
|
+
title: "Payment Method Change"
|
|
286
311
|
},
|
|
287
312
|
invoice: {
|
|
288
313
|
summary: "Summary",
|
|
@@ -303,7 +328,8 @@ module.exports = (0, _flat.default)({
|
|
|
303
328
|
next: "No invoices yet, next invoice will be generated on {date}",
|
|
304
329
|
invoiceNumber: "Invoice Number",
|
|
305
330
|
emptyList: "No Invoice",
|
|
306
|
-
noPaymentRequired: "No Payment Required"
|
|
331
|
+
noPaymentRequired: "No Payment Required",
|
|
332
|
+
payBatch: "Pay Due Invoices"
|
|
307
333
|
},
|
|
308
334
|
payment: {
|
|
309
335
|
empty: "There are no payments",
|
package/lib/locales/zh.js
CHANGED
|
@@ -101,7 +101,13 @@ module.exports = (0, _flat.default)({
|
|
|
101
101
|
stakeAmount: "\u8D28\u62BC\u91D1\u989D",
|
|
102
102
|
slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D",
|
|
103
103
|
know: "\u6211\u77E5\u9053\u4E86",
|
|
104
|
-
relatedSubscription: "\u8BA2\u9605"
|
|
104
|
+
relatedSubscription: "\u8BA2\u9605",
|
|
105
|
+
connect: {
|
|
106
|
+
defaultScan: "\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u5B8C\u6210\u672C\u6B21\u64CD\u4F5C",
|
|
107
|
+
scan: "\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u5B8C\u6210\u672C\u6B21{action}",
|
|
108
|
+
confirm: "\u786E\u8BA4",
|
|
109
|
+
cancel: "\u53D6\u6D88"
|
|
110
|
+
}
|
|
105
111
|
},
|
|
106
112
|
payment: {
|
|
107
113
|
checkout: {
|
|
@@ -173,7 +179,10 @@ module.exports = (0, _flat.default)({
|
|
|
173
179
|
donate: "\u611F\u8C22\u60A8\u7684\u652F\u6301",
|
|
174
180
|
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"
|
|
175
181
|
},
|
|
176
|
-
confirm:
|
|
182
|
+
confirm: {
|
|
183
|
+
withStake: "\u786E\u8BA4\u8BA2\u9605\uFF0C\u5373\u8868\u793A\u60A8\u6388\u6743 {payee} \u4ECE\u60A8\u7684\u8D26\u6237\u6263\u53D6\u672A\u6765\u6B3E\u9879\uFF0C\u5E76\u5728\u5FC5\u8981\u65F6\u7F5A\u6CA1\u8D28\u62BC\u3002\u60A8\u53EF\u968F\u65F6\u53D6\u6D88\u8BA2\u9605\u6216\u64A4\u9500\u8D28\u62BC\u3002",
|
|
184
|
+
withoutStake: "\u786E\u8BA4\u8BA2\u9605\uFF0C\u5373\u8868\u793A\u60A8\u6388\u6743 {payee} \u4ECE\u60A8\u7684\u8D26\u6237\u6263\u53D6\u672A\u6765\u6B3E\u9879\u3002\u60A8\u53EF\u968F\u65F6\u53D6\u6D88\u8BA2\u9605\u3002"
|
|
185
|
+
},
|
|
177
186
|
required: "\u5FC5\u586B\u9879",
|
|
178
187
|
invalid: "\u65E0\u6548",
|
|
179
188
|
billing: {
|
|
@@ -216,7 +225,22 @@ module.exports = (0, _flat.default)({
|
|
|
216
225
|
},
|
|
217
226
|
orderSummary: "\u8BA2\u5355\u6982\u89C8",
|
|
218
227
|
paymentDetails: "\u652F\u4ED8\u4FE1\u606F",
|
|
219
|
-
productListTotal: "\u5305\u62EC {total} \u9879"
|
|
228
|
+
productListTotal: "\u5305\u62EC {total} \u9879",
|
|
229
|
+
connectModal: {
|
|
230
|
+
title: "{action}",
|
|
231
|
+
scan: "\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u5B8C\u6210\u672C\u6B21\u652F\u4ED8",
|
|
232
|
+
confirm: "\u786E\u8BA4",
|
|
233
|
+
cancel: "\u53D6\u6D88"
|
|
234
|
+
},
|
|
235
|
+
fastPay: {
|
|
236
|
+
title: "\u786E\u8BA4\u652F\u4ED8",
|
|
237
|
+
confirmMessage: "\u60A8\u5C06\u652F\u4ED8 {amount} {symbol}\uFF0C\u4ECE{sourceType}\u6263\u9664\u3002",
|
|
238
|
+
autoPaymentReason: "\u7531\u4E8E\u6388\u6743\u6216\u4F59\u989D\u5145\u8DB3\uFF0C\u7CFB\u7EDF\u5C06\u65E0\u9700\u94B1\u5305\u786E\u8BA4\u81EA\u52A8\u5B8C\u6210\u652F\u4ED8\u3002",
|
|
239
|
+
confirmPrompt: "\u8BF7\u786E\u8BA4\u652F\u4ED8\u4FE1\u606F\u65E0\u8BEF\u540E\u7EE7\u7EED\u3002",
|
|
240
|
+
payer: "\u8D26\u6237\u5730\u5740",
|
|
241
|
+
amount: "\u652F\u4ED8\u91D1\u989D",
|
|
242
|
+
failed: "\u8D26\u6237\u53D1\u751F\u53D8\u5316\uFF0C\u65E0\u6CD5\u81EA\u52A8\u5B8C\u6210\u652F\u4ED8\uFF0C\u8BF7\u624B\u52A8\u652F\u4ED8\u3002"
|
|
243
|
+
}
|
|
220
244
|
},
|
|
221
245
|
customer: {
|
|
222
246
|
payments: "\u652F\u4ED8\u5386\u53F2",
|
|
@@ -283,7 +307,8 @@ module.exports = (0, _flat.default)({
|
|
|
283
307
|
select: "\u9009\u62E9\u652F\u4ED8\u65B9\u5F0F",
|
|
284
308
|
submit: "\u786E\u8BA4\u53D8\u66F4",
|
|
285
309
|
confirm: "\u786E\u8BA4\u53D8\u66F4\u65B9\u5F0F\u610F\u5473\u7740\u4F60\u5141\u8BB8 {payee} \u4F7F\u7528\u65B0\u7684\u652F\u4ED8\u65B9\u5F0F\u652F\u4ED8\u4F60\u7684\u672A\u6765\u8D26\u5355\u3002\u4F60\u53EF\u4EE5\u968F\u65F6\u518D\u6B21\u53D8\u66F4\u652F\u4ED8\u65B9\u5F0F\u3002",
|
|
286
|
-
completed: "\u4F60\u7684\u652F\u4ED8\u65B9\u5F0F \u5DF2\u7ECF\u66F4\u65B0\u6210\u529F\u3002\u4F60\u53EF\u4EE5\u5728\u4F60\u7684\u8D26\u6237\u4E2D\u67E5\u770B\u6B64\u652F\u4ED8\u65B9\u5F0F\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002"
|
|
310
|
+
completed: "\u4F60\u7684\u652F\u4ED8\u65B9\u5F0F \u5DF2\u7ECF\u66F4\u65B0\u6210\u529F\u3002\u4F60\u53EF\u4EE5\u5728\u4F60\u7684\u8D26\u6237\u4E2D\u67E5\u770B\u6B64\u652F\u4ED8\u65B9\u5F0F\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002",
|
|
311
|
+
title: "\u652F\u4ED8\u65B9\u5F0F\u53D8\u66F4"
|
|
287
312
|
},
|
|
288
313
|
invoice: {
|
|
289
314
|
summary: "\u6458\u8981",
|
|
@@ -304,7 +329,8 @@ module.exports = (0, _flat.default)({
|
|
|
304
329
|
next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210",
|
|
305
330
|
invoiceNumber: "\u8D26\u5355\u7F16\u53F7",
|
|
306
331
|
emptyList: "\u6CA1\u6709\u8D26\u5355",
|
|
307
|
-
noPaymentRequired: "\u65E0\u9700\u652F\u4ED8"
|
|
332
|
+
noPaymentRequired: "\u65E0\u9700\u652F\u4ED8",
|
|
333
|
+
payBatch: "\u652F\u4ED8\u6B20\u6B3E"
|
|
308
334
|
},
|
|
309
335
|
payment: {
|
|
310
336
|
empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55",
|