@blocklet/payment-react 1.21.3 → 1.21.4
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/locales/en.js +1 -0
- package/es/locales/zh.js +1 -0
- package/es/payment/form/index.js +21 -1
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/payment/form/index.js +19 -1
- package/package.json +3 -3
- package/src/locales/en.tsx +1 -0
- package/src/locales/zh.tsx +1 -0
- package/src/payment/form/index.tsx +30 -2
package/es/locales/en.js
CHANGED
|
@@ -181,6 +181,7 @@ export default flat({
|
|
|
181
181
|
tip: "A payment to {payee} has been completed. You can view the details of this payment in your account."
|
|
182
182
|
},
|
|
183
183
|
vendor: {
|
|
184
|
+
accountRequired: "This action requires a unified account. Please switch accounts and try again.",
|
|
184
185
|
processing: "Processing...",
|
|
185
186
|
progress: "Progress {progress}%",
|
|
186
187
|
delivered: "Installation completed",
|
package/es/locales/zh.js
CHANGED
|
@@ -181,6 +181,7 @@ export default flat({
|
|
|
181
181
|
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"
|
|
182
182
|
},
|
|
183
183
|
vendor: {
|
|
184
|
+
accountRequired: "\u60A8\u5F53\u524D\u4F7F\u7528\u7684\u662F\u975E\u7EDF\u4E00\u8D26\u6237\u767B\u5F55\uFF0C\u6B64\u670D\u52A1\u9700\u8981\u60A8\u4F7F\u7528\u7EDF\u4E00\u8D26\u6237\u3002\u8BF7\u5207\u6362\u5230\u7EDF\u4E00\u8D26\u6237\u767B\u5F55\u540E\u91CD\u8BD5\u3002",
|
|
184
185
|
processing: "\u6B63\u5728\u5B89\u88C5\u4E2D...",
|
|
185
186
|
progress: "\u8FDB\u5EA6 {progress}%",
|
|
186
187
|
delivered: "\u5B89\u88C5\u6210\u529F",
|
package/es/payment/form/index.js
CHANGED
|
@@ -386,13 +386,33 @@ export default function PaymentForm({
|
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
const onFormSubmit = async (data) => {
|
|
389
|
+
const userInfo = session.user;
|
|
390
|
+
if (!userInfo.sourceAppPid) {
|
|
391
|
+
const hasVendorConfig = checkoutSession.line_items?.some(
|
|
392
|
+
(item) => !!item?.price?.product?.vendor_config?.length
|
|
393
|
+
);
|
|
394
|
+
if (hasVendorConfig) {
|
|
395
|
+
Toast.error(t("payment.checkout.vendor.accountRequired"));
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
389
399
|
setState({ submitting: true });
|
|
390
400
|
try {
|
|
391
401
|
let result;
|
|
392
402
|
if (isDonationMode) {
|
|
393
403
|
result = await api.put(`/api/checkout-sessions/${checkoutSession.id}/donate-submit`, data);
|
|
394
404
|
} else {
|
|
395
|
-
|
|
405
|
+
try {
|
|
406
|
+
result = await api.put(`/api/checkout-sessions/${checkoutSession.id}/submit`, data);
|
|
407
|
+
} catch (err) {
|
|
408
|
+
console.error(err);
|
|
409
|
+
if (err.response?.data?.code === "UNIFIED_APP_REQUIRED") {
|
|
410
|
+
Toast.error(t("payment.checkout.vendor.accountRequired"));
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
Toast.error(formatError(err));
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
396
416
|
}
|
|
397
417
|
setState({
|
|
398
418
|
paymentIntent: result.data.paymentIntent,
|
package/lib/locales/en.js
CHANGED
|
@@ -188,6 +188,7 @@ module.exports = (0, _flat.default)({
|
|
|
188
188
|
tip: "A payment to {payee} has been completed. You can view the details of this payment in your account."
|
|
189
189
|
},
|
|
190
190
|
vendor: {
|
|
191
|
+
accountRequired: "This action requires a unified account. Please switch accounts and try again.",
|
|
191
192
|
processing: "Processing...",
|
|
192
193
|
progress: "Progress {progress}%",
|
|
193
194
|
delivered: "Installation completed",
|
package/lib/locales/zh.js
CHANGED
|
@@ -188,6 +188,7 @@ module.exports = (0, _flat.default)({
|
|
|
188
188
|
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"
|
|
189
189
|
},
|
|
190
190
|
vendor: {
|
|
191
|
+
accountRequired: "\u60A8\u5F53\u524D\u4F7F\u7528\u7684\u662F\u975E\u7EDF\u4E00\u8D26\u6237\u767B\u5F55\uFF0C\u6B64\u670D\u52A1\u9700\u8981\u60A8\u4F7F\u7528\u7EDF\u4E00\u8D26\u6237\u3002\u8BF7\u5207\u6362\u5230\u7EDF\u4E00\u8D26\u6237\u767B\u5F55\u540E\u91CD\u8BD5\u3002",
|
|
191
192
|
processing: "\u6B63\u5728\u5B89\u88C5\u4E2D...",
|
|
192
193
|
progress: "\u8FDB\u5EA6 {progress}%",
|
|
193
194
|
delivered: "\u5B89\u88C5\u6210\u529F",
|
|
@@ -447,6 +447,14 @@ function PaymentForm({
|
|
|
447
447
|
}
|
|
448
448
|
};
|
|
449
449
|
const onFormSubmit = async data => {
|
|
450
|
+
const userInfo = session.user;
|
|
451
|
+
if (!userInfo.sourceAppPid) {
|
|
452
|
+
const hasVendorConfig = checkoutSession.line_items?.some(item => !!item?.price?.product?.vendor_config?.length);
|
|
453
|
+
if (hasVendorConfig) {
|
|
454
|
+
_Toast.default.error(t("payment.checkout.vendor.accountRequired"));
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
450
458
|
setState({
|
|
451
459
|
submitting: true
|
|
452
460
|
});
|
|
@@ -455,7 +463,17 @@ function PaymentForm({
|
|
|
455
463
|
if (isDonationMode) {
|
|
456
464
|
result = await _api.default.put(`/api/checkout-sessions/${checkoutSession.id}/donate-submit`, data);
|
|
457
465
|
} else {
|
|
458
|
-
|
|
466
|
+
try {
|
|
467
|
+
result = await _api.default.put(`/api/checkout-sessions/${checkoutSession.id}/submit`, data);
|
|
468
|
+
} catch (err) {
|
|
469
|
+
console.error(err);
|
|
470
|
+
if (err.response?.data?.code === "UNIFIED_APP_REQUIRED") {
|
|
471
|
+
_Toast.default.error(t("payment.checkout.vendor.accountRequired"));
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
_Toast.default.error((0, _util2.formatError)(err));
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
459
477
|
}
|
|
460
478
|
setState({
|
|
461
479
|
paymentIntent: result.data.paymentIntent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.4",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@babel/core": "^7.27.4",
|
|
95
95
|
"@babel/preset-env": "^7.27.2",
|
|
96
96
|
"@babel/preset-react": "^7.27.1",
|
|
97
|
-
"@blocklet/payment-types": "1.21.
|
|
97
|
+
"@blocklet/payment-types": "1.21.4",
|
|
98
98
|
"@storybook/addon-essentials": "^7.6.20",
|
|
99
99
|
"@storybook/addon-interactions": "^7.6.20",
|
|
100
100
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"vite-plugin-babel": "^1.3.1",
|
|
126
126
|
"vite-plugin-node-polyfills": "^0.23.0"
|
|
127
127
|
},
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "d650fbb4c391c1d58bc7ebbd9dedf11901db9f89"
|
|
129
129
|
}
|
package/src/locales/en.tsx
CHANGED
|
@@ -184,6 +184,7 @@ export default flat({
|
|
|
184
184
|
tip: 'A payment to {payee} has been completed. You can view the details of this payment in your account.',
|
|
185
185
|
},
|
|
186
186
|
vendor: {
|
|
187
|
+
accountRequired: 'This action requires a unified account. Please switch accounts and try again.',
|
|
187
188
|
processing: 'Processing...',
|
|
188
189
|
progress: 'Progress {progress}%',
|
|
189
190
|
delivered: 'Installation completed',
|
package/src/locales/zh.tsx
CHANGED
|
@@ -4,7 +4,13 @@ import 'react-international-phone/style.css';
|
|
|
4
4
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
5
5
|
// import { useTheme } from '@arcblock/ux/lib/Theme';
|
|
6
6
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
TCheckoutSession,
|
|
9
|
+
TCustomer,
|
|
10
|
+
TLineItemExpanded,
|
|
11
|
+
TPaymentIntent,
|
|
12
|
+
TPaymentMethodExpanded,
|
|
13
|
+
} from '@blocklet/payment-types';
|
|
8
14
|
import { Box, Button, CircularProgress, Divider, Fade, Stack, Tooltip, Typography } from '@mui/material';
|
|
9
15
|
import { useMemoizedFn, useSetState } from 'ahooks';
|
|
10
16
|
import pWaitFor from 'p-wait-for';
|
|
@@ -515,13 +521,35 @@ export default function PaymentForm({
|
|
|
515
521
|
};
|
|
516
522
|
|
|
517
523
|
const onFormSubmit = async (data: any) => {
|
|
524
|
+
const userInfo = session.user;
|
|
525
|
+
|
|
526
|
+
if (!userInfo.sourceAppPid) {
|
|
527
|
+
const hasVendorConfig = checkoutSession.line_items?.some(
|
|
528
|
+
(item: TLineItemExpanded) => !!item?.price?.product?.vendor_config?.length
|
|
529
|
+
);
|
|
530
|
+
if (hasVendorConfig) {
|
|
531
|
+
Toast.error(t('payment.checkout.vendor.accountRequired'));
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
518
536
|
setState({ submitting: true });
|
|
519
537
|
try {
|
|
520
538
|
let result;
|
|
521
539
|
if (isDonationMode) {
|
|
522
540
|
result = await api.put(`/api/checkout-sessions/${checkoutSession.id}/donate-submit`, data);
|
|
523
541
|
} else {
|
|
524
|
-
|
|
542
|
+
try {
|
|
543
|
+
result = await api.put(`/api/checkout-sessions/${checkoutSession.id}/submit`, data);
|
|
544
|
+
} catch (err: any) {
|
|
545
|
+
console.error(err);
|
|
546
|
+
if (err.response?.data?.code === 'UNIFIED_APP_REQUIRED') {
|
|
547
|
+
Toast.error(t('payment.checkout.vendor.accountRequired'));
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
Toast.error(formatError(err));
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
525
553
|
}
|
|
526
554
|
|
|
527
555
|
setState({
|