@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.
Files changed (177) hide show
  1. package/dist/card-checkout-ui.js +19 -19
  2. package/dist/card-checkout-ui.umd.cjs +19 -19
  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 +31 -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 +45 -34
  10. package/dist/es/components/ApplePay/index.js +19 -13
  11. package/dist/es/components/Card/index.js +334 -155
  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/DropIn/index.js +210 -0
  22. package/dist/es/components/EmailField/EmailField.js +0 -3
  23. package/dist/es/components/EncryptedCard/index.js +35 -75
  24. package/dist/es/components/GooglePay/index.js +69 -28
  25. package/dist/es/components/RecurringTip/index.js +0 -2
  26. package/dist/es/components/SecuredFieldsProvider/index.js +230 -1
  27. package/dist/es/components/SecuredIframe/index.js +3 -1
  28. package/dist/es/components/Sepa/index.js +26 -30
  29. package/dist/es/components/SubmitButton/index.js +0 -2
  30. package/dist/es/components/ThreeDS/index.js +94 -0
  31. package/dist/es/components/WechatPay/index.js +48 -38
  32. package/dist/es/components/index.js +2 -3
  33. package/dist/es/components/internal/Button/Button.js +0 -2
  34. package/dist/es/components/internal/Button/index.js +0 -2
  35. package/dist/es/components/internal/CheckBox/CheckBox.js +0 -2
  36. package/dist/es/components/internal/CheckBox/index.js +0 -2
  37. package/dist/es/components/internal/Form/type.js +0 -2
  38. package/dist/es/components/internal/Info/Info.js +0 -2
  39. package/dist/es/components/internal/Info/index.js +0 -2
  40. package/dist/es/components/internal/Input/Input.js +2 -2
  41. package/dist/es/components/internal/Input/type.js +0 -2
  42. package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -2
  43. package/dist/es/components/internal/LoadingCheck/index.js +0 -2
  44. package/dist/es/components/internal/Modal/Modal.js +40 -0
  45. package/dist/es/components/internal/Modal/modal2.js +1 -0
  46. package/dist/es/components/internal/Select/Select.js +0 -2
  47. package/dist/es/components/internal/Select/SelectMenu.js +0 -2
  48. package/dist/es/components/internal/Select/SelectMenuItem.js +0 -2
  49. package/dist/es/components/internal/icons/Icon3DSFail.js +3 -0
  50. package/dist/es/components/internal/icons/Icon3DSInfo.js +62 -0
  51. package/dist/es/components/internal/icons/Icon3DSSuccess.js +3 -0
  52. package/dist/es/components/internal/icons/IconCard.js +42 -0
  53. package/dist/es/config.js +0 -2
  54. package/dist/es/constant.js +13 -2
  55. package/dist/es/core/PayKKaCheckout.js +106 -42
  56. package/dist/es/core/Session.js +7 -6
  57. package/dist/es/core/environment.js +26 -0
  58. package/dist/es/core/error.js +21 -0
  59. package/dist/es/core/index.js +0 -2
  60. package/dist/es/core/query.js +0 -2
  61. package/dist/es/core.js +34 -34
  62. package/dist/es/hooks/index.js +0 -2
  63. package/dist/es/hooks/useBreakpoints.js +57 -0
  64. package/dist/es/hooks/useI18n.js +1 -2
  65. package/dist/es/hooks/usePayState.js +20 -24
  66. package/dist/es/i18n/index.js +0 -2
  67. package/dist/es/i18n/locales/de-DE.js +14 -1
  68. package/dist/es/i18n/locales/en-GB.js +14 -1
  69. package/dist/es/i18n/locales/es-ES.js +14 -1
  70. package/dist/es/i18n/locales/fr-FR.js +14 -1
  71. package/dist/es/i18n/locales/index.js +8 -6
  72. package/dist/es/i18n/locales/ja-JP.js +14 -1
  73. package/dist/es/i18n/locales/ko-KR.js +14 -1
  74. package/dist/es/i18n/locales/pt-PT.js +14 -1
  75. package/dist/es/i18n/locales/ru-RU.js +14 -1
  76. package/dist/es/i18n/locales/zh-CN.js +14 -1
  77. package/dist/es/i18n/locales/zh-HK.js +14 -1
  78. package/dist/es/i18n/locales/zh-TW.js +14 -1
  79. package/dist/es/i18n/util.js +22 -8
  80. package/dist/es/index.js +8 -2
  81. package/dist/es/style.css +289 -11
  82. package/dist/es/types/message.js +28 -0
  83. package/dist/es/utils/card-brand/brands.js +12 -10
  84. package/dist/es/utils/card-brand/index.js +3 -2
  85. package/dist/es/utils/iframe.js +23 -0
  86. package/dist/es/utils/index.js +0 -1
  87. package/dist/es/utils/style.js +47 -0
  88. package/dist/style.css +1 -1
  89. package/dist/types/api/modules/checkout/map.d.ts +2 -1
  90. package/dist/types/api/modules/checkout/type.d.ts +24 -2
  91. package/dist/types/api/modules/get-browser-params.d.ts +1 -1
  92. package/dist/types/components/AddressField/type.d.ts +1 -0
  93. package/dist/types/components/AliPay/AliPay.d.ts +2 -1
  94. package/dist/types/components/AliPay/type.d.ts +2 -1
  95. package/dist/types/components/ApplePay/ApplePay.d.ts +2 -1
  96. package/dist/types/components/ApplePay/type.d.ts +9 -5
  97. package/dist/types/components/Card/Card.d.ts +2 -1
  98. package/dist/types/components/Card/type.d.ts +55 -9
  99. package/dist/types/components/CardHolderNameField/type.d.ts +1 -1
  100. package/dist/types/components/CombinedCardInfo/CombinedCardInfo.d.ts +5 -0
  101. package/dist/types/components/CombinedCardInfo/index.d.ts +2 -0
  102. package/dist/types/components/{CombinedEncryptedField → CombinedCardInfo}/type.d.ts +3 -2
  103. package/dist/types/components/DropIn/DropIn.d.ts +6 -0
  104. package/dist/types/components/DropIn/components/PaymentTabs/PaymentTabs.d.ts +3 -0
  105. package/dist/types/components/DropIn/components/PaymentTabs/index.d.ts +2 -0
  106. package/dist/types/components/DropIn/components/PaymentTabs/type.d.ts +11 -0
  107. package/dist/types/components/DropIn/index.d.ts +2 -0
  108. package/dist/types/components/DropIn/type.d.ts +49 -0
  109. package/dist/types/components/GooglePay/GooglePay.d.ts +2 -1
  110. package/dist/types/components/GooglePay/type.d.ts +20 -8
  111. package/dist/types/components/SecuredFieldsProvider/index.d.ts +1 -0
  112. package/dist/types/components/SecuredFieldsProvider/type.d.ts +1 -153
  113. package/dist/types/components/SecuredFieldsProvider/utils/index.d.ts +1 -1
  114. package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +2 -1
  115. package/dist/types/components/Sepa/Sepa.d.ts +2 -1
  116. package/dist/types/components/Sepa/type.d.ts +2 -1
  117. package/dist/types/components/ThreeDS/components/ThreeDSAuth/ThreeDSAuth.d.ts +3 -0
  118. package/dist/types/components/ThreeDS/components/ThreeDSAuth/index.d.ts +2 -0
  119. package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +17 -0
  120. package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +2 -0
  121. package/dist/types/components/ThreeDS/components/ThreeDSIframe/index.d.ts +1 -0
  122. package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -0
  123. package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +5 -0
  124. package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +3 -0
  125. package/dist/types/components/ThreeDS/components/ThreeDSStatus/output.d.ts +1 -0
  126. package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +6 -0
  127. package/dist/types/components/ThreeDS/index.d.ts +1 -0
  128. package/dist/types/components/WechatPay/WechatPay.d.ts +2 -1
  129. package/dist/types/components/WechatPay/type.d.ts +2 -1
  130. package/dist/types/components/index.d.ts +2 -1
  131. package/dist/types/components/internal/Input/type.d.ts +1 -0
  132. package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
  133. package/dist/types/components/internal/Loading/index.d.ts +1 -0
  134. package/dist/types/components/internal/Modal/Modal.d.ts +5 -0
  135. package/dist/types/components/internal/Modal/index.d.ts +2 -0
  136. package/dist/types/components/internal/Modal/type.d.ts +20 -0
  137. package/dist/types/components/internal/icons/Icon3DSFail.d.ts +2 -0
  138. package/dist/types/components/internal/icons/Icon3DSInfo.d.ts +2 -0
  139. package/dist/types/components/internal/icons/Icon3DSSuccess.d.ts +2 -0
  140. package/dist/types/components/internal/icons/IconCard.d.ts +2 -0
  141. package/dist/types/components/internal/icons/index.d.ts +4 -0
  142. package/dist/types/constant.d.ts +17 -2
  143. package/dist/types/core/PayKKaCheckout.d.ts +23 -6
  144. package/dist/types/core/Session.d.ts +1 -1
  145. package/dist/types/core/context.d.ts +1 -0
  146. package/dist/types/core/environment.d.ts +4 -0
  147. package/dist/types/core/error.d.ts +16 -0
  148. package/dist/types/core/index.d.ts +1 -0
  149. package/dist/types/hooks/index.d.ts +1 -0
  150. package/dist/types/hooks/useBreakpoints.d.ts +15 -0
  151. package/dist/types/hooks/usePayState.d.ts +3 -6
  152. package/dist/types/i18n/locales/de-DE.d.ts +10 -0
  153. package/dist/types/i18n/locales/en-GB.d.ts +10 -0
  154. package/dist/types/i18n/locales/es-ES.d.ts +10 -0
  155. package/dist/types/i18n/locales/fr-FR.d.ts +10 -0
  156. package/dist/types/i18n/locales/index.d.ts +2 -2
  157. package/dist/types/i18n/locales/ja-JP.d.ts +10 -0
  158. package/dist/types/i18n/locales/ko-KR.d.ts +10 -0
  159. package/dist/types/i18n/locales/pt-PT.d.ts +10 -0
  160. package/dist/types/i18n/locales/ru-RU.d.ts +10 -0
  161. package/dist/types/i18n/locales/zh-CN.d.ts +10 -0
  162. package/dist/types/i18n/locales/zh-HK.d.ts +10 -0
  163. package/dist/types/i18n/locales/zh-TW.d.ts +10 -0
  164. package/dist/types/i18n/util.d.ts +5 -0
  165. package/dist/types/index.d.ts +1 -1
  166. package/dist/types/types/index.d.ts +59 -8
  167. package/dist/types/types/message.d.ts +170 -0
  168. package/dist/types/utils/card-brand/brands.d.ts +1 -8
  169. package/dist/types/utils/card-brand/index.d.ts +2 -2
  170. package/dist/types/utils/index.d.ts +1 -0
  171. package/dist/types/utils/style.d.ts +12 -0
  172. package/package.json +2 -2
  173. package/dist/es/components/CombinedEncryptedField/index.js +0 -75
  174. package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +0 -268
  175. package/dist/types/components/CombinedEncryptedField/CombinedEncryptedField.d.ts +0 -4
  176. package/dist/types/components/CombinedEncryptedField/index.d.ts +0 -2
  177. /package/dist/types/{components/SecuredFieldsProvider/utils → utils}/iframe.d.ts +0 -0
