@paykka/card-checkout-ui 0.6.0 → 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.
Files changed (160) hide show
  1. package/dist/card-checkout-ui.js +12 -12
  2. package/dist/card-checkout-ui.umd.cjs +12 -12
  3. package/dist/es/api/index.js +0 -2
  4. package/dist/es/api/modules/checkout/index.js +1 -15
  5. package/dist/es/api/modules/checkout/map.js +20 -3
  6. package/dist/es/api/modules/index.js +0 -2
  7. package/dist/es/components/AccountNameField/index.js +0 -3
  8. package/dist/es/components/AddressField/index.js +2 -7
  9. package/dist/es/components/AliPay/index.js +8 -7
  10. package/dist/es/components/ApplePay/index.js +7 -8
  11. package/dist/es/components/Card/index.js +301 -125
  12. package/dist/es/components/CardBrands/index.js +0 -2
  13. package/dist/es/components/CardExpireDateField/index.js +1 -4
  14. package/dist/es/components/CardHolderNameField/index.js +3 -5
  15. package/dist/es/components/CardIBANField/index.js +0 -3
  16. package/dist/es/components/CardNo/index.js +0 -2
  17. package/dist/es/components/CardNumberField/index.js +1 -4
  18. package/dist/es/components/CardSecurityCodeField/index.js +1 -4
  19. package/dist/es/components/CardSelector/index.js +0 -3
  20. package/dist/es/components/CombinedCardInfo/index.js +99 -0
  21. package/dist/es/components/EmailField/EmailField.js +0 -3
  22. package/dist/es/components/EncryptedCard/index.js +35 -75
  23. package/dist/es/components/GooglePay/index.js +62 -28
  24. package/dist/es/components/RecurringTip/index.js +0 -2
  25. package/dist/es/components/SecuredFieldsProvider/index.js +230 -1
  26. package/dist/es/components/SecuredIframe/index.js +3 -1
  27. package/dist/es/components/Sepa/index.js +21 -27
  28. package/dist/es/components/SubmitButton/index.js +0 -2
  29. package/dist/es/components/ThreeDS/index.js +94 -0
  30. package/dist/es/components/WechatPay/index.js +26 -25
  31. package/dist/es/components/index.js +1 -3
  32. package/dist/es/components/internal/Button/Button.js +0 -2
  33. package/dist/es/components/internal/Button/index.js +0 -2
  34. package/dist/es/components/internal/CheckBox/CheckBox.js +0 -2
  35. package/dist/es/components/internal/CheckBox/index.js +0 -2
  36. package/dist/es/components/internal/Form/type.js +0 -2
  37. package/dist/es/components/internal/Info/Info.js +0 -2
  38. package/dist/es/components/internal/Info/index.js +0 -2
  39. package/dist/es/components/internal/Input/Input.js +2 -2
  40. package/dist/es/components/internal/Input/type.js +0 -2
  41. package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -2
  42. package/dist/es/components/internal/LoadingCheck/index.js +0 -2
  43. package/dist/es/components/internal/Modal/Modal.js +40 -0
  44. package/dist/es/components/internal/Modal/modal2.js +1 -0
  45. package/dist/es/components/internal/Select/Select.js +0 -2
  46. package/dist/es/components/internal/Select/SelectMenu.js +0 -2
  47. package/dist/es/components/internal/Select/SelectMenuItem.js +0 -2
  48. package/dist/es/components/internal/icons/Icon3DSFail.js +3 -0
  49. package/dist/es/components/internal/icons/Icon3DSInfo.js +62 -0
  50. package/dist/es/components/internal/icons/Icon3DSSuccess.js +3 -0
  51. package/dist/es/config.js +0 -2
  52. package/dist/es/constant.js +3 -2
  53. package/dist/es/core/PayKKaCheckout.js +96 -42
  54. package/dist/es/core/Session.js +7 -6
  55. package/dist/es/core/environment.js +26 -0
  56. package/dist/es/core/error.js +21 -0
  57. package/dist/es/core/index.js +0 -2
  58. package/dist/es/core/query.js +0 -2
  59. package/dist/es/core.js +34 -34
  60. package/dist/es/hooks/index.js +0 -2
  61. package/dist/es/hooks/useBreakpoints.js +57 -0
  62. package/dist/es/hooks/useI18n.js +1 -2
  63. package/dist/es/hooks/usePayState.js +18 -24
  64. package/dist/es/i18n/index.js +0 -2
  65. package/dist/es/i18n/locales/de-DE.js +11 -1
  66. package/dist/es/i18n/locales/en-GB.js +11 -1
  67. package/dist/es/i18n/locales/es-ES.js +11 -1
  68. package/dist/es/i18n/locales/fr-FR.js +11 -1
  69. package/dist/es/i18n/locales/index.js +8 -6
  70. package/dist/es/i18n/locales/ja-JP.js +11 -1
  71. package/dist/es/i18n/locales/ko-KR.js +11 -1
  72. package/dist/es/i18n/locales/pt-PT.js +11 -1
  73. package/dist/es/i18n/locales/ru-RU.js +11 -1
  74. package/dist/es/i18n/locales/zh-CN.js +11 -1
  75. package/dist/es/i18n/locales/zh-HK.js +11 -1
  76. package/dist/es/i18n/locales/zh-TW.js +11 -1
  77. package/dist/es/i18n/util.js +11 -8
  78. package/dist/es/index.js +4 -2
  79. package/dist/es/style.css +186 -4
  80. package/dist/es/types/message.js +28 -0
  81. package/dist/es/utils/card-brand/brands.js +12 -10
  82. package/dist/es/utils/card-brand/index.js +3 -2
  83. package/dist/es/utils/iframe.js +23 -0
  84. package/dist/es/utils/index.js +0 -1
  85. package/dist/es/utils/style.js +47 -0
  86. package/dist/style.css +1 -1
  87. package/dist/types/api/modules/checkout/type.d.ts +14 -1
  88. package/dist/types/api/modules/get-browser-params.d.ts +1 -1
  89. package/dist/types/components/AddressField/type.d.ts +1 -0
  90. package/dist/types/components/AliPay/type.d.ts +4 -2
  91. package/dist/types/components/ApplePay/type.d.ts +4 -3
  92. package/dist/types/components/Card/type.d.ts +56 -10
  93. package/dist/types/components/CardHolderNameField/type.d.ts +1 -1
  94. package/dist/types/components/CombinedCardInfo/CombinedCardInfo.d.ts +5 -0
  95. package/dist/types/components/CombinedCardInfo/index.d.ts +2 -0
  96. package/dist/types/components/{CombinedEncryptedField → CombinedCardInfo}/type.d.ts +3 -2
  97. package/dist/types/components/GooglePay/type.d.ts +4 -3
  98. package/dist/types/components/SecuredFieldsProvider/index.d.ts +1 -0
  99. package/dist/types/components/SecuredFieldsProvider/type.d.ts +1 -153
  100. package/dist/types/components/SecuredFieldsProvider/utils/index.d.ts +1 -1
  101. package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +2 -1
  102. package/dist/types/components/Sepa/type.d.ts +4 -2
  103. package/dist/types/components/ThreeDS/components/ThreeDSAuth/ThreeDSAuth.d.ts +3 -0
  104. package/dist/types/components/ThreeDS/components/ThreeDSAuth/index.d.ts +2 -0
  105. package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +17 -0
  106. package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +2 -0
  107. package/dist/types/components/ThreeDS/components/ThreeDSIframe/index.d.ts +1 -0
  108. package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -0
  109. package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +5 -0
  110. package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +3 -0
  111. package/dist/types/components/ThreeDS/components/ThreeDSStatus/output.d.ts +1 -0
  112. package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +6 -0
  113. package/dist/types/components/ThreeDS/index.d.ts +1 -0
  114. package/dist/types/components/WechatPay/type.d.ts +4 -2
  115. package/dist/types/components/index.d.ts +1 -1
  116. package/dist/types/components/internal/Input/type.d.ts +1 -0
  117. package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
  118. package/dist/types/components/internal/Loading/index.d.ts +1 -0
  119. package/dist/types/components/internal/Modal/Modal.d.ts +5 -0
  120. package/dist/types/components/internal/Modal/index.d.ts +0 -0
  121. package/dist/types/components/internal/Modal/type.d.ts +20 -0
  122. package/dist/types/components/internal/icons/Icon3DSFail.d.ts +2 -0
  123. package/dist/types/components/internal/icons/Icon3DSInfo.d.ts +2 -0
  124. package/dist/types/components/internal/icons/Icon3DSSuccess.d.ts +2 -0
  125. package/dist/types/components/internal/icons/index.d.ts +3 -0
  126. package/dist/types/constant.d.ts +6 -2
  127. package/dist/types/core/PayKKaCheckout.d.ts +22 -6
  128. package/dist/types/core/Session.d.ts +1 -1
  129. package/dist/types/core/context.d.ts +1 -0
  130. package/dist/types/core/environment.d.ts +4 -0
  131. package/dist/types/core/error.d.ts +16 -0
  132. package/dist/types/core/index.d.ts +1 -0
  133. package/dist/types/hooks/index.d.ts +1 -0
  134. package/dist/types/hooks/useBreakpoints.d.ts +15 -0
  135. package/dist/types/hooks/usePayState.d.ts +3 -6
  136. package/dist/types/i18n/locales/de-DE.d.ts +8 -0
  137. package/dist/types/i18n/locales/en-GB.d.ts +8 -0
  138. package/dist/types/i18n/locales/es-ES.d.ts +8 -0
  139. package/dist/types/i18n/locales/fr-FR.d.ts +8 -0
  140. package/dist/types/i18n/locales/index.d.ts +2 -2
  141. package/dist/types/i18n/locales/ja-JP.d.ts +8 -0
  142. package/dist/types/i18n/locales/ko-KR.d.ts +8 -0
  143. package/dist/types/i18n/locales/pt-PT.d.ts +8 -0
  144. package/dist/types/i18n/locales/ru-RU.d.ts +8 -0
  145. package/dist/types/i18n/locales/zh-CN.d.ts +8 -0
  146. package/dist/types/i18n/locales/zh-HK.d.ts +8 -0
  147. package/dist/types/i18n/locales/zh-TW.d.ts +8 -0
  148. package/dist/types/index.d.ts +1 -1
  149. package/dist/types/types/index.d.ts +39 -8
  150. package/dist/types/types/message.d.ts +170 -0
  151. package/dist/types/utils/card-brand/brands.d.ts +1 -8
  152. package/dist/types/utils/card-brand/index.d.ts +2 -2
  153. package/dist/types/utils/index.d.ts +1 -0
  154. package/dist/types/utils/style.d.ts +12 -0
  155. package/package.json +63 -63
  156. package/dist/es/components/CombinedEncryptedField/index.js +0 -75
  157. package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +0 -268
  158. package/dist/types/components/CombinedEncryptedField/CombinedEncryptedField.d.ts +0 -4
  159. package/dist/types/components/CombinedEncryptedField/index.d.ts +0 -2
  160. /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/SecuredFieldsProvider.js";
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/SecuredFieldsProvider.js";
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
+ };
@@ -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 { defaultInputStyleConfig, inputStyleAttrs } from "../../types/index.js";
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 { formItemErrorMessageClassName, formItemLabelClassName } from "../internal/Form/type.js";
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 { CombinedEncryptedField } from "../CombinedEncryptedField/index.js";
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 { style2String, loadStyle } from "../../utils/style.js";
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
- let inputWrapper = {};
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 inputWrapperStyle = `#${parentId} .${inputWrapperClassName} { ${style2String(
126
- inputWrapper.base
127
- )} }`;
128
- const inputWrapperFocusStyle = `#${parentId} .${inputWrapperClassName}--focus { ${style2String(
129
- inputWrapper.focus
130
- )} }`;
131
- const inputWrapperValidStyle = `#${parentId} .${inputWrapperClassName}--success { ${style2String(
132
- inputWrapper.valid
133
- )} }`;
134
- const inputWrapperInvalidStyle = `#${parentId} .${inputWrapperClassName}--error { ${style2String(
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
- loadStyle(style.join("\n"));
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(CombinedEncryptedField, {
229
+ const combinedEncryptedField = create(CombinedCardInfo, {
270
230
  supportedCardBrands: supportedBrands,
271
231
  security: true,
272
232
  className: combinedEncryptedFieldClassName
@@ -1,6 +1,6 @@
1
1
  import { w, F, h, q, y, A, u, b } from "../../core.js";
2
2
  import { isTimeoutError } from "../../api/http.js";
3
- import { PaymentMethod } from "../../constant.js";
3
+ import { PaymentMethod, SessionMode } from "../../constant.js";
4
4
  import { getBrowserParams } from "../../api/modules/get-browser-params.js";
5
5
  import { getGooglePayInfo, googlePay } from "../../api/modules/google-pay/index.js";
6
6
  import { useBEM } from "../../hooks/useBEM.js";
@@ -8,12 +8,12 @@ import "../../core/context.js";
8
8
  import "../../utils/card-brand/brands.js";
9
9
  import "../../utils/system-info/get-browser-info.js";
10
10
  import { extractAreaCodeAndPhoneNumber } from "../../utils/format.js";
11
- import "../../i18n/util.js";
12
- import "../../i18n/locales/index.js";
11
+ import { PayKKaError } from "../../core/error.js";
13
12
  import { usePayState } from "../../hooks/usePayState.js";
14
13
  import { useRetry } from "../../hooks/useRetry.js";
15
14
  import { Info } from "../internal/Info/Info.js";
16
15
  import { loadScript } from "../../utils/load.js";
16
+ import { ThreeDSAuth } from "../ThreeDS/index.js";
17
17
  function createGooglePay(checkout, pay, onClick, onCanUse) {
18
18
  const {
19
19
  transAmount,
@@ -175,17 +175,22 @@ const loadGooglePayJS = (onload, onerror) => {
175
175
  };
176
176
  const { bem } = useBEM("google-pay");
177
177
  const GooglePay = w((props, ref) => {
178
+ var _a;
179
+ const { session, threeDSFrame } = props;
178
180
  F(ref, () => ({
179
181
  checkThreeDS
180
182
  }));
181
- const { sessionReady, session, i18n, fraudDetection } = usePayState();
183
+ const { sessionReady, i18n, fraudDetection } = usePayState(session);
182
184
  const [errorMsg, setErrorMsg] = h("");
183
185
  const [showGooglePay, setShowGooglePay] = h(false);
186
+ const [showThreeDSModal, setShowThreeDSModal] = h(false);
187
+ const [threeDSInfo, setThreeDSInfo] = h();
188
+ const [hosted, setHosted] = h(true);
184
189
  const onTimeout = q(
185
190
  (message) => {
186
- var _a;
191
+ var _a2;
187
192
  setErrorMsg(message || i18n.get("common.payTimeout"));
188
- (_a = props.onTimeout) == null ? void 0 : _a.call(props, "retry");
193
+ (_a2 = props.onTimeout) == null ? void 0 : _a2.call(props, "retry");
189
194
  },
190
195
  [i18n, props.onTimeout]
191
196
  );
@@ -193,30 +198,50 @@ const GooglePay = w((props, ref) => {
193
198
  returnUrl: session == null ? void 0 : session.checkout.returnUrl
194
199
  });
195
200
  y(() => {
196
- var _a;
201
+ var _a2;
197
202
  if (!sessionReady) {
198
203
  return;
199
204
  }
200
- const { status, paymentMethod = [] } = (session == null ? void 0 : session.checkout) || {};
205
+ const { status, paymentMethod = [], sessionMode } = (session == null ? void 0 : session.checkout) || {};
201
206
  if (!paymentMethod.includes(PaymentMethod.GOOGLE_PAY)) {
202
207
  return;
203
208
  }
204
209
  loadGooglePayJS(
205
210
  () => {
206
- var _a2;
211
+ var _a3;
207
212
  setShowGooglePay(true);
208
- (_a2 = props.onLoad) == null ? void 0 : _a2.call(props, true);
213
+ (_a3 = props.onLoad) == null ? void 0 : _a3.call(props, true);
209
214
  },
210
215
  () => {
211
- var _a2;
216
+ var _a3;
212
217
  setShowGooglePay(false);
213
- (_a2 = props.onLoad) == null ? void 0 : _a2.call(props, false);
218
+ (_a3 = props.onLoad) == null ? void 0 : _a3.call(props, false);
214
219
  }
215
220
  );
221
+ setHosted(sessionMode === SessionMode.HOSTED);
216
222
  if (status === "SUCCESS") {
217
- (_a = props.onSuccess) == null ? void 0 : _a.call(props, getPaymentSuccessData());
223
+ (_a2 = props.onSuccess) == null ? void 0 : _a2.call(props, getPaymentSuccessData());
218
224
  }
219
225
  }, [sessionReady]);
226
+ const processThreeDS = (threeDSUrl, incomplete) => {
227
+ var _a2;
228
+ if (hosted) {
229
+ (_a2 = props.onThreeDS) == null ? void 0 : _a2.call(props, threeDSUrl, incomplete);
230
+ } else {
231
+ setShowThreeDSModal(true);
232
+ setThreeDSInfo({
233
+ url: threeDSUrl,
234
+ incomplete,
235
+ width: threeDSFrame == null ? void 0 : threeDSFrame.modalWidth,
236
+ height: threeDSFrame == null ? void 0 : threeDSFrame.modalHeight
237
+ });
238
+ }
239
+ };
240
+ const handleCloseThreeDSModal = () => {
241
+ setShowThreeDSModal(false);
242
+ setThreeDSInfo(void 0);
243
+ checkThreeDS();
244
+ };
220
245
  const { start: startReFetchPayInfo } = useRetry(
221
246
  async (timeout) => {
222
247
  return await pay(void 0, void 0, true, timeout);
@@ -226,10 +251,10 @@ const GooglePay = w((props, ref) => {
226
251
  }
227
252
  );
228
253
  async function pay(token, billAddress, search = false, timeout) {
229
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
254
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
230
255
  setErrorMsg("");
231
256
  if (!search) {
232
- (_a = props.onSubmit) == null ? void 0 : _a.call(props);
257
+ (_a2 = props.onSubmit) == null ? void 0 : _a2.call(props);
233
258
  }
234
259
  try {
235
260
  const res = await (search ? getGooglePayInfo(
@@ -264,7 +289,7 @@ const GooglePay = w((props, ref) => {
264
289
  { locale: i18n.locale }
265
290
  );
266
291
  }());
267
- const { status, orderStatus, errorMessage, threeDSUrl } = res;
292
+ const { status, orderStatus, errorMessage, threeDSUrl, errorCode } = res;
268
293
  if (status === "PROCESSING") {
269
294
  if (orderStatus === "SUCCESS") {
270
295
  (_b = props.onSuccess) == null ? void 0 : _b.call(props, getPaymentSuccessData());
@@ -280,7 +305,7 @@ const GooglePay = w((props, ref) => {
280
305
  } : await startReFetchPayInfo();
281
306
  } else if (orderStatus === "FAILURE") {
282
307
  setErrorMsg(errorMessage);
283
- (_c = props.onError) == null ? void 0 : _c.call(props, "FAILURE");
308
+ (_c = props.onError) == null ? void 0 : _c.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
284
309
  return {
285
310
  end: true,
286
311
  res: {
@@ -299,13 +324,13 @@ const GooglePay = w((props, ref) => {
299
324
  res: { transactionState: "SUCCESS" }
300
325
  };
301
326
  } else if (orderStatus === "IN_THREED") {
302
- (_e = props.onThreeDS) == null ? void 0 : _e.call(props, threeDSUrl, false);
327
+ processThreeDS(threeDSUrl, false);
303
328
  return {
304
329
  end: true,
305
330
  res: { transactionState: "SUCCESS" }
306
331
  };
307
332
  } else if (orderStatus === "IN_PREVIOUS_THREED") {
308
- (_f = props.onThreeDS) == null ? void 0 : _f.call(props, threeDSUrl, true);
333
+ processThreeDS(threeDSUrl, true);
309
334
  return {
310
335
  end: true,
311
336
  res: { transactionState: "SUCCESS" }
@@ -317,19 +342,19 @@ const GooglePay = w((props, ref) => {
317
342
  };
318
343
  }
319
344
  } else if (status === "SUCCESS") {
320
- (_g = props.onSuccess) == null ? void 0 : _g.call(props, getPaymentSuccessData());
345
+ (_e = props.onSuccess) == null ? void 0 : _e.call(props, getPaymentSuccessData());
321
346
  return {
322
347
  end: true,
323
348
  res: { transactionState: "SUCCESS" }
324
349
  };
325
350
  } else if (status === "EXPIRED") {
326
- (_h = props.onExpired) == null ? void 0 : _h.call(props);
351
+ (_f = props.onExpired) == null ? void 0 : _f.call(props);
327
352
  return {
328
353
  end: true,
329
354
  res: { transactionState: "SUCCESS" }
330
355
  };
331
356
  }
332
- (_i = props.onSuccess) == null ? void 0 : _i.call(props, getPaymentSuccessData());
357
+ (_g = props.onSuccess) == null ? void 0 : _g.call(props, getPaymentSuccessData());
333
358
  return {
334
359
  end: false,
335
360
  res: { transactionState: "SUCCESS" }
@@ -354,8 +379,8 @@ const GooglePay = w((props, ref) => {
354
379
  }
355
380
  } else {
356
381
  const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
357
- setErrorMsg(error.i18nKey ? i18n.get(error.i18nKey) : error.message);
358
- (_j = props.onError) == null ? void 0 : _j.call(props, error);
382
+ setErrorMsg(message);
383
+ (_h = props.onError) == null ? void 0 : _h.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
359
384
  return {
360
385
  end: true,
361
386
  res: {
@@ -378,7 +403,7 @@ const GooglePay = w((props, ref) => {
378
403
  }
379
404
  );
380
405
  async function checkThreeDS(search = false) {
381
- var _a, _b, _c, _d, _e;
406
+ var _a2, _b, _c, _d, _e;
382
407
  if (!session)
383
408
  return { end: true };
384
409
  try {
@@ -398,7 +423,7 @@ const GooglePay = w((props, ref) => {
398
423
  } else if (orderStatus === "FAILURE") {
399
424
  setErrorMsg(errorMessage);
400
425
  } else if (orderStatus === "AUTHORIZED") {
401
- (_a = props.onAuthorized) == null ? void 0 : _a.call(props);
426
+ (_a2 = props.onAuthorized) == null ? void 0 : _a2.call(props);
402
427
  } else if (orderStatus === "IN_THREED") {
403
428
  !search && startReFetchCardPay3DSInfo();
404
429
  return { end: false };
@@ -431,7 +456,7 @@ const GooglePay = w((props, ref) => {
431
456
  } else {
432
457
  const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
433
458
  setErrorMsg(message);
434
- (_e = props.onError) == null ? void 0 : _e.call(props, error);
459
+ (_e = props.onError) == null ? void 0 : _e.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
435
460
  return { end: true };
436
461
  }
437
462
  }
@@ -453,7 +478,16 @@ const GooglePay = w((props, ref) => {
453
478
  };
454
479
  return /* @__PURE__ */ u("div", { children: sessionReady && showGooglePay && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
455
480
  !!errorMsg && /* @__PURE__ */ u(Info, { className: bem("error"), content: errorMsg }),
456
- Button()
481
+ Button(),
482
+ /* @__PURE__ */ u(
483
+ ThreeDSAuth,
484
+ {
485
+ show: showThreeDSModal,
486
+ theme: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.theme,
487
+ ...threeDSInfo,
488
+ onClose: handleCloseThreeDSModal
489
+ }
490
+ )
457
491
  ] }) });
458
492
  });
459
493
  export {
@@ -2,8 +2,6 @@ import { u } from "../../core.js";
2
2
  import { CoreContext } from "../../core/context.js";
3
3
  import "../../utils/card-brand/brands.js";
4
4
  import "../../utils/system-info/get-browser-info.js";
5
- import "../../i18n/util.js";
6
- import "../../i18n/locales/index.js";
7
5
  import { useBEM } from "../../hooks/useBEM.js";
8
6
  import { IconInfo } from "../internal/icons/IconInfo.js";
9
7
  const { bem } = useBEM("recurring-tip");