@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,11 +1,12 @@
1
1
  import type { CardBrand } from '../../types';
2
2
  import type { FormItemProps, FormValidationStatus } from '../internal/Form';
3
3
  import type { InputProps } from '../internal/Input';
4
- export interface CombinedEncryptedFieldProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput'> {
4
+ export interface CombinedCardInfoProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput'> {
5
5
  supportedCardBrands?: string[];
6
6
  security: boolean;
7
+ showLabel?: boolean;
7
8
  }
8
- export interface CombinedEncryptedFieldRef {
9
+ export interface CombinedCardInfoRef {
9
10
  focus: () => void;
10
11
  blur: () => void;
11
12
  resetValidation: (status: FormValidationStatus, errorTip?: string) => void;
@@ -1,5 +1,6 @@
1
- import type { PaymentSuccessData } from '../../types';
2
- export interface GooglePayProps {
1
+ import type { PayKKaError } from '../../core';
2
+ import type { CoreProps, PaymentSuccessData } from '../../types';
3
+ export interface GooglePayProps extends CoreProps {
3
4
  /** 支付授权成功后触发 */
4
5
  onSubmit?: () => void;
5
6
  /** 支付成功后触发 */
@@ -7,7 +8,7 @@ export interface GooglePayProps {
7
8
  /** SDK 加载回调,status 为 true 表示加载成功,false 表示加载失败 */
8
9
  onLoad?: (status: boolean) => void;
9
10
  /** 支付失败时触发 */
10
- onError?: (error: any) => void;
11
+ onError?: (error: PayKKaError) => void;
11
12
  /** 支付超时时触发 */
12
13
  onTimeout?: (source: 'retry' | 'channel') => void;
13
14
  /** 收银台已过期时触发 */
@@ -1 +1,2 @@
1
1
  export * from './SecuredFieldsProvider';
2
+ export * from './type';
@@ -1,10 +1,7 @@
1
1
  import type { ReactNode } from 'preact/compat';
2
2
  import type { SessionMode } from '../../constant';
3
3
  import type { I18n } from '../../i18n';
4
- import type { PayRes } from '../../api';
5
- import type { FormValidationStatus } from '../internal/Form';
6
- import type { CardBrand, InputStylesConfig } from '../../types';
7
- import type { EncryptCardRes } from '../../api/modules/encrypted-card/type';
4
+ import type { EncryptCardMessage, InputStylesConfig, Message, MessageAction } from '../../types';
8
5
  export interface SecuredFieldsProviderProps extends SecuredFieldsCallback {
9
6
  i18n: I18n;
10
7
  supportedCardBrands: string[];
@@ -43,49 +40,6 @@ export declare enum EFieldType {
43
40
  EXPIRE_DATE = "EXPIRE_DATE"
44
41
  }
45
42
  export type FieldType = keyof typeof EFieldType;
46
- export declare enum MessageAction {
47
- /** 通知 iframe 初始化 input */
48
- INIT = "init",
49
- /** 表单 iframe DOM 已加载 */
50
- ACTIVATED = "Activated",
51
- /** 隐藏的 iframe 已经加载 */
52
- HIDDEN_IFRAME_READY = "hiddenIframeReady",
53
- /** 是否聚焦 */
54
- FOCUS = "focus",
55
- /** 卡 bin 信息改变 */
56
- BIN_VALUE = "binValue",
57
- /** 检测到卡品牌 */
58
- BRAND = "brand",
59
- /** 传递验证通过信息(附带值) */
60
- VALID_WITH_VALUE = "validWithValue",
61
- /** 通知隐藏 iframe 进行支付 */
62
- PAYMENT = "payment",
63
- /** 通知表单组件支付响应信息 */
64
- AFTER_PAYMENT = "afterPayment",
65
- /** 通知表单组件支付错误信息 */
66
- PAYMENT_ERROR = "paymentError",
67
- /** 通知表单组件支付超时 */
68
- PAYMENT_TIMEOUT = "paymentTimeout",
69
- /** 通知表单项验证信息 */
70
- VALID_STATUS_CHANGED = "validStatusChanged",
71
- /** 通知表单项校验 */
72
- VALIDATE = "validate",
73
- /** 通知表单项校验结果 */
74
- VALIDATED = "validated",
75
- /** 通知表单项配置 */
76
- SET_CONFIG = "setConfig",
77
- /**
78
- * frames
79
- */
80
- /** 通知 clientKey 已校验 */
81
- AUTHORIZED = "authorized",
82
- /** 通知隐藏 iframe 加密卡信息 */
83
- ENCRYPT_CARD = "encryptCard",
84
- /** 通知加密后的卡信息 */
85
- CARD_ENCRYPTED = "cardEncrypted",
86
- /** 通知卡信息加密错误 */
87
- CARD_ENCRYPTION_FAILED = "cardEncryptionFailed"
88
- }
89
43
  export interface SecuredFieldConfig extends FieldIframeConfig, SecuredFieldsCallback {
90
44
  rootNode: HTMLElement;
91
45
  fieldNode: HTMLElement;
@@ -100,112 +54,6 @@ export interface FieldIframeConfig {
100
54
  supportedCardBrands: string[];
101
55
  style?: InputStylesConfig;
102
56
  }
103
- /**
104
- * message data
105
- */
106
- export type Message<T extends MessageAction> = {
107
- action: T;
108
- } & MessageMapping[T];
109
- type MessageMapping = {
110
- [MessageAction.INIT]: InitMessage;
111
- [MessageAction.FOCUS]: FocusMessage;
112
- [MessageAction.BIN_VALUE]: BinValueMessage;
113
- [MessageAction.VALID_WITH_VALUE]: ValidWithValueMessage;
114
- [MessageAction.PAYMENT]: PaymentMessage;
115
- [MessageAction.AFTER_PAYMENT]: AfterPaymentMessage;
116
- [MessageAction.PAYMENT_ERROR]: PaymentErrorMessage;
117
- [MessageAction.PAYMENT_TIMEOUT]: PaymentTimeoutMessage;
118
- [MessageAction.VALID_STATUS_CHANGED]: ValidStatusChangedMessage;
119
- [MessageAction.ENCRYPT_CARD]: EncryptCardMessage;
120
- [MessageAction.CARD_ENCRYPTED]: CardEncryptedMessage;
121
- [MessageAction.CARD_ENCRYPTION_FAILED]: CardEncryptionFailedMessage;
122
- [MessageAction.AUTHORIZED]: AuthorizedMessage;
123
- [MessageAction.BRAND]: BrandMessage;
124
- [MessageAction.ACTIVATED]: ActivatedMessage;
125
- [MessageAction.HIDDEN_IFRAME_READY]: {};
126
- [MessageAction.VALIDATE]: {};
127
- [MessageAction.VALIDATED]: ValidatedMessage;
128
- [MessageAction.SET_CONFIG]: SetConfigMessage;
129
- };
130
- export interface InitMessage {
131
- config?: FieldIframeConfig;
132
- /** 是否隐藏,如不隐藏则为表单iframe */
133
- hidden: boolean;
134
- apiUrl?: string;
135
- cdnUrl?: string;
136
- }
137
- export interface FocusMessage {
138
- focus: boolean;
139
- fieldType: EFieldType;
140
- }
141
- export interface InvalidMessage {
142
- errorTip: string;
143
- fieldType: EFieldType;
144
- }
145
- export interface ValidMessage {
146
- fieldType: EFieldType;
147
- }
148
- export interface BinValueMessage {
149
- binValue: string;
150
- fieldType: EFieldType;
151
- brand?: CardBrand;
152
- }
153
- export interface ValidWithValueMessage {
154
- value: string;
155
- fieldType: EFieldType;
156
- }
157
- export interface PaymentMessage {
158
- formData: any;
159
- locale: string;
160
- }
161
- export interface AfterPaymentMessage {
162
- response: PayRes;
163
- }
164
- export interface PaymentErrorMessage {
165
- error: {
166
- message: string;
167
- code: string;
168
- };
169
- }
170
- export interface ValidStatusChangedMessage {
171
- status: FormValidationStatus;
172
- errorTip?: string;
173
- fieldType: EFieldType;
174
- }
175
- export interface PaymentTimeoutMessage {
176
- message?: string;
177
- }
178
- export interface CardEncryptedMessage {
179
- encryptedInfo: EncryptCardRes;
180
- }
181
- export interface CardEncryptionFailedMessage {
182
- error: {
183
- message: string;
184
- code: string;
185
- };
186
- }
187
- export interface AuthorizedMessage {
188
- success: boolean;
189
- }
190
- export interface BrandMessage {
191
- brand?: CardBrand;
192
- fieldType: EFieldType;
193
- }
194
- export interface EncryptCardMessage {
195
- merchantId: string;
196
- clientKey: string;
197
- }
198
- export interface ActivatedMessage {
199
- fieldType: EFieldType;
200
- }
201
- export interface ValidatedMessage {
202
- status: FormValidationStatus;
203
- fieldType: EFieldType;
204
- }
205
- export interface SetConfigMessage {
206
- style?: InputStylesConfig;
207
- }
208
57
  export declare const SECURED_FILED_ATTR = "data-sf";
209
58
  export declare const SECURED_IFRAME_CLASS_NAME = "secured-iframe";
210
59
  export declare const HIDDEN_IFRAME_NAME = "hidden-pay-iframe";
211
- export {};
@@ -1,2 +1,2 @@
1
1
  export * from './fields';
2
- export * from './iframe';
2
+ export * from './securedFields';
@@ -1,4 +1,5 @@
1
- import { EFieldType, MessageAction, type Message } from '../SecuredFieldsProvider/type';
1
+ import { EFieldType } from '../SecuredFieldsProvider/type';
2
+ import type { Message, MessageAction } from '../../types';
2
3
  export declare const useSecuredInput: () => {
3
4
  value: import("preact/hooks").MutableRef<string>;
4
5
  cardBin: string;
@@ -1,8 +1,10 @@
1
+ import type { PayKKaError } from '../../core';
2
+ import type { CoreProps } from '../../types';
1
3
  import type { FormValidateError } from '../internal/Form';
2
- export interface SepaProps {
4
+ export interface SepaProps extends CoreProps {
3
5
  onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
4
6
  onSuccess?: (returnUrl?: string) => void;
5
- onError?: (error: any) => void;
7
+ onError?: (error: PayKKaError) => void;
6
8
  onTimeout?: () => void;
7
9
  onAuthorized?: () => void;
8
10
  onExpired?: () => void;
@@ -0,0 +1,3 @@
1
+ import type { ThreeDSAuthProps } from './type';
2
+ import './three-ds-auth.scss';
3
+ export declare const ThreeDSAuth: (props: ThreeDSAuthProps) => import("preact").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './ThreeDSAuth';
2
+ export * from './type';
@@ -0,0 +1,17 @@
1
+ import type { CheckoutTheme } from '../../../../api';
2
+ export interface ThreeDSAuthProps {
3
+ /** 是否展示弹框 */
4
+ show: boolean;
5
+ /** 是否已完成 3DS 认证 */
6
+ incomplete?: boolean;
7
+ /** 3DS 认证页面地址 */
8
+ url?: string;
9
+ /** 弹窗宽度,不传就自适应 */
10
+ width?: number | string;
11
+ /** 弹窗高度,不传就自适应 */
12
+ height?: number | string;
13
+ /** 主题 */
14
+ theme?: CheckoutTheme;
15
+ /** 关闭弹框 */
16
+ onClose?: () => void;
17
+ }
@@ -0,0 +1,2 @@
1
+ import type { ThreeDSIframeProps } from './type';
2
+ export declare const ThreeDSIframe: (props: ThreeDSIframeProps) => import("preact").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './ThreeDSIframe';
@@ -0,0 +1,5 @@
1
+ export interface ThreeDSIframeProps {
2
+ uniqueId: string;
3
+ signature: string;
4
+ action: string;
5
+ }
@@ -0,0 +1,3 @@
1
+ import type { ThreeDSStatusProps } from './type';
2
+ import './three-ds-status.scss';
3
+ export declare const ThreeDSStatus: (props: ThreeDSStatusProps) => import("preact").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { LocaleKeyType } from "../../../../i18n";
2
+ export type ThreeDSStatusType = 'success' | 'fail';
3
+ export type ThreeDSStatusProps = {
4
+ status: ThreeDSStatusType;
5
+ locale: LocaleKeyType;
6
+ };
@@ -0,0 +1 @@
1
+ export * from './components/ThreeDSAuth';
@@ -1,9 +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 WechatPayProps {
5
+ export interface WechatPayProps extends CoreProps {
4
6
  onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
5
7
  onSuccess?: (...args: any[]) => void;
6
- onError?: (error: any) => void;
8
+ onError?: (error: PayKKaError) => void;
7
9
  onTimeout?: (source: 'retry' | 'channel') => void;
8
10
  onExpired?: () => void;
9
11
  onSubmitResponse?: (payRes: PayRes) => void;
@@ -16,4 +16,4 @@ export * from './SecuredIframe';
16
16
  export * from './Sepa';
17
17
  export * from './CardIBANField';
18
18
  export * from './EncryptedCard';
19
- export * from './CombinedEncryptedField';
19
+ export * from './CombinedCardInfo';
@@ -7,6 +7,7 @@ export interface InputProps extends HTMLAttributes<HTMLInputElement>, CustomAttr
7
7
  rightIcon?: ReactNode;
8
8
  leftIcon?: ReactNode;
9
9
  inputClassName?: string;
10
+ showStatus?: boolean;
10
11
  onCompositionStart?: (e: CompositionEvent) => void;
11
12
  }
12
13
  export interface InputRef {
@@ -0,0 +1 @@
1
+ export declare const Loading: () => import("preact").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './Loading';
@@ -0,0 +1,5 @@
1
+ import './modal.scss';
2
+ import type { ModalProps, ModalRef } from './type';
3
+ export declare const Modal: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<ModalProps> & {
4
+ ref?: import("preact").Ref<ModalRef> | undefined;
5
+ }>;
@@ -0,0 +1,20 @@
1
+ import type { ReactNode } from "preact/compat";
2
+ import type { CustomAttributes } from "../../../types";
3
+ export interface ModalProps extends CustomAttributes<HTMLDivElement> {
4
+ /** 是否展示弹框 */
5
+ show: boolean;
6
+ /** 弹窗宽度,不传就自适应 */
7
+ width?: number | string;
8
+ /** 弹窗高度,不传就自适应 */
9
+ height?: number | string;
10
+ /** 点击蒙层是否关闭弹窗,不传默认可关闭 */
11
+ maskClosable?: boolean;
12
+ /** 弹窗头部内容 */
13
+ header?: ReactNode;
14
+ /** 弹窗内容 */
15
+ children?: ReactNode;
16
+ /** 弹窗状态改变时调用 */
17
+ onChange?: (status: boolean) => void;
18
+ }
19
+ export interface ModalRef {
20
+ }
@@ -0,0 +1,2 @@
1
+ import type { IconProps } from './type';
2
+ export declare function Icon3DSFail({ size, style, className }: IconProps): import("preact").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { IconProps } from './type';
2
+ export declare function Icon3DSInfo({ size, style, className }: IconProps): import("preact").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { IconProps } from './type';
2
+ export declare function Icon3DSSuccess({ size, style, className }: IconProps): import("preact").JSX.Element;
@@ -14,3 +14,6 @@ export * from './IconArrowDown';
14
14
  export * from './IconTick';
15
15
  export * from './IconSwitch';
16
16
  export * from './IconAdd';
17
+ export * from './Icon3DSFail';
18
+ export * from './Icon3DSSuccess';
19
+ export * from './Icon3DSInfo';
@@ -32,6 +32,10 @@ export declare enum EAddressType {
32
32
  ADDRESS_2 = "ADDRESS_2"
33
33
  }
34
34
  export declare enum SessionMode {
35
- HOSTED = "HOST",
36
- EMBEDDED = "EMBEDDED"
35
+ /** 单页面收银台 */
36
+ HOSTED = "HOSTED",
37
+ /** 嵌入式收银台 */
38
+ DROP_IN = "DROP_IN",
39
+ /** 组件式收银台 */
40
+ COMPONENT = "COMPONENT"
37
41
  }
@@ -1,12 +1,28 @@
1
1
  import type { ComponentType, JSX } from 'preact';
2
- import type { PayKKaInitConfiguration } from '../types';
2
+ import type { CoreProps, PayKKaEnvConfig, PayKKaInitConfiguration } from '../types';
3
+ import { type ComponentInst } from './create';
3
4
  import { Session } from './Session';
5
+ import getFraudDetectionInstance from '../out/fraud-detection';
6
+ export type FraudDetectionType = ReturnType<typeof getFraudDetectionInstance>;
7
+ /**
8
+ * 收银台实例
9
+ * 不能用单例,如果使用单页面应用,在路由切换时不会重新初始化,会导致收银台配置和状态相互影响
10
+ */
4
11
  export declare class PayKKaCheckout {
5
- private readonly config;
6
- private static session?;
7
- private static instance;
12
+ #private;
8
13
  constructor(config: PayKKaInitConfiguration);
9
14
  private init;
10
- static getSession(): Session | undefined;
11
- create<P extends Recordable>(component: ComponentType<P> | ((props: P) => JSX.Element), props?: Partial<P> | null): import("./create").ComponentInst<P>;
15
+ private initSession;
16
+ /**
17
+ * 初始化环境配置
18
+ * _envConfig 优先级高于 env
19
+ */
20
+ private initEnv;
21
+ private initLocale;
22
+ private initExtraParams;
23
+ get session(): Session;
24
+ get envConfig(): PayKKaEnvConfig;
25
+ /** 创建组件,把 session 作为组件的 props 传递 */
26
+ create<P extends Recordable>(component: ComponentType<P> | ((props: P) => JSX.Element), props?: Partial<P> | null): ComponentInst<P>;
27
+ getCoreProps(): CoreProps;
12
28
  }
@@ -3,7 +3,7 @@ export declare class Session {
3
3
  #private;
4
4
  readonly sessionId: string;
5
5
  readonly clientKey?: string;
6
- checkout: CheckoutRes;
6
+ checkout?: CheckoutRes;
7
7
  colors: {
8
8
  primary: string;
9
9
  primaryHover: string;
@@ -3,4 +3,5 @@ import type { Session } from './Session';
3
3
  export declare const CoreContext: import("preact").Context<{
4
4
  i18n?: I18n | null | undefined;
5
5
  session?: Session | null | undefined;
6
+ threeDSMessageListenerInit?: boolean | undefined;
6
7
  } | null>;
@@ -0,0 +1,4 @@
1
+ import type { FraudDetectionEnv, PayKKaEnvType } from '../types';
2
+ export declare const apiEnv: Record<PayKKaEnvType, string>;
3
+ export declare const cdnEnv: Record<PayKKaEnvType, string>;
4
+ export declare const fraudDetectionEnv: Record<PayKKaEnvType, FraudDetectionEnv>;
@@ -0,0 +1,16 @@
1
+ export declare enum EPayKKaError {
2
+ /** 普通错误,基本是前端错误 */
3
+ ERROR = "ERROR",
4
+ /** 请求错误 */
5
+ API_ERROR = "API_ERROR"
6
+ }
7
+ export declare class PayKKaError extends Error {
8
+ /** 错误类型 */
9
+ type: keyof typeof EPayKKaError;
10
+ /** 错误代码 */
11
+ code?: string;
12
+ constructor(type: keyof typeof EPayKKaError, message?: string, info?: {
13
+ code?: string;
14
+ cause?: any;
15
+ });
16
+ }
@@ -3,3 +3,4 @@ export * from './create';
3
3
  export * from './Session';
4
4
  export * from './query';
5
5
  export * from './PayKKaCheckout';
6
+ export * from './error';
@@ -2,3 +2,4 @@ export * from './useBEM';
2
2
  export * from './useI18n';
3
3
  export * from './usePayState';
4
4
  export * from './useRetry';
5
+ export * from './useBreakpoints';
@@ -0,0 +1,15 @@
1
+ declare enum EBreakpoint {
2
+ xs = "xs",
3
+ sm = "sm",
4
+ md = "md",
5
+ lg = "lg",
6
+ xl = "xl",
7
+ xxl = "xxl"
8
+ }
9
+ export type BreakpointType = keyof typeof EBreakpoint;
10
+ export declare const useBreakpoints: () => {
11
+ matches: Record<"xs" | "sm" | "md" | "lg" | "xl" | "xxl", boolean>;
12
+ current: string | null;
13
+ smaller: (breakpointName: BreakpointType) => boolean;
14
+ };
15
+ export {};
@@ -1,19 +1,16 @@
1
1
  import type { SubmitButtonStatus } from '../components';
2
- import { Session } from '../core';
3
- export declare function usePayState(): {
2
+ import type { Session } from '../core';
3
+ export declare function usePayState(session: Session): {
4
4
  validated: boolean;
5
5
  setValidated: import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<boolean>>;
6
6
  submitButtonStatus: SubmitButtonStatus;
7
7
  setSubmitButtonStatus: import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<SubmitButtonStatus>>;
8
8
  errorMsg: string;
9
9
  setErrorMsg: import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<string>>;
10
- session: Session | null;
11
- setSession: import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<Session | null>>;
12
- sessionReady: boolean;
13
- setSessionReady: import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<boolean>>;
14
10
  i18n: import("../i18n").I18n;
15
11
  fraudDetection: {
16
12
  fraudDetectionID: string;
17
13
  createFraudDetection: () => Promise<void>;
18
14
  } | null;
15
+ sessionReady: boolean;
19
16
  };
@@ -16,6 +16,7 @@ declare const _default: {
16
16
  'card.cardSelector.change': string;
17
17
  'card.cardSelector.useOtherCard': string;
18
18
  'card.storeInfo': string;
19
+ 'card.info.label': string;
19
20
  'common.pay': string;
20
21
  'common.payProcessing': string;
21
22
  'common.paySuccess': string;
@@ -27,6 +28,8 @@ declare const _default: {
27
28
  'common.noData': string;
28
29
  'common.netError': string;
29
30
  'common.unknownError': string;
31
+ 'common.cancel': string;
32
+ 'common.confirm': string;
30
33
  'common.email.label': string;
31
34
  'common.email.incomplete': string;
32
35
  'common.email.incorrect': string;
@@ -44,5 +47,10 @@ declare const _default: {
44
47
  'sepa.iban.label': string;
45
48
  'sepa.iban.placeholder': string;
46
49
  'sepa.iban.invalid': string;
50
+ 'threeDS.paymentIncomplete': string;
51
+ 'threeDS.completeFirst': string;
52
+ 'threeDS.authenticationSuccessful': string;
53
+ 'threeDS.authenticationFailed': string;
54
+ 'threeDS.returnToCheckout': string;
47
55
  };
48
56
  export default _default;
@@ -16,6 +16,7 @@ declare const _default: {
16
16
  'card.cardSelector.change': string;
17
17
  'card.cardSelector.useOtherCard': string;
18
18
  'card.storeInfo': string;
19
+ 'card.info.label': string;
19
20
  'common.pay': string;
20
21
  'common.payProcessing': string;
21
22
  'common.paySuccess': string;
@@ -27,6 +28,8 @@ declare const _default: {
27
28
  'common.noData': string;
28
29
  'common.netError': string;
29
30
  'common.unknownError': string;
31
+ 'common.cancel': string;
32
+ 'common.confirm': string;
30
33
  'common.email.label': string;
31
34
  'common.email.incomplete': string;
32
35
  'common.email.incorrect': string;
@@ -44,5 +47,10 @@ declare const _default: {
44
47
  'sepa.iban.label': string;
45
48
  'sepa.iban.placeholder': string;
46
49
  'sepa.iban.invalid': string;
50
+ 'threeDS.paymentIncomplete': string;
51
+ 'threeDS.completeFirst': string;
52
+ 'threeDS.authenticationSuccessful': string;
53
+ 'threeDS.authenticationFailed': string;
54
+ 'threeDS.returnToCheckout': string;
47
55
  };
48
56
  export default _default;
@@ -16,6 +16,7 @@ declare const _default: {
16
16
  'card.cardSelector.change': string;
17
17
  'card.cardSelector.useOtherCard': string;
18
18
  'card.storeInfo': string;
19
+ 'card.info.label': string;
19
20
  'common.pay': string;
20
21
  'common.payProcessing': string;
21
22
  'common.paySuccess': string;
@@ -27,6 +28,8 @@ declare const _default: {
27
28
  'common.noData': string;
28
29
  'common.netError': string;
29
30
  'common.unknownError': string;
31
+ 'common.cancel': string;
32
+ 'common.confirm': string;
30
33
  'common.email.label': string;
31
34
  'common.email.incomplete': string;
32
35
  'common.email.incorrect': string;
@@ -44,5 +47,10 @@ declare const _default: {
44
47
  'sepa.iban.label': string;
45
48
  'sepa.iban.placeholder': string;
46
49
  'sepa.iban.invalid': string;
50
+ 'threeDS.paymentIncomplete': string;
51
+ 'threeDS.completeFirst': string;
52
+ 'threeDS.authenticationSuccessful': string;
53
+ 'threeDS.authenticationFailed': string;
54
+ 'threeDS.returnToCheckout': string;
47
55
  };
48
56
  export default _default;
@@ -16,6 +16,7 @@ declare const _default: {
16
16
  'card.cardSelector.change': string;
17
17
  'card.cardSelector.useOtherCard': string;
18
18
  'card.storeInfo': string;
19
+ 'card.info.label': string;
19
20
  'common.pay': string;
20
21
  'common.payProcessing': string;
21
22
  'common.paySuccess': string;
@@ -27,6 +28,8 @@ declare const _default: {
27
28
  'common.noData': string;
28
29
  'common.netError': string;
29
30
  'common.unknownError': string;
31
+ 'common.cancel': string;
32
+ 'common.confirm': string;
30
33
  'common.email.label': string;
31
34
  'common.email.incomplete': string;
32
35
  'common.email.incorrect': string;
@@ -44,5 +47,10 @@ declare const _default: {
44
47
  'sepa.iban.label': string;
45
48
  'sepa.iban.placeholder': string;
46
49
  'sepa.iban.invalid': string;
50
+ 'threeDS.paymentIncomplete': string;
51
+ 'threeDS.completeFirst': string;
52
+ 'threeDS.authenticationSuccessful': string;
53
+ 'threeDS.authenticationFailed': string;
54
+ 'threeDS.returnToCheckout': string;
47
55
  };
48
56
  export default _default;