@@ -0,0 +1,42 @@
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
+ const IconCard = ({ 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 22 22",
15
+ fill: "none",
16
+ style,
17
+ xmlns: "http://www.w3.org/2000/svg",
18
+ className: normalizedClass(COMMON_CLASS_NAME, className),
19
+ children: [
20
+ /* @__PURE__ */ u("g", { "clip-path": "url(#clip0_646_2366)", children: /* @__PURE__ */ u("g", { "clip-path": "url(#clip1_646_2366)", children: [
21
+ /* @__PURE__ */ u(
22
+ "path",
23
+ {
24
+ "fill-rule": "evenodd",
25
+ "clip-rule": "evenodd",
26
+ d: "M1.66667 8.33337C0.746192 8.33337 0 9.07957 0 10L0 11.6667H20V10C20 9.07957 19.2538 8.33337 18.3333 8.33337H1.66667ZM20 14.1667H0L0 20C0 20.9205 0.746192 21.6667 1.66667 21.6667H18.3333C19.2538 21.6667 20 20.9205 20 20V14.1667Z",
27
+ fill: "#1F1F1F"
28
+ }
29
+ ),
30
+ /* @__PURE__ */ u("rect", { x: "3.33203", y: "16.6667", width: "4.16667", height: "2.5", rx: "0.625", fill: "white" })
31
+ ] }) }),
32
+ /* @__PURE__ */ u("defs", { children: [
33
+ /* @__PURE__ */ u("clipPath", { id: "clip0_646_2366", children: /* @__PURE__ */ u("rect", { width: "30", height: "30", rx: "3.2", fill: "white" }) }),
34
+ /* @__PURE__ */ u("clipPath", { id: "clip1_646_2366", children: /* @__PURE__ */ u("rect", { width: "20", height: "13.75", fill: "white", transform: "translate(0 8.125)" }) })
35
+ ] })
36
+ ]
37
+ }
38
+ );
39
+ };
40
+ export {
41
+ IconCard
42
+ };
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";
@@ -17,6 +17,15 @@ var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
17
17
  PaymentMethod2["SEPA_DEBIT"] = "SEPA_DEBIT";
