@paykka/card-checkout-ui 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/card-checkout-ui.js +12 -12
  2. package/dist/card-checkout-ui.umd.cjs +12 -12
  3. package/dist/es/api/index.js +0 -2
  4. package/dist/es/api/modules/checkout/index.js +1 -15
  5. package/dist/es/api/modules/checkout/map.js +20 -3
  6. package/dist/es/api/modules/index.js +0 -2
  7. package/dist/es/components/AccountNameField/index.js +0 -3
  8. package/dist/es/components/AddressField/index.js +2 -7
  9. package/dist/es/components/AliPay/index.js +8 -7
  10. package/dist/es/components/ApplePay/index.js +7 -8
  11. package/dist/es/components/Card/index.js +301 -125
  12. package/dist/es/components/CardBrands/index.js +0 -2
  13. package/dist/es/components/CardExpireDateField/index.js +1 -4
  14. package/dist/es/components/CardHolderNameField/index.js +3 -5
  15. package/dist/es/components/CardIBANField/index.js +0 -3
  16. package/dist/es/components/CardNo/index.js +0 -2
  17. package/dist/es/components/CardNumberField/index.js +1 -4
  18. package/dist/es/components/CardSecurityCodeField/index.js +1 -4
  19. package/dist/es/components/CardSelector/index.js +0 -3
  20. package/dist/es/components/CombinedCardInfo/index.js +99 -0
  21. package/dist/es/components/EmailField/EmailField.js +0 -3
  22. package/dist/es/components/EncryptedCard/index.js +35 -75
  23. package/dist/es/components/GooglePay/index.js +62 -28
  24. package/dist/es/components/RecurringTip/index.js +0 -2
  25. package/dist/es/components/SecuredFieldsProvider/index.js +230 -1
  26. package/dist/es/components/SecuredIframe/index.js +3 -1
  27. package/dist/es/components/Sepa/index.js +21 -27
  28. package/dist/es/components/SubmitButton/index.js +0 -2
  29. package/dist/es/components/ThreeDS/index.js +94 -0
  30. package/dist/es/components/WechatPay/index.js +26 -25
  31. package/dist/es/components/index.js +1 -3
  32. package/dist/es/components/internal/Button/Button.js +0 -2
  33. package/dist/es/components/internal/Button/index.js +0 -2
  34. package/dist/es/components/internal/CheckBox/CheckBox.js +0 -2
  35. package/dist/es/components/internal/CheckBox/index.js +0 -2
  36. package/dist/es/components/internal/Form/type.js +0 -2
  37. package/dist/es/components/internal/Info/Info.js +0 -2
  38. package/dist/es/components/internal/Info/index.js +0 -2
  39. package/dist/es/components/internal/Input/Input.js +2 -2
  40. package/dist/es/components/internal/Input/type.js +0 -2
  41. package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -2
  42. package/dist/es/components/internal/LoadingCheck/index.js +0 -2
  43. package/dist/es/components/internal/Modal/Modal.js +40 -0
  44. package/dist/es/components/internal/Modal/modal2.js +1 -0
  45. package/dist/es/components/internal/Select/Select.js +0 -2
  46. package/dist/es/components/internal/Select/SelectMenu.js +0 -2
  47. package/dist/es/components/internal/Select/SelectMenuItem.js +0 -2
  48. package/dist/es/components/internal/icons/Icon3DSFail.js +3 -0
  49. package/dist/es/components/internal/icons/Icon3DSInfo.js +62 -0
  50. package/dist/es/components/internal/icons/Icon3DSSuccess.js +3 -0
  51. package/dist/es/config.js +0 -2
  52. package/dist/es/constant.js +3 -2
  53. package/dist/es/core/PayKKaCheckout.js +96 -42
  54. package/dist/es/core/Session.js +7 -6
  55. package/dist/es/core/environment.js +26 -0
  56. package/dist/es/core/error.js +21 -0
  57. package/dist/es/core/index.js +0 -2
  58. package/dist/es/core/query.js +0 -2
  59. package/dist/es/core.js +34 -34
  60. package/dist/es/hooks/index.js +0 -2
  61. package/dist/es/hooks/useBreakpoints.js +57 -0
  62. package/dist/es/hooks/useI18n.js +1 -2
  63. package/dist/es/hooks/usePayState.js +18 -24
  64. package/dist/es/i18n/index.js +0 -2
  65. package/dist/es/i18n/locales/de-DE.js +11 -1
  66. package/dist/es/i18n/locales/en-GB.js +11 -1
  67. package/dist/es/i18n/locales/es-ES.js +11 -1
  68. package/dist/es/i18n/locales/fr-FR.js +11 -1
  69. package/dist/es/i18n/locales/index.js +8 -6
  70. package/dist/es/i18n/locales/ja-JP.js +11 -1
  71. package/dist/es/i18n/locales/ko-KR.js +11 -1
  72. package/dist/es/i18n/locales/pt-PT.js +11 -1
  73. package/dist/es/i18n/locales/ru-RU.js +11 -1
  74. package/dist/es/i18n/locales/zh-CN.js +11 -1
  75. package/dist/es/i18n/locales/zh-HK.js +11 -1
  76. package/dist/es/i18n/locales/zh-TW.js +11 -1
  77. package/dist/es/i18n/util.js +11 -8
  78. package/dist/es/index.js +4 -2
  79. package/dist/es/style.css +186 -4
  80. package/dist/es/types/message.js +28 -0
  81. package/dist/es/utils/card-brand/brands.js +12 -10
  82. package/dist/es/utils/card-brand/index.js +3 -2
  83. package/dist/es/utils/iframe.js +23 -0
  84. package/dist/es/utils/index.js +0 -1
  85. package/dist/es/utils/style.js +47 -0
  86. package/dist/style.css +1 -1
  87. package/dist/types/api/modules/checkout/type.d.ts +14 -1
  88. package/dist/types/api/modules/get-browser-params.d.ts +1 -1
  89. package/dist/types/components/AddressField/type.d.ts +1 -0
  90. package/dist/types/components/AliPay/type.d.ts +4 -2
  91. package/dist/types/components/ApplePay/type.d.ts +4 -3
  92. package/dist/types/components/Card/type.d.ts +56 -10
  93. package/dist/types/components/CardHolderNameField/type.d.ts +1 -1
  94. package/dist/types/components/CombinedCardInfo/CombinedCardInfo.d.ts +5 -0
  95. package/dist/types/components/CombinedCardInfo/index.d.ts +2 -0
  96. package/dist/types/components/{CombinedEncryptedField → CombinedCardInfo}/type.d.ts +3 -2
  97. package/dist/types/components/GooglePay/type.d.ts +4 -3
  98. package/dist/types/components/SecuredFieldsProvider/index.d.ts +1 -0
  99. package/dist/types/components/SecuredFieldsProvider/type.d.ts +1 -153
  100. package/dist/types/components/SecuredFieldsProvider/utils/index.d.ts +1 -1
  101. package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +2 -1
  102. package/dist/types/components/Sepa/type.d.ts +4 -2
  103. package/dist/types/components/ThreeDS/components/ThreeDSAuth/ThreeDSAuth.d.ts +3 -0
  104. package/dist/types/components/ThreeDS/components/ThreeDSAuth/index.d.ts +2 -0
  105. package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +17 -0
  106. package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +2 -0
  107. package/dist/types/components/ThreeDS/components/ThreeDSIframe/index.d.ts +1 -0
  108. package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -0
  109. package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +5 -0
  110. package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +3 -0
  111. package/dist/types/components/ThreeDS/components/ThreeDSStatus/output.d.ts +1 -0
  112. package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +6 -0
  113. package/dist/types/components/ThreeDS/index.d.ts +1 -0
  114. package/dist/types/components/WechatPay/type.d.ts +4 -2
  115. package/dist/types/components/index.d.ts +1 -1
  116. package/dist/types/components/internal/Input/type.d.ts +1 -0
  117. package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
  118. package/dist/types/components/internal/Loading/index.d.ts +1 -0
  119. package/dist/types/components/internal/Modal/Modal.d.ts +5 -0
  120. package/dist/types/components/internal/Modal/index.d.ts +0 -0
  121. package/dist/types/components/internal/Modal/type.d.ts +20 -0
  122. package/dist/types/components/internal/icons/Icon3DSFail.d.ts +2 -0
  123. package/dist/types/components/internal/icons/Icon3DSInfo.d.ts +2 -0
  124. package/dist/types/components/internal/icons/Icon3DSSuccess.d.ts +2 -0
  125. package/dist/types/components/internal/icons/index.d.ts +3 -0
  126. package/dist/types/constant.d.ts +6 -2
  127. package/dist/types/core/PayKKaCheckout.d.ts +22 -6
  128. package/dist/types/core/Session.d.ts +1 -1
  129. package/dist/types/core/context.d.ts +1 -0
  130. package/dist/types/core/environment.d.ts +4 -0
  131. package/dist/types/core/error.d.ts +16 -0
  132. package/dist/types/core/index.d.ts +1 -0
  133. package/dist/types/hooks/index.d.ts +1 -0
  134. package/dist/types/hooks/useBreakpoints.d.ts +15 -0
  135. package/dist/types/hooks/usePayState.d.ts +3 -6
  136. package/dist/types/i18n/locales/de-DE.d.ts +8 -0
  137. package/dist/types/i18n/locales/en-GB.d.ts +8 -0
  138. package/dist/types/i18n/locales/es-ES.d.ts +8 -0
  139. package/dist/types/i18n/locales/fr-FR.d.ts +8 -0
  140. package/dist/types/i18n/locales/index.d.ts +2 -2
  141. package/dist/types/i18n/locales/ja-JP.d.ts +8 -0
  142. package/dist/types/i18n/locales/ko-KR.d.ts +8 -0
  143. package/dist/types/i18n/locales/pt-PT.d.ts +8 -0
  144. package/dist/types/i18n/locales/ru-RU.d.ts +8 -0
  145. package/dist/types/i18n/locales/zh-CN.d.ts +8 -0
  146. package/dist/types/i18n/locales/zh-HK.d.ts +8 -0
  147. package/dist/types/i18n/locales/zh-TW.d.ts +8 -0
  148. package/dist/types/index.d.ts +1 -1
  149. package/dist/types/types/index.d.ts +39 -8
  150. package/dist/types/types/message.d.ts +170 -0
  151. package/dist/types/utils/card-brand/brands.d.ts +1 -8
  152. package/dist/types/utils/card-brand/index.d.ts +2 -2
  153. package/dist/types/utils/index.d.ts +1 -0
  154. package/dist/types/utils/style.d.ts +12 -0
  155. package/package.json +63 -63
  156. package/dist/es/components/CombinedEncryptedField/index.js +0 -75
  157. package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +0 -268
  158. package/dist/types/components/CombinedEncryptedField/CombinedEncryptedField.d.ts +0 -4
  159. package/dist/types/components/CombinedEncryptedField/index.d.ts +0 -2
  160. /package/dist/types/{components/SecuredFieldsProvider/utils → utils}/iframe.d.ts +0 -0
