@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
@@ -1,17 +1,15 @@
1
- import { w, A, h, F, y, q, T, u } from "../../core.js";
1
+ import { w, A, h, F, y, q, T, u, b } from "../../core.js";
2
2
  import { isTimeoutError } from "../../api/http.js";
3
- import { PaymentType, SessionMode, COMMON_CLASS_NAME, PaymentMethod } from "../../constant.js";
3
+ import { PaymentType, SessionMode, COMMON_CLASS_NAME, CardPaymentMethods, PaymentMethod } from "../../constant.js";
4
4
  import { getBrowserParams } from "../../api/modules/get-browser-params.js";
5
5
  import { getCardPayInfo, cardPay } from "../../api/modules/card/index.js";
6
6
  import { CoreContext } from "../../core/context.js";
7
- import { isEmptyObject, isUndefined } from "../../utils/is.js";
8
- import { findCardBrand } from "../../utils/card-brand/index.js";
9
- import "../../utils/system-info/get-browser-info.js";
10
- import { cssVarPrefix, normalizedClass, trimAll, formatAmount } from "../../utils/format.js";
7
+ import { intersection } from "../../utils/index.js";
8
+ import { PayKKaError } from "../../core/error.js";
9
+ import { hidePaymentButton } from "../../config.js";
10
+ import { defaultInputStyleConfig } from "../../types/index.js";
11
11
  import { createAddressCore } from "../../core/Address.js";
12
12
  import { useBEM } from "../../hooks/useBEM.js";
13
- import "../../i18n/util.js";
14
- import "../../i18n/locales/index.js";
15
13
  import { usePayState } from "../../hooks/usePayState.js";
16
14
  import { useRetry } from "../../hooks/useRetry.js";
17
15
  import { AddressField } from "../AddressField/index.js";
@@ -23,25 +21,44 @@ import { CardSecurityCodeField } from "../CardSecurityCodeField/index.js";
23
21
  import { CardSelector } from "../CardSelector/index.js";
24
22
  import { createEmailCore, EmailField } from "../EmailField/EmailField.js";
25
23
  import { CheckBox } from "../internal/CheckBox/CheckBox.js";
24
+ import "../internal/Form/type.js";
26
25
  import "../internal/Form/context.js";
27
26
  import "../internal/Form/FormItem.js";
28
27
  import { Form } from "../internal/Form/Form.js";
29
28
  import { IconSwitch } from "../internal/icons/IconSwitch.js";
30
29
  import { Info } from "../internal/Info/Info.js";
31
30
  import { RecurringTip } from "../RecurringTip/index.js";
32
- import { FieldType, SecuredFieldsProvider } from "../SecuredFieldsProvider/SecuredFieldsProvider.js";
31
+ import { EFieldType, SecuredFieldsProvider } from "../SecuredFieldsProvider/index.js";
33
32
  import { SubmitButton } from "../SubmitButton/index.js";
33
+ import { ThreeDSAuth } from "../ThreeDS/index.js";
34
+ import { CombinedCardInfo } from "../CombinedCardInfo/index.js";
35
+ import { cssVarPrefix, normalizedClass, trimAll, formatAmount } from "../../utils/format.js";
34
36
  import { cardBrandCodes } from "../../utils/card-brand/brands.js";
37
+ import { findCardBrand } from "../../utils/card-brand/index.js";
38
+ import { separateInputStyle } from "../../utils/style.js";
39
+ import { createPromise } from "../../utils/create-promise.js";
40
+ import { isUndefined } from "../../utils/is.js";
35
41
  const { bem } = useBEM("card");
36
42
  const fieldClassNames = bem("field");