18
18
  return PaymentMethod2;
19
19
  })(PaymentMethod || {});
20
+ var PaymentCategory = /* @__PURE__ */ ((PaymentCategory2) => {
21
+ PaymentCategory2["CARD"] = "card";
22
+ PaymentCategory2["APPLE_PAY"] = "applePay";
23
+ PaymentCategory2["GOOGLE_PAY"] = "googlePay";
24
+ PaymentCategory2["SEPA_DEBIT"] = "sepaDebit";
25
+ PaymentCategory2["WECHAT_PAY"] = "wechatPay";
26
+ PaymentCategory2["ALI_PAY"] = "aliPay";
27
+ return PaymentCategory2;
28
+ })(PaymentCategory || {});
20
29
  const CardPaymentMethods = [
21
30
  "VISA",
22
31
  "MASTER_CARD",
@@ -43,8 +52,9 @@ var EAddressType = /* @__PURE__ */ ((EAddressType2) => {
43
52
  return EAddressType2;
44
53
  })(EAddressType || {});
45
54
  var SessionMode = /* @__PURE__ */ ((SessionMode2) => {
46
- SessionMode2["HOSTED"] = "HOST";
47
- SessionMode2["EMBEDDED"] = "EMBEDDED";
55
+ SessionMode2["HOSTED"] = "HOSTED";
56
+ SessionMode2["DROP_IN"] = "DROP_IN";
57
+ SessionMode2["COMPONENT"] = "COMPONENT";
48
58
  return SessionMode2;
49
59
  })(SessionMode || {});
50
60
  export {
@@ -52,6 +62,7 @@ export {
52
62
  CardPaymentMethods,
53
63
  EAddressType,
54
64
  PREFIX,
65
+ PaymentCategory,
55
66
  PaymentMethod,
56
67
  PaymentType,
57
68
  SessionMode
@@ -1,62 +1,126 @@
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]);
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);
52
88
  }
