@paykka/card-checkout-ui 0.5.17 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/dist/card-checkout-ui.js +22 -0
  2. package/dist/card-checkout-ui.umd.cjs +19 -5
  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 +22 -4
  6. package/dist/es/api/modules/encrypted-card/index.js +54 -0
  7. package/dist/es/api/modules/get-browser-params.js +2 -2
  8. package/dist/es/api/modules/index.js +0 -2
  9. package/dist/es/components/AccountNameField/index.js +2 -3
  10. package/dist/es/components/AddressField/index.js +4 -7
  11. package/dist/es/components/AliPay/index.js +13 -12
  12. package/dist/es/components/ApplePay/index.js +75 -19
  13. package/dist/es/components/Card/index.js +335 -143
  14. package/dist/es/components/CardBrands/index.js +0 -2
  15. package/dist/es/components/CardExpireDateField/index.js +6 -6
  16. package/dist/es/components/CardHolderNameField/index.js +5 -5
  17. package/dist/es/components/CardIBANField/index.js +2 -3
  18. package/dist/es/components/CardNo/index.js +0 -2
  19. package/dist/es/components/CardNumberField/index.js +32 -20
  20. package/dist/es/components/CardSecurityCodeField/index.js +6 -6
  21. package/dist/es/components/CardSelector/index.js +1 -3
  22. package/dist/es/components/CombinedCardInfo/index.js +99 -0
  23. package/dist/es/components/EmailField/EmailField.js +2 -3
  24. package/dist/es/components/EncryptedCard/index.js +408 -0
  25. package/dist/es/components/GooglePay/index.js +108 -36
  26. package/dist/es/components/RecurringTip/index.js +0 -2
  27. package/dist/es/components/SecuredFieldsProvider/index.js +230 -1
  28. package/dist/es/components/SecuredIframe/index.js +192 -22
  29. package/dist/es/components/Sepa/index.js +36 -32
  30. package/dist/es/components/SubmitButton/index.js +0 -2
  31. package/dist/es/components/ThreeDS/index.js +94 -0
  32. package/dist/es/components/WechatPay/index.js +31 -30
  33. package/dist/es/components/index.js +4 -2
  34. package/dist/es/components/internal/Button/Button.js +0 -2
  35. package/dist/es/components/internal/Button/index.js +0 -2
  36. package/dist/es/components/internal/CheckBox/CheckBox.js +0 -2
  37. package/dist/es/components/internal/CheckBox/index.js +0 -2
  38. package/dist/es/components/internal/Form/FormItem.js +28 -24
  39. package/dist/es/components/internal/Form/index.js +1 -0
  40. package/dist/es/components/internal/Form/type.js +13 -1
  41. package/dist/es/components/internal/Info/Info.js +0 -2
  42. package/dist/es/components/internal/Info/index.js +0 -2
  43. package/dist/es/components/internal/Input/Input.js +11 -13
  44. package/dist/es/components/internal/Input/index.js +1 -0
  45. package/dist/es/components/internal/Input/type.js +11 -1
  46. package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -2
  47. package/dist/es/components/internal/LoadingCheck/index.js +0 -2
  48. package/dist/es/components/internal/Modal/Modal.js +40 -0
  49. package/dist/es/components/internal/Modal/modal2.js +1 -0
  50. package/dist/es/components/internal/Select/Select.js +2 -2
  51. package/dist/es/components/internal/Select/SelectMenu.js +0 -2
  52. package/dist/es/components/internal/Select/SelectMenuItem.js +0 -2
  53. package/dist/es/components/internal/icons/Icon3DSFail.js +3 -0
  54. package/dist/es/components/internal/icons/Icon3DSInfo.js +62 -0
  55. package/dist/es/components/internal/icons/Icon3DSSuccess.js +3 -0
  56. package/dist/es/config.js +12 -8
  57. package/dist/es/constant.js +13 -2
  58. package/dist/es/core/PayKKaCheckout.js +116 -0
  59. package/dist/es/core/Session.js +7 -6
  60. package/dist/es/core/environment.js +26 -0
  61. package/dist/es/core/error.js +21 -0
  62. package/dist/es/core/index.js +0 -2
  63. package/dist/es/core/query.js +1 -8
  64. package/dist/es/hooks/index.js +0 -2
  65. package/dist/es/hooks/useBreakpoints.js +57 -0
  66. package/dist/es/hooks/useI18n.js +0 -1
  67. package/dist/es/hooks/usePayState.js +20 -33
  68. package/dist/es/i18n/index.js +0 -2
  69. package/dist/es/i18n/locales/de-DE.js +11 -1
  70. package/dist/es/i18n/locales/en-GB.js +11 -1
  71. package/dist/es/i18n/locales/es-ES.js +11 -1
  72. package/dist/es/i18n/locales/fr-FR.js +11 -1
  73. package/dist/es/i18n/locales/index.js +8 -6
  74. package/dist/es/i18n/locales/ja-JP.js +11 -1
  75. package/dist/es/i18n/locales/ko-KR.js +11 -1
  76. package/dist/es/i18n/locales/pt-PT.js +11 -1
  77. package/dist/es/i18n/locales/ru-RU.js +11 -1
  78. package/dist/es/i18n/locales/zh-CN.js +11 -1
  79. package/dist/es/i18n/locales/zh-HK.js +11 -1
  80. package/dist/es/i18n/locales/zh-TW.js +11 -1
  81. package/dist/es/i18n/util.js +11 -8
  82. package/dist/es/index.js +15 -2
  83. package/dist/es/out/fraud-detection.js +99 -0
  84. package/dist/es/style.css +194 -4
  85. package/dist/es/types/{radar.js → fraud-detection.js} +1 -1
  86. package/dist/es/types/index.js +49 -1
  87. package/dist/es/types/message.js +28 -0
  88. package/dist/es/utils/card-brand/brands.js +21 -45
  89. package/dist/es/utils/card-brand/index.js +3 -2
  90. package/dist/es/utils/iframe.js +23 -0
  91. package/dist/es/utils/index.js +11 -1
  92. package/dist/es/utils/load.js +14 -0
  93. package/dist/es/utils/style.js +84 -0
  94. package/dist/style.css +1 -1
  95. package/dist/types/api/modules/checkout/map.d.ts +1 -0
  96. package/dist/types/api/modules/checkout/type.d.ts +14 -1
  97. package/dist/types/api/modules/encrypted-card/index.d.ts +6 -0
  98. package/dist/types/api/modules/encrypted-card/type.d.ts +31 -0
  99. package/dist/types/api/modules/get-browser-params.d.ts +3 -3
  100. package/dist/types/components/AddressField/type.d.ts +1 -0
  101. package/dist/types/components/AliPay/type.d.ts +4 -4
  102. package/dist/types/components/ApplePay/type.d.ts +19 -7
  103. package/dist/types/components/ApplePay/utils.d.ts +3 -0
  104. package/dist/types/components/Card/type.d.ts +64 -6
  105. package/dist/types/components/CardExpireDateField/type.d.ts +1 -0
  106. package/dist/types/components/CardHolderNameField/type.d.ts +1 -1
  107. package/dist/types/components/CardNumberField/type.d.ts +3 -0
  108. package/dist/types/components/CardSecurityCodeField/type.d.ts +1 -0
  109. package/dist/types/components/CombinedCardInfo/CombinedCardInfo.d.ts +5 -0
  110. package/dist/types/components/CombinedCardInfo/index.d.ts +2 -0
  111. package/dist/types/components/CombinedCardInfo/type.d.ts +16 -0
  112. package/dist/types/components/EncryptedCard/EncryptedCard.d.ts +4 -0
  113. package/dist/types/components/EncryptedCard/index.d.ts +4 -0
  114. package/dist/types/components/EncryptedCard/output.d.ts +9 -0
  115. package/dist/types/components/EncryptedCard/type.d.ts +85 -0
  116. package/dist/types/components/GooglePay/type.d.ts +20 -8
  117. package/dist/types/components/GooglePay/utils.d.ts +2 -0
  118. package/dist/types/components/SecuredFieldsProvider/index.d.ts +1 -0
  119. package/dist/types/components/SecuredFieldsProvider/type.d.ts +29 -100
  120. package/dist/types/components/SecuredFieldsProvider/utils/index.d.ts +1 -1
  121. package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +7 -2
  122. package/dist/types/components/Sepa/type.d.ts +4 -4
  123. package/dist/types/components/ThreeDS/components/ThreeDSAuth/ThreeDSAuth.d.ts +3 -0
  124. package/dist/types/components/ThreeDS/components/ThreeDSAuth/index.d.ts +2 -0
  125. package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +17 -0
  126. package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +2 -0
  127. package/dist/types/components/ThreeDS/components/ThreeDSIframe/index.d.ts +1 -0
  128. package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -0
  129. package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +5 -0
  130. package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +3 -0
  131. package/dist/types/components/ThreeDS/components/ThreeDSStatus/output.d.ts +1 -0
  132. package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +6 -0
  133. package/dist/types/components/ThreeDS/index.d.ts +1 -0
  134. package/dist/types/components/WechatPay/type.d.ts +4 -4
  135. package/dist/types/components/index.d.ts +2 -0
  136. package/dist/types/components/internal/Form/FormItem.d.ts +1 -1
  137. package/dist/types/components/internal/Form/type.d.ts +7 -0
  138. package/dist/types/components/internal/Input/Input.d.ts +1 -1
  139. package/dist/types/components/internal/Input/type.d.ts +7 -0
  140. package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
  141. package/dist/types/components/internal/Loading/index.d.ts +1 -0
  142. package/dist/types/components/internal/Modal/Modal.d.ts +5 -0
  143. package/dist/types/components/internal/Modal/index.d.ts +0 -0
  144. package/dist/types/components/internal/Modal/type.d.ts +20 -0
  145. package/dist/types/components/internal/icons/Icon3DSFail.d.ts +2 -0
  146. package/dist/types/components/internal/icons/Icon3DSInfo.d.ts +2 -0
  147. package/dist/types/components/internal/icons/Icon3DSSuccess.d.ts +2 -0
  148. package/dist/types/components/internal/icons/index.d.ts +3 -0
  149. package/dist/types/config.d.ts +7 -3
  150. package/dist/types/constant.d.ts +7 -2
  151. package/dist/types/core/PayKKaCheckout.d.ts +28 -0
  152. package/dist/types/core/Session.d.ts +1 -1
  153. package/dist/types/core/context.d.ts +1 -0
  154. package/dist/types/core/environment.d.ts +4 -0
  155. package/dist/types/core/error.d.ts +16 -0
  156. package/dist/types/core/index.d.ts +2 -0
  157. package/dist/types/core/query.d.ts +2 -2
  158. package/dist/types/hooks/index.d.ts +1 -0
  159. package/dist/types/hooks/useBreakpoints.d.ts +15 -0
  160. package/dist/types/hooks/usePayState.d.ts +6 -25
  161. package/dist/types/i18n/locales/de-DE.d.ts +8 -0
  162. package/dist/types/i18n/locales/en-GB.d.ts +8 -0
  163. package/dist/types/i18n/locales/es-ES.d.ts +8 -0
  164. package/dist/types/i18n/locales/fr-FR.d.ts +8 -0
  165. package/dist/types/i18n/locales/index.d.ts +2 -2
  166. package/dist/types/i18n/locales/ja-JP.d.ts +8 -0
  167. package/dist/types/i18n/locales/ko-KR.d.ts +8 -0
  168. package/dist/types/i18n/locales/pt-PT.d.ts +8 -0
  169. package/dist/types/i18n/locales/ru-RU.d.ts +8 -0
  170. package/dist/types/i18n/locales/zh-CN.d.ts +8 -0
  171. package/dist/types/i18n/locales/zh-HK.d.ts +8 -0
  172. package/dist/types/i18n/locales/zh-TW.d.ts +8 -0
  173. package/dist/types/index.d.ts +2 -2
  174. package/dist/types/out/fraud-detection.d.ts +9 -0
  175. package/dist/types/types/{radar.d.ts → fraud-detection.d.ts} +3 -2
  176. package/dist/types/types/index.d.ts +100 -1
  177. package/dist/types/types/message.d.ts +170 -0
  178. package/dist/types/utils/card-brand/brands.d.ts +4 -18
  179. package/dist/types/utils/card-brand/index.d.ts +10 -9
  180. package/dist/types/utils/format.d.ts +0 -1
  181. package/dist/types/utils/index.d.ts +4 -0
  182. package/dist/types/utils/load.d.ts +7 -0
  183. package/dist/types/utils/style.d.ts +29 -0
  184. package/package.json +63 -63
  185. package/dist/card-checkout-ui.iife.js +0 -8
  186. package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +0 -222
  187. package/dist/es/out/radar.js +0 -123
  188. package/dist/types/out/radar.d.ts +0 -14
  189. /package/dist/types/{components/SecuredFieldsProvider/utils → utils}/iframe.d.ts +0 -0
