@paykka/card-checkout-ui 0.6.0 → 0.8.0
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/dist/card-checkout-ui.js +19 -19
- package/dist/card-checkout-ui.umd.cjs +19 -19
- package/dist/es/api/index.js +0 -2
- package/dist/es/api/modules/checkout/index.js +1 -15
- package/dist/es/api/modules/checkout/map.js +31 -3
- package/dist/es/api/modules/index.js +0 -2
- package/dist/es/components/AccountNameField/index.js +0 -3
- package/dist/es/components/AddressField/index.js +2 -7
- package/dist/es/components/AliPay/index.js +45 -34
- package/dist/es/components/ApplePay/index.js +19 -13
- package/dist/es/components/Card/index.js +334 -155
- package/dist/es/components/CardBrands/index.js +0 -2
- package/dist/es/components/CardExpireDateField/index.js +1 -4
- package/dist/es/components/CardHolderNameField/index.js +3 -5
- package/dist/es/components/CardIBANField/index.js +0 -3
- package/dist/es/components/CardNo/index.js +0 -2
- package/dist/es/components/CardNumberField/index.js +1 -4
- package/dist/es/components/CardSecurityCodeField/index.js +1 -4
- package/dist/es/components/CardSelector/index.js +0 -3
- package/dist/es/components/CombinedCardInfo/index.js +99 -0
- package/dist/es/components/DropIn/index.js +210 -0
- package/dist/es/components/EmailField/EmailField.js +0 -3
- package/dist/es/components/EncryptedCard/index.js +35 -75
- package/dist/es/components/GooglePay/index.js +69 -28
- package/dist/es/components/RecurringTip/index.js +0 -2
- package/dist/es/components/SecuredFieldsProvider/index.js +230 -1
- package/dist/es/components/SecuredIframe/index.js +3 -1
- package/dist/es/components/Sepa/index.js +26 -30
- package/dist/es/components/SubmitButton/index.js +0 -2
- package/dist/es/components/ThreeDS/index.js +94 -0
- package/dist/es/components/WechatPay/index.js +48 -38
- package/dist/es/components/index.js +2 -3
- package/dist/es/components/internal/Button/Button.js +0 -2
- package/dist/es/components/internal/Button/index.js +0 -2
- package/dist/es/components/internal/CheckBox/CheckBox.js +0 -2
- package/dist/es/components/internal/CheckBox/index.js +0 -2
- package/dist/es/components/internal/Form/type.js +0 -2
- package/dist/es/components/internal/Info/Info.js +0 -2
- package/dist/es/components/internal/Info/index.js +0 -2
- package/dist/es/components/internal/Input/Input.js +2 -2
- package/dist/es/components/internal/Input/type.js +0 -2
- package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -2
- package/dist/es/components/internal/LoadingCheck/index.js +0 -2
- package/dist/es/components/internal/Modal/Modal.js +40 -0
- package/dist/es/components/internal/Modal/modal2.js +1 -0
- package/dist/es/components/internal/Select/Select.js +0 -2
- package/dist/es/components/internal/Select/SelectMenu.js +0 -2
- package/dist/es/components/internal/Select/SelectMenuItem.js +0 -2
- package/dist/es/components/internal/icons/Icon3DSFail.js +3 -0
- package/dist/es/components/internal/icons/Icon3DSInfo.js +62 -0
- package/dist/es/components/internal/icons/Icon3DSSuccess.js +3 -0
- package/dist/es/components/internal/icons/IconCard.js +42 -0
- package/dist/es/config.js +0 -2
- package/dist/es/constant.js +13 -2
- package/dist/es/core/PayKKaCheckout.js +106 -42
- package/dist/es/core/Session.js +7 -6
- package/dist/es/core/environment.js +26 -0
- package/dist/es/core/error.js +21 -0
- package/dist/es/core/index.js +0 -2
- package/dist/es/core/query.js +0 -2
- package/dist/es/core.js +34 -34
- package/dist/es/hooks/index.js +0 -2
- package/dist/es/hooks/useBreakpoints.js +57 -0
- package/dist/es/hooks/useI18n.js +1 -2
- package/dist/es/hooks/usePayState.js +20 -24
- package/dist/es/i18n/index.js +0 -2
- package/dist/es/i18n/locales/de-DE.js +14 -1
- package/dist/es/i18n/locales/en-GB.js +14 -1
- package/dist/es/i18n/locales/es-ES.js +14 -1
- package/dist/es/i18n/locales/fr-FR.js +14 -1
- package/dist/es/i18n/locales/index.js +8 -6
- package/dist/es/i18n/locales/ja-JP.js +14 -1
- package/dist/es/i18n/locales/ko-KR.js +14 -1
- package/dist/es/i18n/locales/pt-PT.js +14 -1
- package/dist/es/i18n/locales/ru-RU.js +14 -1
- package/dist/es/i18n/locales/zh-CN.js +14 -1
- package/dist/es/i18n/locales/zh-HK.js +14 -1
- package/dist/es/i18n/locales/zh-TW.js +14 -1
- package/dist/es/i18n/util.js +22 -8
- package/dist/es/index.js +8 -2
- package/dist/es/style.css +289 -11
- package/dist/es/types/message.js +28 -0
- package/dist/es/utils/card-brand/brands.js +12 -10
- package/dist/es/utils/card-brand/index.js +3 -2
- package/dist/es/utils/iframe.js +23 -0
- package/dist/es/utils/index.js +0 -1
- package/dist/es/utils/style.js +47 -0
- package/dist/style.css +1 -1
- package/dist/types/api/modules/checkout/map.d.ts +2 -1
- package/dist/types/api/modules/checkout/type.d.ts +24 -2
- package/dist/types/api/modules/get-browser-params.d.ts +1 -1
- package/dist/types/components/AddressField/type.d.ts +1 -0
- package/dist/types/components/AliPay/AliPay.d.ts +2 -1
- package/dist/types/components/AliPay/type.d.ts +2 -1
- package/dist/types/components/ApplePay/ApplePay.d.ts +2 -1
- package/dist/types/components/ApplePay/type.d.ts +9 -5
- package/dist/types/components/Card/Card.d.ts +2 -1
- package/dist/types/components/Card/type.d.ts +55 -9
- package/dist/types/components/CardHolderNameField/type.d.ts +1 -1
- package/dist/types/components/CombinedCardInfo/CombinedCardInfo.d.ts +5 -0
- package/dist/types/components/CombinedCardInfo/index.d.ts +2 -0
- package/dist/types/components/{CombinedEncryptedField → CombinedCardInfo}/type.d.ts +3 -2
- package/dist/types/components/DropIn/DropIn.d.ts +6 -0
- package/dist/types/components/DropIn/components/PaymentTabs/PaymentTabs.d.ts +3 -0
- package/dist/types/components/DropIn/components/PaymentTabs/index.d.ts +2 -0
- package/dist/types/components/DropIn/components/PaymentTabs/type.d.ts +11 -0
- package/dist/types/components/DropIn/index.d.ts +2 -0
- package/dist/types/components/DropIn/type.d.ts +49 -0
- package/dist/types/components/GooglePay/GooglePay.d.ts +2 -1
- package/dist/types/components/GooglePay/type.d.ts +20 -8
- package/dist/types/components/SecuredFieldsProvider/index.d.ts +1 -0
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +1 -153
- package/dist/types/components/SecuredFieldsProvider/utils/index.d.ts +1 -1
- package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +2 -1
- package/dist/types/components/Sepa/Sepa.d.ts +2 -1
- package/dist/types/components/Sepa/type.d.ts +2 -1
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/ThreeDSAuth.d.ts +3 -0
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/index.d.ts +2 -0
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +17 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +2 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/index.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +5 -0
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +3 -0
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/output.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +6 -0
- package/dist/types/components/ThreeDS/index.d.ts +1 -0
- package/dist/types/components/WechatPay/WechatPay.d.ts +2 -1
- package/dist/types/components/WechatPay/type.d.ts +2 -1
- package/dist/types/components/index.d.ts +2 -1
- package/dist/types/components/internal/Input/type.d.ts +1 -0
- package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
- package/dist/types/components/internal/Loading/index.d.ts +1 -0
- package/dist/types/components/internal/Modal/Modal.d.ts +5 -0
- package/dist/types/components/internal/Modal/index.d.ts +2 -0
- package/dist/types/components/internal/Modal/type.d.ts +20 -0
- package/dist/types/components/internal/icons/Icon3DSFail.d.ts +2 -0
- package/dist/types/components/internal/icons/Icon3DSInfo.d.ts +2 -0
- package/dist/types/components/internal/icons/Icon3DSSuccess.d.ts +2 -0
- package/dist/types/components/internal/icons/IconCard.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +4 -0
- package/dist/types/constant.d.ts +17 -2
- package/dist/types/core/PayKKaCheckout.d.ts +23 -6
- package/dist/types/core/Session.d.ts +1 -1
- package/dist/types/core/context.d.ts +1 -0
- package/dist/types/core/environment.d.ts +4 -0
- package/dist/types/core/error.d.ts +16 -0
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useBreakpoints.d.ts +15 -0
- package/dist/types/hooks/usePayState.d.ts +3 -6
- package/dist/types/i18n/locales/de-DE.d.ts +10 -0
- package/dist/types/i18n/locales/en-GB.d.ts +10 -0
- package/dist/types/i18n/locales/es-ES.d.ts +10 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +10 -0
- package/dist/types/i18n/locales/index.d.ts +2 -2
- package/dist/types/i18n/locales/ja-JP.d.ts +10 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +10 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +10 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +10 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +10 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +10 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +10 -0
- package/dist/types/i18n/util.d.ts +5 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +59 -8
- package/dist/types/types/message.d.ts +170 -0
- package/dist/types/utils/card-brand/brands.d.ts +1 -8
- package/dist/types/utils/card-brand/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/style.d.ts +12 -0
- package/package.json +2 -2
- package/dist/es/components/CombinedEncryptedField/index.js +0 -75
- package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +0 -268
- package/dist/types/components/CombinedEncryptedField/CombinedEncryptedField.d.ts +0 -4
- package/dist/types/components/CombinedEncryptedField/index.d.ts +0 -2
- /package/dist/types/{components/SecuredFieldsProvider/utils → utils}/iframe.d.ts +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { w, A, h, F, y, q, T, u } from "../../core.js";
|
|
1
|
+
import { w, A, h, F, y, q, T, u, b } from "../../core.js";
|
|
2
2
|
import { isTimeoutError } from "../../api/http.js";
|
|
3
|
-
import { PaymentType, SessionMode,
|
|
3
|
+
import { PaymentType, SessionMode, CardPaymentMethods, COMMON_CLASS_NAME, PaymentMethod } from "../../constant.js";
|
|
4
4
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
5
5
|
import { getCardPayInfo, cardPay } from "../../api/modules/card/index.js";
|
|
6
6
|
import { CoreContext } from "../../core/context.js";
|
|
7
7
|
import { intersection } from "../../utils/index.js";
|
|
8
|
+
import { PayKKaError } from "../../core/error.js";
|
|
8
9
|
import { hidePaymentButton } from "../../config.js";
|
|
10
|
+
import { defaultInputStyleConfig } from "../../types/index.js";
|
|
9
11
|
import { createAddressCore } from "../../core/Address.js";
|
|
10
12
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
11
|
-
import "../../i18n/util.js";
|
|
12
|
-
import "../../i18n/locales/index.js";
|
|
13
13
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
14
14
|
import { useRetry } from "../../hooks/useRetry.js";
|
|
15
15
|
import { AddressField } from "../AddressField/index.js";
|
|
@@ -28,23 +28,38 @@ import { Form } from "../internal/Form/Form.js";
|
|
|
28
28
|
import { IconSwitch } from "../internal/icons/IconSwitch.js";
|
|
29
29
|
import { Info } from "../internal/Info/Info.js";
|
|
30
30
|
import { RecurringTip } from "../RecurringTip/index.js";
|
|
31
|
-
import { EFieldType, SecuredFieldsProvider } from "../SecuredFieldsProvider/
|
|
31
|
+
import { EFieldType, SecuredFieldsProvider } from "../SecuredFieldsProvider/index.js";
|
|
32
32
|
import { SubmitButton } from "../SubmitButton/index.js";
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { isEmptyObject, isUndefined } from "../../utils/is.js";
|
|
33
|
+
import { ThreeDSAuth } from "../ThreeDS/index.js";
|
|
34
|
+
import { CombinedCardInfo } from "../CombinedCardInfo/index.js";
|
|
36
35
|
import { cardBrandCodes } from "../../utils/card-brand/brands.js";
|
|
37
36
|
import { findCardBrand } from "../../utils/card-brand/index.js";
|
|
37
|
+
import { separateInputStyle } from "../../utils/style.js";
|
|
38
|
+
import { createPromise } from "../../utils/create-promise.js";
|
|
39
|
+
import { cssVarPrefix, normalizedClass, trimAll, formatAmount } from "../../utils/format.js";
|
|
40
|
+
import { isUndefined } from "../../utils/is.js";
|
|
38
41
|
const { bem } = useBEM("card");
|
|
39
42
|
const fieldClassNames = bem("field");
|
|
40
43
|
const Card = w((props, ref) => {
|
|
41
|
-
var _a, _b, _c, _d, _e, _f;
|
|
42
|
-
const {
|
|
44
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
45
|
+
const {
|
|
46
|
+
showCardBrands = true,
|
|
47
|
+
session,
|
|
48
|
+
cardInfoLayout = "split",
|
|
49
|
+
showHolderName = true,
|
|
50
|
+
showEmail = false,
|
|
51
|
+
showAddress = false,
|
|
52
|
+
threeDSFrame,
|
|
53
|
+
styles,
|
|
54
|
+
enable3DSModal = true,
|
|
55
|
+
isDropIn
|
|
56
|
+
} = props;
|
|
43
57
|
let addressState = createAddressCore();
|
|
44
58
|
let emailState = createEmailCore();
|
|
45
|
-
const { i18n,
|
|
59
|
+
const { i18n, fraudDetection, sessionReady } = usePayState(session);
|
|
46
60
|
const addressFieldRef = A(null);
|
|
47
61
|
const emailFieldRef = A(null);
|
|
62
|
+
const combinedCardInfoRef = A(null);
|
|
48
63
|
const formRef = A(null);
|
|
49
64
|
const [form, setForm] = h({
|
|
50
65
|
email: "",
|
|
@@ -52,6 +67,7 @@ const Card = w((props, ref) => {
|
|
|
52
67
|
expireDate: "",
|
|
53
68
|
securityCode: "",
|
|
54
69
|
holderName: "",
|
|
70
|
+
cardInfo: "",
|
|
55
71
|
address: {
|
|
56
72
|
country: "",
|
|
57
73
|
province: "",
|
|
@@ -65,17 +81,22 @@ const Card = w((props, ref) => {
|
|
|
65
81
|
const [validated, setValidated] = h(false);
|
|
66
82
|
const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
|
|
67
83
|
const [errorMsg, setErrorMsg] = h("");
|
|
68
|
-
const disabledEmail = A(false);
|
|
69
|
-
const [requiredBill, setRequiredBill] = h(false);
|
|
70
84
|
const [storePaymentMethod, setStorePaymentMethod] = h(false);
|
|
71
85
|
const [isEditOtherCard, setIsEditOtherCard] = h(false);
|
|
72
86
|
const [isCheckoutEnabled, setIsCheckoutEnabled] = h(false);
|
|
73
87
|
const [supportedCardBrands, setSupportedCardBrands] = h([]);
|
|
88
|
+
const [showThreeDSModal, setShowThreeDSModal] = h(false);
|
|
89
|
+
const [threeDSInfo, setThreeDSInfo] = h();
|
|
90
|
+
const [fieldStatus, setFieldStatus] = h();
|
|
91
|
+
const [security, setSecurity] = h(false);
|
|
92
|
+
const [tokenAddressFilled, setTokenAddressFilled] = h(true);
|
|
93
|
+
const [inputStyle, setInputStyle] = h({});
|
|
94
|
+
const [splitCardInfo] = h(cardInfoLayout === "split");
|
|
74
95
|
F(ref, () => ({
|
|
75
96
|
checkThreeDS,
|
|
76
97
|
updateAddress: () => {
|
|
77
98
|
var _a2;
|
|
78
|
-
if (!
|
|
99
|
+
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
79
100
|
return;
|
|
80
101
|
setForm(Object.assign(form, { address: addressState.getAddressState() }));
|
|
81
102
|
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressState.getAddressState());
|
|
@@ -86,33 +107,60 @@ const Card = w((props, ref) => {
|
|
|
86
107
|
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
87
108
|
},
|
|
88
109
|
payment: () => {
|
|
89
|
-
|
|
110
|
+
hidePaymentButton && onSubmit();
|
|
90
111
|
}
|
|
91
112
|
}));
|
|
92
|
-
const getPaymentSuccessData = () =>
|
|
93
|
-
returnUrl: session == null ? void 0 : session.checkout.returnUrl
|
|
94
|
-
});
|
|
95
|
-
y(() => {
|
|
113
|
+
const getPaymentSuccessData = () => {
|
|
96
114
|
var _a2;
|
|
115
|
+
return {
|
|
116
|
+
returnUrl: (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const initFieldStatus = () => {
|
|
120
|
+
const field = session.checkout.field;
|
|
121
|
+
const { email, address, holderName } = field;
|
|
122
|
+
if (showEmail && !(email == null ? void 0 : email.show)) {
|
|
123
|
+
email.show = true;
|
|
124
|
+
email.disabled = true;
|
|
125
|
+
}
|
|
126
|
+
if (showAddress && !(address == null ? void 0 : address.show)) {
|
|
127
|
+
address.show = true;
|
|
128
|
+
}
|
|
129
|
+
if (showHolderName && !(holderName == null ? void 0 : holderName.show)) {
|
|
130
|
+
holderName.show = true;
|
|
131
|
+
holderName.disabled = true;
|
|
132
|
+
}
|
|
133
|
+
setFieldStatus({ ...field });
|
|
134
|
+
};
|
|
135
|
+
const initElementStyles = () => {
|
|
136
|
+
if (!styles) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const { input } = separateInputStyle(styles);
|
|
140
|
+
input && setInputStyle(input);
|
|
141
|
+
};
|
|
142
|
+
y(() => {
|
|
143
|
+
var _a2, _b2;
|
|
97
144
|
if (!sessionReady) {
|
|
98
145
|
return;
|
|
99
146
|
}
|
|
100
|
-
const { status, paymentMethod = [], bill = {} } = (session == null ? void 0 : session.checkout) || {};
|
|
101
|
-
|
|
102
|
-
|
|
147
|
+
const { status, paymentMethod = [], bill = {}, sessionMode } = (session == null ? void 0 : session.checkout) || {};
|
|
148
|
+
if (sessionMode === SessionMode.DROP_IN && !isDropIn) {
|
|
149
|
+
(_b2 = (_a2 = props.core.config).onInitError) == null ? void 0 : _b2.call(
|
|
150
|
+
_a2,
|
|
151
|
+
new PayKKaError("ERROR", "Please send the correct mode when creating the checkout")
|
|
152
|
+
);
|
|
103
153
|
return;
|
|
104
154
|
}
|
|
105
|
-
if (
|
|
106
|
-
(_a2 = props.onError) == null ? void 0 : _a2.call(props, "FAILURE");
|
|
155
|
+
if (!intersection(paymentMethod, CardPaymentMethods).length) {
|
|
107
156
|
return;
|
|
108
157
|
}
|
|
109
|
-
|
|
158
|
+
initFieldStatus();
|
|
159
|
+
initElementStyles();
|
|
160
|
+
setSecurity(sessionMode !== SessionMode.HOSTED);
|
|
110
161
|
form.email = bill.email ?? "";
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
setSupportedCardBrands(
|
|
114
|
-
cardBrandCodes.filter((code) => session == null ? void 0 : session.checkout.paymentMethod.includes(code))
|
|
115
|
-
);
|
|
162
|
+
setSupportedCardBrands(intersection(cardBrandCodes, paymentMethod || []));
|
|
163
|
+
setIsCheckoutEnabled(true);
|
|
116
164
|
if (status === "SUCCESS") {
|
|
117
165
|
setSubmitButtonStatus("success");
|
|
118
166
|
processOnSuccess();
|
|
@@ -134,12 +182,44 @@ const Card = w((props, ref) => {
|
|
|
134
182
|
const { start: startReFetchPayInfo } = useRetry((timeout) => pay(true, timeout), {
|
|
135
183
|
onTimeout: () => onTimeout(i18n.get("common.queryTimeout"))
|
|
136
184
|
});
|
|
185
|
+
const validatePromise = A(createPromise());
|
|
186
|
+
const onValidated = (data) => {
|
|
187
|
+
fieldValidStatusMap.current[data.fieldType].status = data.status;
|
|
188
|
+
const results = Object.values(fieldValidStatusMap.current);
|
|
189
|
+
if (results.includes(null)) {
|
|
190
|
+
return;
|
|
191
|
+
} else {
|
|
192
|
+
const validateResult = results.every((result) => result.status === "success");
|
|
193
|
+
if (validateResult) {
|
|
194
|
+
validatePromise.current.resolve(true);
|
|
195
|
+
} else {
|
|
196
|
+
validatePromise.current.reject(false);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const validateCombineCardInfo = async () => {
|
|
201
|
+
var _a2;
|
|
202
|
+
validatePromise.current = createPromise();
|
|
203
|
+
Object.keys(fieldValidStatusMap.current).forEach((key) => {
|
|
204
|
+
fieldValidStatusMap.current[key] = null;
|
|
205
|
+
});
|
|
206
|
+
(_a2 = SFPRef.current) == null ? void 0 : _a2.validate();
|
|
207
|
+
try {
|
|
208
|
+
await validatePromise.current;
|
|
209
|
+
console.log("校验通过");
|
|
210
|
+
} catch (error) {
|
|
211
|
+
console.log("校验失败");
|
|
212
|
+
}
|
|
213
|
+
};
|
|
137
214
|
async function onSubmit() {
|
|
138
215
|
var _a2;
|
|
139
216
|
setErrorMsg("");
|
|
217
|
+
if (!splitCardInfo && security) {
|
|
218
|
+
await validateCombineCardInfo();
|
|
219
|
+
}
|
|
140
220
|
(_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
|
|
141
221
|
var _a3;
|
|
142
|
-
|
|
222
|
+
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressState.setValidateAllFields(true);
|
|
143
223
|
(_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
|
|
144
224
|
if (errors) {
|
|
145
225
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -151,12 +231,22 @@ const Card = w((props, ref) => {
|
|
|
151
231
|
});
|
|
152
232
|
}
|
|
153
233
|
const getPaymentParams = async () => {
|
|
154
|
-
var _a2
|
|
234
|
+
var _a2;
|
|
155
235
|
const cardNo = trimAll(form.number);
|
|
156
236
|
const cardBrand = findCardBrand(cardNo);
|
|
157
237
|
const [expMonth, expYear] = form.expireDate.split("/");
|
|
158
238
|
const isFastPaymentForm = isFastPayment && !isEditOtherCard;
|
|
159
|
-
|
|
239
|
+
let paymentMethod = null;
|
|
240
|
+
if (isFastPayment) {
|
|
241
|
+
paymentMethod = PaymentMethod.BANKCARD;
|
|
242
|
+
} else {
|
|
243
|
+
if (security) {
|
|
244
|
+
const fieldRef = splitCardInfo ? cardNumberFieldRef : combinedCardInfoRef;
|
|
245
|
+
paymentMethod = (_a2 = fieldRef.current) == null ? void 0 : _a2.getCardBrand().code;
|
|
246
|
+
} else {
|
|
247
|
+
paymentMethod = cardBrand.code;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
160
250
|
return {
|
|
161
251
|
sessionId: session.sessionId,
|
|
162
252
|
clientKey: session.clientKey,
|
|
@@ -173,7 +263,7 @@ const Card = w((props, ref) => {
|
|
|
173
263
|
...isShowStoreCheckBox ? { storePaymentMethod } : null
|
|
174
264
|
}
|
|
175
265
|
},
|
|
176
|
-
bill:
|
|
266
|
+
bill: (fieldStatus == null ? void 0 : fieldStatus.address.show) ? {
|
|
177
267
|
email: form.email,
|
|
178
268
|
...form.address,
|
|
179
269
|
province: addressState.getLabel(form.address.province, addressState.getProvinceOption()) ?? form.address.province,
|
|
@@ -187,11 +277,11 @@ const Card = w((props, ref) => {
|
|
|
187
277
|
};
|
|
188
278
|
};
|
|
189
279
|
async function pay(search = false, timeout) {
|
|
190
|
-
var _a2, _b2
|
|
280
|
+
var _a2, _b2;
|
|
191
281
|
try {
|
|
192
282
|
const paymentParams = await getPaymentParams();
|
|
193
|
-
if (!search &&
|
|
194
|
-
(
|
|
283
|
+
if (!search && security) {
|
|
284
|
+
(_a2 = SFPRef.current) == null ? void 0 : _a2.payment(paymentParams);
|
|
195
285
|
return { end: true };
|
|
196
286
|
}
|
|
197
287
|
const options = { locale: i18n.locale, timeout };
|
|
@@ -209,17 +299,39 @@ const Card = w((props, ref) => {
|
|
|
209
299
|
return { end: true };
|
|
210
300
|
}
|
|
211
301
|
} else {
|
|
212
|
-
|
|
213
|
-
(
|
|
302
|
+
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
303
|
+
setErrorMsg(message);
|
|
304
|
+
(_b2 = props.onError) == null ? void 0 : _b2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
214
305
|
setSubmitButtonStatus("unSubmit");
|
|
215
306
|
stopReFetchCardPay3DSInfo();
|
|
216
307
|
return { end: true };
|
|
217
308
|
}
|
|
218
309
|
}
|
|
219
310
|
}
|
|
311
|
+
const processThreeDS = (threeDSUrl, incomplete) => {
|
|
312
|
+
var _a2;
|
|
313
|
+
if (enable3DSModal) {
|
|
314
|
+
console.log("3ds open");
|
|
315
|
+
setShowThreeDSModal(true);
|
|
316
|
+
setThreeDSInfo({
|
|
317
|
+
url: threeDSUrl,
|
|
318
|
+
incomplete,
|
|
319
|
+
width: threeDSFrame == null ? void 0 : threeDSFrame.modalWidth,
|
|
320
|
+
height: threeDSFrame == null ? void 0 : threeDSFrame.modalHeight
|
|
321
|
+
});
|
|
322
|
+
} else {
|
|
323
|
+
(_a2 = props.onThreeDS) == null ? void 0 : _a2.call(props, threeDSUrl, incomplete);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
const handleCloseThreeDSModal = () => {
|
|
327
|
+
console.log("3ds close");
|
|
328
|
+
setShowThreeDSModal(false);
|
|
329
|
+
setThreeDSInfo(void 0);
|
|
330
|
+
checkThreeDS();
|
|
331
|
+
};
|
|
220
332
|
const processAfterPayment = (res, search = false) => {
|
|
221
|
-
var _a2, _b2, _c2
|
|
222
|
-
const { status, orderStatus, errorMessage, threeDSUrl } = res;
|
|
333
|
+
var _a2, _b2, _c2;
|
|
334
|
+
const { status, orderStatus, errorMessage, errorCode, threeDSUrl } = res;
|
|
223
335
|
if (status === "PROCESSING") {
|
|
224
336
|
if (!orderStatus) {
|
|
225
337
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -232,14 +344,14 @@ const Card = w((props, ref) => {
|
|
|
232
344
|
} else if (orderStatus === "FAILURE") {
|
|
233
345
|
setErrorMsg(errorMessage);
|
|
234
346
|
setSubmitButtonStatus("unSubmit");
|
|
235
|
-
(_a2 = props.onError) == null ? void 0 : _a2.call(props, "
|
|
347
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
236
348
|
} else if (orderStatus === "AUTHORIZED") {
|
|
237
349
|
setSubmitButtonStatus("unSubmit");
|
|
238
350
|
(_b2 = props.onAuthorized) == null ? void 0 : _b2.call(props);
|
|
239
351
|
} else if (orderStatus === "IN_THREED") {
|
|
240
|
-
(
|
|
352
|
+
processThreeDS(threeDSUrl, false);
|
|
241
353
|
} else if (orderStatus === "IN_PREVIOUS_THREED") {
|
|
242
|
-
(
|
|
354
|
+
processThreeDS(threeDSUrl, true);
|
|
243
355
|
}
|
|
244
356
|
return { end: true };
|
|
245
357
|
} else if (status === "SUCCESS") {
|
|
@@ -248,7 +360,7 @@ const Card = w((props, ref) => {
|
|
|
248
360
|
return { end: true };
|
|
249
361
|
} else if (status === "EXPIRED") {
|
|
250
362
|
setSubmitButtonStatus("unSubmit");
|
|
251
|
-
(
|
|
363
|
+
(_c2 = props.onExpired) == null ? void 0 : _c2.call(props);
|
|
252
364
|
return { end: true };
|
|
253
365
|
}
|
|
254
366
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -257,27 +369,29 @@ const Card = w((props, ref) => {
|
|
|
257
369
|
};
|
|
258
370
|
const processPaymentError = (error) => {
|
|
259
371
|
var _a2;
|
|
260
|
-
|
|
372
|
+
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
373
|
+
setErrorMsg(message);
|
|
261
374
|
setSubmitButtonStatus("unSubmit");
|
|
262
|
-
(_a2 = props.onError) == null ? void 0 : _a2.call(props, error);
|
|
375
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
263
376
|
};
|
|
264
|
-
|
|
377
|
+
const validateForm = () => {
|
|
265
378
|
var _a2;
|
|
266
379
|
(_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
|
|
267
380
|
setValidated(true);
|
|
268
381
|
}).catch(() => {
|
|
269
382
|
setValidated(false);
|
|
270
383
|
});
|
|
271
|
-
}
|
|
384
|
+
};
|
|
272
385
|
y(() => {
|
|
273
386
|
validateForm();
|
|
274
387
|
}, [form]);
|
|
275
388
|
const Button = () => {
|
|
276
389
|
const { transAmount } = (session == null ? void 0 : session.checkout) ?? {};
|
|
277
390
|
let { symbol = "", amount = "", digits } = transAmount ?? {};
|
|
391
|
+
let amountStr = "";
|
|
278
392
|
if (amount && !isUndefined(digits))
|
|
279
|
-
|
|
280
|
-
const text = i18n.get("common.pay") + (Number(amount) ? ` ${symbol}${
|
|
393
|
+
amountStr = formatAmount(+amount, digits);
|
|
394
|
+
const text = i18n.get("common.pay") + (Number(amount) ? ` ${symbol}${amountStr}` : "");
|
|
281
395
|
return /* @__PURE__ */ u(
|
|
282
396
|
SubmitButton,
|
|
283
397
|
{
|
|
@@ -291,7 +405,7 @@ const Card = w((props, ref) => {
|
|
|
291
405
|
}
|
|
292
406
|
);
|
|
293
407
|
};
|
|
294
|
-
const
|
|
408
|
+
const formStyle = {
|
|
295
409
|
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
296
410
|
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
297
411
|
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
@@ -306,7 +420,7 @@ const Card = w((props, ref) => {
|
|
|
306
420
|
}
|
|
307
421
|
);
|
|
308
422
|
async function checkThreeDS(search = false, timeout = 2e4) {
|
|
309
|
-
var _a2, _b2, _c2;
|
|
423
|
+
var _a2, _b2, _c2, _d2;
|
|
310
424
|
if (!session)
|
|
311
425
|
return { end: true };
|
|
312
426
|
try {
|
|
@@ -320,16 +434,17 @@ const Card = w((props, ref) => {
|
|
|
320
434
|
timeout
|
|
321
435
|
}
|
|
322
436
|
);
|
|
323
|
-
const { status, orderStatus, errorMessage } = res;
|
|
437
|
+
const { status, orderStatus, errorMessage, errorCode } = res;
|
|
324
438
|
if (status === "PROCESSING") {
|
|
325
439
|
if (orderStatus === "PROCESSING") {
|
|
326
440
|
startReFetchPayInfo();
|
|
327
441
|
} else if (orderStatus === "FAILURE") {
|
|
328
442
|
setErrorMsg(errorMessage);
|
|
329
443
|
setSubmitButtonStatus("unSubmit");
|
|
444
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
330
445
|
} else if (orderStatus === "AUTHORIZED") {
|
|
331
446
|
setSubmitButtonStatus("unSubmit");
|
|
332
|
-
(
|
|
447
|
+
(_b2 = props.onAuthorized) == null ? void 0 : _b2.call(props);
|
|
333
448
|
} else if (orderStatus === "IN_THREED") {
|
|
334
449
|
setSubmitButtonStatus("loading");
|
|
335
450
|
!search && startReFetchCardPay3DSInfo();
|
|
@@ -349,7 +464,7 @@ const Card = w((props, ref) => {
|
|
|
349
464
|
return { end: true };
|
|
350
465
|
} else if (status === "EXPIRED") {
|
|
351
466
|
setSubmitButtonStatus("unSubmit");
|
|
352
|
-
(
|
|
467
|
+
(_c2 = props.onExpired) == null ? void 0 : _c2.call(props);
|
|
353
468
|
stopReFetchCardPay3DSInfo();
|
|
354
469
|
return { end: true };
|
|
355
470
|
}
|
|
@@ -366,8 +481,9 @@ const Card = w((props, ref) => {
|
|
|
366
481
|
return { end: true };
|
|
367
482
|
}
|
|
368
483
|
} else {
|
|
369
|
-
|
|
370
|
-
(
|
|
484
|
+
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
485
|
+
setErrorMsg(message);
|
|
486
|
+
(_d2 = props.onError) == null ? void 0 : _d2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
371
487
|
setSubmitButtonStatus("unSubmit");
|
|
372
488
|
stopReFetchCardPay3DSInfo();
|
|
373
489
|
return { end: true };
|
|
@@ -376,31 +492,36 @@ const Card = w((props, ref) => {
|
|
|
376
492
|
}
|
|
377
493
|
const isFastPayment = T(() => {
|
|
378
494
|
var _a2;
|
|
495
|
+
if (!(session == null ? void 0 : session.checkout)) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
379
498
|
const isPurchase = (session == null ? void 0 : session.checkout.paymentType) === PaymentType.PURCHASE;
|
|
380
499
|
const hasCardTokens = !!((_a2 = session == null ? void 0 : session.checkout.tokens) == null ? void 0 : _a2.length);
|
|
381
500
|
return isPurchase && hasCardTokens;
|
|
382
501
|
}, [session == null ? void 0 : session.checkout]);
|
|
383
502
|
const isShowStoreCheckBox = T(() => {
|
|
503
|
+
if (!(session == null ? void 0 : session.checkout)) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
384
506
|
return (session == null ? void 0 : session.checkout.paymentType) === PaymentType.PURCHASE && (session == null ? void 0 : session.checkout.storePaymentMethod);
|
|
385
507
|
}, [session == null ? void 0 : session.checkout]);
|
|
386
508
|
const storeCheckBox = () => {
|
|
387
509
|
const onCheck = (checked) => {
|
|
388
510
|
setStorePaymentMethod(checked);
|
|
389
511
|
};
|
|
390
|
-
return /* @__PURE__ */ u(
|
|
512
|
+
return /* @__PURE__ */ u("div", { className: bem("store-checkbox"), children: /* @__PURE__ */ u(
|
|
391
513
|
CheckBox,
|
|
392
514
|
{
|
|
393
515
|
label: i18n.get("card.storeInfo"),
|
|
394
516
|
checked: storePaymentMethod,
|
|
395
|
-
onChange: onCheck
|
|
396
|
-
style: { marginTop: "40px" }
|
|
517
|
+
onChange: onCheck
|
|
397
518
|
}
|
|
398
|
-
);
|
|
519
|
+
) });
|
|
399
520
|
};
|
|
400
521
|
const changeBox = () => {
|
|
401
|
-
var _a2, _b2;
|
|
402
|
-
const isPurchase = (session == null ? void 0 : session.checkout.paymentType) === PaymentType.PURCHASE;
|
|
403
|
-
const hasCardTokens = !!((
|
|
522
|
+
var _a2, _b2, _c2;
|
|
523
|
+
const isPurchase = ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.paymentType) === PaymentType.PURCHASE;
|
|
524
|
+
const hasCardTokens = !!((_c2 = (_b2 = session == null ? void 0 : session.checkout) == null ? void 0 : _b2.tokens) == null ? void 0 : _c2.length);
|
|
404
525
|
const onClick = () => {
|
|
405
526
|
var _a3;
|
|
406
527
|
(_a3 = formRef.current) == null ? void 0 : _a3.resetValidation();
|
|
@@ -415,7 +536,6 @@ const Card = w((props, ref) => {
|
|
|
415
536
|
var _a2;
|
|
416
537
|
(_a2 = formRef.current) == null ? void 0 : _a2.resetValidation();
|
|
417
538
|
setIsEditOtherCard(true);
|
|
418
|
-
setRequiredBill((session == null ? void 0 : session.checkout.bill.billingAddressCollection) === "REQUIRED");
|
|
419
539
|
};
|
|
420
540
|
const onClickChangeCard = () => {
|
|
421
541
|
var _a2;
|
|
@@ -426,10 +546,8 @@ const Card = w((props, ref) => {
|
|
|
426
546
|
onEditOtherCard();
|
|
427
547
|
};
|
|
428
548
|
const onCardChange = (option) => {
|
|
549
|
+
setTokenAddressFilled(false);
|
|
429
550
|
setForm(Object.assign(form, { token: option == null ? void 0 : option.token }));
|
|
430
|
-
setRequiredBill(
|
|
431
|
-
(session == null ? void 0 : session.checkout.bill.billingAddressCollection) === "REQUIRED" && !(option == null ? void 0 : option.billingAddressFilled)
|
|
432
|
-
);
|
|
433
551
|
};
|
|
434
552
|
const setFormRef = (dom) => {
|
|
435
553
|
formRef.current = dom;
|
|
@@ -453,25 +571,59 @@ const Card = w((props, ref) => {
|
|
|
453
571
|
};
|
|
454
572
|
const onFieldsFocus = (data) => {
|
|
455
573
|
var _a2, _b2;
|
|
456
|
-
const fieldRef = fieldRefMap[data.fieldType];
|
|
574
|
+
const fieldRef = splitCardInfo ? fieldRefMap[data.fieldType] : combinedCardInfoRef;
|
|
457
575
|
if (data.focus) {
|
|
458
576
|
(_a2 = fieldRef.current) == null ? void 0 : _a2.focus();
|
|
459
577
|
} else {
|
|
460
578
|
(_b2 = fieldRef.current) == null ? void 0 : _b2.blur();
|
|
461
579
|
}
|
|
462
580
|
};
|
|
581
|
+
const validateOrder = [EFieldType.CARD_NUMBER, EFieldType.EXPIRE_DATE, EFieldType.CVV];
|
|
582
|
+
const fieldValidStatusMap = A({
|
|
583
|
+
[EFieldType.CARD_NUMBER]: null,
|
|
584
|
+
[EFieldType.EXPIRE_DATE]: null,
|
|
585
|
+
[EFieldType.CVV]: null
|
|
586
|
+
});
|
|
463
587
|
const onFieldValidStatusChanged = (data) => {
|
|
464
|
-
var _a2;
|
|
465
|
-
const fieldRef = fieldRefMap[data.fieldType];
|
|
588
|
+
var _a2, _b2, _c2, _d2;
|
|
589
|
+
const fieldRef = splitCardInfo ? fieldRefMap[data.fieldType] : combinedCardInfoRef;
|
|
466
590
|
const error = data.errorTip && i18n.get(data.errorTip);
|
|
467
|
-
(
|
|
591
|
+
if (!splitCardInfo) {
|
|
592
|
+
fieldValidStatusMap.current[data.fieldType] = {
|
|
593
|
+
status: data.status,
|
|
594
|
+
errorTip: error
|
|
595
|
+
};
|
|
596
|
+
for (const key of validateOrder) {
|
|
597
|
+
const currResult = fieldValidStatusMap.current[key];
|
|
598
|
+
if ((currResult == null ? void 0 : currResult.status) === "error") {
|
|
599
|
+
(_a2 = fieldRef.current) == null ? void 0 : _a2.resetValidation(currResult.status, currResult.errorTip);
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
const isSuccess = Object.values(fieldValidStatusMap.current).every(
|
|
604
|
+
(result) => (result == null ? void 0 : result.status) === "success"
|
|
605
|
+
);
|
|
606
|
+
if (isSuccess) {
|
|
607
|
+
(_b2 = fieldRef.current) == null ? void 0 : _b2.resetValidation("success");
|
|
608
|
+
} else {
|
|
609
|
+
(_c2 = fieldRef.current) == null ? void 0 : _c2.resetValidation("unValidate");
|
|
610
|
+
}
|
|
611
|
+
} else {
|
|
612
|
+
(_d2 = fieldRef.current) == null ? void 0 : _d2.resetValidation(data.status, error);
|
|
613
|
+
}
|
|
468
614
|
setTimeout(() => {
|
|
469
615
|
validateForm();
|
|
470
616
|
}, 100);
|
|
471
617
|
};
|
|
618
|
+
const onBrand = (data) => {
|
|
619
|
+
var _a2;
|
|
620
|
+
const field = splitCardInfo ? cardNumberFieldRef : combinedCardInfoRef;
|
|
621
|
+
(_a2 = field.current) == null ? void 0 : _a2.brandChanged(data.brand);
|
|
622
|
+
};
|
|
472
623
|
const onBinValueChanged = (data) => {
|
|
473
624
|
var _a2;
|
|
474
|
-
|
|
625
|
+
const field = splitCardInfo ? cardNumberFieldRef : combinedCardInfoRef;
|
|
626
|
+
(_a2 = field.current) == null ? void 0 : _a2.binValueChanged(data.binValue);
|
|
475
627
|
};
|
|
476
628
|
const onAfterPayment = (data) => {
|
|
477
629
|
processAfterPayment(data.response);
|
|
@@ -479,17 +631,41 @@ const Card = w((props, ref) => {
|
|
|
479
631
|
const onPaymentError = (data) => {
|
|
480
632
|
processPaymentError(data.error);
|
|
481
633
|
};
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
634
|
+
const Email = () => {
|
|
635
|
+
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
636
|
+
EmailField,
|
|
637
|
+
{
|
|
638
|
+
ref: emailFieldRef,
|
|
639
|
+
value: form.email,
|
|
640
|
+
disabled: fieldStatus == null ? void 0 : fieldStatus.email.disabled
|
|
641
|
+
}
|
|
642
|
+
) }) });
|
|
643
|
+
};
|
|
644
|
+
const Address = () => {
|
|
645
|
+
var _a2, _b2;
|
|
646
|
+
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: bem("address"), children: /* @__PURE__ */ u(
|
|
647
|
+
AddressField,
|
|
648
|
+
{
|
|
649
|
+
ref: addressFieldRef,
|
|
650
|
+
value: form.address,
|
|
651
|
+
country: ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.country) || ((_b2 = session == null ? void 0 : session.checkout) == null ? void 0 : _b2.bill.country),
|
|
652
|
+
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
653
|
+
}
|
|
654
|
+
) }) });
|
|
655
|
+
};
|
|
656
|
+
const ErrorMessage = () => {
|
|
657
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }) });
|
|
658
|
+
};
|
|
659
|
+
const CardInfo = q(() => {
|
|
660
|
+
var _a2, _b2, _c2, _d2;
|
|
661
|
+
return splitCardInfo ? /* @__PURE__ */ u(b, { children: [
|
|
486
662
|
/* @__PURE__ */ u("div", { className: fieldClassNames, children: [
|
|
487
663
|
/* @__PURE__ */ u("div", { className: bem("card-number-wrapper"), children: [
|
|
488
664
|
/* @__PURE__ */ u(
|
|
489
665
|
CardNumberField,
|
|
490
666
|
{
|
|
491
667
|
supportedCardBrands: (_b2 = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.paymentMethod) == null ? void 0 : _b2.filter(Boolean),
|
|
492
|
-
security
|
|
668
|
+
security,
|
|
493
669
|
ref: cardNumberFieldRef
|
|
494
670
|
}
|
|
495
671
|
),
|
|
@@ -499,7 +675,7 @@ const Card = w((props, ref) => {
|
|
|
499
675
|
CardBrands,
|
|
500
676
|
{
|
|
501
677
|
className: bem("card-brands"),
|
|
502
|
-
supportedCardBrands: (
|
|
678
|
+
supportedCardBrands: (_d2 = (_c2 = session == null ? void 0 : session.checkout) == null ? void 0 : _c2.paymentMethod) == null ? void 0 : _d2.filter(Boolean)
|
|
503
679
|
}
|
|
504
680
|
)
|
|
505
681
|
] }),
|
|
@@ -507,7 +683,7 @@ const Card = w((props, ref) => {
|
|
|
507
683
|
/* @__PURE__ */ u(
|
|
508
684
|
CardExpireDateField,
|
|
509
685
|
{
|
|
510
|
-
security
|
|
686
|
+
security,
|
|
511
687
|
className: fieldClassNames,
|
|
512
688
|
ref: cardExpireDateFieldRef
|
|
513
689
|
}
|
|
@@ -515,93 +691,96 @@ const Card = w((props, ref) => {
|
|
|
515
691
|
/* @__PURE__ */ u(
|
|
516
692
|
CardSecurityCodeField,
|
|
517
693
|
{
|
|
518
|
-
security
|
|
694
|
+
security,
|
|
519
695
|
className: fieldClassNames,
|
|
520
696
|
ref: cardSecurityCodeFieldRef
|
|
521
697
|
}
|
|
522
698
|
)
|
|
523
|
-
] })
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
699
|
+
] })
|
|
700
|
+
] }) : /* @__PURE__ */ u("div", { className: bem("card-info"), children: /* @__PURE__ */ u(
|
|
701
|
+
CombinedCardInfo,
|
|
702
|
+
{
|
|
703
|
+
ref: combinedCardInfoRef,
|
|
704
|
+
supportedCardBrands,
|
|
705
|
+
showLabel: true,
|
|
706
|
+
security
|
|
707
|
+
}
|
|
708
|
+
) });
|
|
709
|
+
}, [splitCardInfo, security]);
|
|
710
|
+
const cardForm = () => {
|
|
711
|
+
var _a2;
|
|
712
|
+
return /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: formStyle, children: [
|
|
713
|
+
Email(),
|
|
714
|
+
CardInfo(),
|
|
715
|
+
(fieldStatus == null ? void 0 : fieldStatus.holderName.show) && /* @__PURE__ */ u("div", { className: bem("holder-name"), children: /* @__PURE__ */ u(CardHolderNameField, { disabled: fieldStatus == null ? void 0 : fieldStatus.holderName.disabled }) }),
|
|
716
|
+
Address(),
|
|
717
|
+
((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.paymentType) === PaymentType.RECURRING && RecurringTip(),
|
|
534
718
|
isShowStoreCheckBox && storeCheckBox(),
|
|
535
|
-
|
|
719
|
+
ErrorMessage(),
|
|
536
720
|
!hidePaymentButton && Button()
|
|
537
721
|
] }) });
|
|
538
722
|
};
|
|
539
723
|
const fastPaymentCardForm = () => {
|
|
540
|
-
var _a2, _b2, _c2, _d2
|
|
541
|
-
return /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: [
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
/* @__PURE__ */ u(
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
)
|
|
565
|
-
] })
|
|
724
|
+
var _a2, _b2, _c2, _d2;
|
|
725
|
+
return /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: formStyle, children: [
|
|
726
|
+
Email(),
|
|
727
|
+
/* @__PURE__ */ u("div", { className: bem("card-selector-wrapper"), children: [
|
|
728
|
+
/* @__PURE__ */ u(
|
|
729
|
+
CardSelector,
|
|
730
|
+
{
|
|
731
|
+
value: (_c2 = (_b2 = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.tokens) == null ? void 0 : _b2[0]) == null ? void 0 : _c2.token,
|
|
732
|
+
cardList: (_d2 = session == null ? void 0 : session.checkout) == null ? void 0 : _d2.tokens,
|
|
733
|
+
onClickEdit: onEditOtherCard,
|
|
734
|
+
onClickChange: onClickChangeCard,
|
|
735
|
+
onCardChange,
|
|
736
|
+
style: { flex: 2, marginRight: "12px" }
|
|
737
|
+
}
|
|
738
|
+
),
|
|
739
|
+
/* @__PURE__ */ u(
|
|
740
|
+
CardSecurityCodeField,
|
|
741
|
+
{
|
|
742
|
+
className: fieldClassNames,
|
|
743
|
+
style: { flex: 1, marginLeft: "12px" },
|
|
744
|
+
security,
|
|
745
|
+
ref: cardSecurityCodeFieldRef
|
|
746
|
+
}
|
|
747
|
+
)
|
|
566
748
|
] }),
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
{
|
|
570
|
-
ref: addressFieldRef,
|
|
571
|
-
value: form.address,
|
|
572
|
-
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
573
|
-
}
|
|
574
|
-
) }),
|
|
575
|
-
!!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }),
|
|
749
|
+
tokenAddressFilled && Address(),
|
|
750
|
+
ErrorMessage(),
|
|
576
751
|
!hidePaymentButton && Button()
|
|
577
|
-
] });
|
|
752
|
+
] }) });
|
|
578
753
|
};
|
|
579
|
-
return /* @__PURE__ */ u(
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
754
|
+
return /* @__PURE__ */ u(CoreContext.Provider, { value: { i18n }, children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
|
|
755
|
+
/* @__PURE__ */ u(
|
|
756
|
+
SecuredFieldsProvider,
|
|
757
|
+
{
|
|
758
|
+
ref: SFPRef,
|
|
583
759
|
i18n,
|
|
584
|
-
session
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
760
|
+
sessionMode: (_g = session.checkout) == null ? void 0 : _g.sessionMode,
|
|
761
|
+
supportedCardBrands,
|
|
762
|
+
style: inputStyle || defaultInputStyleConfig,
|
|
763
|
+
onFocus: onFieldsFocus,
|
|
764
|
+
onBinValue: onBinValueChanged,
|
|
765
|
+
onBrand,
|
|
766
|
+
onAfterPayment,
|
|
767
|
+
onPaymentError,
|
|
768
|
+
onPaymentTimeout: ({ message }) => onTimeout(i18n.get(message)),
|
|
769
|
+
onValidStatusChanged: onFieldValidStatusChanged,
|
|
770
|
+
onValidated,
|
|
771
|
+
children: showFastPaymentForm ? fastPaymentCardForm() : cardForm()
|
|
772
|
+
}
|
|
773
|
+
),
|
|
774
|
+
/* @__PURE__ */ u(
|
|
775
|
+
ThreeDSAuth,
|
|
776
|
+
{
|
|
777
|
+
show: showThreeDSModal,
|
|
778
|
+
theme: (_h = session == null ? void 0 : session.checkout) == null ? void 0 : _h.theme,
|
|
779
|
+
onClose: handleCloseThreeDSModal,
|
|
780
|
+
...threeDSInfo
|
|
781
|
+
}
|
|
782
|
+
)
|
|
783
|
+
] }) });
|
|
605
784
|
});
|
|
606
785
|
export {
|
|
607
786
|
Card
|