89
+ get envConfig() {
90
+ return __privateGet(this, _envConfig);
91
+ }
92
+ get config() {
93
+ return __privateGet(this, _config);
94
+ }
95
+ /** 创建组件,把 session 作为组件的 props 传递 */
53
96
  create(component, props) {
54
- return create(component, props);
97
+ var _a;
98
+ const { onSubmit, onSuccess, onError, onTimeout, onExpired } = __privateGet(this, _config);
99
+ const coreProps = this.getCoreProps();
100
+ const componentInst = create(component, {
101
+ onSubmit,
102
+ onSuccess,
103
+ onError,
104
+ onTimeout,
105
+ onExpired,
106
+ ...props,
107
+ ...coreProps
108
+ });
109
+ (_a = __privateGet(this, _componentInsts)) == null ? void 0 : _a.push(componentInst);
110
+ return componentInst;
55
111
  }
56
- };
57
- __publicField(_PayKKaCheckout, "session");
58
- __publicField(_PayKKaCheckout, "instance", null);
59
- let PayKKaCheckout = _PayKKaCheckout;
112
+ getCoreProps() {
113
+ return {
114
+ session: __privateGet(this, _session),
115
+ core: this,
116
+ threeDSFrame: __privateGet(this, _config).threeDSFrame
117
+ };
118
+ }
119
+ }
120
+ _config = new WeakMap();
121
+ _envConfig = new WeakMap();
122
+ _session = new WeakMap();
123
+ _componentInsts = new WeakMap();
60
124
  export {
61
125
  PayKKaCheckout
62
126
  };