@@ -0,0 +1,28 @@
1
+ var MessageAction = /* @__PURE__ */ ((MessageAction2) => {
2
+ MessageAction2["INIT"] = "init";
3
+ MessageAction2["ACTIVATED"] = "Activated";
4
+ MessageAction2["HIDDEN_IFRAME_READY"] = "hiddenIframeReady";
5
+ MessageAction2["FOCUS"] = "focus";
6
+ MessageAction2["BIN_VALUE"] = "binValue";
7
+ MessageAction2["BRAND"] = "brand";
8
+ MessageAction2["VALID_WITH_VALUE"] = "validWithValue";
9
+ MessageAction2["PAYMENT"] = "payment";
10
+ MessageAction2["AFTER_PAYMENT"] = "afterPayment";
11
+ MessageAction2["PAYMENT_ERROR"] = "paymentError";
12
+ MessageAction2["PAYMENT_TIMEOUT"] = "paymentTimeout";
13
+ MessageAction2["VALID_STATUS_CHANGED"] = "validStatusChanged";
14
+ MessageAction2["VALIDATE"] = "validate";
15
+ MessageAction2["VALIDATED"] = "validated";
16
+ MessageAction2["SET_CONFIG"] = "setConfig";
17
+ MessageAction2["AUTHORIZED"] = "authorized";
18
+ MessageAction2["ENCRYPT_CARD"] = "encryptCard";
19
+ MessageAction2["CARD_ENCRYPTED"] = "cardEncrypted";
20
+ MessageAction2["CARD_ENCRYPTION_FAILED"] = "cardEncryptionFailed";
21
+ MessageAction2["CHECK_THREE_DS"] = "checkThreeDS";
22
+ MessageAction2["THREE_DS_STATUS_INIT"] = "threeDSStatusInit";
23
+ MessageAction2["THREE_DS_STATUS_CONFIG"] = "threeDSStatusConfig";
24
+ return MessageAction2;
25
+ })(MessageAction || {});
26
+ export {
27
+ MessageAction
28
+ };
@@ -1,90 +1,66 @@
1
1
  import { IconAmex } from "../../components/internal/icons/IconAmex.js";
2
2
  import "../../core.js";
3
3
  import "../system-info/get-browser-info.js";
4
+ import { CardBrandCode } from "../../types/index.js";
4
5
  import { IconDinnersClub } from "../../components/internal/icons/IconDinnersClub.js";
5
6
  import { IconDiscover } from "../../components/internal/icons/IconDiscover.js";
6
7
  import { IconJcb } from "../../components/internal/icons/IconJcb.js";
7
8
  import { IconMasterCard } from "../../components/internal/icons/IconMasterCard.js";
8
9
  import { IconVisa } from "../../components/internal/icons/IconVisa.js";
9
- var CardBrandCode = /* @__PURE__ */ ((CardBrandCode2) => {
10
- CardBrandCode2["VISA"] = "VISA";
11
- CardBrandCode2["MASTER_CARD"] = "MASTER_CARD";
12
- CardBrandCode2["JCB"] = "JCB";
13
- CardBrandCode2["AMEX"] = "AMEX";
14
- CardBrandCode2["DISCOVER"] = "DISCOVER";
15
- CardBrandCode2["DINERS_CLUB"] = "DINERS_CLUB";
16
- return CardBrandCode2;
17
- })(CardBrandCode || {});
18
10
  const cardBrandCodes = Object.values(CardBrandCode);
