@paykka/card-checkout-ui 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dist/card-checkout-ui.js +19 -19
  2. package/dist/card-checkout-ui.umd.cjs +19 -19
  3. package/dist/es/api/index.js +0 -2
  4. package/dist/es/api/modules/checkout/index.js +1 -15
  5. package/dist/es/api/modules/checkout/map.js +31 -3
  6. package/dist/es/api/modules/index.js +0 -2
  7. package/dist/es/components/AccountNameField/index.js +0 -3
  8. package/dist/es/components/AddressField/index.js +2 -7
  9. package/dist/es/components/AliPay/index.js +45 -34
  10. package/dist/es/components/ApplePay/index.js +19 -13
  11. package/dist/es/components/Card/index.js +334 -155
  12. package/dist/es/components/CardBrands/index.js +0 -2
  13. package/dist/es/components/CardExpireDateField/index.js +1 -4
  14. package/dist/es/components/CardHolderNameField/index.js +3 -5
  15. package/dist/es/components/CardIBANField/index.js +0 -3
  16. package/dist/es/components/CardNo/index.js +0 -2
  17. package/dist/es/components/CardNumberField/index.js +1 -4
  18. package/dist/es/components/CardSecurityCodeField/index.js +1 -4
  19. package/dist/es/components/CardSelector/index.js +0 -3
  20. package/dist/es/components/CombinedCardInfo/index.js +99 -0
  21. package/dist/es/components/DropIn/index.js +210 -0
  22. package/dist/es/components/EmailField/EmailField.js +0 -3
  23. package/dist/es/components/EncryptedCard/index.js +35 -75
  24. package/dist/es/components/GooglePay/index.js +69 -28
  25. package/dist/es/components/RecurringTip/index.js +0 -2
  26. package/dist/es/components/SecuredFieldsProvider/index.js +230 -1
  27. package/dist/es/components/SecuredIframe/index.js +3 -1
  28. package/dist/es/components/Sepa/index.js +26 -30
  29. package/dist/es/components/SubmitButton/index.js +0 -2
  30. package/dist/es/components/ThreeDS/index.js +94 -0
  31. package/dist/es/components/WechatPay/index.js +48 -38
  32. package/dist/es/components/index.js +2 -3
  33. package/dist/es/components/internal/Button/Button.js +0 -2
  34. package/dist/es/components/internal/Button/index.js +0 -2
  35. package/dist/es/components/internal/CheckBox/CheckBox.js +0 -2
  36. package/dist/es/components/internal/CheckBox/index.js +0 -2
  37. package/dist/es/components/internal/Form/type.js +0 -2
  38. package/dist/es/components/internal/Info/Info.js +0 -2
  39. package/dist/es/components/internal/Info/index.js +0 -2
  40. package/dist/es/components/internal/Input/Input.js +2 -2
  41. package/dist/es/components/internal/Input/type.js +0 -2
  42. package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -2
  43. package/dist/es/components/internal/LoadingCheck/index.js +0 -2
  44. package/dist/es/components/internal/Modal/Modal.js +40 -0
  45. package/dist/es/components/internal/Modal/modal2.js +1 -0
  46. package/dist/es/components/internal/Select/Select.js +0 -2
  47. package/dist/es/components/internal/Select/SelectMenu.js +0 -2
  48. package/dist/es/components/internal/Select/SelectMenuItem.js +0 -2
  49. package/dist/es/components/internal/icons/Icon3DSFail.js +3 -0
  50. package/dist/es/components/internal/icons/Icon3DSInfo.js +62 -0
  51. package/dist/es/components/internal/icons/Icon3DSSuccess.js +3 -0
  52. package/dist/es/components/internal/icons/IconCard.js +42 -0
  53. package/dist/es/config.js +0 -2
  54. package/dist/es/constant.js +13 -2
  55. package/dist/es/core/PayKKaCheckout.js +106 -42
  56. package/dist/es/core/Session.js +7 -6
  57. package/dist/es/core/environment.js +26 -0
  58. package/dist/es/core/error.js +21 -0
  59. package/dist/es/core/index.js +0 -2
  60. package/dist/es/core/query.js +0 -2
  61. package/dist/es/core.js +34 -34
  62. package/dist/es/hooks/index.js +0 -2
  63. package/dist/es/hooks/useBreakpoints.js +57 -0
  64. package/dist/es/hooks/useI18n.js +1 -2
  65. package/dist/es/hooks/usePayState.js +20 -24
  66. package/dist/es/i18n/index.js +0 -2
  67. package/dist/es/i18n/locales/de-DE.js +14 -1
  68. package/dist/es/i18n/locales/en-GB.js +14 -1
  69. package/dist/es/i18n/locales/es-ES.js +14 -1
  70. package/dist/es/i18n/locales/fr-FR.js +14 -1
  71. package/dist/es/i18n/locales/index.js +8 -6
  72. package/dist/es/i18n/locales/ja-JP.js +14 -1
  73. package/dist/es/i18n/locales/ko-KR.js +14 -1
  74. package/dist/es/i18n/locales/pt-PT.js +14 -1
  75. package/dist/es/i18n/locales/ru-RU.js +14 -1
  76. package/dist/es/i18n/locales/zh-CN.js +14 -1
  77. package/dist/es/i18n/locales/zh-HK.js +14 -1
  78. package/dist/es/i18n/locales/zh-TW.js +14 -1
  79. package/dist/es/i18n/util.js +22 -8
  80. package/dist/es/index.js +8 -2
  81. package/dist/es/style.css +289 -11
  82. package/dist/es/types/message.js +28 -0
  83. package/dist/es/utils/card-brand/brands.js +12 -10
  84. package/dist/es/utils/card-brand/index.js +3 -2
  85. package/dist/es/utils/iframe.js +23 -0
  86. package/dist/es/utils/index.js +0 -1
  87. package/dist/es/utils/style.js +47 -0
  88. package/dist/style.css +1 -1
  89. package/dist/types/api/modules/checkout/map.d.ts +2 -1
  90. package/dist/types/api/modules/checkout/type.d.ts +24 -2
  91. package/dist/types/api/modules/get-browser-params.d.ts +1 -1
  92. package/dist/types/components/AddressField/type.d.ts +1 -0
  93. package/dist/types/components/AliPay/AliPay.d.ts +2 -1
  94. package/dist/types/components/AliPay/type.d.ts +2 -1
  95. package/dist/types/components/ApplePay/ApplePay.d.ts +2 -1
  96. package/dist/types/components/ApplePay/type.d.ts +9 -5
  97. package/dist/types/components/Card/Card.d.ts +2 -1
  98. package/dist/types/components/Card/type.d.ts +55 -9
  99. package/dist/types/components/CardHolderNameField/type.d.ts +1 -1
  100. package/dist/types/components/CombinedCardInfo/CombinedCardInfo.d.ts +5 -0
  101. package/dist/types/components/CombinedCardInfo/index.d.ts +2 -0
  102. package/dist/types/components/{CombinedEncryptedField → CombinedCardInfo}/type.d.ts +3 -2
  103. package/dist/types/components/DropIn/DropIn.d.ts +6 -0
  104. package/dist/types/components/DropIn/components/PaymentTabs/PaymentTabs.d.ts +3 -0
  105. package/dist/types/components/DropIn/components/PaymentTabs/index.d.ts +2 -0
  106. package/dist/types/components/DropIn/components/PaymentTabs/type.d.ts +11 -0
  107. package/dist/types/components/DropIn/index.d.ts +2 -0
  108. package/dist/types/components/DropIn/type.d.ts +49 -0
  109. package/dist/types/components/GooglePay/GooglePay.d.ts +2 -1
  110. package/dist/types/components/GooglePay/type.d.ts +20 -8
  111. package/dist/types/components/SecuredFieldsProvider/index.d.ts +1 -0
  112. package/dist/types/components/SecuredFieldsProvider/type.d.ts +1 -153
  113. package/dist/types/components/SecuredFieldsProvider/utils/index.d.ts +1 -1
  114. package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +2 -1
  115. package/dist/types/components/Sepa/Sepa.d.ts +2 -1
  116. package/dist/types/components/Sepa/type.d.ts +2 -1
  117. package/dist/types/components/ThreeDS/components/ThreeDSAuth/ThreeDSAuth.d.ts +3 -0
  118. package/dist/types/components/ThreeDS/components/ThreeDSAuth/index.d.ts +2 -0
  119. package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +17 -0
  120. package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +2 -0
  121. package/dist/types/components/ThreeDS/components/ThreeDSIframe/index.d.ts +1 -0
  122. package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -0
  123. package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +5 -0
  124. package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +3 -0
  125. package/dist/types/components/ThreeDS/components/ThreeDSStatus/output.d.ts +1 -0
  126. package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +6 -0
  127. package/dist/types/components/ThreeDS/index.d.ts +1 -0
  128. package/dist/types/components/WechatPay/WechatPay.d.ts +2 -1
  129. package/dist/types/components/WechatPay/type.d.ts +2 -1
  130. package/dist/types/components/index.d.ts +2 -1
  131. package/dist/types/components/internal/Input/type.d.ts +1 -0
  132. package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
  133. package/dist/types/components/internal/Loading/index.d.ts +1 -0
  134. package/dist/types/components/internal/Modal/Modal.d.ts +5 -0
  135. package/dist/types/components/internal/Modal/index.d.ts +2 -0
  136. package/dist/types/components/internal/Modal/type.d.ts +20 -0
  137. package/dist/types/components/internal/icons/Icon3DSFail.d.ts +2 -0
  138. package/dist/types/components/internal/icons/Icon3DSInfo.d.ts +2 -0
  139. package/dist/types/components/internal/icons/Icon3DSSuccess.d.ts +2 -0
  140. package/dist/types/components/internal/icons/IconCard.d.ts +2 -0
  141. package/dist/types/components/internal/icons/index.d.ts +4 -0
  142. package/dist/types/constant.d.ts +17 -2
  143. package/dist/types/core/PayKKaCheckout.d.ts +23 -6
  144. package/dist/types/core/Session.d.ts +1 -1
  145. package/dist/types/core/context.d.ts +1 -0
  146. package/dist/types/core/environment.d.ts +4 -0
  147. package/dist/types/core/error.d.ts +16 -0
  148. package/dist/types/core/index.d.ts +1 -0
  149. package/dist/types/hooks/index.d.ts +1 -0
  150. package/dist/types/hooks/useBreakpoints.d.ts +15 -0
  151. package/dist/types/hooks/usePayState.d.ts +3 -6
  152. package/dist/types/i18n/locales/de-DE.d.ts +10 -0
  153. package/dist/types/i18n/locales/en-GB.d.ts +10 -0
  154. package/dist/types/i18n/locales/es-ES.d.ts +10 -0
  155. package/dist/types/i18n/locales/fr-FR.d.ts +10 -0
  156. package/dist/types/i18n/locales/index.d.ts +2 -2
  157. package/dist/types/i18n/locales/ja-JP.d.ts +10 -0
  158. package/dist/types/i18n/locales/ko-KR.d.ts +10 -0
  159. package/dist/types/i18n/locales/pt-PT.d.ts +10 -0
  160. package/dist/types/i18n/locales/ru-RU.d.ts +10 -0
  161. package/dist/types/i18n/locales/zh-CN.d.ts +10 -0
  162. package/dist/types/i18n/locales/zh-HK.d.ts +10 -0
  163. package/dist/types/i18n/locales/zh-TW.d.ts +10 -0
  164. package/dist/types/i18n/util.d.ts +5 -0
  165. package/dist/types/index.d.ts +1 -1
  166. package/dist/types/types/index.d.ts +59 -8
  167. package/dist/types/types/message.d.ts +170 -0
  168. package/dist/types/utils/card-brand/brands.d.ts +1 -8
  169. package/dist/types/utils/card-brand/index.d.ts +2 -2
  170. package/dist/types/utils/index.d.ts +1 -0
  171. package/dist/types/utils/style.d.ts +12 -0
  172. package/package.json +2 -2
  173. package/dist/es/components/CombinedEncryptedField/index.js +0 -75
  174. package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +0 -268
  175. package/dist/types/components/CombinedEncryptedField/CombinedEncryptedField.d.ts +0 -4
  176. package/dist/types/components/CombinedEncryptedField/index.d.ts +0 -2
  177. /package/dist/types/{components/SecuredFieldsProvider/utils → utils}/iframe.d.ts +0 -0