@@ -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";
@@ -0,0 +1,57 @@
1
+ import { h, y, T } from "../core.js";
2
+ const breakpoints = {
3
+ xs: 480,
4
+ sm: 928,
5
+ md: 992,
6
+ lg: 1200,
7
+ xl: 1366,
8
+ xxl: 1600
9
+ };
10
+ const useBreakpoints = () => {
11
+ const [width, setWidth] = h(() => {
12
+ return typeof window !== "undefined" ? window.innerWidth : 0;
13
+ });
14
+ y(() => {
15
+ if (typeof window === "undefined")
16
+ return;
17
+ const handleResize = () => {
18
+ setWidth(window.innerWidth);
19
+ };
20
+ window.addEventListener("resize", handleResize);
21
+ return () => window.removeEventListener("resize", handleResize);
22
+ }, []);
23
+ const sortedEntries = T(() => {
24
+ return Object.entries(breakpoints).sort((a, b) => a[1] - b[1]);
25
+ }, [breakpoints]);
26
+ const { matches, current } = T(() => {
27
+ const matches2 = {
28
+ xs: false,
29
+ sm: false,
30
+ md: false,
31
+ lg: false,
32
+ xl: false,
33
+ xxl: false
34
+ };
35
+ let current2 = null;
36
+ for (let i = sortedEntries.length - 1; i >= 0; i--) {
37
+ const [name, value] = sortedEntries[i];
38
+ const isMatch = width >= value;
39
+ matches2[name] = isMatch;
40
+ if (isMatch && !current2) {
41
+ current2 = name;
42
+ }
43
+ }
44
+ return { matches: matches2, current: current2 };
45
+ }, [width, sortedEntries]);
46
+ const smaller = (breakpointName) => {
47
+ const threshold = breakpoints[breakpointName];
48
+ if (threshold === void 0) {
49
+ return false;
50
+ }
51
+ return width < threshold;
52
+ };
53
+ return { matches, current, smaller };
54
+ };
55
+ export {
56
+ useBreakpoints
57
+ };
@@ -3,11 +3,10 @@ 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
5
  import { I18n } from "../i18n/I18n.js";
6
- import "../i18n/locales/index.js";
7
6
  function useI18n(locale) {
8
7
  const coreContext = x(CoreContext);
9
8
  const [_i18n] = h((coreContext == null ? void 0 : coreContext.i18n) ?? new I18n());
10
- _i18n.load(locale);
9
+ locale && _i18n.load(locale);
11
10
  return { i18n: _i18n };
12
11
  }
