@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
@@ -6,8 +6,6 @@ import "../../../core/context.js";
6
6
  import "../../../utils/card-brand/brands.js";
7
7
  import "../../../utils/system-info/get-browser-info.js";
8
8
  import { normalizedClass } from "../../../utils/format.js";
9
- import "../../../i18n/util.js";
10
- import "../../../i18n/locales/index.js";
11
9
  import { IconError } from "../icons/IconError.js";
12
10
  const { bem } = useBEM("info");
13
11
  const iconMap = {
@@ -3,5 +3,3 @@ import "./info2.js";
3
3
  import "../../../utils/card-brand/brands.js";
4
4
  import "../../../utils/system-info/get-browser-info.js";
5
5
  import "../../../core/context.js";
6
- import "../../../i18n/util.js";
7
- import "../../../i18n/locales/index.js";
@@ -16,7 +16,7 @@ const statusIconMap = {
16
16
  success: IconSuccess
17
17
  };
18
18
  const Input = w((props, ref) => {
19
- const { inputClassName, style, disabled, children } = props;
19
+ const { inputClassName, style, disabled, children, showStatus = true } = props;
20
20
  F(ref, () => ({
21
21
  input: inputRef.current,
22
22
  focus: () => {
@@ -40,7 +40,7 @@ const Input = w((props, ref) => {
40
40
  if (status === "unValidate")
41
41
  status = void 0;
42
42
  let { rightIcon } = props;
43
- if (!rightIcon && status) {
43
+ if (showStatus && status) {
44
44
  const StatusIcon = statusIconMap[status];
45
45
  rightIcon = /* @__PURE__ */ u(StatusIcon, { size: 16 });
46
46
  }
@@ -3,8 +3,6 @@ import "../../../core.js";
3
3
  import "../../../core/context.js";
4
4
  import "../../../utils/card-brand/brands.js";
5
5
  import "../../../utils/system-info/get-browser-info.js";
6
- import "../../../i18n/util.js";
7
- import "../../../i18n/locales/index.js";
8
6
  const inputBEM = useBEM("input");
9
7
  const inputWrapperClassName = inputBEM.bem("input-wrapper");
10
8
  export {
@@ -7,8 +7,6 @@ import { isUndefined } from "../../../utils/is.js";
7
7
  import "../../../utils/card-brand/brands.js";
8
8
  import "../../../utils/system-info/get-browser-info.js";
9
9
  import { normalizedClass, normalizedStyle } from "../../../utils/format.js";
10
- import "../../../i18n/util.js";
11
- import "../../../i18n/locales/index.js";
12
10
  const SIZE = 40;
13
11
  const SVG_VIEW_BOX = `0 0 ${SIZE} ${SIZE}`;
14
12
  const CIRCLE_STROKE_WIDTH = 3.3;
@@ -3,5 +3,3 @@ import "./loading-check.js";
3
3
  import "../../../utils/card-brand/brands.js";
4
4
  import "../../../utils/system-info/get-browser-info.js";
5
5
  import "../../../core/context.js";
6
- import "../../../i18n/util.js";
7
- import "../../../i18n/locales/index.js";
@@ -0,0 +1,40 @@
1
+ import { w, h, T, u, b } from "../../../core.js";
2
+ import { useBEM } from "../../../hooks/useBEM.js";
3
+ import { useI18n } from "../../../hooks/useI18n.js";
4
+ import "../../../utils/card-brand/brands.js";
5
+ import "../../../utils/system-info/get-browser-info.js";
6
+ import "./modal2.js";
7
+ const { bem } = useBEM("modal");
8
+ const Modal = w((props) => {
9
+ const { show, width, height, maskClosable, header, children, onChange, style } = props;
10
+ const [modalWidth, setModalWidth] = h();
11
+ const [modalHeight, setModalHeight] = h();
12
+ const { i18n } = useI18n();
13
+ T(() => {
14
+ setModalWidth(typeof width === "number" ? `${width}px` : width);
15
+ setModalHeight(typeof height === "number" ? `${height}px` : height);
16
+ }, [width, height]);
17
+ const handleClickMask = () => {
18
+ maskClosable && (onChange == null ? void 0 : onChange(false));
19
+ };
20
+ const handleClickClose = () => {
21
+ onChange == null ? void 0 : onChange(false);
22
+ };
23
+ return /* @__PURE__ */ u(b, { children: show && /* @__PURE__ */ u("div", { className: bem(), children: [
24
+ /* @__PURE__ */ u("div", { className: bem("mask"), onClick: handleClickMask }),
25
+ /* @__PURE__ */ u(
26
+ "div",
27
+ {
28
+ className: bem("content"),
29
+ style: { width: modalWidth, height: modalHeight, ...style },
30
+ children: [
31
+ header || /* @__PURE__ */ u("div", { className: bem("header"), children: /* @__PURE__ */ u("div", { className: bem("close"), onClick: handleClickClose, children: i18n.get("common.cancel") }) }),
32
+ /* @__PURE__ */ u("div", { className: bem("body"), children })
33
+ ]
34
+ }
35
+ )
36
+ ] }) });
37
+ });
38
+ export {
39
+ Modal
40
+ };
@@ -4,8 +4,6 @@ import "../../../core/context.js";
4
4
  import { isNil } from "../../../utils/is.js";
5
5
  import "../../../utils/card-brand/brands.js";
6
6
  import "../../../utils/system-info/get-browser-info.js";
7
- import "../../../i18n/util.js";
8
- import "../../../i18n/locales/index.js";
9
7
  import "../Form/type.js";
10
8
  import { FormItemContext } from "../Form/context.js";
11
9
  import "../Form/FormItem.js";
@@ -4,8 +4,6 @@ import { useBEM } from "../../../hooks/useBEM.js";
4
4
  import "../../../core/context.js";
5
5
  import "../../../utils/card-brand/brands.js";
6
6
  import "../../../utils/system-info/get-browser-info.js";
7
- import "../../../i18n/util.js";
8
- import "../../../i18n/locales/index.js";
9
7
  const { bem } = useBEM("select");
10
8
  function SelectMenu(props) {
11
9
  const { style, children } = props;
@@ -5,8 +5,6 @@ import "../../../core/context.js";
5
5
  import { isFunction } from "../../../utils/is.js";
6
6
  import "../../../utils/card-brand/brands.js";
7
7
  import "../../../utils/system-info/get-browser-info.js";
8
- import "../../../i18n/util.js";
9
- import "../../../i18n/locales/index.js";
10
8
  import { IconTick } from "../icons/IconTick.js";
11
9
  const { bem } = useBEM("select");
12
10
  function SelectMenuItem(props) {
@@ -0,0 +1,3 @@
1
+ import "../../../core.js";
2
+ import "../../../utils/card-brand/brands.js";
3
+ import "../../../utils/system-info/get-browser-info.js";
@@ -0,0 +1,62 @@
1
+ import { u } from "../../../core.js";
2
+ import { COMMON_CLASS_NAME } from "../../../constant.js";
3
+ import { isUndefined } from "../../../utils/is.js";
4
+ import "../../../utils/card-brand/brands.js";
5
+ import "../../../utils/system-info/get-browser-info.js";
6
+ import { normalizedClass } from "../../../utils/format.js";
7
+ function Icon3DSInfo({ size, style, className }) {
8
+ const computedSize = !isUndefined(size) ? `${size}px` : "1em";
9
+ return /* @__PURE__ */ u(
10
+ "svg",
11
+ {
12
+ width: computedSize,
13
+ height: computedSize,
14
+ viewBox: "0 0 64 64",
15
+ style,
16
+ fill: "none",
17
+ xmlns: "http://www.w3.org/2000/svg",
18
+ className: normalizedClass(COMMON_CLASS_NAME, className),
19
+ children: [
20
+ /* @__PURE__ */ u("g", { id: "icon-warning", "clip-path": "url(#clip0_25_1509)", children: [
21
+ /* @__PURE__ */ u(
22
+ "path",
23
+ {
24
+ id: "Vector",
25
+ d: "M32 0.5C14.3437 0.5 0 14.8437 0 32.5C0 50.1563 14.3437 64.5 32 64.5C49.6563 64.5 64 50.1563 64 32.5C64 14.8437 49.6563 0.5 32 0.5ZM32 3.28261C48.1524 3.28261 61.2174 16.3476 61.2174 32.5C61.2174 48.6524 48.1524 61.7174 32 61.7174C15.8476 61.7174 2.78261 48.6524 2.78261 32.5C2.78261 16.3476 15.8476 3.28261 32 3.28261Z",
26
+ fill: "#FCA605"
27
+ }
28
+ ),
29
+ /* @__PURE__ */ u(
30
+ "path",
31
+ {
32
+ id: "Vector_2",
33
+ d: "M32 15.5V39.5",
34
+ stroke: "#FCA605",
35
+ "stroke-width": "2.8",
36
+ "stroke-linecap": "round",
37
+ "stroke-linejoin": "round"
38
+ }
39
+ ),
40
+ /* @__PURE__ */ u(
41
+ "circle",
42
+ {
43
+ id: "Ellipse 642",
44
+ cx: "32",
45
+ cy: "47.5",
46
+ r: "1",
47
+ fill: "#FCA605",
48
+ stroke: "#FCA605",
49
+ "stroke-width": "2.8",
50
+ "stroke-linecap": "round",
51
+ "stroke-linejoin": "round"
52
+ }
53
+ )
54
+ ] }),
55
+ /* @__PURE__ */ u("defs", { children: /* @__PURE__ */ u("clipPath", { id: "clip0_25_1509", children: /* @__PURE__ */ u("rect", { width: "64", height: "64", fill: "white", transform: "translate(0 0.5)" }) }) })
56
+ ]
57
+ }
58
+ );
59
+ }
60
+ export {
61
+ Icon3DSInfo
62
+ };
@@ -0,0 +1,3 @@
1
+ import "../../../core.js";
2
+ import "../../../utils/card-brand/brands.js";
3
+ import "../../../utils/system-info/get-browser-info.js";
package/dist/es/config.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import "./utils/card-brand/brands.js";
2
2
  import "./utils/system-info/get-browser-info.js";
3
- import "./i18n/util.js";
4
3
  import "./core.js";
5
- import "./i18n/locales/index.js";
6
4
  let apiUrl = "https://checkout.aq.paykka.com";
7
5
  let cdnOrigin = "https://checkout.aq.paykka.com";
8
6
  let cdnDir = "/cp";
@@ -43,8 +43,9 @@ var EAddressType = /* @__PURE__ */ ((EAddressType2) => {
43
43
  return EAddressType2;
44
44
  })(EAddressType || {});
45
45
  var SessionMode = /* @__PURE__ */ ((SessionMode2) => {
46
- SessionMode2["HOSTED"] = "HOST";
47
- SessionMode2["EMBEDDED"] = "EMBEDDED";
46
+ SessionMode2["HOSTED"] = "HOSTED";
47
+ SessionMode2["DROP_IN"] = "DROP_IN";
48
+ SessionMode2["COMPONENT"] = "COMPONENT";
48
49
  return SessionMode2;
49
50
  })(SessionMode || {});
50
51
  export {
@@ -1,62 +1,116 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1
+ var __accessCheck = (obj, member, msg) => {
2
+ if (!member.has(obj))
3
+ throw TypeError("Cannot " + msg);
4
+ };
5
+ var __privateGet = (obj, member, getter) => {
6
+ __accessCheck(obj, member, "read from private field");
7
+ return getter ? getter.call(obj) : member.get(obj);
8
+ };
9
+ var __privateAdd = (obj, member, value) => {
10
+ if (member.has(obj))
11
+ throw TypeError("Cannot add the same private member more than once");
12
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ };
14
+ var __privateSet = (obj, member, value, setter) => {
15
+ __accessCheck(obj, member, "write to private field");
16
+ setter ? setter.call(obj, value) : member.set(obj, value);
5
17
  return value;
6
18
  };
19
+ var _config, _envConfig, _session, _componentInsts;
7
20
  import { create } from "./create.js";
8
21
  import { Session } from "./Session.js";
9
- import { setCheckoutConfig, setCDNUrl, setFraudDetectionEnv, setCustomLocale, setApiUrl } from "../config.js";
10
- const _PayKKaCheckout = class _PayKKaCheckout {
22
+ import { setApiUrl, setCDNUrl, setFraudDetectionEnv, setCheckoutConfig, setCustomLocale } from "../config.js";
23
+ import { PayKKaError } from "./error.js";
24
+ import { apiEnv, cdnEnv, fraudDetectionEnv } from "./environment.js";
25
+ import { isEmptyObject } from "../utils/is.js";
26
+ import "../utils/card-brand/brands.js";
27
+ import "../utils/system-info/get-browser-info.js";
28
+ class PayKKaCheckout {
11
29
  constructor(config) {
12
- __publicField(this, "config");
13
- if (_PayKKaCheckout.instance) {
14
- return _PayKKaCheckout.instance;
15
- }
16
- this.config = config;
30
+ __privateAdd(this, _config, void 0);
31
+ __privateAdd(this, _envConfig, void 0);
32
+ __privateAdd(this, _session, void 0);
33
+ __privateAdd(this, _componentInsts, []);
34
+ __privateSet(this, _config, config);
17
35
  this.init();
18
- _PayKKaCheckout.instance = this;
19
36
  }
20
37
  init() {
21
- const {
22
- sandbox,
23
- sessionId,
24
- clientKey,
25
- locale,
26
- fraudDetectionEnv,
27
- hidePaymentButton,
28
- onPaymentMethodsReady,
29
- onInitError
30
- } = this.config;
31
- fraudDetectionEnv && setFraudDetectionEnv(fraudDetectionEnv);
32
- locale && setCustomLocale(locale);
33
- setCheckoutConfig({
34
- hidePaymentButton
35
- });
36
- if (sandbox) {
37
- setApiUrl("https://checkout-sandbox.aq.paykka.com");
38
- setCDNUrl("https://checkout-sandbox.aq.paykka.com/cp");
38
+ this.initEnv();
39
+ this.initLocale();
40
+ this.initExtraParams();
41
+ this.initSession();
42
+ }
43
+ initSession() {
44
+ const { sessionId, clientKey, onPaymentMethodsReady, onInitError } = __privateGet(this, _config);
45
+ if (!sessionId) {
46
+ onInitError == null ? void 0 : onInitError(new PayKKaError("ERROR", "SessionId is required"));
47
+ return;
39
48
  }
40
- _PayKKaCheckout.session = new Session(sessionId, clientKey);
41
- _PayKKaCheckout.session.ready().then(() => {
42
- var _a;
43
- const { paymentMethod = [] } = ((_a = _PayKKaCheckout.session) == null ? void 0 : _a.checkout) || {};
49
+ __privateSet(this, _session, new Session(sessionId, clientKey));
50
+ __privateGet(this, _session).ready().then(() => {
51
+ var _a, _b;
52
+ if (isEmptyObject((_a = __privateGet(this, _session)) == null ? void 0 : _a.checkout)) {
53
+ onInitError == null ? void 0 : onInitError(new PayKKaError("ERROR", "Checkout is empty"));
54
+ return;
55
+ }
56
+ const { paymentMethod = [] } = ((_b = __privateGet(this, _session)) == null ? void 0 : _b.checkout) || {};
44
57
  onPaymentMethodsReady == null ? void 0 : onPaymentMethodsReady(paymentMethod);
45
58
  }).catch((error) => {
46
59
  onInitError == null ? void 0 : onInitError(error);
47
- console.log(error);
48
60
  });
49
61
  }
50
- static getSession() {
51
- return _PayKKaCheckout.session;
62
+ /**
63
+ * 初始化环境配置
64
+ * _envConfig 优先级高于 env
65
+ */
66
+ initEnv() {
67
+ const { env, _envConfig: _envConfig2, onInitError } = __privateGet(this, _config);
68
+ if (!env) {
69
+ onInitError == null ? void 0 : onInitError(new PayKKaError("ERROR", "Env is required"));
70
+ return;
71
+ }
72
+ setApiUrl((_envConfig2 == null ? void 0 : _envConfig2.api) || apiEnv[env]);
73
+ setCDNUrl((_envConfig2 == null ? void 0 : _envConfig2.cdn) || cdnEnv[env]);
74
+ setFraudDetectionEnv((_envConfig2 == null ? void 0 : _envConfig2.fraudDetection) || fraudDetectionEnv[env]);
52
75
  }
76
+ initLocale() {
77
+ const { locale } = __privateGet(this, _config);
78
+ locale && setCustomLocale(locale);
79
+ }
80
+ initExtraParams() {
81
+ const { hidePaymentButton = false } = __privateGet(this, _config);
82
+ setCheckoutConfig({
83
+ hidePaymentButton
84
+ });
85
+ }
86
+ get session() {
87
+ return __privateGet(this, _session);
88
+ }
89
+ get envConfig() {
90
+ return __privateGet(this, _envConfig);
91
+ }
92
+ /** 创建组件,把 session 作为组件的 props 传递 */
53
93
  create(component, props) {
54
- return create(component, props);
94
+ var _a;
95
+ const coreProps = this.getCoreProps();
96
+ const componentInst = create(component, {
97
+ ...props,
98
+ ...coreProps
99
+ });
100
+ (_a = __privateGet(this, _componentInsts)) == null ? void 0 : _a.push(componentInst);
101
+ return componentInst;
55
102
  }
56
- };
57
- __publicField(_PayKKaCheckout, "session");
58
- __publicField(_PayKKaCheckout, "instance", null);
59
- let PayKKaCheckout = _PayKKaCheckout;
103
+ getCoreProps() {
104
+ return {
105
+ session: __privateGet(this, _session),
106
+ threeDSFrame: __privateGet(this, _config).threeDSFrame
107
+ };
108
+ }
109
+ }
110
+ _config = new WeakMap();
111
+ _envConfig = new WeakMap();
112
+ _session = new WeakMap();
113
+ _componentInsts = new WeakMap();
60
114
  export {
61
115
  PayKKaCheckout
62
116
  };
@@ -26,24 +26,24 @@ import "../utils/card-brand/brands.js";
26
26
  import "../utils/system-info/get-browser-info.js";
27
27
  import { generateColors } from "../utils/colors.js";
28
28
  import { createPromise } from "../utils/create-promise.js";
29
- import "../i18n/util.js";
30
29
  import "../core.js";
31
- import "../i18n/locales/index.js";
30
+ import { PayKKaError } from "./error.js";
32
31
  import { querySession } from "./query.js";
33
32
  class Session {
34
33
  constructor(sessionId, clientKey) {
35
34
  __privateAdd(this, _init);
36
35
  __privateAdd(this, _genColors);
37
- __privateAdd(this, _readyPromise, createPromise());
38
36
  __publicField(this, "sessionId");
39
37
  __publicField(this, "clientKey");
40
38
  __publicField(this, "checkout");
41
39
  __publicField(this, "colors", null);
40
+ __privateAdd(this, _readyPromise, createPromise());
42
41
  this.sessionId = sessionId;
43
42
  this.clientKey = clientKey;
44
43
  __privateMethod(this, _init, init_fn).call(this).then(() => __privateGet(this, _readyPromise).resolve(true)).catch((err) => {
45
- console.log(err);
46
- return __privateGet(this, _readyPromise).reject(false);
44
+ return __privateGet(this, _readyPromise).reject(
45
+ new PayKKaError("API_ERROR", err.message, { code: err.code })
46
+ );
47
47
  });
48
48
  }
49
49
  ready() {
@@ -61,7 +61,8 @@ init_fn = async function() {
61
61
  };
62
62
  _genColors = new WeakSet();
63
63
  genColors_fn = function() {
64
- const { payButtonBackgroundColor } = this.checkout.theme || {};
64
+ var _a;
65
+ const { payButtonBackgroundColor } = ((_a = this.checkout) == null ? void 0 : _a.theme) || {};
65
66
  if (payButtonBackgroundColor) {
66
67
  const colors = generateColors(payButtonBackgroundColor, {
67
68
  theme: "default",
@@ -0,0 +1,26 @@
1
+ const apiEnv = {
2
+ eu: "https://checkout.eu.paykka.com",
3
+ hk: "https://checkout.aq.paykka.com",
4
+ sandbox: "https://checkout-sandbox.aq.paykka.com"
5
+ };
6
+ const cdnEnv = {
7
+ eu: "https://checkout.eu.paykka.com/cp",
8
+ hk: "https://checkout.aq.paykka.com/cp",
9
+ sandbox: "https://checkout-sandbox.aq.paykka.com/cp"
10
+ };
11
+ const fraudDetectionEnv = {
12
+ eu: {
13
+ SR: "pk_live_51QSXl2G2tOepMLcRVNu0S2T6MxyB1AIgCP5g7qMQvAviQS37v0wkPhJRKqfcbTql6ZkCkGktux4ixfXuZtFy6ZpP00awbGlLEq"
14
+ },
15
+ hk: {
16
+ SR: "pk_live_51QSXh9Azq7GQL5iqwZNLz3KJ896MIUnai4H7H0z9DtlklJkgoH1VAlHKy382vWPqDm80nTy8MKUdJIKs0fFbTlKx006WcKWEDu"
17
+ },
18
+ sandbox: {
19
+ SR: "pk_test_51QaC2P5VarcojPHdg13yagk5TqrGkIkeK8I21BgQUZe8BzyRmbtmOg3dKsXjkxt6JlsjyjJMTvBH9dFMCZWRxOkt00tWQ1eHFU"
20
+ }
21
+ };
22
+ export {
23
+ apiEnv,
24
+ cdnEnv,
25
+ fraudDetectionEnv
26
+ };
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ class PayKKaError extends Error {
8
+ constructor(type, message, info) {
9
+ super(message);
10
+ /** 错误类型 */
11
+ __publicField(this, "type");
12
+ /** 错误代码 */
13
+ __publicField(this, "code");
14
+ this.type = type;
15
+ this.code = info == null ? void 0 : info.code;
16
+ this.cause = info == null ? void 0 : info.cause;
17
+ }
18
+ }
19
+ export {
20
+ PayKKaError
21
+ };
@@ -2,5 +2,3 @@ import "./context.js";
2
2
  import "../core.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";
@@ -1,8 +1,6 @@
1
1
  import "../utils/card-brand/brands.js";
2
2
  import "../utils/system-info/get-browser-info.js";
3
- import "../i18n/util.js";
4
3
  import "../core.js";
5
- import "../i18n/locales/index.js";
6
4
  import { onceGetCheckoutInfo } from "../api/modules/checkout/index.js";
7
5
  async function querySession({ sessionId, clientKey }, options) {
8
6
  return onceGetCheckoutInfo({ sessionId, clientKey }, options);
package/dist/es/core.js CHANGED
@@ -675,36 +675,6 @@ l$3.diffed = function(n2) {
675
675
  var t2 = n2.props, e2 = n2.__e;
676
676
  null != e2 && "textarea" === n2.type && "value" in t2 && t2.value !== e2.value && (e2.value = null == t2.value ? "" : t2.value);
677
677
  };
678
- function e$1(e2, n2) {
679
- return n2 = n2 || {}, new Promise(function(t2, r2) {
680
- var s2 = new XMLHttpRequest(), o2 = [], u2 = {}, a2 = function e3() {
681
- return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() {
682
- return Promise.resolve(s2.responseText);
683
- }, json: function() {
684
- return Promise.resolve(s2.responseText).then(JSON.parse);
685
- }, blob: function() {
686
- return Promise.resolve(new Blob([s2.response]));
687
- }, clone: e3, headers: { keys: function() {
688
- return o2;
689
- }, entries: function() {
690
- return o2.map(function(e4) {
691
- return [e4, s2.getResponseHeader(e4)];
692
- });
693
- }, get: function(e4) {
694
- return s2.getResponseHeader(e4);
695
- }, has: function(e4) {
696
- return null != s2.getResponseHeader(e4);
697
- } } };
698
- };
699
- for (var i2 in s2.open(n2.method || "get", e2, true), s2.onload = function() {
700
- s2.getAllResponseHeaders().toLowerCase().replace(/^(.+?):/gm, function(e3, n3) {
701
- u2[n3] || o2.push(u2[n3] = n3);
702
- }), t2(a2());
703
- }, s2.onerror = r2, s2.withCredentials = "include" == n2.credentials, n2.headers)
704
- s2.setRequestHeader(i2, n2.headers[i2]);
705
- s2.send(n2.body || null);
706
- });
707
- }
708
678
  var __assign = function() {
709
679
  __assign = Object.assign || function __assign2(t2) {
710
680
  for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) {
@@ -3917,7 +3887,7 @@ function t() {
3917
3887
  }
3918
3888
  var o = void 0;
3919
3889
  var h = void 0, s$1 = 0, f = 0, v = 0;
3920
- function e(i2) {
3890
+ function e$1(i2) {
3921
3891
  if (void 0 !== o) {
3922
3892
  var t2 = i2.n;
3923
3893
  if (void 0 === t2 || t2.t !== o) {
@@ -4008,7 +3978,7 @@ u.prototype.peek = function() {
4008
3978
  }
4009
3979
  };
4010
3980
  Object.defineProperty(u.prototype, "value", { get: function() {
4011
- var i2 = e(this);
3981
+ var i2 = e$1(this);
4012
3982
  if (void 0 !== i2)
4013
3983
  i2.i = this.i;
4014
3984
  return this.v;
@@ -4139,7 +4109,7 @@ y.prototype.N = function() {
4139
4109
  Object.defineProperty(y.prototype, "value", { get: function() {
4140
4110
  if (1 & this.f)
4141
4111
  throw new Error("Cycle detected");
4142
- var i2 = e(this);
4112
+ var i2 = e$1(this);
4143
4113
  this.h();
4144
4114
  if (void 0 !== i2)
4145
4115
  i2.i = this.i;
@@ -4422,6 +4392,36 @@ function useSignal(n2) {
4422
4392
  return d$1(n2);
4423
4393
  }, []);
4424
4394
  }
4395
+ function e(e2, n2) {
4396
+ return n2 = n2 || {}, new Promise(function(t2, r2) {
4397
+ var s2 = new XMLHttpRequest(), o2 = [], u2 = {}, a2 = function e3() {
4398
+ return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() {
4399
+ return Promise.resolve(s2.responseText);
4400
+ }, json: function() {
4401
+ return Promise.resolve(s2.responseText).then(JSON.parse);
4402
+ }, blob: function() {
4403
+ return Promise.resolve(new Blob([s2.response]));
4404
+ }, clone: e3, headers: { keys: function() {
4405
+ return o2;
4406
+ }, entries: function() {
4407
+ return o2.map(function(e4) {
4408
+ return [e4, s2.getResponseHeader(e4)];
4409
+ });
4410
+ }, get: function(e4) {
4411
+ return s2.getResponseHeader(e4);
4412
+ }, has: function(e4) {
4413
+ return null != s2.getResponseHeader(e4);
4414
+ } } };
4415
+ };
4416
+ for (var i2 in s2.open(n2.method || "get", e2, true), s2.onload = function() {
4417
+ s2.getAllResponseHeaders().toLowerCase().replace(/^(.+?):/gm, function(e3, n3) {
4418
+ u2[n3] || o2.push(u2[n3] = n3);
4419
+ }), t2(a2());
4420
+ }, s2.onerror = r2, s2.withCredentials = "include" == n2.credentials, n2.headers)
4421
+ s2.setRequestHeader(i2, n2.headers[i2]);
4422
+ s2.send(n2.body || null);
4423
+ });
4424
+ }
4425
4425
  export {
4426
4426
  A$1 as A,
4427
4427
  B$2 as B,
@@ -4431,7 +4431,7 @@ export {
4431
4431
  _$3 as _,
4432
4432
  b$1 as b,
4433
4433
  d$1 as d,
4434
- e$1 as e,
4434
+ e,
4435
4435
  h$1 as h,
4436
4436
  index,
4437
4437
  inputToRGB,
@@ -2,5 +2,3 @@ import "../utils/card-brand/brands.js";
2
2
  import "../utils/system-info/get-browser-info.js";
3
3
  import "../core.js";
4
4
  import "../core/context.js";
5
- import "../i18n/util.js";
6
- import "../i18n/locales/index.js";