19
11
  const cardBrands = [
20
12
  {
21
13
  name: "Visa",
22
- code: "VISA",
14
+ code: CardBrandCode.VISA,
23
15
  pattern: /^4[0-9]{0,18}$/,
24
16
  lengths: [13, 16, 19],
25
17
  order: 1
26
18
  },
27
19
  {
28
20
  name: "MasterCard",
29
- code: "MASTER_CARD",
21
+ code: CardBrandCode.MASTER_CARD,
30
22
  lengths: [16],
31
23
  pattern: /^(5[1-5][0-9]{0,14}|2[2-7][0-9]{0,14})$/,
32
24
  order: 2
33
25
  },
34
26
  {
35
27
  name: "JCB",
36
- code: "JCB",
28
+ code: CardBrandCode.JCB,
37
29
  pattern: /^(352[8,9]{1}[0-9]{0,15}|35[4-8]{1}[0-9]{0,16})$/,
38
30
  lengths: [16, 19],
39
31
  order: 3
40
32
  },
41
33
  {
42
34
  name: "American Express",
43
- code: "AMEX",
35
+ code: CardBrandCode.AMEX,
44
36
  pattern: /^3[47][0-9]{0,13}$/,
45
37
  lengths: [15],
46
38
  order: 6
47
39
  },
48
40
  {
49
41
  name: "Discover",
50
- code: "DISCOVER",
51
- pattern: /^(6011[0-9]{12,15})|(622((1((2[6-9])|([3-9][0-9])))|([2-8][0-9]{2})|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10,13})|(64[4-9][0-9]{13,16})|(65[0-9]{14,17})$/,
42
+ code: CardBrandCode.DISCOVER,
43
+ pattern: /^(?:6011|65\d{0,2}|64[4-9]\d?)\d{0,12}/,
52
44
  lengths: [16],
53
45
  order: 4
54
46
  },
55
47
  {
56
48
  name: "Diners Club",
57
- code: "DINERS_CLUB",
58
- pattern: /^(36)[0-9]{0,12}$/,
59
- lengths: [14],
49
+ code: CardBrandCode.DINERS_CLUB,
50
+ pattern: /^3(?:0([0-5]|9)|[689]\d?)\d{0,11}/,
51
+ lengths: [14, 16],
60
52
  order: 5
61
53
  }
62
54
  ];