37
43
  const Card = w((props, ref) => {
38
- var _a, _b, _c, _d, _e, _f;
39
- const { sessionId, clientKey, showCardBrands = true } = props;
44
+ var _a, _b, _c, _d, _e, _f, _g, _h;
45
+ const {
46
+ showCardBrands = true,
47
+ session,
48
+ cardInfoLayout = "split",
49
+ showHolderName = true,
50
+ showEmail = false,
51
+ showAddress = false,
52
+ threeDSFrame,
53
+ styles,
54
+ enable3DSModal = true
55
+ } = props;
40
56
  let addressState = createAddressCore();
41
57
  let emailState = createEmailCore();
42
- const { i18n, session, sessionReady, payKKaRadar } = usePayState(props);
58
+ const { i18n, fraudDetection, sessionReady } = usePayState(session);
43
59
  const addressFieldRef = A(null);
44
60
  const emailFieldRef = A(null);
61
+ const combinedCardInfoRef = A(null);
45
62
  const formRef = A(null);
46
63
  const [form, setForm] = h({
47
64
  email: "",
@@ -49,6 +66,7 @@ const Card = w((props, ref) => {
49
66
  expireDate: "",
50
67
  securityCode: "",
51
68
  holderName: "",
69
+ cardInfo: "",
52
70
  address: {
53
71
  country: "",
54
72
  province: "",
@@ -62,17 +80,22 @@ const Card = w((props, ref) => {
62
80
  const [validated, setValidated] = h(false);
63
81
  const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
64
82
  const [errorMsg, setErrorMsg] = h("");
65
- const disabledEmail = A(false);
66
- const [requiredBill, setRequiredBill] = h(false);
67
83
  const [storePaymentMethod, setStorePaymentMethod] = h(false);
68
84
  const [isEditOtherCard, setIsEditOtherCard] = h(false);
69
85
  const [isCheckoutEnabled, setIsCheckoutEnabled] = h(false);
70
86
  const [supportedCardBrands, setSupportedCardBrands] = h([]);
87
+ const [showThreeDSModal, setShowThreeDSModal] = h(false);
88
+ const [threeDSInfo, setThreeDSInfo] = h();
89
+ const [fieldStatus, setFieldStatus] = h();
90
+ const [security, setSecurity] = h(false);
91
+ const [tokenAddressFilled, setTokenAddressFilled] = h(true);
92
+ const [inputStyle, setInputStyle] = h({});
93
+ const [splitCardInfo] = h(cardInfoLayout === "split");
71
94
  F(ref, () => ({
72
95
  checkThreeDS,
73
96
  updateAddress: () => {
74
97
  var _a2;
75
- if (!requiredBill)
98
+ if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
76
99
  return;
77
100
  setForm(Object.assign(form, { address: addressState.getAddressState() }));
78
101
  (_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressState.getAddressState());
@@ -81,31 +104,64 @@ const Card = w((props, ref) => {
81
104
  var _a2;
82
105
  setForm(Object.assign(form, { email: emailState.email }));
83
106
  (_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
107
+ },
108
+ payment: () => {
109
+ hidePaymentButton && onSubmit();
84
110
  }
85
111
  }));
112
+ const getPaymentSuccessData = () => {
113
+ var _a2;
114
+ return {
115
+ returnUrl: (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl
116
+ };
117
+ };
118
+ const initFieldStatus = () => {
119
+ const field = session.checkout.field;
120
+ const { email, address, holderName } = field;
121
+ if (showEmail && !(email == null ? void 0 : email.show)) {
122
+ email.show = true;
123
+ email.disabled = true;
124
+ }
125
+ if (showAddress && !(address == null ? void 0 : address.show)) {
126
+ address.show = true;
127
+ }
128
+ if (showHolderName && !(holderName == null ? void 0 : holderName.show)) {
129
+ holderName.show = true;
130
+ holderName.disabled = true;
131
+ }
132
+ setFieldStatus({ ...field });
133
+ };
134
+ const initElementStyles = () => {
135
+ if (!styles) {
136
+ return;
137
+ }
138
+ const { input } = separateInputStyle(styles);
139
+ input && setInputStyle(input);
140
+ };
86
141
  y(() => {
87
- if (session) {
88
- session.ready().then(() => {
142
+ if (!sessionReady) {
143
+ return;
144
+ }
145
+ const { status, paymentMethod = [], bill = {}, sessionMode } = (session == null ? void 0 : session.checkout) || {};
146
+ if (!intersection(paymentMethod, CardPaymentMethods).length) {
147
+ return;
148
+ }
149
+ initFieldStatus();
150
+ initElementStyles();
151
+ setSecurity(sessionMode !== SessionMode.HOSTED);
152
+ form.email = bill.email ?? "";
153
+ setSupportedCardBrands(
154
+ cardBrandCodes.filter((code) => {
89
155
  var _a2;
90
- if (isEmptyObject(session.checkout)) {
91
- (_a2 = props.onError) == null ? void 0 : _a2.call(props, "FAILURE");
92
- return;
93
- }
94
- setIsCheckoutEnabled(true);
95
- const { bill, status } = session.checkout;
96
- form.email = bill.email ?? "";
97
- disabledEmail.current = !!bill.email;
98
- setRequiredBill(bill.billingAddressCollection === "REQUIRED");
99
- setSupportedCardBrands(
100
- cardBrandCodes.filter((code) => session == null ? void 0 : session.checkout.paymentMethod.includes(code))
101
- );
102
- if (status === "SUCCESS") {
103
- setSubmitButtonStatus("success");
104
- processOnSuccess();
105
- }
106
- });
156
+ return (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.paymentMethod.includes(code);
157
+ })
158
+ );
159
+ setIsCheckoutEnabled(true);
160
+ if (status === "SUCCESS") {
161
+ setSubmitButtonStatus("success");
162
+ processOnSuccess();
107
163
  }
108
- }, [session]);
164
+ }, [sessionReady]);
109
165
  const onTimeout = q(
110
166
  (message) => {
111
167
  var _a2;
@@ -116,18 +172,50 @@ const Card = w((props, ref) => {
116
172
  [i18n, props.onTimeout]
117
173
  );
118
174
  const processOnSuccess = () => {
119
- var _a2, _b2;
120
- (_b2 = props.onSuccess) == null ? void 0 : _b2.call(props, (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl);
175
+ var _a2;
176
+ (_a2 = props.onSuccess) == null ? void 0 : _a2.call(props, getPaymentSuccessData());
121
177
  };
122
178
  const { start: startReFetchPayInfo } = useRetry((timeout) => pay(true, timeout), {
123
179
  onTimeout: () => onTimeout(i18n.get("common.queryTimeout"))
124
180
  });
181
+ const validatePromise = A(createPromise());
182
+ const onValidated = (data) => {
183
+ fieldValidStatusMap.current[data.fieldType].status = data.status;
184
+ const results = Object.values(fieldValidStatusMap.current);
185
+ if (results.includes(null)) {
186
+ return;
187
+ } else {
188
+ const validateResult = results.every((result) => result.status === "success");
189
+ if (validateResult) {
190
+ validatePromise.current.resolve(true);
191
+ } else {
192
+ validatePromise.current.reject(false);
193
+ }
194
+ }
195
+ };
196
+ const validateCombineCardInfo = async () => {
197
+ var _a2;
198
+ validatePromise.current = createPromise();
199
+ Object.keys(fieldValidStatusMap.current).forEach((key) => {
200
+ fieldValidStatusMap.current[key] = null;
201
+ });
202
+ (_a2 = SFPRef.current) == null ? void 0 : _a2.validate();
203
+ try {
204
+ await validatePromise.current;
205
+ console.log("校验通过");
206
+ } catch (error) {
207
+ console.log("校验失败");
208
+ }
209
+ };
125
210
  async function onSubmit() {
126
211
  var _a2;
127
212
  setErrorMsg("");
213
+ if (!splitCardInfo && security) {
214
+ await validateCombineCardInfo();
215
+ }
128
216
  (_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
129
217
  var _a3;
130
- requiredBill && addressState.setValidateAllFields(true);
218
+ (fieldStatus == null ? void 0 : fieldStatus.address.show) && addressState.setValidateAllFields(true);
131
219
  (_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
132
220
  if (errors) {
133
221
  setSubmitButtonStatus("unSubmit");
@@ -139,15 +227,25 @@ const Card = w((props, ref) => {
139
227
  });
140
228
  }
141
229
  const getPaymentParams = async () => {
142
- var _a2, _b2;
230
+ var _a2;
143
231
  const cardNo = trimAll(form.number);
144
232
  const cardBrand = findCardBrand(cardNo);
145
233
  const [expMonth, expYear] = form.expireDate.split("/");
146
234
  const isFastPaymentForm = isFastPayment && !isEditOtherCard;
147
- const paymentMethod = isFastPayment ? PaymentMethod.BANKCARD : ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.sessionMode) === SessionMode.EMBEDDED ? (_b2 = cardNumberFieldRef.current) == null ? void 0 : _b2.getCardBrand().code : cardBrand.code;
235
+ let paymentMethod = null;
236
+ if (isFastPayment) {
237
+ paymentMethod = PaymentMethod.BANKCARD;
238
+ } else {
239
+ if (security) {
240
+ const fieldRef = splitCardInfo ? cardNumberFieldRef : combinedCardInfoRef;
241
+ paymentMethod = (_a2 = fieldRef.current) == null ? void 0 : _a2.getCardBrand().code;
242
+ } else {
243
+ paymentMethod = cardBrand.code;
244
+ }
245
+ }
148
246
  return {
149
- sessionId,
150
- clientKey,
247
+ sessionId: session.sessionId,
248
+ clientKey: session.clientKey,
151
249
  payment: {
152
250
  paymentMethod,
153
251
  cvv: form.securityCode,
@@ -161,7 +259,7 @@ const Card = w((props, ref) => {
161
259
  ...isShowStoreCheckBox ? { storePaymentMethod } : null
162
260
  }
163
261
  },
164
- bill: requiredBill ? {
262
+ bill: (fieldStatus == null ? void 0 : fieldStatus.address.show) ? {
165
263
  email: form.email,
166
264
  ...form.address,
167
265
  province: addressState.getLabel(form.address.province, addressState.getProvinceOption()) ?? form.address.province,
@@ -170,20 +268,23 @@ const Card = w((props, ref) => {
170
268
  email: form.email
171
269
  },
172
270
  browser: await getBrowserParams({
173
- radarId: payKKaRadar == null ? void 0 : payKKaRadar.radarId
271
+ fraudDetectionId: fraudDetection == null ? void 0 : fraudDetection.fraudDetectionID
174
272
  })
175
273
  };
176
274
  };
177
275
  async function pay(search = false, timeout) {
178
- var _a2, _b2, _c2;
276
+ var _a2, _b2;
179
277
  try {
180
278
  const paymentParams = await getPaymentParams();
181
- if (!search && ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.sessionMode) === SessionMode.EMBEDDED) {
182
- (_b2 = SFPRef.current) == null ? void 0 : _b2.payment(paymentParams);
279
+ if (!search && security) {
280
+ (_a2 = SFPRef.current) == null ? void 0 : _a2.payment(paymentParams);
183
281
  return { end: true };
184
282
  }
185
283
  const options = { locale: i18n.locale, timeout };
186
- const res = search ? await getCardPayInfo({ sessionId, clientKey }, options) : await cardPay(paymentParams, options);
284
+ const res = search ? await getCardPayInfo(
285
+ { sessionId: session.sessionId, clientKey: session.clientKey },
286
+ options
287
+ ) : await cardPay(paymentParams, options);
187
288
  return processAfterPayment(res, search);
188
289
  } catch (error) {
189
290
  if (isTimeoutError(error)) {
@@ -194,17 +295,39 @@ const Card = w((props, ref) => {
194
295
  return { end: true };
195
296
  }
196
297
  } else {
197
- setErrorMsg(error.i18nKey ? i18n.get(error.i18nKey) : error.message);
198
- (_c2 = props.onError) == null ? void 0 : _c2.call(props, error);
298
+ const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
299
+ setErrorMsg(message);
300
+ (_b2 = props.onError) == null ? void 0 : _b2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
199
301
  setSubmitButtonStatus("unSubmit");
200
302
  stopReFetchCardPay3DSInfo();
201
303
  return { end: true };
202
304
  }
203
305
  }
204
306
  }
307
+ const processThreeDS = (threeDSUrl, incomplete) => {
308
+ var _a2;
309
+ if (enable3DSModal) {
310
+ console.log("3ds open");
311
+ setShowThreeDSModal(true);
312
+ setThreeDSInfo({
313
+ url: threeDSUrl,
314
+ incomplete,
315
+ width: threeDSFrame == null ? void 0 : threeDSFrame.modalWidth,
316
+ height: threeDSFrame == null ? void 0 : threeDSFrame.modalHeight
317
+ });
318
+ } else {
319
+ (_a2 = props.onThreeDS) == null ? void 0 : _a2.call(props, threeDSUrl, incomplete);
320
+ }
321
+ };
322
+ const handleCloseThreeDSModal = () => {
323
+ console.log("3ds close");
324
+ setShowThreeDSModal(false);
325
+ setThreeDSInfo(void 0);
326
+ checkThreeDS();
327
+ };
205
328
  const processAfterPayment = (res, search = false) => {
206
- var _a2, _b2, _c2, _d2, _e2;
207
- const { status, orderStatus, errorMessage, threeDSUrl } = res;
329
+ var _a2, _b2, _c2;
330
+ const { status, orderStatus, errorMessage, errorCode, threeDSUrl } = res;
208
331
  if (status === "PROCESSING") {
209
332
  if (!orderStatus) {
210
333
  setSubmitButtonStatus("unSubmit");
@@ -217,14 +340,14 @@ const Card = w((props, ref) => {
217
340
  } else if (orderStatus === "FAILURE") {
218
341
  setErrorMsg(errorMessage);
219
342
  setSubmitButtonStatus("unSubmit");
220
- (_a2 = props.onError) == null ? void 0 : _a2.call(props, "FAILURE");
343
+ (_a2 = props.onError) == null ? void 0 : _a2.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
221
344
  } else if (orderStatus === "AUTHORIZED") {
222
345
  setSubmitButtonStatus("unSubmit");
223
346
  (_b2 = props.onAuthorized) == null ? void 0 : _b2.call(props);
224
347
  } else if (orderStatus === "IN_THREED") {
225
- (_c2 = props.onThreeDS) == null ? void 0 : _c2.call(props, threeDSUrl, false);
348
+ processThreeDS(threeDSUrl, false);
226
349
  } else if (orderStatus === "IN_PREVIOUS_THREED") {
227
- (_d2 = props.onThreeDS) == null ? void 0 : _d2.call(props, threeDSUrl, true);
350
+ processThreeDS(threeDSUrl, true);
228
351
  }
229
352
  return { end: true };
230
353
  } else if (status === "SUCCESS") {
@@ -233,7 +356,7 @@ const Card = w((props, ref) => {
233
356
  return { end: true };
234
357
  } else if (status === "EXPIRED") {
235
358
  setSubmitButtonStatus("unSubmit");
236
- (_e2 = props.onExpired) == null ? void 0 : _e2.call(props);
359
+ (_c2 = props.onExpired) == null ? void 0 : _c2.call(props);
237
360
  return { end: true };
238
361
  }
239
362
  setSubmitButtonStatus("unSubmit");
@@ -242,18 +365,19 @@ const Card = w((props, ref) => {
242
365
  };
243
366
  const processPaymentError = (error) => {
244
367
  var _a2;
245
- setErrorMsg(error.i18nKey ? i18n.get(error.i18nKey) : error.message);
368
+ const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
369
+ setErrorMsg(message);
246
370
  setSubmitButtonStatus("unSubmit");
247
- (_a2 = props.onError) == null ? void 0 : _a2.call(props, error);
371
+ (_a2 = props.onError) == null ? void 0 : _a2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
248
372
  };
249
- function validateForm() {
373
+ const validateForm = () => {
250
374
  var _a2;
251
375
  (_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
252
376
  setValidated(true);
253
377
  }).catch(() => {
254
378
  setValidated(false);
255
379
  });
256
- }
380
+ };
257
381
  y(() => {
258
382
  validateForm();
259
383
  }, [form]);
@@ -291,7 +415,7 @@ const Card = w((props, ref) => {
291
415
  }
292
416
  );
293
417
  async function checkThreeDS(search = false, timeout = 2e4) {
294
- var _a2, _b2, _c2;
418
+ var _a2, _b2, _c2, _d2;
295
419
  if (!session)
296
420
  return { end: true };
297
421
  try {
@@ -305,16 +429,17 @@ const Card = w((props, ref) => {
305
429
  timeout
306
430
  }
307
431
  );
308
- const { status, orderStatus, errorMessage } = res;
432
+ const { status, orderStatus, errorMessage, errorCode } = res;
309
433
  if (status === "PROCESSING") {
310
434
  if (orderStatus === "PROCESSING") {
311
435
  startReFetchPayInfo();
312
436
  } else if (orderStatus === "FAILURE") {
313
437
  setErrorMsg(errorMessage);
314
438
  setSubmitButtonStatus("unSubmit");
439
+ (_a2 = props.onError) == null ? void 0 : _a2.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
315
440
  } else if (orderStatus === "AUTHORIZED") {
316
441
  setSubmitButtonStatus("unSubmit");
317
- (_a2 = props.onAuthorized) == null ? void 0 : _a2.call(props);
442
+ (_b2 = props.onAuthorized) == null ? void 0 : _b2.call(props);
318
443
  } else if (orderStatus === "IN_THREED") {
319
444
  setSubmitButtonStatus("loading");
320
445
  !search && startReFetchCardPay3DSInfo();
@@ -334,7 +459,7 @@ const Card = w((props, ref) => {
334
459
  return { end: true };
335
460
  } else if (status === "EXPIRED") {
336
461
  setSubmitButtonStatus("unSubmit");
337
- (_b2 = props.onExpired) == null ? void 0 : _b2.call(props);
462
+ (_c2 = props.onExpired) == null ? void 0 : _c2.call(props);
338
463
  stopReFetchCardPay3DSInfo();
339
464
  return { end: true };
340
465
  }
@@ -351,8 +476,9 @@ const Card = w((props, ref) => {
351
476
  return { end: true };
352
477
  }
353
478
  } else {
354
- setErrorMsg(error.i18nKey ? i18n.get(error.i18nKey) : error.message);
355
- (_c2 = props.onError) == null ? void 0 : _c2.call(props, error);
479
+ const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
480
+ setErrorMsg(message);
481
+ (_d2 = props.onError) == null ? void 0 : _d2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
356
482
  setSubmitButtonStatus("unSubmit");
357
483
  stopReFetchCardPay3DSInfo();
358
484
  return { end: true };
@@ -361,31 +487,36 @@ const Card = w((props, ref) => {
361
487
  }
362
488
  const isFastPayment = T(() => {
363
489
  var _a2;
490
+ if (!(session == null ? void 0 : session.checkout)) {
491
+ return;
492
+ }
364
493
  const isPurchase = (session == null ? void 0 : session.checkout.paymentType) === PaymentType.PURCHASE;
365
494
  const hasCardTokens = !!((_a2 = session == null ? void 0 : session.checkout.tokens) == null ? void 0 : _a2.length);
366
495
  return isPurchase && hasCardTokens;
367
496
  }, [session == null ? void 0 : session.checkout]);
368
497
  const isShowStoreCheckBox = T(() => {
498
+ if (!(session == null ? void 0 : session.checkout)) {
499
+ return;
500
+ }
369
501
  return (session == null ? void 0 : session.checkout.paymentType) === PaymentType.PURCHASE && (session == null ? void 0 : session.checkout.storePaymentMethod);
370
502
  }, [session == null ? void 0 : session.checkout]);
371
503
  const storeCheckBox = () => {
372
504
  const onCheck = (checked) => {
373
505
  setStorePaymentMethod(checked);
374
506
  };
375
- return /* @__PURE__ */ u(
507
+ return /* @__PURE__ */ u("div", { className: bem("store-checkbox"), children: /* @__PURE__ */ u(
376
508
  CheckBox,
377
509
  {
378
510
  label: i18n.get("card.storeInfo"),
379
511
  checked: storePaymentMethod,
380
- onChange: onCheck,
381
- style: { marginTop: "40px" }
512
+ onChange: onCheck
382
513
  }
383
- );
514
+ ) });
384
515
  };
385
516
  const changeBox = () => {
386
- var _a2, _b2;
387
- const isPurchase = (session == null ? void 0 : session.checkout.paymentType) === PaymentType.PURCHASE;
388
- const hasCardTokens = !!((_b2 = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.tokens) == null ? void 0 : _b2.length);
517
+ var _a2, _b2, _c2;
518
+ const isPurchase = ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.paymentType) === PaymentType.PURCHASE;
519
+ const hasCardTokens = !!((_c2 = (_b2 = session == null ? void 0 : session.checkout) == null ? void 0 : _b2.tokens) == null ? void 0 : _c2.length);
389
520
  const onClick = () => {
390
521
  var _a3;
391
522
  (_a3 = formRef.current) == null ? void 0 : _a3.resetValidation();
@@ -400,7 +531,6 @@ const Card = w((props, ref) => {
400
531
  var _a2;
401
532
  (_a2 = formRef.current) == null ? void 0 : _a2.resetValidation();
402
533
  setIsEditOtherCard(true);
403
- setRequiredBill((session == null ? void 0 : session.checkout.bill.billingAddressCollection) === "REQUIRED");
404
534
  };
405
535
  const onClickChangeCard = () => {
406
536
  var _a2;
@@ -411,10 +541,8 @@ const Card = w((props, ref) => {
411
541
  onEditOtherCard();
412
542
  };
413
543
  const onCardChange = (option) => {
544
+ setTokenAddressFilled(false);
414
545
  setForm(Object.assign(form, { token: option == null ? void 0 : option.token }));
415
- setRequiredBill(
416
- (session == null ? void 0 : session.checkout.bill.billingAddressCollection) === "REQUIRED" && !(option == null ? void 0 : option.billingAddressFilled)
417
- );
418
546
  };
419
547
  const setFormRef = (dom) => {
420
548
  formRef.current = dom;
@@ -432,31 +560,65 @@ const Card = w((props, ref) => {
432
560
  (_a2 = SFPRef.current) == null ? void 0 : _a2.reload();
433
561
  }, [showFastPaymentForm]);
434
562
  const fieldRefMap = {
435
- [FieldType.CARD_NUMBER]: cardNumberFieldRef,
436
- [FieldType.CVV]: cardSecurityCodeFieldRef,
437
- [FieldType.EXPIRE_DATE]: cardExpireDateFieldRef
563
+ [EFieldType.CARD_NUMBER]: cardNumberFieldRef,
564
+ [EFieldType.CVV]: cardSecurityCodeFieldRef,
565
+ [EFieldType.EXPIRE_DATE]: cardExpireDateFieldRef
438
566
  };
439
567
  const onFieldsFocus = (data) => {
440
568
  var _a2, _b2;
441
- const fieldRef = fieldRefMap[data.fieldType];
569
+ const fieldRef = splitCardInfo ? fieldRefMap[data.fieldType] : combinedCardInfoRef;
442
570
  if (data.focus) {
443
571
  (_a2 = fieldRef.current) == null ? void 0 : _a2.focus();
444
572
  } else {
445
573
  (_b2 = fieldRef.current) == null ? void 0 : _b2.blur();
446
574
  }
447
575
  };
576
+ const validateOrder = [EFieldType.CARD_NUMBER, EFieldType.EXPIRE_DATE, EFieldType.CVV];
577
+ const fieldValidStatusMap = A({
578
+ [EFieldType.CARD_NUMBER]: null,
579
+ [EFieldType.EXPIRE_DATE]: null,
580
+ [EFieldType.CVV]: null
581
+ });
448
582
  const onFieldValidStatusChanged = (data) => {
449
- var _a2;
450
- const fieldRef = fieldRefMap[data.fieldType];
583
+ var _a2, _b2, _c2, _d2;
584
+ const fieldRef = splitCardInfo ? fieldRefMap[data.fieldType] : combinedCardInfoRef;
451
585
  const error = data.errorTip && i18n.get(data.errorTip);
452
- (_a2 = fieldRef.current) == null ? void 0 : _a2.resetValidation(data.status, error);
586
+ if (!splitCardInfo) {
587
+ fieldValidStatusMap.current[data.fieldType] = {
588
+ status: data.status,
589
+ errorTip: error
590
+ };
591
+ for (const key of validateOrder) {
592
+ const currResult = fieldValidStatusMap.current[key];
593
+ if ((currResult == null ? void 0 : currResult.status) === "error") {
594
+ (_a2 = fieldRef.current) == null ? void 0 : _a2.resetValidation(currResult.status, currResult.errorTip);
595
+ return;
596
+ }
597
+ }
598
+ const isSuccess = Object.values(fieldValidStatusMap.current).every(
599
+ (result) => (result == null ? void 0 : result.status) === "success"
600
+ );
601
+ if (isSuccess) {
602
+ (_b2 = fieldRef.current) == null ? void 0 : _b2.resetValidation("success");
603
+ } else {
604
+ (_c2 = fieldRef.current) == null ? void 0 : _c2.resetValidation("unValidate");
605
+ }
606
+ } else {
607
+ (_d2 = fieldRef.current) == null ? void 0 : _d2.resetValidation(data.status, error);
608
+ }
453
609
  setTimeout(() => {
454
610
  validateForm();
455
611
  }, 100);
456
612
  };
613
+ const onBrand = (data) => {
614
+ var _a2;
615
+ const field = splitCardInfo ? cardNumberFieldRef : combinedCardInfoRef;
616
+ (_a2 = field.current) == null ? void 0 : _a2.brandChanged(data.brand);
617
+ };
457
618
  const onBinValueChanged = (data) => {
458
619
  var _a2;
459
- (_a2 = cardNumberFieldRef.current) == null ? void 0 : _a2.binValueChanged(data.binValue);
620
+ const field = splitCardInfo ? cardNumberFieldRef : combinedCardInfoRef;
621
+ (_a2 = field.current) == null ? void 0 : _a2.binValueChanged(data.binValue);
460
622
  };
461
623
  const onAfterPayment = (data) => {
462
624
  processAfterPayment(data.response);
@@ -464,17 +626,41 @@ const Card = w((props, ref) => {
464
626
  const onPaymentError = (data) => {
465
627
  processPaymentError(data.error);
466
628
  };
467
- const cardForm = () => {
468
- var _a2, _b2, _c2, _d2, _e2, _f2, _g;
469
- return /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: cardStyle, children: [
470
- /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(EmailField, { ref: emailFieldRef, value: form.email, disabled: !!disabledEmail.current }) }),
629
+ const Email = () => {
630
+ return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
631
+ EmailField,
632
+ {
633
+ ref: emailFieldRef,
634
+ value: form.email,
635
+ disabled: fieldStatus == null ? void 0 : fieldStatus.email.disabled
636
+ }
637
+ ) }) });
638
+ };
639
+ const Address = () => {
640
+ var _a2, _b2;
641
+ return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: bem("address"), children: /* @__PURE__ */ u(
642
+ AddressField,
643
+ {
644
+ ref: addressFieldRef,
645
+ value: form.address,
646
+ country: ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.country) || ((_b2 = session == null ? void 0 : session.checkout) == null ? void 0 : _b2.bill.country),
647
+ onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
648
+ }
649
+ ) }) });
650
+ };
651
+ const ErrorMessage = () => {
652
+ return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }) });
653
+ };
654
+ const CardInfo = q(() => {
655
+ var _a2, _b2, _c2, _d2;
656
+ return splitCardInfo ? /* @__PURE__ */ u(b, { children: [
471
657
  /* @__PURE__ */ u("div", { className: fieldClassNames, children: [
472
658
  /* @__PURE__ */ u("div", { className: bem("card-number-wrapper"), children: [
473
659
  /* @__PURE__ */ u(
474
660
  CardNumberField,
475
661
  {
476
662
  supportedCardBrands: (_b2 = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.paymentMethod) == null ? void 0 : _b2.filter(Boolean),
477
- security: ((_c2 = session == null ? void 0 : session.checkout) == null ? void 0 : _c2.sessionMode) === SessionMode.EMBEDDED,
663
+ security,
478
664
  ref: cardNumberFieldRef
479
665
  }
480
666
  ),
@@ -484,7 +670,7 @@ const Card = w((props, ref) => {
484
670
  CardBrands,
485
671
  {
486
672
  className: bem("card-brands"),
487
- supportedCardBrands: (_e2 = (_d2 = session == null ? void 0 : session.checkout) == null ? void 0 : _d2.paymentMethod) == null ? void 0 : _e2.filter(Boolean)
673
+ supportedCardBrands: (_d2 = (_c2 = session == null ? void 0 : session.checkout) == null ? void 0 : _c2.paymentMethod) == null ? void 0 : _d2.filter(Boolean)
488
674
  }
489
675
  )
490
676
  ] }),
@@ -492,7 +678,7 @@ const Card = w((props, ref) => {
492
678
  /* @__PURE__ */ u(
493
679
  CardExpireDateField,
494
680
  {
495
- security: ((_f2 = session == null ? void 0 : session.checkout) == null ? void 0 : _f2.sessionMode) === SessionMode.EMBEDDED,
681
+ security,
496
682
  className: fieldClassNames,
497
683
  ref: cardExpireDateFieldRef
498
684
  }
@@ -500,32 +686,40 @@ const Card = w((props, ref) => {
500
686
  /* @__PURE__ */ u(
501
687
  CardSecurityCodeField,
502
688
  {
503
- security: ((_g = session == null ? void 0 : session.checkout) == null ? void 0 : _g.sessionMode) === SessionMode.EMBEDDED,
689
+ security,
504
690
  className: fieldClassNames,
505
691
  ref: cardSecurityCodeFieldRef
506
692
  }
507
693
  )
508
- ] }),
509
- /* @__PURE__ */ u("div", { className: bem("holder-name"), children: /* @__PURE__ */ u(CardHolderNameField, {}) }),
510
- requiredBill && /* @__PURE__ */ u("div", { className: bem("address"), children: /* @__PURE__ */ u(
511
- AddressField,
512
- {
513
- ref: addressFieldRef,
514
- value: form.address,
515
- onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
516
- }
517
- ) }),
518
- (session == null ? void 0 : session.checkout.paymentType) === PaymentType.RECURRING && RecurringTip(),
694
+ ] })
695
+ ] }) : /* @__PURE__ */ u("div", { className: bem("card-info"), children: /* @__PURE__ */ u(
696
+ CombinedCardInfo,
697
+ {
698
+ ref: combinedCardInfoRef,
699
+ supportedCardBrands,
700
+ showLabel: true,
701
+ security
702
+ }
703
+ ) });
704
+ }, [splitCardInfo, security]);
705
+ const cardForm = () => {
706
+ var _a2;
707
+ return /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: cardStyle, children: [
708
+ Email(),
709
+ CardInfo(),
710
+ (fieldStatus == null ? void 0 : fieldStatus.holderName.show) && /* @__PURE__ */ u("div", { className: bem("holder-name"), children: /* @__PURE__ */ u(CardHolderNameField, { disabled: fieldStatus == null ? void 0 : fieldStatus.holderName.disabled }) }),
711
+ Address(),
712
+ ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.paymentType) === PaymentType.RECURRING && RecurringTip(),
519
713
  isShowStoreCheckBox && storeCheckBox(),
520
- !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }),
521
- Button()
714
+ ErrorMessage(),
715
+ !hidePaymentButton && Button()
522
716
  ] }) });
523
717
  };
524
718
  const fastPaymentCardForm = () => {
525
- var _a2, _b2, _c2, _d2, _e2;
719
+ var _a2, _b2, _c2, _d2;
526
720
  return /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: [
527
721
  /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: cardStyle, children: [
528
- /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(EmailField, { ref: emailFieldRef, value: form.email, disabled: !!disabledEmail.current }) }),
722
+ Email(),
529
723
  /* @__PURE__ */ u("div", { className: bem("card-selector-wrapper"), children: [
530
724
  /* @__PURE__ */ u(
531
725
  CardSelector,
@@ -543,49 +737,47 @@ const Card = w((props, ref) => {
543
737
  {
544
738
  className: fieldClassNames,
545
739
  style: { flex: 1, marginLeft: "12px" },
546
- security: ((_e2 = session == null ? void 0 : session.checkout) == null ? void 0 : _e2.sessionMode) === SessionMode.EMBEDDED,
740
+ security,
547
741
  ref: cardSecurityCodeFieldRef
548
742
  }
549
743
  )
550
744
  ] })
551
745
  ] }),
552
- requiredBill && /* @__PURE__ */ u("div", { className: bem("address"), children: /* @__PURE__ */ u(
553
- AddressField,
554
- {
555
- ref: addressFieldRef,
556
- value: form.address,
557
- onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
558
- }
559
- ) }),
560
- !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }),
561
- Button()
746
+ tokenAddressFilled && Address(),
747
+ ErrorMessage(),
748
+ !hidePaymentButton && Button()
562
749
  ] });
563
750
  };
564
- return /* @__PURE__ */ u(
565
- CoreContext.Provider,
566
- {
567
- value: {
751
+ return /* @__PURE__ */ u(CoreContext.Provider, { value: { i18n }, children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
752
+ /* @__PURE__ */ u(
753
+ SecuredFieldsProvider,
754
+ {
755
+ ref: SFPRef,
568
756
  i18n,
569
- session
570
- },
571
- children: sessionReady && isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(
572
- SecuredFieldsProvider,
573
- {
574
- ref: SFPRef,
575
- i18n,
576
- sessionMode: session.checkout.sessionMode,
577
- supportedCardBrands,
578
- onFocus: onFieldsFocus,
579
- onBinValue: onBinValueChanged,
580
- onAfterPayment,
581
- onPaymentError,
582
- onPaymentTimeout: ({ message }) => onTimeout(i18n.get(message)),
583
- onValidStatusChanged: onFieldValidStatusChanged,
584
- children: showFastPaymentForm ? fastPaymentCardForm() : cardForm()
585
- }
586
- )
587
- }
588
- );
757
+ sessionMode: (_g = session.checkout) == null ? void 0 : _g.sessionMode,
758
+ supportedCardBrands,
759
+ style: inputStyle || defaultInputStyleConfig,
760
+ onFocus: onFieldsFocus,
761
+ onBinValue: onBinValueChanged,
762
+ onBrand,
763
+ onAfterPayment,
764
+ onPaymentError,
765
+ onPaymentTimeout: ({ message }) => onTimeout(i18n.get(message)),
766
+ onValidStatusChanged: onFieldValidStatusChanged,
767
+ onValidated,
768
+ children: showFastPaymentForm ? fastPaymentCardForm() : cardForm()
769
+ }
770
+ ),
771
+ /* @__PURE__ */ u(
772
+ ThreeDSAuth,
773
+ {
774
+ show: showThreeDSModal,
775
+ theme: (_h = session == null ? void 0 : session.checkout) == null ? void 0 : _h.theme,
776
+ onClose: handleCloseThreeDSModal,
777
+ ...threeDSInfo
778
+ }
779
+ )
780
+ ] }) });
589
781
  });
590
782
  export {
591
783
  Card