@blocklet/payment-react 1.18.19 → 1.18.21
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.d.ts +3 -1
- package/es/components/over-due-invoice-payment.js +15 -7
- package/es/libs/phone-validator.d.ts +7 -0
- package/es/libs/phone-validator.js +93 -2
- package/es/locales/en.js +7 -5
- package/es/locales/zh.js +7 -4
- package/es/payment/donation-form.js +62 -22
- package/es/payment/form/index.js +101 -65
- package/es/payment/form/phone.js +31 -10
- package/es/payment/index.js +11 -8
- package/es/payment/product-donation.js +7 -4
- package/lib/components/over-due-invoice-payment.d.ts +3 -1
- package/lib/components/over-due-invoice-payment.js +15 -7
- package/lib/libs/phone-validator.d.ts +7 -0
- package/lib/libs/phone-validator.js +97 -6
- package/lib/locales/en.js +7 -5
- package/lib/locales/zh.js +7 -4
- package/lib/payment/donation-form.js +51 -15
- package/lib/payment/form/index.js +106 -62
- package/lib/payment/form/phone.js +25 -9
- package/lib/payment/index.js +9 -8
- package/lib/payment/product-donation.js +7 -4
- package/package.json +6 -6
- package/src/components/over-due-invoice-payment.tsx +14 -6
- package/src/libs/phone-validator.ts +89 -2
- package/src/locales/en.tsx +6 -5
- package/src/locales/zh.tsx +6 -4
- package/src/payment/donation-form.tsx +57 -19
- package/src/payment/form/index.tsx +133 -69
- package/src/payment/form/phone.tsx +34 -12
- package/src/payment/index.tsx +13 -8
- package/src/payment/product-donation.tsx +7 -5
package/es/payment/form/phone.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { InputAdornment } from "@mui/material";
|
|
3
3
|
import omit from "lodash/omit";
|
|
4
|
-
import { useEffect } from "react";
|
|
4
|
+
import { useEffect, useRef, useCallback } from "react";
|
|
5
5
|
import { useFormContext, useWatch } from "react-hook-form";
|
|
6
6
|
import { defaultCountries, usePhoneInput } from "react-international-phone";
|
|
7
7
|
import FormInput from "../../components/input.js";
|
|
@@ -11,25 +11,46 @@ export default function PhoneInput({ ...props }) {
|
|
|
11
11
|
const countryFieldName = props.countryFieldName || "billing_address.country";
|
|
12
12
|
const { control, getValues, setValue } = useFormContext();
|
|
13
13
|
const values = getValues();
|
|
14
|
+
const isUpdatingRef = useRef(false);
|
|
15
|
+
const safeUpdate = useCallback((callback) => {
|
|
16
|
+
if (isUpdatingRef.current)
|
|
17
|
+
return;
|
|
18
|
+
try {
|
|
19
|
+
isUpdatingRef.current = true;
|
|
20
|
+
callback();
|
|
21
|
+
} finally {
|
|
22
|
+
requestAnimationFrame(() => {
|
|
23
|
+
isUpdatingRef.current = false;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
14
27
|
const { phone, handlePhoneValueChange, inputRef, country, setCountry } = usePhoneInput({
|
|
15
28
|
defaultCountry: isValidCountry(values[countryFieldName]) ? values[countryFieldName] : "us",
|
|
16
29
|
value: values[props.name] || "",
|
|
17
30
|
countries: defaultCountries,
|
|
18
31
|
onChange: (data) => {
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
safeUpdate(() => {
|
|
33
|
+
setValue(props.name, data.phone);
|
|
34
|
+
setValue(countryFieldName, data.country);
|
|
35
|
+
});
|
|
21
36
|
}
|
|
22
37
|
});
|
|
23
38
|
const userCountry = useWatch({ control, name: countryFieldName });
|
|
24
39
|
useEffect(() => {
|
|
25
|
-
if (userCountry
|
|
40
|
+
if (!userCountry || userCountry === country)
|
|
41
|
+
return;
|
|
42
|
+
safeUpdate(() => {
|
|
26
43
|
setCountry(userCountry);
|
|
27
|
-
}
|
|
28
|
-
}, [userCountry]);
|
|
29
|
-
const onCountryChange = (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
});
|
|
45
|
+
}, [userCountry, country, setCountry, safeUpdate]);
|
|
46
|
+
const onCountryChange = useCallback(
|
|
47
|
+
(v) => {
|
|
48
|
+
safeUpdate(() => {
|
|
49
|
+
setCountry(v);
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
[setCountry, safeUpdate]
|
|
53
|
+
);
|
|
33
54
|
return (
|
|
34
55
|
// @ts-ignore
|
|
35
56
|
/* @__PURE__ */ jsx(
|
package/es/payment/index.js
CHANGED
|
@@ -28,6 +28,7 @@ import PaymentSkeleton from "./skeleton/payment.js";
|
|
|
28
28
|
import PaymentSuccess from "./success.js";
|
|
29
29
|
import PaymentSummary from "./summary.js";
|
|
30
30
|
import { useMobile } from "../hooks/mobile.js";
|
|
31
|
+
import { formatPhone } from "../libs/phone-validator.js";
|
|
31
32
|
PaymentInner.defaultProps = {
|
|
32
33
|
completed: false,
|
|
33
34
|
showCheckoutSummary: true
|
|
@@ -58,20 +59,22 @@ function PaymentInner({
|
|
|
58
59
|
defaultValues: {
|
|
59
60
|
customer_name: customer?.name || session?.user?.fullName || "",
|
|
60
61
|
customer_email: customer?.email || session?.user?.email || "",
|
|
61
|
-
customer_phone: customer?.phone || session?.user?.phone || "",
|
|
62
|
+
customer_phone: formatPhone(customer?.phone || session?.user?.phone || ""),
|
|
62
63
|
payment_method: defaultMethodId,
|
|
63
64
|
payment_currency: defaultCurrencyId,
|
|
64
65
|
billing_address: Object.assign(
|
|
65
66
|
{
|
|
66
|
-
country: "",
|
|
67
|
-
state: "",
|
|
68
|
-
city: "",
|
|
69
|
-
line1: "",
|
|
70
|
-
line2: "",
|
|
71
|
-
postal_code: ""
|
|
67
|
+
country: session?.user?.address?.country || "",
|
|
68
|
+
state: session?.user?.address?.province || "",
|
|
69
|
+
city: session?.user?.address?.city || "",
|
|
70
|
+
line1: session?.user?.address?.line1 || "",
|
|
71
|
+
line2: session?.user?.address?.line2 || "",
|
|
72
|
+
postal_code: session?.user?.address?.postalCode || ""
|
|
72
73
|
},
|
|
73
74
|
customer?.address || {},
|
|
74
|
-
{
|
|
75
|
+
{
|
|
76
|
+
country: isValidCountry(customer?.address?.country || session?.user?.address?.country || "") ? customer?.address?.country : "us"
|
|
77
|
+
}
|
|
75
78
|
)
|
|
76
79
|
}
|
|
77
80
|
});
|
|
@@ -35,9 +35,6 @@ export default function ProductDonation({
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
const getDefaultPreset = () => {
|
|
38
|
-
if (settings?.amount?.preset) {
|
|
39
|
-
return formatAmount(settings.amount.preset);
|
|
40
|
-
}
|
|
41
38
|
try {
|
|
42
39
|
const savedPreset = localStorage.getItem(getUserStorageKey(DONATION_PRESET_KEY_BASE));
|
|
43
40
|
if (savedPreset) {
|
|
@@ -53,7 +50,13 @@ export default function ProductDonation({
|
|
|
53
50
|
}
|
|
54
51
|
if (presets.length > 0) {
|
|
55
52
|
const middleIndex = Math.floor(presets.length / 2);
|
|
56
|
-
return presets[middleIndex]
|
|
53
|
+
return presets[middleIndex];
|
|
54
|
+
}
|
|
55
|
+
if (settings?.amount?.preset) {
|
|
56
|
+
return formatAmount(settings.amount.preset);
|
|
57
|
+
}
|
|
58
|
+
if (presets.length > 0) {
|
|
59
|
+
return presets[0];
|
|
57
60
|
}
|
|
58
61
|
return "0";
|
|
59
62
|
};
|
|
@@ -17,6 +17,7 @@ type Props = {
|
|
|
17
17
|
dialogProps?: DialogProps;
|
|
18
18
|
detailLinkOptions?: DetailLinkOptions;
|
|
19
19
|
successToast?: boolean;
|
|
20
|
+
alertMessage?: string;
|
|
20
21
|
children?: (handlePay: (item: SummaryItem) => void, data: {
|
|
21
22
|
subscription?: Subscription;
|
|
22
23
|
summary: {
|
|
@@ -32,7 +33,7 @@ type SummaryItem = {
|
|
|
32
33
|
currency: PaymentCurrency;
|
|
33
34
|
method: PaymentMethod;
|
|
34
35
|
};
|
|
35
|
-
declare function OverdueInvoicePayment({ subscriptionId, customerId, mode, dialogProps, children, onPaid, detailLinkOptions, successToast, }: Props): import("react").JSX.Element | null;
|
|
36
|
+
declare function OverdueInvoicePayment({ subscriptionId, customerId, mode, dialogProps, children, onPaid, detailLinkOptions, successToast, alertMessage, }: Props): import("react").JSX.Element | null;
|
|
36
37
|
declare namespace OverdueInvoicePayment {
|
|
37
38
|
var defaultProps: {
|
|
38
39
|
mode: string;
|
|
@@ -47,6 +48,7 @@ declare namespace OverdueInvoicePayment {
|
|
|
47
48
|
subscriptionId: undefined;
|
|
48
49
|
customerId: undefined;
|
|
49
50
|
successToast: boolean;
|
|
51
|
+
alertMessage: string;
|
|
50
52
|
};
|
|
51
53
|
}
|
|
52
54
|
export default OverdueInvoicePayment;
|
|
@@ -43,7 +43,8 @@ function OverdueInvoicePayment({
|
|
|
43
43
|
detailLinkOptions = {
|
|
44
44
|
enabled: true
|
|
45
45
|
},
|
|
46
|
-
successToast = true
|
|
46
|
+
successToast = true,
|
|
47
|
+
alertMessage = ""
|
|
47
48
|
}) {
|
|
48
49
|
const {
|
|
49
50
|
t
|
|
@@ -274,19 +275,25 @@ function OverdueInvoicePayment({
|
|
|
274
275
|
});
|
|
275
276
|
}
|
|
276
277
|
if (customerId) {
|
|
278
|
+
let title = "";
|
|
277
279
|
if (summaryList.length === 1) {
|
|
278
|
-
|
|
280
|
+
title = t("payment.customer.overdue.title", {
|
|
279
281
|
subscriptionCount: data.subscriptionCount || 0,
|
|
280
282
|
count: data.invoices?.length,
|
|
281
283
|
total: (0, _util.formatAmount)(summaryList[0]?.amount, summaryList[0]?.currency?.decimal),
|
|
282
284
|
symbol: summaryList[0]?.currency?.symbol,
|
|
283
285
|
method: getMethodText(summaryList[0]?.method)
|
|
284
286
|
});
|
|
287
|
+
} else {
|
|
288
|
+
title = t("payment.customer.overdue.simpleTitle", {
|
|
289
|
+
subscriptionCount: data.subscriptionCount || 0,
|
|
290
|
+
count: data.invoices?.length
|
|
291
|
+
});
|
|
285
292
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
})
|
|
293
|
+
if (alertMessage) {
|
|
294
|
+
return `${title}${alertMessage}`;
|
|
295
|
+
}
|
|
296
|
+
return `${title}${t("payment.customer.overdue.defaultAlert")}`;
|
|
290
297
|
}
|
|
291
298
|
return "";
|
|
292
299
|
};
|
|
@@ -442,6 +449,7 @@ OverdueInvoicePayment.defaultProps = {
|
|
|
442
449
|
},
|
|
443
450
|
subscriptionId: void 0,
|
|
444
451
|
customerId: void 0,
|
|
445
|
-
successToast: true
|
|
452
|
+
successToast: true,
|
|
453
|
+
alertMessage: ""
|
|
446
454
|
};
|
|
447
455
|
module.exports = OverdueInvoicePayment;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export declare const getPhoneUtil: () => Promise<any>;
|
|
2
2
|
export declare const validatePhoneNumber: (phoneNumber: string) => Promise<any>;
|
|
3
|
+
/**
|
|
4
|
+
* Format a phone number to international format
|
|
5
|
+
* @param phoneNumber The original phone number
|
|
6
|
+
* @param defaultCountry Default country code (ISO 3166-1 alpha-2)
|
|
7
|
+
* @returns Formatted phone number
|
|
8
|
+
*/
|
|
9
|
+
export declare const formatPhone: (phoneNumber: string | undefined, defaultCountry?: string) => string;
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.validatePhoneNumber = exports.getPhoneUtil = void 0;
|
|
6
|
+
exports.validatePhoneNumber = exports.getPhoneUtil = exports.formatPhone = void 0;
|
|
7
7
|
let phoneUtil = null;
|
|
8
8
|
const getPhoneUtil = async () => {
|
|
9
9
|
if (!phoneUtil) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const result = await Promise.resolve().then(() => require("google-libphonenumber"));
|
|
11
|
+
const PhoneNumberUtil = (result.default || result)?.PhoneNumberUtil;
|
|
12
|
+
if (!PhoneNumberUtil) {
|
|
13
|
+
throw new Error("PhoneNumberUtil not found");
|
|
14
|
+
}
|
|
13
15
|
phoneUtil = PhoneNumberUtil.getInstance();
|
|
14
16
|
}
|
|
15
17
|
return phoneUtil;
|
|
@@ -17,7 +19,13 @@ const getPhoneUtil = async () => {
|
|
|
17
19
|
exports.getPhoneUtil = getPhoneUtil;
|
|
18
20
|
const validatePhoneNumber = async phoneNumber => {
|
|
19
21
|
try {
|
|
20
|
-
|
|
22
|
+
let util = null;
|
|
23
|
+
try {
|
|
24
|
+
util = await getPhoneUtil();
|
|
25
|
+
} catch (err) {
|
|
26
|
+
const pattern = /^[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,6}$/im;
|
|
27
|
+
return pattern.test(phoneNumber);
|
|
28
|
+
}
|
|
21
29
|
const parsed = util.parseAndKeepRawInput(phoneNumber);
|
|
22
30
|
return util.isValidNumber(parsed);
|
|
23
31
|
} catch (err) {
|
|
@@ -25,4 +33,87 @@ const validatePhoneNumber = async phoneNumber => {
|
|
|
25
33
|
return false;
|
|
26
34
|
}
|
|
27
35
|
};
|
|
28
|
-
exports.validatePhoneNumber = validatePhoneNumber;
|
|
36
|
+
exports.validatePhoneNumber = validatePhoneNumber;
|
|
37
|
+
const formatPhone = (phoneNumber, defaultCountry = "US") => {
|
|
38
|
+
if (!phoneNumber || phoneNumber.trim() === "") {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
const cleanedNumber = phoneNumber.replace(/[^\d+]/g, "");
|
|
42
|
+
if (cleanedNumber.startsWith("+")) {
|
|
43
|
+
return cleanedNumber;
|
|
44
|
+
}
|
|
45
|
+
const COUNTRY_CODES = {
|
|
46
|
+
US: "1",
|
|
47
|
+
// United States
|
|
48
|
+
CA: "1",
|
|
49
|
+
// Canada
|
|
50
|
+
CN: "86",
|
|
51
|
+
// China
|
|
52
|
+
HK: "852",
|
|
53
|
+
// Hong Kong
|
|
54
|
+
IN: "91",
|
|
55
|
+
// India
|
|
56
|
+
UK: "44",
|
|
57
|
+
// United Kingdom
|
|
58
|
+
GB: "44",
|
|
59
|
+
// United Kingdom
|
|
60
|
+
JP: "81",
|
|
61
|
+
// Japan
|
|
62
|
+
KR: "82",
|
|
63
|
+
// South Korea
|
|
64
|
+
AU: "61",
|
|
65
|
+
// Australia
|
|
66
|
+
DE: "49",
|
|
67
|
+
// Germany
|
|
68
|
+
FR: "33",
|
|
69
|
+
// France
|
|
70
|
+
IT: "39",
|
|
71
|
+
// Italy
|
|
72
|
+
ES: "34",
|
|
73
|
+
// Spain
|
|
74
|
+
BR: "55",
|
|
75
|
+
// Brazil
|
|
76
|
+
RU: "7",
|
|
77
|
+
// Russia
|
|
78
|
+
MX: "52",
|
|
79
|
+
// Mexico
|
|
80
|
+
SG: "65",
|
|
81
|
+
// Singapore
|
|
82
|
+
AE: "971"
|
|
83
|
+
// UAE
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const COUNTRY_PATTERNS = [[/^1[3-9]\d{9}$/, "86"],
|
|
87
|
+
// China mobile: 11 digits, starts with 1
|
|
88
|
+
[/^\d{10}$/, "1"],
|
|
89
|
+
// US/Canada: 10 digits
|
|
90
|
+
[/^[6-9]\d{9}$/, "91"],
|
|
91
|
+
// India: 10 digits, starts with 6-9
|
|
92
|
+
[/^0[1-9]\d{8,9}$/, "81"],
|
|
93
|
+
// Japan: 10-11 digits, starts with 0
|
|
94
|
+
[/^07\d{9}$/, "44"],
|
|
95
|
+
// UK mobile: 11 digits, starts with 07
|
|
96
|
+
[/^04\d{8}$/, "61"],
|
|
97
|
+
// Australia mobile: 10 digits, starts with 04
|
|
98
|
+
[/^01[0-9]\d{7,8}$/, "82"],
|
|
99
|
+
// Korea mobile: 10-11 digits, starts with 01
|
|
100
|
+
[/^[0-9]\d{8}$/, "86"]
|
|
101
|
+
// China landline: 9 digits
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
let numberToFormat = cleanedNumber;
|
|
105
|
+
if (numberToFormat.startsWith("0")) {
|
|
106
|
+
numberToFormat = numberToFormat.substring(1);
|
|
107
|
+
}
|
|
108
|
+
for (const [pattern, countryCode2] of COUNTRY_PATTERNS) {
|
|
109
|
+
if (pattern.test(cleanedNumber)) {
|
|
110
|
+
if (cleanedNumber.startsWith("0") && !["1", "86"].includes(countryCode2)) {
|
|
111
|
+
return `+${countryCode2}${cleanedNumber.substring(1)}`;
|
|
112
|
+
}
|
|
113
|
+
return `+${countryCode2}${cleanedNumber}`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const countryCode = COUNTRY_CODES[defaultCountry.toUpperCase()] || defaultCountry;
|
|
117
|
+
return `+${countryCode}${numberToFormat}`;
|
|
118
|
+
};
|
|
119
|
+
exports.formatPhone = formatPhone;
|
package/lib/locales/en.js
CHANGED
|
@@ -138,6 +138,7 @@ module.exports = (0, _flat.default)({
|
|
|
138
138
|
empty: "No supporters yet",
|
|
139
139
|
gaveTips: "{count} people gave tips",
|
|
140
140
|
tipAmount: "Tip Amount",
|
|
141
|
+
tabHint: "to switch amount",
|
|
141
142
|
benefits: {
|
|
142
143
|
one: "{name} will receive all tips",
|
|
143
144
|
multiple: "Tips will be distributed to {count} beneficiaries",
|
|
@@ -151,7 +152,7 @@ module.exports = (0, _flat.default)({
|
|
|
151
152
|
later: "Configure Later",
|
|
152
153
|
configTip: "Configure donation settings in Payment Kit"
|
|
153
154
|
},
|
|
154
|
-
cardPay: "{action} with card",
|
|
155
|
+
cardPay: "{action} with bank card",
|
|
155
156
|
empty: "No thing to pay",
|
|
156
157
|
per: "per",
|
|
157
158
|
pay: "Pay {payee}",
|
|
@@ -248,7 +249,7 @@ module.exports = (0, _flat.default)({
|
|
|
248
249
|
warning: "Past due invoices need to be paid immediately, otherwise you can not make new purchases anymore.",
|
|
249
250
|
alert: {
|
|
250
251
|
title: "You have unpaid invoices",
|
|
251
|
-
|
|
252
|
+
customMessage: "Please pay immediately, otherwise new purchases or subscriptions will be prohibited.",
|
|
252
253
|
confirm: "Pay Now"
|
|
253
254
|
},
|
|
254
255
|
view: "View Due Invoices"
|
|
@@ -324,9 +325,10 @@ module.exports = (0, _flat.default)({
|
|
|
324
325
|
owner: "Subscription Owner"
|
|
325
326
|
},
|
|
326
327
|
overdue: {
|
|
327
|
-
title: "You have {count} due invoices for {subscriptionCount} subscriptions, totaling {total} {symbol}{method}.
|
|
328
|
-
simpleTitle: "You have {count} due invoices.
|
|
329
|
-
empty: "Great! You have no due invoices."
|
|
328
|
+
title: "You have {count} due invoices for {subscriptionCount} subscriptions, totaling {total} {symbol}{method}. ",
|
|
329
|
+
simpleTitle: "You have {count} due invoices. ",
|
|
330
|
+
empty: "Great! You have no due invoices.",
|
|
331
|
+
defaultAlert: "Please pay immediately to avoid service disruption."
|
|
330
332
|
}
|
|
331
333
|
},
|
|
332
334
|
invoice: {
|
package/lib/locales/zh.js
CHANGED
|
@@ -138,6 +138,7 @@ module.exports = (0, _flat.default)({
|
|
|
138
138
|
empty: "\u2764\uFE0F \u652F\u6301\u4E00\u4E0B",
|
|
139
139
|
gaveTips: "\u5DF2\u6709 {count} \u4EBA\u6253\u8D4F",
|
|
140
140
|
tipAmount: "\u6253\u8D4F\u91D1\u989D",
|
|
141
|
+
tabHint: "\u5FEB\u901F\u5207\u6362\u91D1\u989D",
|
|
141
142
|
benefits: {
|
|
142
143
|
one: "{name} \u5C06\u83B7\u5F97\u5168\u90E8\u6253\u8D4F",
|
|
143
144
|
multiple: "\u6253\u8D4F\u5C06\u6309\u6BD4\u4F8B\u5206\u914D\u7ED9 {count} \u4F4D\u53D7\u76CA\u4EBA",
|
|
@@ -151,7 +152,7 @@ module.exports = (0, _flat.default)({
|
|
|
151
152
|
later: "\u7A0D\u540E\u914D\u7F6E",
|
|
152
153
|
configTip: "\u524D\u5F80 Payment Kit \u914D\u7F6E\u6253\u8D4F\u9009\u9879"
|
|
153
154
|
},
|
|
154
|
-
cardPay: "\u4F7F\u7528\u5361
|
|
155
|
+
cardPay: "\u4F7F\u7528\u94F6\u884C\u5361{action}",
|
|
155
156
|
empty: "\u6CA1\u6709\u53EF\u652F\u4ED8\u7684\u9879\u76EE",
|
|
156
157
|
per: "\u6BCF",
|
|
157
158
|
pay: "\u4ED8\u6B3E\u7ED9 {payee}",
|
|
@@ -249,6 +250,7 @@ module.exports = (0, _flat.default)({
|
|
|
249
250
|
alert: {
|
|
250
251
|
title: "\u4F60\u6709\u6B20\u8D39\u8D26\u5355",
|
|
251
252
|
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",
|
|
253
|
+
customMessage: "\u8BF7\u7ACB\u5373\u652F\u4ED8\uFF0C\u5426\u5219\u65B0\u7684\u8D2D\u4E70\u6216\u8005\u8BA2\u9605\u5C06\u88AB\u7981\u6B62\u3002",
|
|
252
254
|
confirm: "\u53BB\u652F\u4ED8"
|
|
253
255
|
},
|
|
254
256
|
view: "\u67E5\u770B\u6B20\u8D39\u660E\u7EC6"
|
|
@@ -324,9 +326,10 @@ module.exports = (0, _flat.default)({
|
|
|
324
326
|
owner: "\u8BA2\u9605\u62E5\u6709\u8005"
|
|
325
327
|
},
|
|
326
328
|
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
|
|
328
|
-
simpleTitle: "\u60A8\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355
|
|
329
|
-
empty: "\u606D\u559C\uFF01\u60A8\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355\u3002"
|
|
329
|
+
title: "\u60A8\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u6D89\u53CA {subscriptionCount} \u4E2A\u8BA2\u9605\uFF0C\u603B\u91D1\u989D {total} {symbol}{method}\u3002",
|
|
330
|
+
simpleTitle: "\u60A8\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355,",
|
|
331
|
+
empty: "\u606D\u559C\uFF01\u60A8\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355\u3002",
|
|
332
|
+
defaultAlert: "\u8BF7\u7ACB\u5373\u652F\u4ED8\uFF0C\u4EE5\u514D\u5F71\u54CD\u60A8\u7684\u4F7F\u7528\u3002"
|
|
330
333
|
}
|
|
331
334
|
},
|
|
332
335
|
invoice: {
|
|
@@ -28,6 +28,7 @@ var _productDonation = _interopRequireDefault(require("./product-donation"));
|
|
|
28
28
|
var _confirm = _interopRequireDefault(require("../components/confirm"));
|
|
29
29
|
var _paymentBeneficiaries = _interopRequireDefault(require("../components/payment-beneficiaries"));
|
|
30
30
|
var _donation = _interopRequireDefault(require("./skeleton/donation"));
|
|
31
|
+
var _phoneValidator = require("../libs/phone-validator");
|
|
31
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
33
|
const getBenefits = async (id, url) => {
|
|
33
34
|
const {
|
|
@@ -62,6 +63,9 @@ function PaymentInner({
|
|
|
62
63
|
settings,
|
|
63
64
|
session
|
|
64
65
|
} = (0, _payment.usePaymentContext)();
|
|
66
|
+
const {
|
|
67
|
+
isMobile
|
|
68
|
+
} = (0, _mobile.useMobile)();
|
|
65
69
|
const [state, setState] = (0, _ahooks.useSetState)({
|
|
66
70
|
checkoutSession,
|
|
67
71
|
submitting: false,
|
|
@@ -86,18 +90,18 @@ function PaymentInner({
|
|
|
86
90
|
defaultValues: {
|
|
87
91
|
customer_name: customer?.name || session?.user?.fullName || "",
|
|
88
92
|
customer_email: customer?.email || session?.user?.email || "",
|
|
89
|
-
customer_phone: customer?.phone || session?.user?.phone || "",
|
|
93
|
+
customer_phone: (0, _phoneValidator.formatPhone)(customer?.phone || session?.user?.phone || ""),
|
|
90
94
|
payment_method: defaultMethodId,
|
|
91
95
|
payment_currency: defaultCurrencyId,
|
|
92
96
|
billing_address: Object.assign({
|
|
93
|
-
country: "",
|
|
94
|
-
state: "",
|
|
95
|
-
city: "",
|
|
96
|
-
line1: "",
|
|
97
|
-
line2: "",
|
|
98
|
-
postal_code: ""
|
|
97
|
+
country: session?.user?.address?.country || "",
|
|
98
|
+
state: session?.user?.address?.province || "",
|
|
99
|
+
city: session?.user?.address?.city || "",
|
|
100
|
+
line1: session?.user?.address?.line1 || "",
|
|
101
|
+
line2: session?.user?.address?.line2 || "",
|
|
102
|
+
postal_code: session?.user?.address?.postalCode || ""
|
|
99
103
|
}, customer?.address || {}, {
|
|
100
|
-
country: (0, _util2.isValidCountry)(customer?.address?.country || "") ? customer?.address?.country : "us"
|
|
104
|
+
country: (0, _util2.isValidCountry)(customer?.address?.country || session?.user?.address?.country || "") ? customer?.address?.country : "us"
|
|
101
105
|
})
|
|
102
106
|
}
|
|
103
107
|
});
|
|
@@ -234,16 +238,48 @@ function PaymentInner({
|
|
|
234
238
|
sx: {
|
|
235
239
|
display: benefitsState.open ? "none" : "block"
|
|
236
240
|
},
|
|
237
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.
|
|
238
|
-
|
|
241
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
242
|
+
direction: "row",
|
|
243
|
+
justifyContent: "space-between",
|
|
244
|
+
alignItems: "center",
|
|
239
245
|
sx: {
|
|
240
|
-
color: "text.primary",
|
|
241
|
-
fontSize: "18px",
|
|
242
|
-
fontWeight: "500",
|
|
243
|
-
lineHeight: "24px",
|
|
244
246
|
mb: 2
|
|
245
247
|
},
|
|
246
|
-
children:
|
|
248
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
249
|
+
title: t("payment.checkout.orderSummary"),
|
|
250
|
+
sx: {
|
|
251
|
+
color: "text.primary",
|
|
252
|
+
fontSize: "18px",
|
|
253
|
+
fontWeight: "500",
|
|
254
|
+
lineHeight: "24px"
|
|
255
|
+
},
|
|
256
|
+
children: t("payment.checkout.donation.tipAmount")
|
|
257
|
+
}), !isMobile && donationSettings?.amount?.presets && donationSettings.amount.presets.length > 0 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
258
|
+
sx: {
|
|
259
|
+
color: "text.secondary",
|
|
260
|
+
fontSize: "13px",
|
|
261
|
+
display: "flex",
|
|
262
|
+
alignItems: "center",
|
|
263
|
+
gap: 0.5,
|
|
264
|
+
opacity: 0.8
|
|
265
|
+
},
|
|
266
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
267
|
+
component: "span",
|
|
268
|
+
sx: {
|
|
269
|
+
border: "1px solid",
|
|
270
|
+
borderColor: "divider",
|
|
271
|
+
borderRadius: 0.75,
|
|
272
|
+
px: 0.75,
|
|
273
|
+
py: 0.25,
|
|
274
|
+
fontSize: "12px",
|
|
275
|
+
lineHeight: 1,
|
|
276
|
+
color: "text.secondary",
|
|
277
|
+
fontWeight: "400",
|
|
278
|
+
bgcolor: "transparent"
|
|
279
|
+
},
|
|
280
|
+
children: "Tab"
|
|
281
|
+
}), t("payment.checkout.donation.tabHint")]
|
|
282
|
+
})]
|
|
247
283
|
}), items.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_productDonation.default, {
|
|
248
284
|
item: x,
|
|
249
285
|
settings: donationSettings,
|