63
- const cardBrandIconMap = {
64
- [
65
- "VISA"
66
- /* VISA */
67
- ]: IconVisa,
68
- [
69
- "MASTER_CARD"
70
- /* MASTER_CARD */
71
- ]: IconMasterCard,
72
- [
73
- "JCB"
74
- /* JCB */
75
- ]: IconJcb,
76
- [
77
- "AMEX"
78
- /* AMEX */
79
- ]: IconAmex,
80
- [
81
- "DISCOVER"
82
- /* DISCOVER */
83
- ]: IconDiscover,
84
- [
85
- "DINERS_CLUB"
86
- /* DINERS_CLUB */
87
- ]: IconDinnersClub
55
+ const getCardBrandIconMap = (code) => {
56
+ return {
57
+ [CardBrandCode.VISA]: IconVisa,
58
+ [CardBrandCode.MASTER_CARD]: IconMasterCard,
59
+ [CardBrandCode.JCB]: IconJcb,
60
+ [CardBrandCode.AMEX]: IconAmex,
61
+ [CardBrandCode.DISCOVER]: IconDiscover,
62
+ [CardBrandCode.DINERS_CLUB]: IconDinnersClub
63
+ }[code];
88
64
  };
89
65
  [
90
66
  ...cardBrands.reduce((acc, cur) => {
@@ -94,6 +70,6 @@ const cardBrandIconMap = {
94
70
  ];
95
71
  export {
96
72
  cardBrandCodes,
97
- cardBrandIconMap,
98
- cardBrands
73
+ cardBrands,
74
+ getCardBrandIconMap
99
75
  };
@@ -1,4 +1,4 @@
1
- import { cardBrands, cardBrandIconMap } from "./brands.js";
1
+ import { cardBrands, getCardBrandIconMap } from "./brands.js";
2
2
  function getSupportedCardBrands(supportedCardBrands) {
3
3
  return supportedCardBrands ? cardBrands.filter((brand) => supportedCardBrands.includes(brand.code)).sort((a, b) => a.order - b.order) : [];
4
4
  }
@@ -10,6 +10,7 @@ function findCardBrand(number, brands = cardBrands) {
10
10
  }
11
11
  }
12
12
  function findCardBrandInfo(number, brands = cardBrands) {
13
+ console.log(number, brands);
13
14
  for (const item of brands) {
14
15
  if (item.pattern.test(number)) {
15
16
  return getCardBrandInfo(item);
@@ -19,7 +20,7 @@ function findCardBrandInfo(number, brands = cardBrands) {
19
20
  function getCardBrandInfo(brand) {
20
21
  return {
21
22
  ...brand,
22
- icon: cardBrandIconMap[brand.code]
23
+ icon: getCardBrandIconMap(brand.code)
23
24
  };
24
25
  }
25
26
  function finCardBrandInfoByCode(code) {
@@ -0,0 +1,23 @@
1
+ import { SECURED_IFRAME_CLASS_NAME } from "../components/SecuredFieldsProvider/index.js";
2
+ const createIframe = (src) => {
3
+ const iframeEl = document.createElement("iframe");
4
+ iframeEl.setAttribute("src", src);
5
+ iframeEl.classList.add(SECURED_IFRAME_CLASS_NAME);
6
+ iframeEl.setAttribute("allowtransparency", "true");
7
+ iframeEl.setAttribute("referrerpolicy", "origin");
8
+ Object.defineProperty(iframeEl, "src", { configurable: false, writable: false });
9
+ const noIframeElContent = document.createTextNode("<p>Your browser does not support iframes.</p>");
10
+ iframeEl.appendChild(noIframeElContent);
11
+ return iframeEl;
12
+ };
13
+ const postMessageToIframe = (data, iframe, targetOrigin = "*") => {
14
+ if (!iframe) {
15
+ return;
16
+ }
17
+ const dataStr = JSON.stringify(data);
18
+ iframe == null ? void 0 : iframe.postMessage(dataStr, { targetOrigin });
19
+ };
20
+ export {
21
+ createIframe,
22
+ postMessageToIframe
23
+ };
@@ -17,7 +17,6 @@ const safeParse = (dataStr, defaultValue = {}) => {
17
17
  try {
18
18
  return JSON.parse(dataStr);
19
19
  } catch (error) {
20
- console.log(error);
21
20
  return defaultValue;
22
21
  }
23
22
  };
@@ -27,9 +26,20 @@ function isExpired(expireDate) {
27
26
  const currentDate = /* @__PURE__ */ new Date();
28
27
  return expiryDate < currentDate;
29
28
  }
29
+ const intersection = (...arrays) => {
30
+ if (arrays.length === 0)
31
+ return [];
32
+ let result = arrays[0];
33
+ for (let i = 1; i < arrays.length; i++) {
34
+ const set = new Set(result);
35
+ result = arrays[i].filter((item) => set.has(item));
36
+ }
37
+ return result;
38
+ };
30
39
  export {
31
40
  clamp,
32
41
  getIf,
42
+ intersection,
33
43
  isExpired,
34
44
  safeParse
35
45
  };
@@ -0,0 +1,14 @@
1
+ const loadScript = (params) => {
2
+ var _a;
3
+ const { src, onload = null, onerror = null } = params;
4
+ const script = document.createElement("script");
5
+ script.type = "text/javascript";
6
+ script.src = src;
7
+ script.onload = onload;
8
+ script.onerror = onerror;
9
+ Object.assign(script, params.extraOptions);
10
+ (_a = document.getElementsByTagName("head")[0]) == null ? void 0 : _a.appendChild(script);
11
+ };
12
+ export {
13
+ loadScript
14
+ };
@@ -0,0 +1,84 @@
1
+ import { inputStyleAttrs } from "../types/index.js";
2
+ const style2String = (style = {}) => {
3
+ return Object.entries(style).map(([key, value]) => {
4
+ const kebabKey = key.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
5
+ return `${kebabKey}: ${value}`;
6
+ }).join("; ");
7
+ };
8
+ const generateClassNameMap = (selector) => {
9
+ return {
10
+ focus: `${selector}_focus`,
11
+ hover: `${selector}_hover`,
12
+ valid: `${selector}_valid`,
13
+ invalid: `${selector}_invalid`
14
+ };
15
+ };
16
+ const loadStyle = (styleStr, extraOptions) => {
17
+ var _a;
18
+ const style = document.createElement("style");
19
+ style.textContent = styleStr;
20
+ Object.assign(style, extraOptions);
21
+ (_a = document.getElementsByTagName("head")[0]) == null ? void 0 : _a.appendChild(style);
22
+ };
23
+ const createPlaceholderStyle = (selector, style = {}) => {
24
+ const styleStr = style2String(style);
25
+ const placeholderStyle = `
26
+ ${selector}::placeholder { ${styleStr} }
27
+ ${selector}::-webkit-input-placeholder { ${styleStr} }
28
+ ${selector}:-moz-placeholder { ${styleStr} }
29
+ ${selector}:-ms-input-placeholder { ${styleStr} }
30
+ `;
31
+ return placeholderStyle;
32
+ };
33
+ const separateInputStyle = (styles) => {
34
+ const { input } = styles;
35
+ let inputWrapper = {};
36
+ let inputStyle = {};
37
+ if (input) {
38
+ inputWrapper = JSON.parse(JSON.stringify(input));
39
+ Reflect.deleteProperty(inputWrapper, "placeholder");
40
+ Reflect.deleteProperty(inputWrapper, "hover");
41
+ inputStyle = {
42
+ placeholder: input == null ? void 0 : input.placeholder,
43
+ hover: input == null ? void 0 : input.hover
44
+ };
45
+ const statusList = Object.keys(inputWrapper);
46
+ statusList.forEach((key) => {
47
+ if (key === "placeholder" || key === "hover") {
48
+ return;
49
+ }
50
+ const style = inputWrapper[key];
51
+ if (!style) {
52
+ return;
53
+ }
54
+ inputStyleAttrs.forEach((attr) => {
55
+ if (!inputStyle[key]) {
56
+ inputStyle[key] = {};
57
+ }
58
+ if (style[attr]) {
59
+ inputStyle[key][attr] = style[attr];
60
+ Reflect.deleteProperty(style, attr);
61
+ }
62
+ });
63
+ });
64
+ }
65
+ return {
66
+ ...styles,
67
+ inputWrapper,
68
+ input: inputStyle
69
+ };
70
+ };
71
+ const genComponentStyle = (list = []) => {
72
+ const style = list.map(({ selector, style: style2 }) => {
73
+ return `${selector} { ${style2String(style2)} }`;
74
+ });
75
+ return style.join("\n");
76
+ };
77
+ export {
78
+ createPlaceholderStyle,
79
+ genComponentStyle,
80
+ generateClassNameMap,
81
+ loadStyle,
82
+ separateInputStyle,
83
+ style2String
84
+ };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .paykka-card-checkout,.paykka-card-checkout *{box-sizing:border-box}@media (min-width: 480px){.paykka-card-checkout-ali-pay__email{padding-bottom:20px}}.paykka-card-checkout-ali-pay__error{margin-top:16px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-ali-pay__error{margin-top:20px}}.paykka-card-checkout-ali-pay__button{margin-top:16px;transition:margin-top .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-ali-pay__button{margin-top:20px}}.paykka-card-checkout-address-field__first-item .paykka-card-checkout-input__input-wrapper{padding:8px 0;border-bottom-right-radius:0;border-bottom-left-radius:0}.paykka-card-checkout-address-field__mid-item .paykka-card-checkout-input__input-wrapper{padding:8px 0;border-radius:0;border-top:0}.paykka-card-checkout-address-field__mid-item .paykka-card-checkout-input__input-wrapper:active,.paykka-card-checkout-address-field__mid-item .paykka-card-checkout-input__input-wrapper--focus,.paykka-card-checkout-address-field__mid-item .paykka-card-checkout-input__input-wrapper:focus{border-top:1px solid var(--paykka-card-checkout-input-color, #4F43DF);box-shadow:0 0 0 1px var(--paykka-card-checkout-input-color, #4F43DF)}.paykka-card-checkout-address-field__last-item .paykka-card-checkout-input__input-wrapper{padding:8px 0;border-top-right-radius:0;border-top-left-radius:0;border-top:0}.paykka-card-checkout-address-field__last-item .paykka-card-checkout-input__input-wrapper:active,.paykka-card-checkout-address-field__last-item .paykka-card-checkout-input__input-wrapper--focus,.paykka-card-checkout-address-field__last-item .paykka-card-checkout-input__input-wrapper:focus{border-top:1px solid var(--paykka-card-checkout-input-color, #4F43DF);box-shadow:0 0 0 1px var(--paykka-card-checkout-input-color, #4F43DF)}.paykka-card-checkout-form-item{font-size:16px}.paykka-card-checkout-form-item__label{margin-bottom:8px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1);-webkit-user-select:none;user-select:none}@media (min-width: 480px){.paykka-card-checkout-form-item__label{margin-bottom:10px}}.paykka-card-checkout-form-item__error-text{margin-top:4px;color:#f53f3f;font-size:14px}.paykka-card-checkout-input{position:relative;box-sizing:border-box;font-size:16px}.paykka-card-checkout-input__input-wrapper{display:flex;align-items:center;height:44px;width:100%;border-radius:8px;border:1px solid #E1E1E5;transition:border .2s cubic-bezier(.4,0,.2,1),box-shadow .2s cubic-bezier(.4,0,.2,1);caret-color:var(--paykka-card-checkout-input-color, #4F43DF) .paykka-card-checkout-input__input-wrapper --success;caret-color-border-bottom:1px solid #00B42A}.paykka-card-checkout-input__input-wrapper--error{border:1px solid #F53F3F}.paykka-card-checkout-input__input-wrapper:active,.paykka-card-checkout-input__input-wrapper--focus,.paykka-card-checkout-input__input-wrapper:focus{border:1px solid var(--paykka-card-checkout-input-color, #4F43DF);box-shadow:0 0 0 2px var(--paykka-card-checkout-input-color, #4F43DF)}.paykka-card-checkout-input__input-wrapper-disabled{cursor:not-allowed;background:#f5f5f7}.paykka-card-checkout-input__input-wrapper-disabled:active,.paykka-card-checkout-input__input-wrapper-disabled--focus,.paykka-card-checkout-input__input-wrapper-disabled:focus{border:1px solid #F5F5F7;box-shadow:0 0 0 2px #f5f5f7}.paykka-card-checkout-input__input{outline:none;border:none;height:100%;width:100%;border-radius:12px;caret-color:var(--paykka-card-checkout-input-color, #4F43DF);font-size:16px;padding-left:12px}.paykka-card-checkout-input__input::placeholder{color:#c2c2c2}.paykka-card-checkout-input__right-icon{padding-right:12px;display:flex;align-items:center;flex-shrink:0;margin-left:12px}.paykka-card-checkout-select__wrapper{width:100%;position:relative;cursor:pointer}.paykka-card-checkout-select__render-label{position:absolute;top:0;line-height:44px;height:44px;padding:0 16px;display:flex}.paykka-card-checkout-select__render-label--placeholder{color:#c2c2c2}.paykka-card-checkout-select__render-label--hidden{visibility:hidden}.paykka-card-checkout-select__menu{margin-top:4px;width:100%;max-height:260px;background:#fff;box-shadow:0 4px 14px #0000001a;border-radius:4px;border:1px solid #EBEBEF;overflow-y:auto;z-index:999;position:absolute}.paykka-card-checkout-select__menu-item{padding:6px 12px;line-height:32px;color:#626266;cursor:pointer;display:flex;justify-content:space-between}.paykka-card-checkout-select__menu-item:hover,.paykka-card-checkout-select__menu-item:active,.paykka-card-checkout-select__menu-item--selected,.paykka-card-checkout-select__menu-item:focus{color:#1f1f1f;background:#f3f3f5}.paykka-card-checkout-select__menu-item-icon{margin-left:10px;display:flex;align-items:center}.paykka-card-checkout-select__menu-no-data{height:200px;display:flex;justify-content:center;align-items:center;color:#c2c2c2}.paykka-card-checkout-info{display:flex;align-items:center;padding:10px 14px;border-radius:4px}.paykka-card-checkout-info--error{background-color:#ffece8}.paykka-card-checkout-info__icon{margin-right:8px;height:1.3em;display:flex;align-items:center}.paykka-card-checkout-info__content{text-align:justify;word-break:break-all}.paykka-card-checkout-recurring-tip{display:flex;color:#a9a9a9}.paykka-card-checkout-recurring-tip__icon{width:20px;display:flex;padding-top:4px;padding-right:4px}.paykka-card-checkout-submit-button--success{opacity:1!important;background-color:#00b42a!important}.paykka-card-checkout-submit-button__text{line-height:1}.paykka-card-checkout-submit-button__text--not-verified{color:#fff9}.paykka-card-checkout-button{display:flex;align-items:center;justify-content:center;width:100%;height:44px;padding:0 14px;border-radius:8px;border:0;background-color:var(--paykka-card-checkout-button-bg-color, #4F43DF);color:var(--paykka-card-checkout-button-text-color, #fff);font-size:16px;cursor:pointer;text-decoration:none;transition:background-color .3s cubic-bezier(.4,0,.2,1)}.paykka-card-checkout-button:not(.paykka-card-checkout-button--loading).paykka-card-checkout-button:not(.paykka-card-checkout-button--disabled).paykka-card-checkout-button:not(.paykka-card-checkout-button--dashed):hover{background-color:var(--paykka-card-checkout-button-bg-color-hover, #3f33bb)}.paykka-card-checkout-button:not(.paykka-card-checkout-button--loading).paykka-card-checkout-button:not(.paykka-card-checkout-button--disabled).paykka-card-checkout-button:not(.paykka-card-checkout-button--dashed):active{background-color:var(--paykka-card-checkout-button-bg-color-active, #312498)}.paykka-card-checkout-button--loading{cursor:wait}.paykka-card-checkout-button--disabled{cursor:not-allowed;opacity:.5}.paykka-card-checkout-button--dashed{border:1px dashed #DFDFE5;color:#1f1f1f;background-color:transparent}.paykka-card-checkout-button__icon{display:flex;align-items:center;margin-right:12px}.paykka-card-checkout-loading-check{display:inline-flex;align-items:center;overflow:hidden;--circle-transition-time: .3s;--check-dashoffset: 50}.paykka-card-checkout-loading-check__circle{transition:stroke-dasharray var(--circle-transition-time) linear}.paykka-card-checkout-loading-check__circle--loading{animation:spin 1s infinite linear;transform-origin:center}.paykka-card-checkout-loading-check__check{stroke-dasharray:var(--check-dashoffset);stroke-dashoffset:var(--check-dashoffset);animation:tick .5s ease-out;animation-fill-mode:forwards;animation-delay:var(--circle-transition-time)}@keyframes tick{0%{stroke-dashoffset:var(--check-dashoffset)}to{stroke-dashoffset:0}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.paykka-card-checkout-card{min-width:280px}.paykka-card-checkout-card__field{margin-bottom:24px}.paykka-card-checkout-card__center{display:flex;justify-content:space-between}.paykka-card-checkout-card__center>div{width:calc((100% - 20px)/2);transition:width .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-card__center>div{width:calc((100% - 32px)/2)}}.paykka-card-checkout-card__holder-name{padding-bottom:16px}@media (min-width: 480px){.paykka-card-checkout-card__holder-name{padding-bottom:20px}}.paykka-card-checkout-card__button{margin-top:16px;transition:margin-top .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-card__button{margin-top:20px}}.paykka-card-checkout-card__card-brands{margin-top:8px}.paykka-card-checkout-card__card-number-wrapper{position:relative}.paykka-card-checkout-card__change-box{display:flex;align-items:center;color:#4f43df;font-size:14px;position:absolute;top:0;right:0;cursor:pointer}.paykka-card-checkout-card__card-selector-wrapper{display:flex;justify-content:space-between}.paykka-card-checkout-card-brands{display:flex;flex-wrap:wrap;gap:6px}.paykka-card-checkout-card-brands__more{line-height:32px;font-size:13px;color:#687282}.paykka-card-checkout-card-selector__action{padding:8px 12px}.paykka-card-checkout-card-selector__label{display:flex;align-items:center}.paykka-card-checkout-card-selector__card-no{margin-left:12px}.paykka-card-checkout-card-selector__change{display:flex;align-items:center;color:#4f43df;font-size:14px}.paykka-card-checkout-card-no__wrapper{display:flex;align-items:center}.paykka-card-checkout-card-no__dot{width:4px;height:4px;background:currentColor;margin-right:4px;border-radius:50%}.paykka-card-checkout-card-no__card-no{margin-left:4px}.paykka-card-checkout-check-box{display:inline-flex;align-items:center;font-size:14px;background-color:transparent;cursor:pointer}.paykka-card-checkout-check-box:hover .paykka-card-checkout-check-box__inner{border-color:#4f43df}.paykka-card-checkout-check-box--checked .paykka-card-checkout-check-box__inner{border-color:#4f43df;background-color:#4f43df}.paykka-card-checkout-check-box__inner{width:14px;height:14px;border:1px solid #E1E1E5;border-radius:2px;margin-right:8px;transition:border-color .2s cubic-bezier(.4,0,.2,1);display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}@media (min-width: 480px){.paykka-card-checkout-wechat-pay__email{padding-bottom:20px}}.paykka-card-checkout-wechat-pay__error{margin-top:16px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-wechat-pay__error{margin-top:20px}}.paykka-card-checkout-wechat-pay__button{margin-top:16px;transition:margin-top .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-wechat-pay__button{margin-top:20px}}.paykka-card-checkout-apple-pay__error{margin-bottom:16px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-apple-pay__error{margin-bottom:20px}}.paykka-card-checkout-apple-pay__button{width:100%;display:flex;align-items:center;justify-content:center;height:44px;--apple-pay-button-width: 100%;--apple-pay-button-height: 44px;--apple-pay-button-border-radius: 8px;--apple-pay-button-padding: 0px 0px;--apple-pay-button-box-sizing: border-box}.paykka-card-checkout-google-pay__error{margin-bottom:16px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-google-pay__error{margin-bottom:20px}}::-webkit-scrollbar{height:6px;width:6px}::-webkit-scrollbar-thumb{background-color:#00000040;border-radius:4px}::-webkit-scrollbar-button{display:none!important}::-moz-scrollbar-button{display:none!important}.paykka-card-checkout-sepa{min-width:280px}.paykka-card-checkout-sepa__field{margin-bottom:24px}.paykka-card-checkout-sepa__holder-name{padding-bottom:16px}@media (min-width: 480px){.paykka-card-checkout-sepa__holder-name{padding-bottom:20px}}.paykka-card-checkout-sepa__button{margin-top:16px;transition:margin-top .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-sepa__button{margin-top:20px}}
1
+ .paykka-card-checkout,.paykka-card-checkout *{box-sizing:border-box}@media (min-width: 480px){.paykka-card-checkout-ali-pay__email{padding-bottom:20px}}.paykka-card-checkout-ali-pay__error{margin-top:16px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-ali-pay__error{margin-top:20px}}.paykka-card-checkout-ali-pay__button{margin-top:16px;transition:margin-top .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-ali-pay__button{margin-top:20px}}.paykka-card-checkout-address-field__first-item .paykka-card-checkout-input__input-wrapper{padding:8px 0;border-bottom-right-radius:0;border-bottom-left-radius:0}.paykka-card-checkout-address-field__mid-item .paykka-card-checkout-input__input-wrapper{padding:8px 0;border-radius:0;border-top:0}.paykka-card-checkout-address-field__mid-item .paykka-card-checkout-input__input-wrapper:active,.paykka-card-checkout-address-field__mid-item .paykka-card-checkout-input__input-wrapper--focus,.paykka-card-checkout-address-field__mid-item .paykka-card-checkout-input__input-wrapper:focus{border-top:1px solid var(--paykka-card-checkout-input-color, #4F43DF);box-shadow:0 0 0 1px var(--paykka-card-checkout-input-color, #4F43DF)}.paykka-card-checkout-address-field__last-item .paykka-card-checkout-input__input-wrapper{padding:8px 0;border-top-right-radius:0;border-top-left-radius:0;border-top:0}.paykka-card-checkout-address-field__last-item .paykka-card-checkout-input__input-wrapper:active,.paykka-card-checkout-address-field__last-item .paykka-card-checkout-input__input-wrapper--focus,.paykka-card-checkout-address-field__last-item .paykka-card-checkout-input__input-wrapper:focus{border-top:1px solid var(--paykka-card-checkout-input-color, #4F43DF);box-shadow:0 0 0 1px var(--paykka-card-checkout-input-color, #4F43DF)}.paykka-card-checkout-form-item{font-size:16px}.paykka-card-checkout-form-item__label{margin-bottom:8px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1);-webkit-user-select:none;user-select:none}@media (min-width: 480px){.paykka-card-checkout-form-item__label{margin-bottom:10px}}.paykka-card-checkout-form-item__error-text{margin-top:4px;color:#f53f3f;font-size:14px}.paykka-card-checkout-input{position:relative;box-sizing:border-box;font-size:16px}.paykka-card-checkout-input__input-wrapper{display:flex;align-items:center;height:44px;width:100%;border-radius:8px;border:1px solid #E1E1E5;transition:border .2s cubic-bezier(.4,0,.2,1),box-shadow .2s cubic-bezier(.4,0,.2,1);caret-color:var(--paykka-card-checkout-input-color, #4F43DF) .paykka-card-checkout-input__input-wrapper --success;caret-color-border-bottom:1px solid #00B42A}.paykka-card-checkout-input__input-wrapper--error{border:1px solid #F53F3F}.paykka-card-checkout-input__input-wrapper:active,.paykka-card-checkout-input__input-wrapper--focus,.paykka-card-checkout-input__input-wrapper:focus{border:1px solid var(--paykka-card-checkout-input-color, #4F43DF);box-shadow:0 0 0 2px var(--paykka-card-checkout-input-color, #4F43DF)}.paykka-card-checkout-input__input-wrapper-disabled{cursor:not-allowed;background:#f5f5f7}.paykka-card-checkout-input__input-wrapper-disabled:active,.paykka-card-checkout-input__input-wrapper-disabled--focus,.paykka-card-checkout-input__input-wrapper-disabled:focus{border:1px solid #F5F5F7;box-shadow:0 0 0 2px #f5f5f7}.paykka-card-checkout-input__input{outline:none;border:none;height:100%;width:100%;border-radius:8px;caret-color:var(--paykka-card-checkout-input-color, #4F43DF);font-size:16px;padding-left:12px;background-color:transparent}.paykka-card-checkout-input__input::placeholder{color:#c2c2c2}.paykka-card-checkout-input__right-icon{padding-right:12px;display:flex;align-items:center;flex-shrink:0;margin-left:12px}.paykka-card-checkout-input__left-icon{padding-left:12px;display:flex;align-items:center;flex-shrink:0;margin-right:12px}.paykka-card-checkout-select__wrapper{width:100%;position:relative;cursor:pointer}.paykka-card-checkout-select__render-label{position:absolute;top:0;line-height:44px;height:44px;padding:0 16px;display:flex}.paykka-card-checkout-select__render-label--placeholder{color:#c2c2c2}.paykka-card-checkout-select__render-label--hidden{visibility:hidden}.paykka-card-checkout-select__menu{margin-top:4px;width:100%;max-height:260px;background:#fff;box-shadow:0 4px 14px #0000001a;border-radius:4px;border:1px solid #EBEBEF;overflow-y:auto;z-index:999;position:absolute}.paykka-card-checkout-select__menu-item{padding:6px 12px;line-height:32px;color:#626266;cursor:pointer;display:flex;justify-content:space-between}.paykka-card-checkout-select__menu-item:hover,.paykka-card-checkout-select__menu-item:active,.paykka-card-checkout-select__menu-item--selected,.paykka-card-checkout-select__menu-item:focus{color:#1f1f1f;background:#f3f3f5}.paykka-card-checkout-select__menu-item-icon{margin-left:10px;display:flex;align-items:center}.paykka-card-checkout-select__menu-no-data{height:200px;display:flex;justify-content:center;align-items:center;color:#c2c2c2}.paykka-card-checkout-info{display:flex;align-items:center;padding:10px 14px;border-radius:4px}.paykka-card-checkout-info--error{background-color:#ffece8}.paykka-card-checkout-info__icon{margin-right:8px;height:1.3em;display:flex;align-items:center}.paykka-card-checkout-info__content{text-align:justify;word-break:break-all}.paykka-card-checkout-recurring-tip{display:flex;color:#a9a9a9}.paykka-card-checkout-recurring-tip__icon{width:20px;display:flex;padding-top:4px;padding-right:4px}.paykka-card-checkout-submit-button--success{opacity:1!important;background-color:#00b42a!important}.paykka-card-checkout-submit-button__text{line-height:1}.paykka-card-checkout-submit-button__text--not-verified{color:#fff9}.paykka-card-checkout-button{display:flex;align-items:center;justify-content:center;width:100%;height:44px;padding:0 14px;border-radius:8px;border:0;background-color:var(--paykka-card-checkout-button-bg-color, #4F43DF);color:var(--paykka-card-checkout-button-text-color, #fff);font-size:16px;cursor:pointer;text-decoration:none;transition:background-color .3s cubic-bezier(.4,0,.2,1)}.paykka-card-checkout-button:not(.paykka-card-checkout-button--loading).paykka-card-checkout-button:not(.paykka-card-checkout-button--disabled).paykka-card-checkout-button:not(.paykka-card-checkout-button--dashed):hover{background-color:var(--paykka-card-checkout-button-bg-color-hover, #3f33bb)}.paykka-card-checkout-button:not(.paykka-card-checkout-button--loading).paykka-card-checkout-button:not(.paykka-card-checkout-button--disabled).paykka-card-checkout-button:not(.paykka-card-checkout-button--dashed):active{background-color:var(--paykka-card-checkout-button-bg-color-active, #312498)}.paykka-card-checkout-button--loading{cursor:wait}.paykka-card-checkout-button--disabled{cursor:not-allowed;opacity:.5}.paykka-card-checkout-button--dashed{border:1px dashed #DFDFE5;color:#1f1f1f;background-color:transparent}.paykka-card-checkout-button__icon{display:flex;align-items:center;margin-right:12px}.paykka-card-checkout-loading-check{display:inline-flex;align-items:center;overflow:hidden;--circle-transition-time: .3s;--check-dashoffset: 50}.paykka-card-checkout-loading-check__circle{transition:stroke-dasharray var(--circle-transition-time) linear}.paykka-card-checkout-loading-check__circle--loading{animation:spin 1s infinite linear;transform-origin:center}.paykka-card-checkout-loading-check__check{stroke-dasharray:var(--check-dashoffset);stroke-dashoffset:var(--check-dashoffset);animation:tick .5s ease-out;animation-fill-mode:forwards;animation-delay:var(--circle-transition-time)}@keyframes tick{0%{stroke-dashoffset:var(--check-dashoffset)}to{stroke-dashoffset:0}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.paykka-card-checkout-card{min-width:280px}.paykka-card-checkout-card__field{margin-bottom:16px}@media (min-width: 480px){.paykka-card-checkout-card__field{margin-bottom:20px}}.paykka-card-checkout-card__center{display:flex;justify-content:space-between}.paykka-card-checkout-card__center>div{width:calc((100% - 20px)/2);transition:width .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-card__center>div{width:calc((100% - 32px)/2)}}.paykka-card-checkout-card__card-info{margin-bottom:16px}@media (min-width: 480px){.paykka-card-checkout-card__card-info{margin-bottom:20px}}.paykka-card-checkout-card__holder-name{margin-bottom:16px}@media (min-width: 480px){.paykka-card-checkout-card__holder-name{margin-bottom:20px}}.paykka-card-checkout-card__button{margin-top:16px;transition:margin-top .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-card__button{margin-top:20px}}.paykka-card-checkout-card__card-brands{margin-top:8px}.paykka-card-checkout-card__card-number-wrapper{position:relative}.paykka-card-checkout-card__change-box{display:flex;align-items:center;color:#4f43df;font-size:14px;position:absolute;top:0;right:0;cursor:pointer}.paykka-card-checkout-card__card-selector-wrapper{display:flex;justify-content:space-between}.paykka-card-checkout-card__address{margin-bottom:16px}@media (min-width: 480px){.paykka-card-checkout-card__address{margin-bottom:20px}}.paykka-card-checkout-card__store-checkbox{margin-top:16px}@media (min-width: 480px){.paykka-card-checkout-card__store-checkbox{margin-top:20px}}.paykka-card-checkout-card-brands{display:flex;flex-wrap:wrap;gap:6px}.paykka-card-checkout-card-brands__more{line-height:32px;font-size:13px;color:#687282}.paykka-card-checkout-card-selector__action{padding:8px 12px}.paykka-card-checkout-card-selector__label{display:flex;align-items:center}.paykka-card-checkout-card-selector__card-no{margin-left:12px}.paykka-card-checkout-card-selector__change{display:flex;align-items:center;color:#4f43df;font-size:14px}.paykka-card-checkout-card-no__wrapper{display:flex;align-items:center}.paykka-card-checkout-card-no__dot{width:4px;height:4px;background:currentColor;margin-right:4px;border-radius:50%}.paykka-card-checkout-card-no__card-no{margin-left:4px}.paykka-card-checkout-check-box{display:inline-flex;align-items:center;font-size:14px;background-color:transparent;cursor:pointer}.paykka-card-checkout-check-box:hover .paykka-card-checkout-check-box__inner{border-color:#4f43df}.paykka-card-checkout-check-box--checked .paykka-card-checkout-check-box__inner{border-color:#4f43df;background-color:#4f43df}.paykka-card-checkout-check-box__inner{width:14px;height:14px;border:1px solid #E1E1E5;border-radius:2px;margin-right:8px;transition:border-color .2s cubic-bezier(.4,0,.2,1);display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}.paykka-card-checkout-modal{position:fixed;left:0;right:0;top:0;bottom:0;z-index:9999;display:flex;flex-direction:column;align-items:center;justify-content:center}.paykka-card-checkout-modal__mask{position:fixed;left:0;right:0;top:0;bottom:0;background-color:#0006}.paykka-card-checkout-modal__content{position:relative;z-index:9999;border-radius:8px;background-color:#fff;box-shadow:0 8px 16px -8px #00000014,0 12px 32px #0000000f,0 16px 48px 16px #0000000a;display:flex;flex-direction:column}.paykka-card-checkout-modal__close{cursor:pointer;right:0;position:absolute;transform:translateY(-150%);color:#d2d2d2}.paykka-card-checkout-modal__close:hover{color:#fff}.paykka-card-checkout-modal__body{flex:1;padding:36px 28px 24px}.paykka-card-checkout-three-ds-auth__content{height:100%}.paykka-card-checkout-three-ds-auth__last-three-ds{width:100%;height:100%;display:flex;align-items:center;justify-content:center;flex-direction:column}.paykka-card-checkout-three-ds-auth__last-three-ds-title{margin-top:20px;margin-bottom:40px;color:#1f1f1f;font-size:20px;font-weight:700;text-align:center}.paykka-card-checkout-combined-card-info{width:100%;height:100%;display:flex}.paykka-card-checkout-combined-card-info__card-number{flex:1}.paykka-card-checkout-combined-card-info__expire-date{width:100px}.paykka-card-checkout-combined-card-info__cvv{width:60px}.paykka-card-checkout-combined-card-info__blank-icon{width:16px;height:16px}@media (min-width: 480px){.paykka-card-checkout-wechat-pay__email{padding-bottom:20px}}.paykka-card-checkout-wechat-pay__error{margin-top:16px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-wechat-pay__error{margin-top:20px}}.paykka-card-checkout-wechat-pay__button{margin-top:16px;transition:margin-top .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-wechat-pay__button{margin-top:20px}}.paykka-card-checkout-apple-pay__error{margin-bottom:16px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-apple-pay__error{margin-bottom:20px}}.paykka-card-checkout-apple-pay__button{width:100%;display:flex;align-items:center;justify-content:center;height:44px;--apple-pay-button-width: 100%;--apple-pay-button-height: 44px;--apple-pay-button-border-radius: 8px;--apple-pay-button-padding: 0px 0px;--apple-pay-button-box-sizing: border-box}.paykka-card-checkout-google-pay__error{margin-bottom:16px;transition:margin-bottom .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-google-pay__error{margin-bottom:20px}}::-webkit-scrollbar{height:6px;width:6px}::-webkit-scrollbar-thumb{background-color:#00000040;border-radius:4px}::-webkit-scrollbar-button{display:none!important}::-moz-scrollbar-button{display:none!important}.paykka-card-checkout-sepa{min-width:280px}.paykka-card-checkout-sepa__field{margin-bottom:24px}.paykka-card-checkout-sepa__holder-name{padding-bottom:16px}@media (min-width: 480px){.paykka-card-checkout-sepa__holder-name{padding-bottom:20px}}.paykka-card-checkout-sepa__button{margin-top:16px;transition:margin-top .1s cubic-bezier(.4,0,.2,1)}@media (min-width: 480px){.paykka-card-checkout-sepa__button{margin-top:20px}}
@@ -1,2 +1,3 @@
1
1
  import type { CheckoutRes } from './type';
2
+ export declare function formatPaymentMethodInfo(paymentMethods?: Recordable[]): Pick<CheckoutRes, 'paymentMethod' | 'channelParams'>;
2
3
  export declare function checkoutMap(res?: Recordable): CheckoutRes;
@@ -1,3 +1,4 @@
1
+ import type { SessionMode } from '../../../constant';
1
2
  import type { Amount } from '../type';
2
3
  export interface CheckoutTheme {
3
4
  merchantName: string;
@@ -46,7 +47,7 @@ export interface CheckoutRes {
46
47
  status: 'PROCESSING' | 'SUCCESS' | 'EXPIRED';
47
48
  transAmount: Amount;
48
49
  expireTime: string;
49
- sessionMode: 'HOST' | 'EMBEDDED';
50
+ sessionMode: `${SessionMode}`;
50
51
  merchantName: string;
51
52
  returnUrl: string;
52
53
  locale?: string;
@@ -57,6 +58,18 @@ export interface CheckoutRes {
57
58
  channelParams?: ChannelParams;
58
59
  tokens?: CardTokenInfo[];
59
60
  storePaymentMethod?: boolean;
61
+ field: FieldStatusConfig;
62
+ country?: string;
63
+ }
64
+ export interface FieldStatusConfig {
65
+ holderName: FieldStatus;
66
+ email: FieldStatus;
67
+ address: FieldStatus;
68
+ }
69
+ export interface FieldStatus {
70
+ show: boolean;
71
+ required: boolean;
72
+ disabled?: boolean;
60
73
  }
61
74
  export interface QueryCheckoutParams {
62
75
  sessionId: string;
@@ -0,0 +1,6 @@
1
+ import { type RequestOptions } from '../../http';
2
+ import type { EncryptCardReq, EncryptCardRes, VerifyClientKeyRes } from './type';
3
+ /** 校验 client key 是否有效 */
4
+ declare const verifyClientKey: (clientKey: string, merchantId: string, options?: RequestOptions) => Promise<VerifyClientKeyRes | null>;
5
+ declare const encryptCard: (card: EncryptCardReq, options?: RequestOptions) => Promise<EncryptCardRes>;
6
+ export { verifyClientKey, encryptCard };
@@ -0,0 +1,31 @@
1
+ import type { CardBrand } from '../../../types';
2
+ export interface VerifyClientKeyRes {
3
+ brands: CardBrand[];
4
+ }
5
+ export interface EncryptCardReq {
6
+ clientKey: string;
7
+ merchantId: string;
8
+ expYear: string;
9
+ expMonth: string;
10
+ cardNo: string;
11
+ cvv: string;
12
+ }
13
+ export interface EncryptCardRes {
14
+ /** 加密后的卡号 */
15
+ encryptedCardNumber: string;
16
+ /** 加密后的 CVV */
17
+ encryptedCVV: string;
18
+ /** 加密后的有效期年份 */
19
+ encryptedExpireYear: string;
20
+ /** 加密后的有效期月份 */
21
+ encryptedExpireMonth: string;
22
+ /** 卡信息 */
23
+ cardInfo: {
24
+ /** 卡 bin */
25
+ bin: string;
26
+ /** 卡品牌 */
27
+ brand: CardBrand;
28
+ /** 卡号后 4 位 */
29
+ last4: string;
30
+ };
31
+ }
@@ -1,11 +1,11 @@
1
1
  export declare function getBrowserParams(params?: {
2
- radarId?: string;
2
+ fraudDetectionId?: string;
3
3
  }): Promise<{
4
4
  user_agent: string;
5
5
  color_depth: number;
6
6
  language: string;
7
7
  java_enabled: boolean;
8
- device_type: StringUnion<"MOBILE" | "TABLET" | "PC" | "OTHER" | "POS">;
8
+ device_type: StringUnion<"PC" | "OTHER" | "MOBILE" | "TABLET" | "POS">;
9
9
  timezone_offset: string;
10
10
  screen_height: number;
11
11
  screen_width: number;
@@ -13,5 +13,5 @@ export declare function getBrowserParams(params?: {
13
13
  device_os: string;
14
14
  device_finger_print_id: string;
15
15
  terminal_type: string;
16
- paykka_radar_id: string | undefined;
16
+ fraud_detection_id: string | undefined;
17
17
  }>;
@@ -1,6 +1,7 @@
1
1
  export interface AddressFieldProps {
2
2
  value: Address;
3
3
  onAddressChange: (value: Address) => void;
4
+ country?: string;
4
5
  }
5
6
  export interface Address {
6
7
  country: string;
@@ -1,11 +1,11 @@
1
1
  import type { PayRes } from '../../api';
2
+ import type { PayKKaError } from '../../core';
3
+ import type { CoreProps } from '../../types';
2
4
  import type { FormValidateError } from '../internal/Form';
3
- export interface AliPayProps {
4
- sessionId: string;
5
- clientKey?: string;
5
+ export interface AliPayProps extends CoreProps {
6
6
  onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
7
7
  onSuccess?: (...args: any[]) => void;
8
- onError?: (error: any) => void;
8
+ onError?: (error: PayKKaError) => void;
9
9
  onTimeout?: (source: 'retry' | 'channel') => void;
10
10
  onExpired?: () => void;
11
11
  onSubmitResponse?: (payRes: PayRes) => void;
@@ -1,15 +1,27 @@
1
- import type { PayRes } from '../../api';
2
- export interface ApplePayProps {
3
- sessionId: string;
4
- clientKey?: string;
1
+ import type { PayKKaError } from '../../core';
2
+ import type { CoreProps, PaymentSuccessData } from '../../types';
3
+ export interface ApplePayProps extends CoreProps {
4
+ /** 支付授权成功后触发 */
5
5
  onSubmit?: () => void;
6
- onSuccess?: (...args: any[]) => void;
7
- onError?: (error: any) => void;
6
+ /** 支付成功后触发 */
7
+ onSuccess?: (data: PaymentSuccessData) => void;
8
+ /** SDK 加载回调,status 为 true 表示加载成功,false 表示加载失败 */
9
+ onLoad?: (status: boolean) => void;
10
+ /** 支付失败时触发 */
11
+ onError?: (error: PayKKaError) => void;
12
+ /** 支付超时时触发 */
8
13
  onTimeout?: (source: 'retry' | 'channel') => void;
14
+ /** 收银台已过期时触发 */
9
15
  onExpired?: () => void;
10
- onSubmitResponse?: (payRes: PayRes) => void;
16
+ /** 交易被风控拦截时触发 */
11
17
  onAuthorized?: () => void;
18
+ /** 支付取消时触发 */
12
19
  onCancel?: () => void;
20
+ /** Apple Pay 按钮是否可用 */
21
+ onCanUse?: (canUse: boolean) => void;
22
+ /**
23
+ * 内部使用
24
+ */
13
25
  /** 点击 ApplePay 按钮 */
14
26
  onBtnClick?: () => void;
15
27
  }
@@ -0,0 +1,3 @@
1
+ /** 动态加载ApplePay */
2
+ export declare const loadApplePayJS: (onload?: () => void, onerror?: () => void) => void;
3
+ export declare function applePayEnv(id?: string): Promise<boolean | undefined>;
@@ -1,18 +1,76 @@
1
+ import type { PayKKaError } from '../../core';
2
+ import type { CoreProps, ElementStylesConfig, PaymentSuccessData } from '../../types';
1
3
  import type { FormValidateError } from '../internal/Form';
2
- export interface CardProps {
3
- sessionId: string;
4
- clientKey?: string;
4
+ export interface CardProps extends CoreProps {
5
+ /** 定义卡敏感信息表单布局展示,split 为分割布局,combine 为合并布局 */
6
+ cardInfoLayout?: CardInfoLayout;
7
+ /**
8
+ * 是否展示邮箱
9
+ * 若配置 true 但创建收银台时已经传了,就展示禁用状态。
10
+ * 若配置 false 但创建收银台时未传,依旧会展示该输入框。
11
+ */
12
+ showEmail?: boolean;
13
+ /**
14
+ * 是否展示邮箱
15
+ * 若配置 true 但创建收银台时已经传了,还是展示,先不禁用。
16
+ * 若配置 false 但创建收银台时未传,依旧会展示该输入框。
17
+ */
18
+ showAddress?: boolean;
19
+ /** 是否在卡号输入框下展示收银台支持的发卡行图标 */
5
20
  showCardBrands?: boolean;
21
+ /**
22
+ * @internal
23
+ * 是否展示持卡人姓名,目前一定展示
24
+ */
25
+ styles?: ElementStylesConfig;
26
+ /**
27
+ * @internal
28
+ * 是否展示持卡人姓名,目前一定展示
29
+ */
30
+ showHolderName?: boolean;
31
+ /**
32
+ * @internal
33
+ * 是否展示3ds modal,默认为 true,配置 false 则抛出 onThreeDS 回调
34
+ */
35
+ enable3DSModal?: boolean;
36
+ /** 提交表单时触发 */
6
37
  onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
7
- onSuccess?: (returnUrl?: string) => void;
8
- onError?: (error: any) => void;
38
+ /** 支付成功后触发 */
39
+ onSuccess?: (data: PaymentSuccessData) => void;
40
+ /** 支付失败时触发 */
41
+ onError?: (error: PayKKaError) => void;
42
+ /** 支付超时时触发 */
9
43
  onTimeout?: () => void;
10
- onAuthorized?: () => void;
44
+ /** 收银台已过期时触发 */
11
45
  onExpired?: () => void;
46
+ /**
47
+ * @internal
48
+ * 交易被风控拦截时触发
49
+ */
50
+ onAuthorized?: () => void;
51
+ /**
52
+ * @internal
53
+ * 交易需要 3DS 验证时触发,url 为 3DS 验证链接,incomplete 为 false 表示目前要开始进行 3DS 验证,为 true 表示上一次 3DS 验证还未完成
54
+ */
12
55
  onThreeDS?: (url: string, incomplete: boolean) => void;
13
56
  }
14
57
  export interface CardRef {
58
+ /** 不展示支付按钮时,可调用该方法进行支付 */
59
+ payment: () => void;
60
+ /**
61
+ * @internal
62
+ * 3DS 验证流程结束后可调用该方法轮询收银台支付状态
63
+ */
15
64
  checkThreeDS: () => void;
65
+ /**
66
+ * @internal
67
+ * 进行表单切换时更新已填的地址信息
68
+ */
16
69
  updateAddress: () => void;
70
+ /**
71
+ * @internal
72
+ * 进行表单切换时更新已填的邮箱信息
73
+ */
17
74
  updateEmail: () => void;
18
75
  }
76
+ export type CardInfoLayout = 'split' | 'combine';
@@ -2,6 +2,7 @@ import type { FormItemProps, FormValidationStatus } from '../internal/Form';
2
2
  import type { InputProps } from '../internal/Input';
3
3
  export interface CardExpireDateFieldProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput'> {
4
4
  security: boolean;
5
+ showLabel?: boolean;
5
6
  }
6
7
  export interface CardExpireDateFieldRef {
7
8
  focus: () => void;
@@ -1,4 +1,4 @@
1
1
  import type { FormItemProps } from '../internal/Form';
2
2
  import type { InputProps } from '../internal/Input';
3
- export interface CardHolderNameFieldProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput'> {
3
+ export interface CardHolderNameFieldProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput' | 'disabled'> {
4
4
  }