@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
|
@@ -3,8 +3,6 @@ import { COMMON_CLASS_NAME } from "../../constant.js";
|
|
|
3
3
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
4
4
|
import "../../core/context.js";
|
|
5
5
|
import { clamp } from "../../utils/index.js";
|
|
6
|
-
import "../../i18n/util.js";
|
|
7
|
-
import "../../i18n/locales/index.js";
|
|
8
6
|
import { getSupportedCardBrands, getCardBrandInfo } from "../../utils/card-brand/index.js";
|
|
9
7
|
import { normalizedClass } from "../../utils/format.js";
|
|
10
8
|
const { bem } = useBEM("card-brands");
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { w, A, F, h, u } from "../../core.js";
|
|
2
2
|
import { isExpired } from "../../utils/index.js";
|
|
3
3
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
4
|
-
import "../../core/context.js";
|
|
5
|
-
import "../../i18n/util.js";
|
|
6
|
-
import "../../i18n/locales/index.js";
|
|
7
4
|
import "../internal/Form/type.js";
|
|
8
5
|
import "../internal/Form/context.js";
|
|
9
6
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
10
7
|
import "../internal/Form/Form.js";
|
|
11
8
|
import { Input } from "../internal/Input/Input.js";
|
|
12
9
|
import "../internal/Input/type.js";
|
|
13
|
-
import { EFieldType } from "../SecuredFieldsProvider/
|
|
10
|
+
import { EFieldType } from "../SecuredFieldsProvider/index.js";
|
|
14
11
|
import { limitedToNumber } from "../../utils/format.js";
|
|
15
12
|
import { isUndefined } from "../../utils/is.js";
|
|
16
13
|
const CardExpireDateField = w((props, ref) => {
|
|
@@ -2,9 +2,6 @@ import { u } from "../../core.js";
|
|
|
2
2
|
import "../../utils/card-brand/brands.js";
|
|
3
3
|
import "../../utils/system-info/get-browser-info.js";
|
|
4
4
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
5
|
-
import "../../core/context.js";
|
|
6
|
-
import "../../i18n/util.js";
|
|
7
|
-
import "../../i18n/locales/index.js";
|
|
8
5
|
import "../internal/Form/type.js";
|
|
9
6
|
import "../internal/Form/context.js";
|
|
10
7
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -12,7 +9,7 @@ import "../internal/Form/Form.js";
|
|
|
12
9
|
import { Input } from "../internal/Input/Input.js";
|
|
13
10
|
import "../internal/Input/type.js";
|
|
14
11
|
function CardHolderNameField(props) {
|
|
15
|
-
const { className, style } = props;
|
|
12
|
+
const { className, style, disabled } = props;
|
|
16
13
|
const { i18n } = useI18n();
|
|
17
14
|
const rule = {
|
|
18
15
|
trigger: ["blur", "submit"],
|
|
@@ -40,7 +37,8 @@ function CardHolderNameField(props) {
|
|
|
40
37
|
{
|
|
41
38
|
maxLength: 100,
|
|
42
39
|
placeholder: i18n.get("card.cardHolderName.placeholder"),
|
|
43
|
-
onInput
|
|
40
|
+
onInput,
|
|
41
|
+
disabled
|
|
44
42
|
}
|
|
45
43
|
)
|
|
46
44
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { A, h, u } from "../../core.js";
|
|
2
2
|
import { clamp } from "../../utils/index.js";
|
|
3
3
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
4
|
-
import "../../core/context.js";
|
|
5
|
-
import "../../i18n/util.js";
|
|
6
|
-
import "../../i18n/locales/index.js";
|
|
7
4
|
import "../internal/Form/type.js";
|
|
8
5
|
import "../internal/Form/context.js";
|
|
9
6
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -5,8 +5,6 @@ import "../../core/context.js";
|
|
|
5
5
|
import "../../utils/card-brand/brands.js";
|
|
6
6
|
import "../../utils/system-info/get-browser-info.js";
|
|
7
7
|
import { normalizedClass } from "../../utils/format.js";
|
|
8
|
-
import "../../i18n/util.js";
|
|
9
|
-
import "../../i18n/locales/index.js";
|
|
10
8
|
const { bem } = useBEM("card-no");
|
|
11
9
|
const CardNo = (props) => {
|
|
12
10
|
const { value, className, style } = props;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { w, A, F, h, y, u } from "../../core.js";
|
|
2
2
|
import { clamp } from "../../utils/index.js";
|
|
3
3
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
4
|
-
import "../../core/context.js";
|
|
5
|
-
import "../../i18n/util.js";
|
|
6
|
-
import "../../i18n/locales/index.js";
|
|
7
4
|
import "../internal/Form/type.js";
|
|
8
5
|
import "../internal/Form/context.js";
|
|
9
6
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -11,7 +8,7 @@ import "../internal/Form/Form.js";
|
|
|
11
8
|
import { IconCardNo } from "../internal/icons/IconCardNo.js";
|
|
12
9
|
import { Input } from "../internal/Input/Input.js";
|
|
13
10
|
import "../internal/Input/type.js";
|
|
14
|
-
import { EFieldType } from "../SecuredFieldsProvider/
|
|
11
|
+
import { EFieldType } from "../SecuredFieldsProvider/index.js";
|
|
15
12
|
import { getSupportedCardBrands, getSupportedCardBrandsLengths, finCardBrandInfoByCode, findCardBrandInfo } from "../../utils/card-brand/index.js";
|
|
16
13
|
import { trimAll, limitedToNumber } from "../../utils/format.js";
|
|
17
14
|
const CardNumberField = w((props, ref) => {
|
|
@@ -3,17 +3,14 @@ import { isUndefined } from "../../utils/is.js";
|
|
|
3
3
|
import "../../utils/card-brand/brands.js";
|
|
4
4
|
import "../../utils/system-info/get-browser-info.js";
|
|
5
5
|
import { limitedToNumber } from "../../utils/format.js";
|
|
6
|
+
import { EFieldType } from "../SecuredFieldsProvider/index.js";
|
|
6
7
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
7
|
-
import "../../core/context.js";
|
|
8
|
-
import "../../i18n/util.js";
|
|
9
|
-
import "../../i18n/locales/index.js";
|
|
10
8
|
import "../internal/Form/type.js";
|
|
11
9
|
import "../internal/Form/context.js";
|
|
12
10
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
13
11
|
import "../internal/Form/Form.js";
|
|
14
12
|
import { Input } from "../internal/Input/Input.js";
|
|
15
13
|
import "../internal/Input/type.js";
|
|
16
|
-
import { EFieldType } from "../SecuredFieldsProvider/SecuredFieldsProvider.js";
|
|
17
14
|
const CardSecurityCodeField = w((props, ref) => {
|
|
18
15
|
const { className, style, security, showLabel } = props;
|
|
19
16
|
const inputRef = A(null);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { A, h, y, u } from "../../core.js";
|
|
2
2
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
3
3
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
4
|
-
import "../../core/context.js";
|
|
5
4
|
import { finCardBrandInfoByCode } from "../../utils/card-brand/index.js";
|
|
6
5
|
import "../../utils/system-info/get-browser-info.js";
|
|
7
|
-
import "../../i18n/util.js";
|
|
8
|
-
import "../../i18n/locales/index.js";
|
|
9
6
|
import "../internal/Form/type.js";
|
|
10
7
|
import "../internal/Form/context.js";
|
|
11
8
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { w, A, F, h, u } from "../../core.js";
|
|
2
|
+
import "../internal/Form/type.js";
|
|
3
|
+
import "../internal/Form/context.js";
|
|
4
|
+
import { FormItem } from "../internal/Form/FormItem.js";
|
|
5
|
+
import "../internal/Form/Form.js";
|
|
6
|
+
import { Input } from "../internal/Input/Input.js";
|
|
7
|
+
import "../internal/Input/type.js";
|
|
8
|
+
import { EFieldType } from "../SecuredFieldsProvider/index.js";
|
|
9
|
+
import { finCardBrandInfoByCode, findCardBrandInfo, getSupportedCardBrands } from "../../utils/card-brand/index.js";
|
|
10
|
+
import "../../utils/system-info/get-browser-info.js";
|
|
11
|
+
import { trimAll } from "../../utils/format.js";
|
|
12
|
+
import { IconCardNo } from "../internal/icons/IconCardNo.js";
|
|
13
|
+
import { useBEM } from "../../hooks/useBEM.js";
|
|
14
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
15
|
+
const { bem } = useBEM("combined-card-info");
|
|
16
|
+
const CombinedCardInfo = w(
|
|
17
|
+
(props, ref) => {
|
|
18
|
+
const { supportedCardBrands = [], className, showLabel = false, security } = props;
|
|
19
|
+
const inputRef = A(null);
|
|
20
|
+
const formItemRef = A(null);
|
|
21
|
+
const { i18n } = useI18n();
|
|
22
|
+
F(ref, () => ({
|
|
23
|
+
input: inputRef.current,
|
|
24
|
+
focus: () => {
|
|
25
|
+
var _a;
|
|
26
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
27
|
+
},
|
|
28
|
+
blur: () => {
|
|
29
|
+
var _a;
|
|
30
|
+
(_a = inputRef.current) == null ? void 0 : _a.blur();
|
|
31
|
+
},
|
|
32
|
+
resetValidation: (status, errorTip) => {
|
|
33
|
+
var _a;
|
|
34
|
+
(_a = formItemRef.current) == null ? void 0 : _a.resetValidation(status, [{ message: errorTip }]);
|
|
35
|
+
},
|
|
36
|
+
binValueChanged: (binValue2) => {
|
|
37
|
+
setBinValue(binValue2);
|
|
38
|
+
},
|
|
39
|
+
brandChanged: (brand) => {
|
|
40
|
+
if (brand) {
|
|
41
|
+
const brandInfo = finCardBrandInfoByCode(brand);
|
|
42
|
+
setBrandIcon(() => brandInfo == null ? void 0 : brandInfo.icon);
|
|
43
|
+
} else {
|
|
44
|
+
setBrandIcon(void 0);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
getCardBrand: () => {
|
|
48
|
+
return findCardBrandInfo(trimAll(binValue), getSupportedCardBrands(supportedCardBrands)) || {};
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
const rule = {
|
|
52
|
+
trigger: ["submit"],
|
|
53
|
+
validator() {
|
|
54
|
+
if (security) {
|
|
55
|
+
const result = formItemRef.current.getValidateResult();
|
|
56
|
+
if (result.status === "error") {
|
|
57
|
+
throw new Error(result.errors[0].message);
|
|
58
|
+
} else if (result.status === "success") {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const [binValue, setBinValue] = h("");
|
|
66
|
+
const [brandIcon, setBrandIcon] = h(void 0);
|
|
67
|
+
const LeftIcon = () => {
|
|
68
|
+
const Icon = brandIcon ?? IconCardNo;
|
|
69
|
+
return /* @__PURE__ */ u(Icon, { size: 32 });
|
|
70
|
+
};
|
|
71
|
+
return /* @__PURE__ */ u(
|
|
72
|
+
FormItem,
|
|
73
|
+
{
|
|
74
|
+
showLabel,
|
|
75
|
+
ref: formItemRef,
|
|
76
|
+
label: i18n.get("card.info.label"),
|
|
77
|
+
className,
|
|
78
|
+
path: "cardInfo",
|
|
79
|
+
rule,
|
|
80
|
+
children: /* @__PURE__ */ u(
|
|
81
|
+
Input,
|
|
82
|
+
{
|
|
83
|
+
ref: inputRef,
|
|
84
|
+
leftIcon: LeftIcon(),
|
|
85
|
+
rightIcon: /* @__PURE__ */ u("div", { className: bem("blank-icon") }),
|
|
86
|
+
children: /* @__PURE__ */ u("div", { className: bem(), children: [
|
|
87
|
+
/* @__PURE__ */ u("div", { className: bem("card-number"), "data-sf": EFieldType.CARD_NUMBER }),
|
|
88
|
+
/* @__PURE__ */ u("div", { className: bem("expire-date"), "data-sf": EFieldType.EXPIRE_DATE }),
|
|
89
|
+
/* @__PURE__ */ u("div", { className: bem("cvv"), "data-sf": EFieldType.CVV })
|
|
90
|
+
] })
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
export {
|
|
98
|
+
CombinedCardInfo
|
|
99
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { u, w, h, A, F, y, b } from "../../core.js";
|
|
2
|
+
import "../../utils/card-brand/brands.js";
|
|
3
|
+
import "../../utils/system-info/get-browser-info.js";
|
|
4
|
+
import { CoreContext } from "../../core/context.js";
|
|
5
|
+
import { CardPaymentMethods, PaymentMethod, PaymentCategory, SessionMode } from "../../constant.js";
|
|
6
|
+
import { Card } from "../Card/index.js";
|
|
7
|
+
import { ApplePay } from "../ApplePay/index.js";
|
|
8
|
+
import { GooglePay } from "../GooglePay/index.js";
|
|
9
|
+
import { useBEM } from "../../hooks/useBEM.js";
|
|
10
|
+
import { intersection } from "../../utils/index.js";
|
|
11
|
+
import { PayKKaError } from "../../core/error.js";
|
|
12
|
+
import { usePayState } from "../../hooks/usePayState.js";
|
|
13
|
+
import { IconCard } from "../internal/icons/IconCard.js";
|
|
14
|
+
const dropInSupportedPaymentMethods = [
|
|
15
|
+
...CardPaymentMethods,
|
|
16
|
+
PaymentMethod.GOOGLE_PAY,
|
|
17
|
+
PaymentMethod.APPLE_PAY
|
|
18
|
+
];
|
|
19
|
+
const PaymentComponentMap = {
|
|
20
|
+
[PaymentCategory.CARD]: Card,
|
|
21
|
+
[PaymentCategory.APPLE_PAY]: ApplePay,
|
|
22
|
+
[PaymentCategory.GOOGLE_PAY]: GooglePay
|
|
23
|
+
// [PaymentCategory.WECHAT_PAY]: WechatPay,
|
|
24
|
+
// [PaymentCategory.ALI_PAY]: AliPay,
|
|
25
|
+
// [PaymentCategory.SEPA_DEBIT]: Sepa
|
|
26
|
+
};
|
|
27
|
+
const { bem: bem$1 } = useBEM("payment-tabs");
|
|
28
|
+
const PaymentTabs = (props) => {
|
|
29
|
+
const { value, tabs, themeColor = "#4F43DF" } = props;
|
|
30
|
+
const handleClickTab = (tab) => {
|
|
31
|
+
var _a;
|
|
32
|
+
if (tab.type === value) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
(_a = props.onChange) == null ? void 0 : _a.call(props, tab.type);
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ u("div", { className: bem$1(), children: tabs.map((tab) => /* @__PURE__ */ u(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
className: bem$1("tab"),
|
|
41
|
+
style: tab.type === value ? { borderColor: themeColor } : "",
|
|
42
|
+
onClick: () => handleClickTab(tab),
|
|
43
|
+
children: [
|
|
44
|
+
tab.icon,
|
|
45
|
+
/* @__PURE__ */ u(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
className: bem$1("name"),
|
|
49
|
+
style: tab.type === value ? { color: themeColor } : "",
|
|
50
|
+
children: tab.name
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
)) });
|
|
56
|
+
};
|
|
57
|
+
const { bem } = useBEM("drop-in");
|
|
58
|
+
const DropIn = w((props, ref) => {
|
|
59
|
+
const { paymentMethods: paymentMethodsConfig, layout = "tabs", session } = props;
|
|
60
|
+
const { i18n, sessionReady } = usePayState(session);
|
|
61
|
+
const [paymentCategoryOptions, setPaymentCategoryOptions] = h([]);
|
|
62
|
+
const [activePaymentCategory, setActivePaymentCategory] = h(
|
|
63
|
+
null
|
|
64
|
+
);
|
|
65
|
+
const [headerPaymentCategories, setHeaderPaymentCategories] = h(
|
|
66
|
+
[]
|
|
67
|
+
);
|
|
68
|
+
const [paymentCategories, setPaymentCategories] = h([]);
|
|
69
|
+
const componentMountRefMap = A({});
|
|
70
|
+
const componentInstMap = A({});
|
|
71
|
+
F(ref, () => ({
|
|
72
|
+
payment: () => {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
if (activePaymentCategory) {
|
|
75
|
+
const instRef = (_a = componentInstMap.current[activePaymentCategory]) == null ? void 0 : _a.ref;
|
|
76
|
+
(_b = instRef == null ? void 0 : instRef.payment) == null ? void 0 : _b.call(instRef);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
80
|
+
y(() => {
|
|
81
|
+
if (!activePaymentCategory) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (componentInstMap.current[activePaymentCategory]) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
renderComponent(activePaymentCategory);
|
|
88
|
+
}, [activePaymentCategory]);
|
|
89
|
+
y(() => {
|
|
90
|
+
if (headerPaymentCategories == null ? void 0 : headerPaymentCategories.length) {
|
|
91
|
+
renderComponent(PaymentCategory.APPLE_PAY);
|
|
92
|
+
renderComponent(PaymentCategory.GOOGLE_PAY);
|
|
93
|
+
}
|
|
94
|
+
}, [headerPaymentCategories]);
|
|
95
|
+
const createComponent = (category) => {
|
|
96
|
+
const { onError, onSuccess, onTimeout, onExpired, onSubmit } = props;
|
|
97
|
+
return props.core.create(PaymentComponentMap[category], {
|
|
98
|
+
onError,
|
|
99
|
+
onSuccess,
|
|
100
|
+
onTimeout,
|
|
101
|
+
onExpired,
|
|
102
|
+
onSubmit,
|
|
103
|
+
...paymentMethodsConfig == null ? void 0 : paymentMethodsConfig[category],
|
|
104
|
+
isDropIn: true
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
const renderComponent = (category) => {
|
|
108
|
+
const inst = createComponent(category);
|
|
109
|
+
const container = componentMountRefMap.current[category];
|
|
110
|
+
if (container) {
|
|
111
|
+
inst.mount(container);
|
|
112
|
+
componentInstMap.current[category] = inst;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const initPaymentCategories = (enablePaymentMethods) => {
|
|
116
|
+
const paymentCategoryOptions2 = [];
|
|
117
|
+
const paymentCategories2 = [];
|
|
118
|
+
const headerPaymentCategories2 = [];
|
|
119
|
+
if (enablePaymentMethods.includes(PaymentMethod.APPLE_PAY)) {
|
|
120
|
+
if (layout === "tabs") {
|
|
121
|
+
headerPaymentCategories2.push(PaymentCategory.APPLE_PAY);
|
|
122
|
+
} else {
|
|
123
|
+
paymentCategories2.push(PaymentCategory.APPLE_PAY);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (enablePaymentMethods.includes(PaymentMethod.GOOGLE_PAY)) {
|
|
127
|
+
if (layout === "tabs") {
|
|
128
|
+
headerPaymentCategories2.push(PaymentCategory.GOOGLE_PAY);
|
|
129
|
+
} else {
|
|
130
|
+
paymentCategories2.push(PaymentCategory.APPLE_PAY);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const isCardEnable = !!intersection(enablePaymentMethods, CardPaymentMethods).length;
|
|
134
|
+
if (isCardEnable) {
|
|
135
|
+
paymentCategories2.push(PaymentCategory.CARD);
|
|
136
|
+
paymentCategoryOptions2.push({
|
|
137
|
+
type: PaymentCategory.CARD,
|
|
138
|
+
name: i18n.get("dropIn.card.label"),
|
|
139
|
+
icon: /* @__PURE__ */ u(IconCard, { size: 16 })
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (paymentCategoryOptions2.length) {
|
|
143
|
+
setPaymentCategoryOptions(paymentCategoryOptions2);
|
|
144
|
+
setActivePaymentCategory(paymentCategoryOptions2[0].type);
|
|
145
|
+
}
|
|
146
|
+
setHeaderPaymentCategories(headerPaymentCategories2);
|
|
147
|
+
setPaymentCategories(paymentCategories2);
|
|
148
|
+
};
|
|
149
|
+
const handlePaymentCategoryChange = (newPaymentCategory) => {
|
|
150
|
+
setActivePaymentCategory(newPaymentCategory);
|
|
151
|
+
};
|
|
152
|
+
y(() => {
|
|
153
|
+
var _a, _b, _c;
|
|
154
|
+
if (!sessionReady || !i18n.ready.value) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (((_a = session.checkout) == null ? void 0 : _a.sessionMode) === SessionMode.COMPONENT) {
|
|
158
|
+
(_c = (_b = props.core.config).onInitError) == null ? void 0 : _c.call(
|
|
159
|
+
_b,
|
|
160
|
+
new PayKKaError("ERROR", "Please send the correct mode when creating the checkout")
|
|
161
|
+
);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const { paymentMethod = [] } = (session == null ? void 0 : session.checkout) || {};
|
|
165
|
+
const enablePaymentMethods = intersection(
|
|
166
|
+
paymentMethod,
|
|
167
|
+
dropInSupportedPaymentMethods
|
|
168
|
+
);
|
|
169
|
+
if (!enablePaymentMethods.length) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
initPaymentCategories(enablePaymentMethods);
|
|
173
|
+
}, [sessionReady, i18n.ready.value]);
|
|
174
|
+
return /* @__PURE__ */ u(CoreContext.Provider, { value: { i18n }, children: i18n.ready.value && /* @__PURE__ */ u("div", { className: bem(), children: layout === "accordion" ? /* @__PURE__ */ u(b, {}) : /* @__PURE__ */ u(b, { children: [
|
|
175
|
+
headerPaymentCategories == null ? void 0 : headerPaymentCategories.map((category) => /* @__PURE__ */ u(
|
|
176
|
+
"div",
|
|
177
|
+
{
|
|
178
|
+
className: bem("header-payment"),
|
|
179
|
+
ref: (el) => componentMountRefMap.current[category] = el
|
|
180
|
+
}
|
|
181
|
+
)),
|
|
182
|
+
!!paymentCategoryOptions.length && activePaymentCategory && /* @__PURE__ */ u(b, { children: [
|
|
183
|
+
!!(headerPaymentCategories == null ? void 0 : headerPaymentCategories.length) && /* @__PURE__ */ u("div", { className: bem("other"), children: [
|
|
184
|
+
/* @__PURE__ */ u("div", { className: bem("other-line") }),
|
|
185
|
+
/* @__PURE__ */ u("div", { className: bem("other-text"), children: i18n.get("dropIn.otherPaymentMethod") }),
|
|
186
|
+
/* @__PURE__ */ u("div", { className: bem("other-line") })
|
|
187
|
+
] }),
|
|
188
|
+
/* @__PURE__ */ u("div", { className: bem("tabs-wrapper"), children: /* @__PURE__ */ u(
|
|
189
|
+
PaymentTabs,
|
|
190
|
+
{
|
|
191
|
+
value: activePaymentCategory,
|
|
192
|
+
tabs: paymentCategoryOptions,
|
|
193
|
+
onChange: (item) => handlePaymentCategoryChange(item)
|
|
194
|
+
}
|
|
195
|
+
) }),
|
|
196
|
+
paymentCategories == null ? void 0 : paymentCategories.map((category) => /* @__PURE__ */ u(
|
|
197
|
+
"div",
|
|
198
|
+
{
|
|
199
|
+
style: { display: category === activePaymentCategory ? "block" : "none" },
|
|
200
|
+
ref: (el) => componentMountRefMap.current[category] = el
|
|
201
|
+
}
|
|
202
|
+
))
|
|
203
|
+
] })
|
|
204
|
+
] }) }) });
|
|
205
|
+
});
|
|
206
|
+
export {
|
|
207
|
+
DropIn,
|
|
208
|
+
PaymentComponentMap,
|
|
209
|
+
dropInSupportedPaymentMethods
|
|
210
|
+
};
|
|
@@ -9,9 +9,6 @@ import { isValuable } from "../../utils/is.js";
|
|
|
9
9
|
import "../../utils/card-brand/brands.js";
|
|
10
10
|
import "../../utils/system-info/get-browser-info.js";
|
|
11
11
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
12
|
-
import "../../core/context.js";
|
|
13
|
-
import "../../i18n/util.js";
|
|
14
|
-
import "../../i18n/locales/index.js";
|
|
15
12
|
import "../internal/Form/type.js";
|
|
16
13
|
import "../internal/Form/context.js";
|
|
17
14
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -6,21 +6,21 @@ import { getBrowserInfo } from "../../utils/system-info/get-browser-info.js";
|
|
|
6
6
|
import { w, F, h, A, y, u } from "../../core.js";
|
|
7
7
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
8
8
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
9
|
+
import { defaultInputStyleConfig } from "../../types/index.js";
|
|
9
10
|
import { intersection } from "../../utils/index.js";
|
|
10
|
-
import {
|
|
11
|
-
import { EFieldType, SecuredFieldsProvider } from "../SecuredFieldsProvider/SecuredFieldsProvider.js";
|
|
11
|
+
import { EFieldType, SecuredFieldsProvider } from "../SecuredFieldsProvider/index.js";
|
|
12
12
|
import { CardNumberField } from "../CardNumberField/index.js";
|
|
13
13
|
import { CardExpireDateField } from "../CardExpireDateField/index.js";
|
|
14
14
|
import { CardSecurityCodeField } from "../CardSecurityCodeField/index.js";
|
|
15
15
|
import { verifyClientKey } from "../../api/modules/encrypted-card/index.js";
|
|
16
|
-
import {
|
|
16
|
+
import { formItemLabelClassName, formItemErrorMessageClassName } from "../internal/Form/type.js";
|
|
17
17
|
import "../internal/Form/context.js";
|
|
18
18
|
import "../internal/Form/FormItem.js";
|
|
19
19
|
import "../internal/Form/Form.js";
|
|
20
|
-
import {
|
|
20
|
+
import { CombinedCardInfo } from "../CombinedCardInfo/index.js";
|
|
21
21
|
import "../internal/Input/Input.js";
|
|
22
22
|
import { inputWrapperClassName } from "../internal/Input/type.js";
|
|
23
|
-
import {
|
|
23
|
+
import { separateInputStyle, genComponentStyle, loadStyle } from "../../utils/style.js";
|
|
24
24
|
import { createPromise } from "../../utils/create-promise.js";
|
|
25
25
|
const ENCRYPTED_CARD_WRAPPER_ID = "encryptedCardWrapper";
|
|
26
26
|
const ENCRYPTED_CARD_ITEM_ATTR = "data-eci";
|
|
@@ -90,78 +90,38 @@ const EncryptedCard = w((props, ref) => {
|
|
|
90
90
|
if (!styles) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
const { input, label, errorMessage } = styles;
|
|
94
|
-
|
|
95
|
-
if (input) {
|
|
96
|
-
inputWrapper = JSON.parse(JSON.stringify(input));
|
|
97
|
-
Reflect.deleteProperty(inputWrapper, "placeholder");
|
|
98
|
-
const inputStyle2 = {
|
|
99
|
-
placeholder: input == null ? void 0 : input.placeholder
|
|
100
|
-
};
|
|
101
|
-
const statusList = Object.keys(inputWrapper);
|
|
102
|
-
statusList.forEach((key) => {
|
|
103
|
-
if (key === "placeholder") {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
const style = inputWrapper[key];
|
|
107
|
-
if (!style) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
inputStyleAttrs.forEach((attr) => {
|
|
111
|
-
if (!inputStyle2[key]) {
|
|
112
|
-
inputStyle2[key] = {};
|
|
113
|
-
}
|
|
114
|
-
if (style[attr]) {
|
|
115
|
-
inputStyle2[key][attr] = style[attr];
|
|
116
|
-
Reflect.deleteProperty(style, attr);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
setInputStyle(inputStyle2);
|
|
121
|
-
}
|
|
93
|
+
const { input, label, errorMessage, inputWrapper } = separateInputStyle(styles);
|
|
94
|
+
input && setInputStyle(input);
|
|
122
95
|
if (!document.querySelector(`style#${encryptedCardStyleId}`)) {
|
|
123
|
-
const style = [];
|
|
124
96
|
const parentId = ENCRYPTED_CARD_WRAPPER_ID;
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
inputWrapper.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
inputWrapper.invalid
|
|
136
|
-
)} }`;
|
|
137
|
-
const labelClassName = formItemLabelClassName;
|
|
138
|
-
const labelStyle = `#${parentId} .${labelClassName} { ${style2String(label == null ? void 0 : label.base)} }`;
|
|
139
|
-
const labelFocusStyle = `#${parentId} .${labelClassName}--focus { ${style2String(
|
|
140
|
-
label == null ? void 0 : label.focus
|
|
141
|
-
)} }`;
|
|
142
|
-
const labelValidStyle = `#${parentId} .${labelClassName}--success { ${style2String(
|
|
143
|
-
label == null ? void 0 : label.valid
|
|
144
|
-
)} }`;
|
|
145
|
-
const labelInvalidStyle = `#${parentId} .${labelClassName}--error { ${style2String(
|
|
146
|
-
label == null ? void 0 : label.invalid
|
|
147
|
-
)} }`;
|
|
148
|
-
const errorMessageStyle = `#${parentId} .${formItemErrorMessageClassName} { ${style2String(
|
|
149
|
-
errorMessage
|
|
150
|
-
)} }`;
|
|
151
|
-
style.push(
|
|
152
|
-
...[
|
|
153
|
-
inputWrapperStyle,
|
|
154
|
-
inputWrapperFocusStyle,
|
|
155
|
-
inputWrapperValidStyle,
|
|
156
|
-
inputWrapperInvalidStyle,
|
|
157
|
-
labelStyle,
|
|
158
|
-
labelFocusStyle,
|
|
159
|
-
labelValidStyle,
|
|
160
|
-
labelInvalidStyle,
|
|
161
|
-
errorMessageStyle
|
|
162
|
-
]
|
|
97
|
+
const inputWrapperPrefix = `#${parentId} .${inputWrapperClassName}`;
|
|
98
|
+
const labelPrefix = `#${parentId} .${formItemLabelClassName}`;
|
|
99
|
+
const errorMessagePrefix = `#${parentId} .${formItemErrorMessageClassName}`;
|
|
100
|
+
const inputWrapperStyle = genComponentStyle(
|
|
101
|
+
Object.entries(inputWrapper || {}).map(([type, style2]) => {
|
|
102
|
+
return {
|
|
103
|
+
selector: type === "base" ? inputWrapperPrefix : `${inputWrapperPrefix}--${type}`,
|
|
104
|
+
style: style2
|
|
105
|
+
};
|
|
106
|
+
})
|
|
163
107
|
);
|
|
164
|
-
|
|
108
|
+
const labelStyle = genComponentStyle(
|
|
109
|
+
Object.entries(label || {}).map(([type, style2]) => {
|
|
110
|
+
return {
|
|
111
|
+
selector: type === "base" ? labelPrefix : `${labelPrefix}--${type}`,
|
|
112
|
+
style: style2
|
|
113
|
+
};
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
const errorMessageStyle = genComponentStyle([
|
|
117
|
+
{
|
|
118
|
+
selector: errorMessagePrefix,
|
|
119
|
+
style: errorMessage
|
|
120
|
+
}
|
|
121
|
+
]);
|
|
122
|
+
const style = `${inputWrapperStyle}${labelStyle}${errorMessageStyle}`;
|
|
123
|
+
console.log(style);
|
|
124
|
+
loadStyle(style, { id: encryptedCardStyleId });
|
|
165
125
|
}
|
|
166
126
|
};
|
|
167
127
|
const classNameMap = {
|
|
@@ -266,7 +226,7 @@ const EncryptedCard = w((props, ref) => {
|
|
|
266
226
|
const embedEncryptedCard = () => {
|
|
267
227
|
if (single) {
|
|
268
228
|
const cardWrapper = wrapperDomMap.current[EEncryptedCardType.CARD];
|
|
269
|
-
const combinedEncryptedField = create(
|
|
229
|
+
const combinedEncryptedField = create(CombinedCardInfo, {
|
|
270
230
|
supportedCardBrands: supportedBrands,
|
|
271
231
|
security: true,
|
|
272
232
|
className: combinedEncryptedFieldClassName
|