13
12
  export {
@@ -1,31 +1,30 @@
1
1
  import { h, y } from "../core.js";
2
- import "../core/context.js";
3
- import "../utils/card-brand/brands.js";
4
- import "../utils/system-info/get-browser-info.js";
5
- import { customLocale, fraudDetectionEnv } from "../config.js";
6
- import { PayKKaCheckout } from "../core/PayKKaCheckout.js";
7
2
  import { getFraudDetectionInstance } from "../out/fraud-detection.js";
8
3
  import { useI18n } from "./useI18n.js";
9
- function usePayState() {
4
+ import { customLocale, fraudDetectionEnv } from "../config.js";
5
+ import "../utils/card-brand/brands.js";
6
+ import { getBrowserInfo } from "../utils/system-info/get-browser-info.js";
7
+ import { getRealLocale } from "../i18n/util.js";
8
+ function usePayState(session) {
10
9
  const [validated, setValidated] = h(false);
11
10
  const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
12
11
  const [errorMsg, setErrorMsg] = h("");
13
- const [session, setSession] = h(null);
14
12
  const [sessionReady, setSessionReady] = h(false);
15
13
  const [fraudDetection, setFraudDetection] = h(null);
16
- setSession(PayKKaCheckout.getSession());
17
- const { i18n } = useI18n(customLocale);
14
+ const { i18n } = useI18n();
18
15
  y(() => {
19
- if (session) {
20
- session.ready().then(() => {
21
- setSessionReady(true);
22
- i18n.load(session.checkout.locale || customLocale);
23
- const fraudDetection2 = getFraudDetectionInstance(fraudDetectionEnv);
24
- setFraudDetection(fraudDetection2);
25
- fraudDetection2 == null ? void 0 : fraudDetection2.createFraudDetection();
26
- });
27
- }
28
- }, [session]);
16
+ session.ready().then(() => {
17
+ var _a;
18
+ setSessionReady(true);
19
+ const locale = getRealLocale(
20
+ customLocale || ((_a = session.checkout) == null ? void 0 : _a.locale) || getBrowserInfo().language
21
+ );
22
+ i18n.load(locale);
23
+ const fraudDetection2 = getFraudDetectionInstance(fraudDetectionEnv);
24
+ setFraudDetection(fraudDetection2);
25
+ fraudDetection2 == null ? void 0 : fraudDetection2.createFraudDetection();
26
+ });
27
+ }, []);
29
28
  return {
30
29
  validated,
31
30
  setValidated,
@@ -33,12 +32,9 @@ function usePayState() {
33
32
  setSubmitButtonStatus,
34
33
  errorMsg,
35
34
  setErrorMsg,
36
- session,
37
- setSession,
38
- sessionReady,
39
- setSessionReady,
40
35
  i18n,
41
- fraudDetection
36
+ fraudDetection,
37
+ sessionReady
42
38
  };
43
39
  }
44
40
  export {
@@ -1,5 +1,3 @@
1
1
  import "../utils/card-brand/brands.js";
2
2
  import "../utils/system-info/get-browser-info.js";
3
- import "./util.js";
4
3
  import "../core.js";
5
- import "./locales/index.js";
@@ -1,4 +1,7 @@
1
1
  const deDE = {
2
+ // Drop In
3
+ "dropIn.card.label": "Bankkarte",
4
+ "dropIn.otherPaymentMethod": "Andere Zahlungsmethode",
2
5
  // card number
3
6
  "card.cardNumber.label": "Kartennummer",
4
7
  "card.cardNumber.incomplete": "Ihre Kartennummer ist unvollständig",
@@ -21,6 +24,8 @@ const deDE = {
21
24
  "card.cardSelector.change": "Ändern",
22
25
  "card.cardSelector.useOtherCard": "Andere Karte verwenden",
23
26
  "card.storeInfo": "Meine Kartendaten für zukünftige Nutzung speichern",
27
+ // card info
28
+ "card.info.label": "Kartendaten",
24
29
  // common
25
30
  "common.pay": "Jetzt kaufen",
26
31
  "common.payProcessing": "Wird bearbeitet...",
@@ -33,6 +38,8 @@ const deDE = {
33
38
  "common.noData": "Keine Daten",
34
39
  "common.netError": "Netzwerkfehler",
35
40
  "common.unknownError": "Unbekannter Fehler",
41
+ "common.cancel": "Abbrechen",
42
+ "common.confirm": "Bestätigen",
36
43
  // common email
37
44
  "common.email.label": "E-Mail",
38
45
  "common.email.incomplete": "Bitte geben Sie Ihre E-Mail-Adresse ein",
@@ -53,7 +60,13 @@ const deDE = {
53
60
  // sepa
54
61
  "sepa.iban.label": "IBAN",
55
62
  "sepa.iban.placeholder": "DE00 0000 0000 0000 0000 00",
56
- "sepa.iban.invalid": "Die eingegebene IBAN ist ungültig"
63
+ "sepa.iban.invalid": "Die eingegebene IBAN ist ungültig",
64
+ // threeDS
65
+ "threeDS.paymentIncomplete": "Ihre letzte Zahlung ist unvollständig,",
66
+ "threeDS.completeFirst": "bitte vervollständigen Sie zunächst die Bearbeitung.",
67
+ "threeDS.authenticationSuccessful": "Authentifizierung erfolgreich,",
68
+ "threeDS.authenticationFailed": "Authentifizierung fehlgeschlagen,",
69
+ "threeDS.returnToCheckout": "Rückkehr erfolgt in Kürze."
57
70
  };
58
71
  export {
59
72
  deDE as default