@@ -1,5 +1,3 @@
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";
@@ -12,23 +12,9 @@ async function queryCheckout({ sessionId, clientKey }, options) {
12
12
  options
13
13
  );
14
14
  }
15
- function getPaymentMethods({ sessionId, clientKey }, options) {
16
- return http.post(
17
- "/session/payment-methods",
18
- {
19
- session_id: sessionId,
20
- client_key: clientKey
21
- },
22
- options
23
- );
24
- }
25
15
  async function getCheckoutInfo({ sessionId, clientKey }, options) {
26
16
  const checkoutInfo = await queryCheckout({ sessionId, clientKey }, options);
27
- let paymentMethods = {};
28
- if (checkoutInfo) {
29
- paymentMethods = await getPaymentMethods({ sessionId, clientKey }, options);
30
- }
31
- return checkoutMap({ ...checkoutInfo, ...paymentMethods });
17
+ return checkoutMap({ ...checkoutInfo, ...checkoutInfo == null ? void 0 : checkoutInfo.support_methods });
32
18
  }
33
19
  let getCheckoutInfoIns;
34
20
  async function onceGetCheckoutInfo({ sessionId, clientKey }, options) {
@@ -34,15 +34,17 @@ function formatPaymentMethodInfo(paymentMethods = []) {
34
34
  }
35
35
  function checkoutMap(res = {}) {
36
36
  var _a, _b, _c;
37
- const { theme, bill, payment_methods } = res;
37
+ const { theme, bill, payment_methods, field } = res;
38
38
  const paymentMethodsInfo = formatPaymentMethodInfo(payment_methods);
39
+ const sessionMode = res.session_mode === "HOST" ? "HOSTED" : res.session_mode;
39
40
  return {
41
+ country: res.country,
40
42
  merchantId: res.merchant_id,
41
43
  sessionId: res.session_id,
42
44
  status: res.status,
43
45
  transAmount: amountMap(res.trans_amount),
44
46
  expireTime: res.expire_time,
45
- sessionMode: res.session_mode,
47
+ sessionMode,
46
48
  merchantName: (_a = res.theme) == null ? void 0 : _a.merchant_name,
47
49
  returnUrl: res.return_url,
48
50
  locale: res.locale,
@@ -60,7 +62,8 @@ function checkoutMap(res = {}) {
60
62
  addressLine1: bill == null ? void 0 : bill.address_line1,
61
63
  addressLine2: bill == null ? void 0 : bill.address_line2,
62
64
  email: bill == null ? void 0 : bill.email,
63
- descriptor: bill == null ? void 0 : bill.descriptor
65
+ descriptor: bill == null ? void 0 : bill.descriptor,
66
+ country: bill == null ? void 0 : bill.country
64
67
  },
65
68
  tokens: (_b = res.tokens) == null ? void 0 : _b.map((card) => ({
66
69
  token: card.token,
@@ -69,6 +72,20 @@ function checkoutMap(res = {}) {
69
72
  billingAddressFilled: card.billing_address_filled
70
73
  })),
71
74
  storePaymentMethod: (_c = res.payment) == null ? void 0 : _c.store_payment_method,
75
+ field: {
76
+ holderName: {
77
+ show: !!(field == null ? void 0 : field.holder_name_display),
78
+ required: !!(field == null ? void 0 : field.holder_name_required)
79
+ },
80
+ email: {
81
+ show: !!(field == null ? void 0 : field.bill_email_display),
82
+ required: !!(field == null ? void 0 : field.bill_email_required)
83
+ },
84
+ address: {
85
+ show: !!(field == null ? void 0 : field.bill_address_display),
86
+ required: !!(field == null ? void 0 : field.bill_address_required)
87
+ }
88
+ },
72
89
  ...paymentMethodsInfo
73
90
  };
74
91
  }
@@ -1,5 +1,3 @@
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";
@@ -2,9 +2,6 @@ import { u } from "../../core.js";
2
2
  import "../../utils/card-brand/brands.js";
3
3
  import "../../utils/system-info/get-browser-info.js";
4
4
  import { useI18n } from "../../hooks/useI18n.js";
5
- import "../../core/context.js";
6
- import "../../i18n/util.js";
7
- import "../../i18n/locales/index.js";
8
5
  import "../internal/Form/type.js";
9
6
  import "../internal/Form/context.js";
10
7
  import { FormItem } from "../internal/Form/FormItem.js";
@@ -4,12 +4,9 @@ import { EAddressType } from "../../constant.js";
4
4
  import { createAddressCore } from "../../core/Address.js";
5
5
  import { useBEM } from "../../hooks/useBEM.js";
6
6
  import { useI18n } from "../../hooks/useI18n.js";
7
- import "../../core/context.js";
8
7
  import { isArray, isNil } from "../../utils/is.js";
9
8
  import "../../utils/card-brand/brands.js";
10
9
  import "../../utils/system-info/get-browser-info.js";
11
- import "../../i18n/util.js";
12
- import "../../i18n/locales/index.js";
13
10
  import "../internal/Form/type.js";
14
11
  import "../internal/Form/context.js";
15
12
  import { FormItem } from "../internal/Form/FormItem.js";
@@ -107,10 +104,8 @@ const AddressField = w((props, ref) => {
107
104
  });
108
105
  }
109
106
  async function getDefaultCountry() {
110
- const language = navigator.language;
111
- const areaCode = language.split("-");
112
- const countryCode = (areaCode == null ? void 0 : areaCode[1]) ?? "US";
113
- onSelectCountry(countryCode);
107
+ const countryCode = props.country;
108
+ onSelectCountry(countryCode || "");
114
109
  onAddressChange({
115
110
  country: addressState.country ?? "",
116
111
  province: addressState.province ?? "",
@@ -7,8 +7,7 @@ import "../../utils/system-info/get-browser-info.js";
7
7
  import { formatAmount } from "../../utils/format.js";
8
8
  import { PaymentType } from "../../constant.js";
9
9
  import { CoreContext } from "../../core/context.js";
10
- import "../../i18n/util.js";
11
- import "../../i18n/locales/index.js";
10
+ import { PayKKaError } from "../../core/error.js";
12
11
  import { createAddressCore } from "../../core/Address.js";
13
12
  import { useBEM } from "../../hooks/useBEM.js";
14
13
  import { usePayState } from "../../hooks/usePayState.js";
@@ -24,9 +23,10 @@ import { RecurringTip } from "../RecurringTip/index.js";
24
23
  import { SubmitButton } from "../SubmitButton/index.js";
25
24
  const { bem } = useBEM("ali-pay");
26
25
  const AliPay = w((props, ref) => {
26
+ const { session } = props;
27
27
  let addressState = createAddressCore();
28
28
  let emailState = createEmailCore();
29
- const { setErrorMsg, i18n, session, errorMsg, sessionReady } = usePayState();
29
+ const { setErrorMsg, i18n, errorMsg, sessionReady } = usePayState(session);
30
30
  const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
31
31
  const formRef = A(null);
32
32
  const [form, setForm] = h({
@@ -131,7 +131,7 @@ const AliPay = w((props, ref) => {
131
131
  },
132
132
  { locale: i18n.locale, timeout }
133
133
  );
134
- const { status, orderStatus, errorMessage } = res;
134
+ const { status, orderStatus, errorMessage, errorCode } = res;
135
135
  !search && ((_a = props.onSubmitResponse) == null ? void 0 : _a.call(props, res));
136
136
  if (status === "PROCESSING") {
137
137
  if (!orderStatus) {
@@ -145,7 +145,7 @@ const AliPay = w((props, ref) => {
145
145
  } else if (orderStatus === "FAILURE") {
146
146
  setErrorMsg(errorMessage);
147
147
  setSubmitButtonStatus("unSubmit");
148
- (_c = props.onError) == null ? void 0 : _c.call(props, "FAILURE");
148
+ (_c = props.onError) == null ? void 0 : _c.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
149
149
  return {
150
150
  end: true
151
151
  };
@@ -188,8 +188,9 @@ const AliPay = w((props, ref) => {
188
188
  return { end: true };
189
189
  }
190
190
  } else {
191
- setErrorMsg(error.i18nKey ? i18n.get(error.i18nKey) : error.message);
192
- (_h = props.onError) == null ? void 0 : _h.call(props, error);
191
+ const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
192
+ setErrorMsg(message);
193
+ (_h = props.onError) == null ? void 0 : _h.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
193
194
  setSubmitButtonStatus("unSubmit");
194
195
  return { end: true };
195
196
  }
@@ -8,8 +8,7 @@ import "../../core/context.js";
8
8
  import "../../utils/card-brand/brands.js";
9
9
  import "../../utils/system-info/get-browser-info.js";
10
10
  import { parseE164, underscoreToUpperCamelCase } from "../../utils/format.js";
11
- import "../../i18n/util.js";
12
- import "../../i18n/locales/index.js";
11
+ import { PayKKaError } from "../../core/error.js";
13
12
  import { usePayState } from "../../hooks/usePayState.js";
14
13
  import { useRetry } from "../../hooks/useRetry.js";
15
14
  import { Info } from "../internal/Info/Info.js";
@@ -44,8 +43,9 @@ async function applePayEnv(id) {
44
43
  }
45
44
  const { bem } = useBEM("apple-pay");
46
45
  const ApplePay = w((props) => {
46
+ const { session } = props;
47
47
  let applePaySession;
48
- const { i18n, session, sessionReady, fraudDetection } = usePayState();
48
+ const { i18n, sessionReady, fraudDetection } = usePayState(session);
49
49
  const [errorMsg, setErrorMsg] = h("");
50
50
  const [showApplePay, setShowApplePay] = h(false);
51
51
  const getPaymentSuccessData = () => ({
@@ -62,7 +62,7 @@ const ApplePay = w((props) => {
62
62
  }
63
63
  loadApplePayJS(
64
64
  async () => {
65
- var _a2, _b, _c, _d, _e;
65
+ var _a2, _b, _c, _d;
66
66
  const envSupported = await applePayEnv(
67
67
  (_c = (_b = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.channelParams) == null ? void 0 : _b.applePay) == null ? void 0 : _c.merchantIdentifier
68
68
  );
@@ -71,7 +71,6 @@ const ApplePay = w((props) => {
71
71
  }
72
72
  setShowApplePay(true);
73
73
  (_d = props.onLoad) == null ? void 0 : _d.call(props, true);
74
- console.log((_e = ApplePaySession.canMakePayments) == null ? void 0 : _e.call(ApplePaySession));
75
74
  },
76
75
  () => {
77
76
  var _a2;
@@ -139,7 +138,7 @@ const ApplePay = w((props) => {
139
138
  { locale: i18n.locale }
140
139
  );
141
140
  }());
142
- const { status, orderStatus, errorMessage } = res;
141
+ const { status, orderStatus, errorMessage, errorCode } = res;
143
142
  if (status === "PROCESSING") {
144
143
  if (orderStatus === "SUCCESS") {
145
144
  applePaySession.completePayment({
@@ -156,7 +155,7 @@ const ApplePay = w((props) => {
156
155
  };
157
156
  } else if (orderStatus === "FAILURE") {
158
157
  setErrorMsg(errorMessage);
159
- (_b = props.onError) == null ? void 0 : _b.call(props, "FAILURE");
158
+ (_b = props.onError) == null ? void 0 : _b.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
160
159
  applePaySession.completePayment({
161
160
  status: 1,
162
161
  errors: [new ApplePayError("unknown", void 0, errorMessage)]
@@ -211,7 +210,7 @@ const ApplePay = w((props) => {
211
210
  } else {
212
211
  const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
213
212
  setErrorMsg(message);
214
- (_g = props.onError) == null ? void 0 : _g.call(props, error);
213
+ (_g = props.onError) == null ? void 0 : _g.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
215
214
  applePaySession.completePayment({
216
215
  status: 1,
217
216
  errors: [new ApplePayError("unknown", void 0, message)]