@@ -1,5 +1,6 @@
1
1
  import './ali-pay.scss';
2
2
  import type { AliPayProps, AliPayRef } from './type';
3
- export declare const AliPay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<AliPayProps> & {
3
+ import type { CoreProps } from '../../types';
4
+ export declare const AliPay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<AliPayProps & CoreProps> & {
4
5
  ref?: import("preact").Ref<AliPayRef> | undefined;
5
6
  }>;
@@ -1,9 +1,10 @@
1
1
  import type { PayRes } from '../../api';
2
+ import type { PayKKaError } from '../../core';
2
3
  import type { FormValidateError } from '../internal/Form';
3
4
  export interface AliPayProps {
4
5
  onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
5
6
  onSuccess?: (...args: any[]) => void;
6
- onError?: (error: any) => void;
7
+ onError?: (error: PayKKaError) => void;
7
8
  onTimeout?: (source: 'retry' | 'channel') => void;
8
9
  onExpired?: () => void;
9
10
  onSubmitResponse?: (payRes: PayRes) => void;
@@ -1,5 +1,6 @@
1
1
  import './apple-pay.scss';
2
2
  import type { ApplePayProps, ApplePayRef } from './type';
3
- export declare const ApplePay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<ApplePayProps> & {
3
+ import type { CoreProps } from '../../types';
4
+ export declare const ApplePay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<ApplePayProps & CoreProps> & {
4
5
  ref?: import("preact").Ref<ApplePayRef> | undefined;
5
6
  }>;
@@ -1,3 +1,4 @@
1
+ import type { PayKKaError } from '../../core';
1
2
  import type { PaymentSuccessData } from '../../types';
2
3
  export interface ApplePayProps {
3
4
  /** 支付授权成功后触发 */
@@ -7,21 +8,24 @@ export interface ApplePayProps {
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
  /** 收银台已过期时触发 */
14
15
  onExpired?: () => void;
15
- /** 交易被风控拦截时触发 */
16
- onAuthorized?: () => void;
17
16
  /** 支付取消时触发 */
18
17
  onCancel?: () => void;
19
18
  /** Apple Pay 按钮是否可用 */
20
19
  onCanUse?: (canUse: boolean) => void;
21
20
  /**
22
- * 内部使用
21
+ * @internal
22
+ * 交易被风控拦截时触发
23
+ */
24
+ onAuthorized?: () => void;
25
+ /**
26
+ * @internal
27
+ * 点击 GooglePay 按钮
23
28
  */
24
- /** 点击 ApplePay 按钮 */
25
29
  onBtnClick?: () => void;
26
30
  }
27
31
  export interface ApplePayRef {
@@ -1,5 +1,6 @@
1
1
  import './card.scss';
2
2
  import type { CardProps, CardRef } from './type';
3
- export declare const Card: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<CardProps> & {
3
+ import { type CoreProps } from '../../types';
4
+ export declare const Card: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<CardProps & CoreProps> & {
4
5
  ref?: import("preact").Ref<CardRef> | undefined;
5
6
  }>;
@@ -1,30 +1,76 @@
1
- import type { PaymentSuccessData } from '../../types';
1
+ import type { PayKKaError } from '../../core';
2
+ import type { ElementStylesConfig, PaymentSuccessData } from '../../types';
2
3
  import type { FormValidateError } from '../internal/Form';
3
4
  export interface CardProps {
5
+ /** 定义卡敏感信息表单布局展示,split 为分割布局,combine 为合并布局 */
6
+ cardInfoLayout?: CardInfoLayout;
7
+ /**
8
+ * 是否展示邮箱
9
+ * 若配置 true 但创建收银台时已经传了,就展示禁用状态。
10
+ * 若配置 false 但创建收银台时未传,依旧会展示该输入框。
11
+ */
12
+ showEmail?: boolean;
13
+ /**
14
+ * 是否展示邮箱
15
+ * 若配置 true 但创建收银台时已经传了,还是展示,先不禁用。
16
+ * 若配置 false 但创建收银台时未传,依旧会展示该输入框。
17
+ */
18
+ showAddress?: boolean;
4
19
  /** 是否在卡号输入框下展示收银台支持的发卡行图标 */
5
20
  showCardBrands?: boolean;
21
+ /**
22
+ * @internal
23
+ * 是否展示持卡人姓名,目前一定展示
24
+ */
25
+ styles?: ElementStylesConfig;
26
+ /**
27
+ * @internal
28
+ * 是否展示持卡人姓名,目前一定展示
29
+ */
30
+ showHolderName?: boolean;
31
+ /**
32
+ * @internal
33
+ * 是否展示3ds modal,默认为 true,配置 false 则抛出 onThreeDS 回调
34
+ */
35
+ enable3DSModal?: boolean;
6
36
  /** 提交表单时触发 */
7
37
  onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
8
38
  /** 支付成功后触发 */
9
39
  onSuccess?: (data: PaymentSuccessData) => void;
10
40
  /** 支付失败时触发 */
11
- onError?: (error: any) => void;
41
+ onError?: (error: PayKKaError) => void;
12
42
  /** 支付超时时触发 */
13
43
  onTimeout?: () => void;
14
- /** 交易被风控拦截时触发 */
15
- onAuthorized?: () => void;
16
44
  /** 收银台已过期时触发 */
17
45
  onExpired?: () => void;
18
- /** 交易需要 3DS 验证时触发,url 为 3DS 验证链接,incomplete 为 false 表示目前要开始进行 3DS 验证,为 true 表示上一次 3DS 验证还未完成 */
46
+ /**
47
+ * @internal
48
+ * 交易被风控拦截时触发
49
+ */
50
+ onAuthorized?: () => void;
51
+ /**
52
+ * @internal
53
+ * 交易需要 3DS 验证时触发,url 为 3DS 验证链接,incomplete 为 false 表示目前要开始进行 3DS 验证,为 true 表示上一次 3DS 验证还未完成
54
+ */
19
55
  onThreeDS?: (url: string, incomplete: boolean) => void;
20
56
  }
21
57
  export interface CardRef {
22
- /** 3DS 验证流程结束后可调用该方法轮询收银台支付状态 */
23
- checkThreeDS: () => void;
24
58
  /** 不展示支付按钮时,可调用该方法进行支付 */
25
59
  payment: () => void;
26
- /** 进行表单切换时更新已填的地址信息 */
60
+ /**
61
+ * @internal
62
+ * 3DS 验证流程结束后可调用该方法轮询收银台支付状态
63
+ */
64
+ checkThreeDS: () => void;
65
+ /**
66
+ * @internal
67
+ * 进行表单切换时更新已填的地址信息
68
+ */
27
69
  updateAddress: () => void;
28
- /** 进行表单切换时更新已填的邮箱信息 */
70
+ /**
71
+ * @internal
72
+ * 进行表单切换时更新已填的邮箱信息
73
+ */
29
74
  updateEmail: () => void;
30
75
  }
76
+ export type CardInfoLayout = 'split' | 'combine';
@@ -1,4 +1,4 @@
1
1
  import type { FormItemProps } from '../internal/Form';
2
2
  import type { InputProps } from '../internal/Input';
3
- export interface CardHolderNameFieldProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput'> {
3
+ export interface CardHolderNameFieldProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput' | 'disabled'> {
4
4
  }
@@ -0,0 +1,5 @@
1
+ import type { CombinedCardInfoProps, CombinedCardInfoRef } from './type';
2
+ import './combined-card-info.scss';
3
+ export declare const CombinedCardInfo: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<CombinedCardInfoProps> & {
4
+ ref?: import("preact").Ref<CombinedCardInfoRef> | undefined;
5
+ }>;
@@ -0,0 +1,2 @@
1
+ export * from './CombinedCardInfo';
2
+ export * from './type';
@@ -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;
@@ -0,0 +1,6 @@
1
+ import { type DropInProps, type DropInRefs } from './type';
2
+ import './drop-in.scss';
3
+ import type { CoreProps } from '../../types';
4
+ export declare const DropIn: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<DropInProps & CoreProps> & {
5
+ ref?: import("preact").Ref<DropInRefs> | undefined;
6
+ }>;
@@ -0,0 +1,3 @@
1
+ import type { PaymentTabsProps } from './type';
2
+ import './payment-tabs.scss';
3
+ export declare const PaymentTabs: (props: PaymentTabsProps) => import("preact").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './type';
2
+ export * from './PaymentTabs';
@@ -0,0 +1,11 @@
1
+ import type { PaymentCategory } from '../../../../constant';
2
+ import type { PaymentTypeOptions } from '../../type';
3
+ export interface PaymentTabsProps {
4
+ value: PaymentCategory;
5
+ tabs: PaymentTypeOptions[];
6
+ enabled?: PaymentCategory;
7
+ themeColor?: string;
8
+ onChange?: (type: PaymentCategory) => void;
9
+ }
10
+ export interface PaymentTabsRefs {
11
+ }
@@ -0,0 +1,2 @@
1
+ export * from './DropIn';
2
+ export * from './type';
@@ -0,0 +1,49 @@
1
+ import type { ReactNode } from 'preact/compat';
2
+ import type { PaymentSuccessData } from '../../types';
3
+ import { PaymentCategory, PaymentMethod } from '../../constant';
4
+ import type { ComponentType } from 'preact';
5
+ import type { FormValidateError } from '../internal/Form';
6
+ import type { PayKKaError } from '../../core';
7
+ export interface DropInProps {
8
+ /**
9
+ * 配置各种支付方式的参数
10
+ * 最终展示的支付方式由创建收银台请求返回结果决定,而不是由该参数决定
11
+ */
12
+ paymentMethods?: PaymentMethodsConfig;
13
+ /**
14
+ * 布局,tabs 表示在tab切换式布局,accordion 表示折叠式布局(手风琴)
15
+ * 目前暂不支持 accordion 布局
16
+ * @default tabs
17
+ */
18
+ layout?: 'tabs' | 'accordion';
19
+ /** 提交表单时触发 */
20
+ onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
21
+ /** 支付成功后触发 */
22
+ onSuccess?: (data: PaymentSuccessData) => void;
23
+ /** 支付失败时触发 */
24
+ onError?: (error: PayKKaError) => void;
25
+ /** 支付超时时触发 */
26
+ onTimeout?: () => void;
27
+ /** 收银台已过期时触发 */
28
+ onExpired?: () => void;
29
+ }
30
+ export interface DropInRefs {
31
+ /** 不展示支付按钮时,可调用该方法进行支付 */
32
+ payment: () => void;
33
+ }
34
+ export type PaymentMethodsConfig = {
35
+ [key in DropInPaymentCategory]: Partial<PaymentComponentProps<key>>;
36
+ };
37
+ export interface PaymentTypeOptions {
38
+ icon: ReactNode;
39
+ name: string;
40
+ type: DropInPaymentCategory;
41
+ }
42
+ /**
43
+ * 当前 drop in 支持的支付方式
44
+ * 目前暂不支持 WeChatPay 和 Alipay
45
+ */
46
+ export declare const dropInSupportedPaymentMethods: PaymentMethod[];
47
+ export type DropInPaymentCategory = PaymentCategory.APPLE_PAY | PaymentCategory.GOOGLE_PAY | PaymentCategory.CARD;
48
+ export declare const PaymentComponentMap: Record<DropInPaymentCategory, ComponentType<any>>;
49
+ export type PaymentComponentProps<P extends keyof typeof PaymentComponentMap> = React.ComponentProps<(typeof PaymentComponentMap)[P]>;
@@ -1,5 +1,6 @@
1
1
  import './google-pay.scss';
2
2
  import type { GooglePayProps, GooglePayRef } from './type';
3
- export declare const GooglePay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<GooglePayProps> & {
3
+ import type { CoreProps } from '../../types';
4
+ export declare const GooglePay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<GooglePayProps & CoreProps> & {
4
5
  ref?: import("preact").Ref<GooglePayRef> | undefined;
5
6
  }>;
@@ -1,3 +1,4 @@
1
+ import type { PayKKaError } from '../../core';
1
2
  import type { PaymentSuccessData } from '../../types';
2
3
  export interface GooglePayProps {
3
4
  /** 支付授权成功后触发 */
@@ -7,24 +8,35 @@ 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
  /** 收银台已过期时触发 */
14
15
  onExpired?: () => void;
15
- /** 交易被风控拦截时触发 */
16
- onAuthorized?: () => void;
17
- /** 交易需要 3DS 验证时触发,url 为 3DS 验证链接,incomplete 为 false 表示目前要开始进行 3DS 验证,为 true 表示上一次 3DS 验证还未完成 */
18
- onThreeDS?: (url: string, incomplete: boolean) => void;
19
16
  /** 当前设备环境是否可用于 Google Pay 支付 */
20
17
  onCanUse?: (canUse: boolean) => void;
21
18
  /**
22
- * 内部使用
19
+ * @internal
20
+ * 交易被风控拦截时触发
21
+ */
22
+ onAuthorized?: () => void;
23
+ /**
24
+ * @internal
25
+ * 交易需要 3DS 验证时触发
26
+ * url 为 3DS 验证链接
27
+ * incomplete 为 false 表示目前要开始进行 3DS 验证,为 true 表示上一次 3DS 验证还未完成
28
+ */
29
+ onThreeDS?: (url: string, incomplete: boolean) => void;
30
+ /**
31
+ * @internal
32
+ * 点击 GooglePay 按钮
23
33
  */
24
- /** 点击 GooglePay 按钮 */
25
34
  onBtnClick?: () => void;
26
35
  }
27
36
  export interface GooglePayRef {
28
- /** 3DS 验证流程结束后可调用该方法轮询收银台支付状态 */
37
+ /**
38
+ * @internal
39
+ * 3DS 验证流程结束后可调用该方法轮询收银台支付状态
40
+ */
29
41
  checkThreeDS: () => void;
30
42
  }
@@ -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,5 +1,6 @@
1
1
  import './sepa.scss';
2
2
  import type { SepaProps, SepaRef } from './type';
3
- export declare const Sepa: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<SepaProps> & {
3
+ import type { CoreProps } from '../../types';
4
+ export declare const Sepa: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<SepaProps & CoreProps> & {
4
5
  ref?: import("preact").Ref<SepaRef> | undefined;
5
6
  }>;
@@ -1,8 +1,9 @@
1
+ import type { PayKKaError } from '../../core';
1
2
  import type { FormValidateError } from '../internal/Form';
2
3
  export interface SepaProps {
3
4
  onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
4
5
  onSuccess?: (returnUrl?: string) => void;
5
- onError?: (error: any) => void;
6
+ onError?: (error: PayKKaError) => void;
6
7
  onTimeout?: () => void;
7
8
  onAuthorized?: () => void;
8
9
  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,5 +1,6 @@
1
1
  import './wechat-pay.scss';
2
2
  import type { WechatPayProps, WechatPayRef } from './type';
3
- export declare const WechatPay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<WechatPayProps> & {
3
+ import type { CoreProps } from '../../types';
4
+ export declare const WechatPay: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<WechatPayProps & CoreProps> & {
4
5
  ref?: import("preact").Ref<WechatPayRef> | undefined;
5
6
  }>;
@@ -1,9 +1,10 @@
1
1
  import type { PayRes } from '../../api';
2
+ import type { PayKKaError } from '../../core';
2
3
  import type { FormValidateError } from '../internal/Form';
3
4
  export interface WechatPayProps {
4
5
  onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
5
6
  onSuccess?: (...args: any[]) => void;
6
- onError?: (error: any) => void;
7
+ onError?: (error: PayKKaError) => void;
7
8
  onTimeout?: (source: 'retry' | 'channel') => void;
8
9
  onExpired?: () => void;
9
10
  onSubmitResponse?: (payRes: PayRes) => void;
@@ -16,4 +16,5 @@ 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';
20
+ export * from './DropIn';