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