@paykka/card-checkout-ui 0.13.8 → 0.13.13

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 (175) hide show
  1. package/dist/card-checkout-ui.js +20 -20
  2. package/dist/card-checkout-ui.umd.cjs +21 -21
  3. package/dist/es/_commonjsHelpers.js +1 -82
  4. package/dist/es/api/index.js +2 -1
  5. package/dist/es/api/modules/checkout/map.js +1 -0
  6. package/dist/es/api/modules/get-browser-params.js +20 -8
  7. package/dist/es/api/modules/index.js +2 -1
  8. package/dist/es/api/modules/map.js +2 -1
  9. package/dist/es/api/modules/risk/index.js +21 -18
  10. package/dist/es/api/modules/threeDS/index.js +2 -1
  11. package/dist/es/api/modules/vietqr/index.js +2 -1
  12. package/dist/es/api/utils/index.js +4 -1
  13. package/dist/es/components/AccordionItem/AccordionItem.js +0 -1
  14. package/dist/es/components/AccountNameField/index.js +1 -1
  15. package/dist/es/components/AddressField/index.js +1 -2
  16. package/dist/es/components/AliPay/index.js +4 -2
  17. package/dist/es/components/ApplePay/index.js +201 -135
  18. package/dist/es/components/Boost/index.js +4 -2
  19. package/dist/es/components/CPFField/index.js +88 -0
  20. package/dist/es/components/Card/index.js +5 -11
  21. package/dist/es/components/CardBrands/index.js +0 -1
  22. package/dist/es/components/CardExpireDateField/index.js +1 -1
  23. package/dist/es/components/CardHolderNameField/index.js +1 -1
  24. package/dist/es/components/CardIBANField/index.js +1 -1
  25. package/dist/es/components/CardNo/index.js +0 -1
  26. package/dist/es/components/CardNumberField/index.js +1 -1
  27. package/dist/es/components/CardSecurityCodeField/index.js +1 -1
  28. package/dist/es/components/CardSelector/index.js +1 -1
  29. package/dist/es/components/CombinedCardInfo/index.js +1 -1
  30. package/dist/es/components/DropIn/index.js +0 -1
  31. package/dist/es/components/EmailField/EmailField.js +1 -1
  32. package/dist/es/components/EncryptedCard/index.js +12 -11
  33. package/dist/es/components/GooglePay/index.js +1 -0
  34. package/dist/es/components/GrabPay/index.js +4 -2
  35. package/dist/es/components/GuideCard/index.js +1 -1
  36. package/dist/es/components/LinePay/index.js +4 -2
  37. package/dist/es/components/MayBankQRPay/index.js +4 -2
  38. package/dist/es/components/NinePay/index.js +4 -2
  39. package/dist/es/components/RecurringTip/index.js +1 -2
  40. package/dist/es/components/SecuredFieldsProvider/index.js +20 -3
  41. package/dist/es/components/SecuredIframe/index.js +50 -22
  42. package/dist/es/components/Sepa/index.js +4 -2
  43. package/dist/es/components/ShopeePay/index.js +4 -2
  44. package/dist/es/components/SubmitButton/index.js +1 -1
  45. package/dist/es/components/TNGWallet/index.js +4 -2
  46. package/dist/es/components/ThreeDS/index.js +1 -2
  47. package/dist/es/components/Tip/index.js +18 -0
  48. package/dist/es/components/WechatPay/index.js +4 -2
  49. package/dist/es/components/business/QRCodeModal/QRCodeModal.js +1 -1
  50. package/dist/es/components/business/QRCodeModal/index.js +0 -1
  51. package/dist/es/components/business/index.js +0 -1
  52. package/dist/es/components/index.js +0 -1
  53. package/dist/es/components/internal/Accordion/index.js +0 -1
  54. package/dist/es/components/internal/Button/Button.js +0 -1
  55. package/dist/es/components/internal/Button/index.js +0 -1
  56. package/dist/es/components/internal/CheckBox/CheckBox.js +0 -1
  57. package/dist/es/components/internal/CheckBox/index.js +0 -1
  58. package/dist/es/components/internal/Form/type.js +0 -1
  59. package/dist/es/components/internal/Info/Info.js +0 -1
  60. package/dist/es/components/internal/Info/index.js +0 -1
  61. package/dist/es/components/internal/Input/Input.js +1 -1
  62. package/dist/es/components/internal/Input/type.js +0 -1
  63. package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -1
  64. package/dist/es/components/internal/LoadingCheck/index.js +0 -1
  65. package/dist/es/components/internal/Modal/Modal.js +1 -1
  66. package/dist/es/components/internal/QRCode/QRCode.js +0 -1
  67. package/dist/es/components/internal/QRCode/index.js +0 -1
  68. package/dist/es/components/internal/Select/Select.js +14 -17
  69. package/dist/es/components/internal/Select/SelectMenu.js +2 -3
  70. package/dist/es/components/internal/Select/SelectMenuItem.js +0 -1
  71. package/dist/es/components/wallets/GCash/GCash.js +4 -2
  72. package/dist/es/components/wallets/OpayWallet/OpayWallet.js +8 -9
  73. package/dist/es/components/wallets/PagaWallet/PagaWallet.js +8 -9
  74. package/dist/es/components/wallets/Paymaya/Paymaya.js +4 -2
  75. package/dist/es/components/wallets/PicPay/PicPay.js +136 -72
  76. package/dist/es/components/wallets/Pix/Pix.js +136 -72
  77. package/dist/es/components/wallets/Vietqr/Vietqr.js +4 -2
  78. package/dist/es/components/wallets/Zalopay/Zalopay.js +4 -2
  79. package/dist/es/config.js +1 -1
  80. package/dist/es/constant.js +2 -0
  81. package/dist/es/core/checkout.js +15 -3
  82. package/dist/es/core/environment.js +10 -2
  83. package/dist/es/core/index.js +0 -1
  84. package/dist/es/core/query.js +2 -1
  85. package/dist/es/core/session.js +6 -2
  86. package/dist/es/core/theme.js +0 -1
  87. package/dist/es/core.js +585 -4
  88. package/dist/es/hooks/index.js +0 -1
  89. package/dist/es/hooks/useI18n.js +0 -1
  90. package/dist/es/hooks/usePayState.js +13 -6
  91. package/dist/es/i18n/locales/de-DE.js +6 -1
  92. package/dist/es/i18n/locales/en-GB.js +6 -1
  93. package/dist/es/i18n/locales/es-ES.js +6 -1
  94. package/dist/es/i18n/locales/fr-FR.js +7 -2
  95. package/dist/es/i18n/locales/ja-JP.js +6 -1
  96. package/dist/es/i18n/locales/ko-KR.js +6 -1
  97. package/dist/es/i18n/locales/nl-NL.js +6 -1
  98. package/dist/es/i18n/locales/pt-PT.js +6 -1
  99. package/dist/es/i18n/locales/ru-RU.js +6 -1
  100. package/dist/es/i18n/locales/zh-CN.js +6 -1
  101. package/dist/es/i18n/locales/zh-HK.js +7 -2
  102. package/dist/es/i18n/locales/zh-TW.js +7 -2
  103. package/dist/es/index.js +6 -3
  104. package/dist/es/out/base-fraud-detection.js +134 -0
  105. package/dist/es/out/config.js +16 -0
  106. package/dist/es/out/fraud-detection.js +118 -27
  107. package/dist/es/out/paykka-detection.js +63 -0
  108. package/dist/es/out/stripe-radar.js +25 -51
  109. package/dist/es/out/worldpay-ddc.js +52 -99
  110. package/dist/es/out/worldpay-jsc-origin.js +0 -1
  111. package/dist/es/out/worldpay-jsc.js +21 -43
  112. package/dist/es/style.css +1 -1
  113. package/dist/es/types/event.js +33 -13
  114. package/dist/es/types/index.js +14 -0
  115. package/dist/es/utils/cpf.js +48 -0
  116. package/dist/es/utils/encrypt.js +18 -0
  117. package/dist/es/utils/iframe.js +1 -1
  118. package/dist/es/utils/location.js +4 -2
  119. package/dist/es/utils/redirect.js +8 -5
  120. package/dist/es/utils/system-info/index.js +1 -3
  121. package/dist/style.css +1 -1
  122. package/dist/types/api/modules/checkout/type.d.ts +2 -0
  123. package/dist/types/api/modules/get-browser-params.d.ts +25 -1
  124. package/dist/types/api/modules/risk/index.d.ts +28 -12
  125. package/dist/types/api/modules/type.d.ts +5 -0
  126. package/dist/types/api/utils/index.d.ts +3 -0
  127. package/dist/types/components/ApplePay/config.d.ts +9 -0
  128. package/dist/types/components/ApplePay/hooks/useApplePay.d.ts +15 -0
  129. package/dist/types/components/ApplePay/type.d.ts +53 -10
  130. package/dist/types/components/ApplePay/utils.d.ts +8 -2
  131. package/dist/types/components/CPFField/CPFField.d.ts +4 -0
  132. package/dist/types/components/CPFField/index.d.ts +2 -0
  133. package/dist/types/components/CPFField/type.d.ts +21 -0
  134. package/dist/types/components/SecuredFieldsProvider/type.d.ts +8 -3
  135. package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +2 -5
  136. package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +6 -0
  137. package/dist/types/components/Tip/Tip.d.ts +3 -0
  138. package/dist/types/components/Tip/index.d.ts +2 -0
  139. package/dist/types/components/Tip/type.d.ts +12 -0
  140. package/dist/types/constant.d.ts +3 -1
  141. package/dist/types/core/checkout.d.ts +1 -1
  142. package/dist/types/core/environment.d.ts +12 -0
  143. package/dist/types/core/session.d.ts +1 -0
  144. package/dist/types/i18n/locales/de-DE.d.ts +4 -0
  145. package/dist/types/i18n/locales/en-GB.d.ts +4 -0
  146. package/dist/types/i18n/locales/es-ES.d.ts +4 -0
  147. package/dist/types/i18n/locales/fr-FR.d.ts +4 -0
  148. package/dist/types/i18n/locales/ja-JP.d.ts +4 -0
  149. package/dist/types/i18n/locales/ko-KR.d.ts +4 -0
  150. package/dist/types/i18n/locales/nl-NL.d.ts +4 -0
  151. package/dist/types/i18n/locales/pt-PT.d.ts +4 -0
  152. package/dist/types/i18n/locales/ru-RU.d.ts +4 -0
  153. package/dist/types/i18n/locales/zh-CN.d.ts +4 -0
  154. package/dist/types/i18n/locales/zh-HK.d.ts +4 -0
  155. package/dist/types/i18n/locales/zh-TW.d.ts +4 -0
  156. package/dist/types/out/base-fraud-detection.d.ts +53 -0
  157. package/dist/types/out/config.d.ts +11 -0
  158. package/dist/types/out/fraud-detection.d.ts +14 -3
  159. package/dist/types/out/paykka-detection.d.ts +20 -0
  160. package/dist/types/out/stripe-radar.d.ts +7 -9
  161. package/dist/types/out/types.d.ts +8 -2
  162. package/dist/types/out/worldpay-ddc.d.ts +7 -19
  163. package/dist/types/out/worldpay-jsc.d.ts +8 -18
  164. package/dist/types/types/event.d.ts +86 -39
  165. package/dist/types/types/fraud-detection.d.ts +1 -1
  166. package/dist/types/types/index.d.ts +22 -2
  167. package/dist/types/types/message.d.ts +12 -12
  168. package/dist/types/utils/app-payment.d.ts +2 -0
  169. package/dist/types/utils/cpf.d.ts +32 -0
  170. package/dist/types/utils/encrypt.d.ts +9 -0
  171. package/dist/types/utils/location.d.ts +1 -0
  172. package/dist/types/utils/system-info/index.d.ts +0 -1
  173. package/package.json +5 -4
  174. package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +0 -3
  175. package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +0 -6
@@ -89,5 +89,7 @@ export declare enum SessionMode {
89
89
  }
90
90
  export declare enum ChannelCode {
91
91
  STRIPE = "STRIPE",
92
- WORLDPAY = "WORLD_PAY"
92
+ WORLDPAY = "WORLD_PAY",
93
+ WORLDPAY_JSC = "WORLDPAY_JSC",
94
+ PAYKKA = "PAYKKA"
93
95
  }
@@ -1,5 +1,5 @@
1
1
  import type { ComponentType, JSX } from 'preact';
2
- import type { CoreProps, PayKKaEnvConfig, PayKKaInitConfiguration } from '../types';
2
+ import { type CoreProps, type PayKKaEnvConfig, type PayKKaInitConfiguration } from '../types';
3
3
  import { type ComponentInst } from './create';
4
4
  import { Session } from './session';
5
5
  import getFraudDetectionInstance from '../out/fraud-detection';
@@ -1,3 +1,15 @@
1
+ /**
2
+ * 环境配置
3
+ * 打正式包时,fat/dev 环境会被剔除
4
+ */
1
5
  import type { PayKKaEnvType } from '../types';
2
6
  export declare const apiEnv: Record<PayKKaEnvType, string>;
3
7
  export declare const cdnEnv: Record<PayKKaEnvType, string>;
8
+ /**
9
+ * cdn 地址映射到 api 地址
10
+ * @remark
11
+ * 1. cdn 没有 dev 地址
12
+ * 2. 之所以直接用域名映射,是因为一些特殊的 CDN 文件,如 3DS iframe 需要进行一些请求,但是又没法拿到商户传给 SDK 的 env,所以直接用域名映射
13
+ * 3. 一定要保证映射正确,如果之后新增了域名,一定要在这里添加映射
14
+ */
15
+ export declare const cdn2ApiMap: Record<string, string>;
@@ -15,6 +15,7 @@ export declare class Session {
15
15
  #private;
16
16
  sessionId?: string;
17
17
  readonly clientKey?: string;
18
+ paykkaDetectionKey?: string;
18
19
  checkout?: CheckoutRes;
19
20
  theme: import("@preact/signals").Signal<Recordable<any>>;
20
21
  extraParams: Recordable;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -75,5 +75,9 @@ declare const _default: {
75
75
  'qrCode.scanByGcash': string;
76
76
  'qrCode.scanByZalopay': string;
77
77
  'qrCode.scanByVietqr': string;
78
+ 'cpf.label': string;
79
+ 'cpf.incomplete': string;
80
+ 'cpf.placeholder': string;
81
+ iofTip: string;
78
82
  };
79
83
  export default _default;
@@ -0,0 +1,53 @@
1
+ import type { FraudDetectionOptions } from './types';
2
+ import { FraudDetectionEventType, type EventData } from '../types/event';
3
+ import type { ChannelCode } from '../constant';
4
+ import type { ChannelSDKConfig } from '../api';
5
+ /**
6
+ * 欺诈检测收集器的抽象类
7
+ * 用于处理各个渠道下,各个生命周期下得通用行为,包括事件上报
8
+ */
9
+ export declare abstract class BaseFraudDetection {
10
+ /** 当前渠道 */
11
+ protected channel: ChannelCode;
12
+ protected options?: FraudDetectionOptions;
13
+ /** 欺诈检测 id */
14
+ protected fraudDetectionId?: string;
15
+ /** 渠道配置 */
16
+ protected channelConfig?: ChannelSDKConfig;
17
+ /** 超时时间,单位:毫秒,如果渠道需要设置超时时间,则需要传入 */
18
+ protected timeout?: number | null;
19
+ private timer;
20
+ private initPromise;
21
+ constructor(params: {
22
+ channel: ChannelCode;
23
+ channelConfig?: ChannelSDKConfig;
24
+ timeout?: number | null;
25
+ options?: FraudDetectionOptions;
26
+ });
27
+ /** 如果渠道获取 id 需要一些配置,则需要实现该方法进行校验 */
28
+ protected validateChannelConfig(): boolean;
29
+ /** 如果渠道需要加载外部资源,则需要实现该方法进行加载 */
30
+ protected load(): Promise<void>;
31
+ /** 获取欺诈检测 id */
32
+ protected abstract collect(...args: any[]): Promise<string | undefined>;
33
+ /**
34
+ * 通用初始化方法
35
+ * 1. 上报开始事件
36
+ * 2. 校验渠道配置,如果校验失败,上报渠道配置错误事件
37
+ * 3. 加载渠道资源,如果加载失败,上报加载失败事件
38
+ * 4. 收集欺诈检测 id
39
+ * 5. 上报成功事件,如果收集失败,上报失败事件
40
+ */
41
+ init(...args: any[]): Promise<void>;
42
+ private clearTimer;
43
+ private createTimeoutPromise;
44
+ getFraudDetectionId(): string | undefined | null;
45
+ protected onError(error: Error): void;
46
+ protected onWarning(message?: string): void;
47
+ /**
48
+ * 统一的事件上报方法,尽量不要在子类中调用该方法,减少耦合
49
+ * @param eventType 事件类型
50
+ * @param data 事件数据(可选,无需传 channel)
51
+ */
52
+ protected reportEvent<T extends FraudDetectionEventType>(eventType: T, data?: Omit<EventData<T>, 'channel'>): void;
53
+ }
@@ -0,0 +1,11 @@
1
+ export declare const JSC_LIVE_CONFIG: {
2
+ organizationId: string;
3
+ profilingDomain: string;
4
+ };
5
+ export declare const JSC_TEST_CONFIG: {
6
+ organizationId: string;
7
+ profilingDomain: string;
8
+ };
9
+ export declare const STRIPE_RADAR_SCRIPT_URL = "https://js.stripe.com/v3/";
10
+ /** ddc 超时时间, 10s */
11
+ export declare const DDC_TIMEOUT = 10000;
@@ -1,10 +1,21 @@
1
- import { type CollModeType, type FraudDetectionEnv } from '../types';
2
- import type { FraudDetectionOptions } from './types';
1
+ import { type CollModeType } from '../types';
2
+ import type { FraudDetectionConfig, FraudDetectionOptions } from './types';
3
3
  type FraudDetectionType = {
4
4
  getFraudDetectionId: (options?: {
5
5
  bin?: string;
6
6
  }) => Promise<string>;
7
7
  createFraudDetection: () => Promise<void>;
8
8
  };
9
- export default function getFraudDetectionInstance(env?: FraudDetectionEnv, mode?: CollModeType[], options?: FraudDetectionOptions): FraudDetectionType;
9
+ export default function getFraudDetectionInstance(config: FraudDetectionConfig,
10
+ /**
11
+ * 内部配置
12
+ * @internal
13
+ */
14
+ options?: FraudDetectionOptions,
15
+ /**
16
+ * 可用渠道列表
17
+ * 仅供Hosted等页面收银台使用,不能让用户知道我们有哪些渠道
18
+ * @internal
19
+ */
20
+ mode?: CollModeType[]): FraudDetectionType;
10
21
  export {};
@@ -0,0 +1,20 @@
1
+ import { type ChannelSDKConfig } from '../api';
2
+ import { BaseFraudDetection } from './base-fraud-detection';
3
+ import type { FraudDetectionOptions } from './types';
4
+ /**
5
+ * 环境检测
6
+ * 目前只用最简单的方式,直接获取 referer 和 origin 进行上报
7
+ * 1. 获取 referer 和 origin,剔除参数
8
+ * 2. 加密数据,AES-GCM 加密,密钥用 clientKey 的 SHA-256 哈希,nonce 随机,不幂等
9
+ * 3. 上报数据,获取 paykka id
10
+ */
11
+ export declare class PayKKaDetection extends BaseFraudDetection {
12
+ private static instance;
13
+ constructor(options?: FraudDetectionOptions, channelConfig?: ChannelSDKConfig);
14
+ protected validateChannelConfig(): boolean;
15
+ protected collect(): Promise<any>;
16
+ /** 获取页面来源域名 */
17
+ private getReferer;
18
+ /** 获取当前页面域名 */
19
+ private getOrigin;
20
+ }
@@ -1,3 +1,5 @@
1
+ import { type ChannelSDKConfig } from '../api';
2
+ import { BaseFraudDetection } from './base-fraud-detection';
1
3
  import type { FraudDetectionOptions } from './types';
2
4
  /**
3
5
  * Stripe Radar,单例模式,radar session id 是非必须的,不用等待其完成
@@ -8,14 +10,10 @@ import type { FraudDetectionOptions } from './types';
8
10
  *
9
11
  * @see {@link https://docs.stripe.com/radar/radar-session}
10
12
  */
11
- export declare class StripeRadar {
13
+ export declare class StripeRadar extends BaseFraudDetection {
12
14
  private static instance;
13
- private options?;
14
- private radarSessionId;
15
- constructor(options?: FraudDetectionOptions);
16
- private init;
17
- getFraudDetectionId(): string | undefined;
18
- private setRadarSessionId;
19
- private getStripeKey;
20
- private loadStripeScript;
15
+ constructor(options?: FraudDetectionOptions, channelConfig?: ChannelSDKConfig);
16
+ protected validateChannelConfig(): boolean;
17
+ protected collect(): Promise<string | undefined>;
18
+ protected load(): Promise<void>;
21
19
  }
@@ -1,2 +1,8 @@
1
- import type { PayKKaInitConfiguration } from '../types';
2
- export type FraudDetectionOptions = {} & Pick<PayKKaInitConfiguration, 'onEvent'>;
1
+ import type { FraudDetectionEnv, PayKKaInitConfiguration } from '../types';
2
+ export type FraudDetectionOptions = {
3
+ sessionMode?: string;
4
+ } & Pick<PayKKaInitConfiguration, 'onEvent'>;
5
+ export type FraudDetectionConfig = {
6
+ env?: FraudDetectionEnv;
7
+ clientKey: string;
8
+ };
@@ -1,4 +1,6 @@
1
+ import { type ChannelSDKConfig } from '../api/modules/risk';
1
2
  import type { FraudDetectionOptions } from './types';
3
+ import { BaseFraudDetection } from './base-fraud-detection';
2
4
  /**
3
5
  * worldpay ddc,单例模式,此处 SessionId 指的是 fraudDetectionId
4
6
  *
@@ -11,26 +13,14 @@ import type { FraudDetectionOptions } from './types';
11
13
  *
12
14
  * @see {@link https://docs.worldpay.com/apis/wpg/directintegration/cardinalsecuretest}
13
15
  */
14
- export declare class WorldpayDDC {
16
+ export declare class WorldpayDDC extends BaseFraudDetection {
15
17
  private static instance;
16
18
  private iframe;
17
- private jwt;
18
19
  private listener;
19
- private timer;
20
- private fraudDetectionId;
21
- private p;
22
- private options?;
23
- private config;
24
- constructor(config?: {
25
- ddcOrigin?: string;
26
- ddcCollectUrl?: string;
27
- }, options?: FraudDetectionOptions);
28
- /**
29
- * 获取 fraudDetectionId,每次支付的时候都要调用
30
- * @param bin 最好是完整卡号,至少得是 6 位卡 bin
31
- */
32
- getFraudDetectionId(bin: string): Promise<string>;
33
- private requestFraudDetectionId;
20
+ constructor(options?: FraudDetectionOptions, channelConfig?: ChannelSDKConfig);
21
+ protected validateChannelConfig(): boolean;
22
+ protected load(): Promise<void>;
23
+ protected collect(bin: string): Promise<string>;
34
24
  private sendJWTAndBin;
35
25
  /**
36
26
  * 监听 worldpay 返回的 fraudDetectionId
@@ -39,6 +29,4 @@ export declare class WorldpayDDC {
39
29
  */
40
30
  private listenFraudDetectionId;
41
31
  private clearListener;
42
- private getJWT;
43
- private initIframe;
44
32
  }
@@ -1,5 +1,7 @@
1
1
  import './worldpay-jsc-origin';
2
2
  import type { FraudDetectionOptions } from './types';
3
+ import { BaseFraudDetection } from './base-fraud-detection';
4
+ import type { ChannelSDKConfig } from '../api';
3
5
  /**
4
6
  * {@link https://docs.worldpay.com/apis/wpg/fraudsightglobal/fraudsightdirect#worldpay-device-javascript-collector-jsc-}
5
7
  * {@link https://developer.worldpay.com/products/fraudsight/device-data/web?utm_source=chatgpt.com}
@@ -16,23 +18,11 @@ import type { FraudDetectionOptions } from './types';
16
18
  * 如何判断需要更新垃圾代码:worldpay 会给脚本添加一个 version 字段,如果变了,就需要更新垃圾代码(目前是 4)
17
19
  * 更新垃圾代码之后记得将变量 threatmetrix 替换成 window.worldpayJSCOrigin,profile 替换成 load
18
20
  */
19
- export declare class WorldpayJSC {
21
+ export declare class WorldpayJSC extends BaseFraudDetection {
20
22
  private static instance;
21
- private options?;
22
- fraudDetectionId: string | null;
23
- config: {
24
- organizationId: string;
25
- profilingDomain: string;
26
- };
27
- constructor(config?: {
28
- organizationId?: string;
29
- profilingDomain?: string;
30
- }, options?: FraudDetectionOptions);
31
- private init;
32
- private loadJSC;
33
- /**
34
- * 生成一个随机 fraudDetectionId
35
- * @returns 随机生成的 fraudDetectionId
36
- */
37
- private getFraudDetectionId;
23
+ constructor(options?: FraudDetectionOptions, channelConfig?: ChannelSDKConfig);
24
+ protected validateChannelConfig(): boolean;
25
+ /** 生成一个随机 fraudDetectionId */
26
+ protected collect(): Promise<string>;
27
+ private getRandomId;
38
28
  }
@@ -1,53 +1,100 @@
1
+ import type { ChannelCode } from '../constant';
2
+ import type { PaymentMethod } from '../constant';
1
3
  /**
2
4
  * 事件类型
3
5
  * 适用于埋点上报
4
6
  */
5
- export type EventType = FraudDetectionEventType;
7
+ export type EventType = FraudDetectionEventType | ApplePayEventType | GooglePayEventType | PaymentEventType;
8
+ export type EventData<T extends EventType> = EventDataMapping[T];
6
9
  /** fraud detection 事件类型 */
7
10
  export declare enum FraudDetectionEventType {
8
11
  /** fraud detection 数据转换报错 */
9
12
  FRAUD_DETECTION_TRANSFORM_ERROR = "fraudDetection:transFormError",
10
- /** stripe radar 获取 sessionId 报错 */
11
- STRIPE_RADAR_ERROR = "stripeRadar:error",
12
- /** stripe radar 加载失败 */
13
- STRIPE_RADAR_LOAD_ERROR = "stripeRadar:loadError",
14
- /** stripe radar 渠道配置 API 报错 */
15
- STRIPE_RADAR_API_ERROR = "stripeRadar:apiError",
16
- /** stripe radar 开始获取 */
17
- STRIPE_RADAR_START = "stripeRadar:start",
18
- /** stripe radar 成功 */
19
- STRIPE_RADAR_SUCCESS = "stripeRadar:success",
20
- /** worldpay ddc 开始获取 */
21
- WORLDPAY_DDC_START = "worldpayDDC:start",
22
- /** worldpay ddc 获取 sessionId 报错 */
23
- WORLDPAY_DDC_ERROR = "worldpayDDC:error",
24
- /** worldpay ddc 超时 */
25
- WORLDPAY_DDC_TIMEOUT = "worldpayDDC:timeout",
26
- /** worldpay ddc 成功 */
27
- WORLDPAY_DDC_SUCCESS = "worldpayDDC:success",
28
- /** worldpay jsc 开始获取 */
29
- WORLDPAY_JSC_START = "worldpayJSC:start",
30
- /** worldpay jsc 获取 sessionId 报错 */
31
- WORLDPAY_JSC_ERROR = "worldpayJSC:error",
32
- /** worldpay jsc 成功 */
33
- WORLDPAY_JSC_SUCCESS = "worldpayJSC:success"
34
- }
35
- export type EventData<T extends FraudDetectionEventType> = EventDataMapping[T];
13
+ /** fraud detection 渠道配置 API 报错 */
14
+ FRAUD_DETECTION_CHANNEL_CONFIG_ERROR = "fraudDetection:channelConfigError",
15
+ /** fraud detection 开始获取 id */
16
+ FRAUD_DETECTION_START = "fraudDetection:start",
17
+ /** fraud detection 获取 id 成功 */
18
+ FRAUD_DETECTION_SUCCESS = "fraudDetection:success",
19
+ /** fraud detection 获取 id 报错 */
20
+ FRAUD_DETECTION_ERROR = "fraudDetection:error",
21
+ /** fraud detection 超时 */
22
+ FRAUD_DETECTION_TIMEOUT = "fraudDetection:timeout",
23
+ /** fraud detection 加载失败 */
24
+ FRAUD_DETECTION_LOAD_ERROR = "fraudDetection:loadError",
25
+ /** fraud detection 警告事件 */
26
+ FRAUD_DETECTION_WARNING = "fraudDetection:warning"
27
+ }
28
+ export declare enum ApplePayEventType {
29
+ /** Apple Pay SDK 加载失败 */
30
+ APPLE_PAY_LOAD_ERROR = "applePay:loadError",
31
+ /** 当前环境不支持 Apple Pay */
32
+ APPLE_PAY_CAN_NOT_USE = "applePay:canNotUse",
33
+ /** 点击 Apple Pay 按钮 */
34
+ APPLE_PAY_BUTTON_CLICKED = "applePay:buttonClicked",
35
+ /** Apple Pay 正在验证商户 */
36
+ APPLE_PAY_VALIDATE_MERCHANT = "applePay:validateMerchant",
37
+ /** Apple Pay 支付授权成功 */
38
+ APPLE_PAY_AUTHORIZED = "applePay:authorized",
39
+ /** Apple Pay 取消支付 */
40
+ APPLE_PAY_CANCELLED = "applePay:cancelled"
41
+ }
42
+ export declare enum GooglePayEventType {
43
+ /** Google Pay SDK 加载失败 */
44
+ GOOGLE_PAY_LOAD_ERROR = "googlePay:loadError",
45
+ /** 当前环境不支持 Google Pay */
46
+ GOOGLE_PAY_CAN_NOT_USE = "googlePay:canNotUse",
47
+ /** 点击 Google Pay 按钮 */
48
+ GOOGLE_PAY_BUTTON_CLICKED = "googlePay:buttonClicked"
49
+ }
50
+ export declare enum PaymentEventType {
51
+ /** 支付成功 */
52
+ PAYMENT_SUCCESS = "payment:success",
53
+ /** 支付失败 */
54
+ PAYMENT_FAILURE = "payment:failure",
55
+ /** 支付超时 */
56
+ PAYMENT_TIMEOUT = "payment:timeout",
57
+ /** 支付过期 */
58
+ PAYMENT_EXPIRED = "payment:expired"
59
+ }
36
60
  export interface EventDataMapping {
37
61
  [FraudDetectionEventType.FRAUD_DETECTION_TRANSFORM_ERROR]: undefined;
38
- [FraudDetectionEventType.STRIPE_RADAR_API_ERROR]: CommonEventData;
39
- [FraudDetectionEventType.STRIPE_RADAR_LOAD_ERROR]: undefined;
40
- [FraudDetectionEventType.STRIPE_RADAR_SUCCESS]: undefined;
41
- [FraudDetectionEventType.STRIPE_RADAR_START]: undefined;
42
- [FraudDetectionEventType.WORLDPAY_DDC_ERROR]: undefined;
43
- [FraudDetectionEventType.WORLDPAY_DDC_TIMEOUT]: undefined;
44
- [FraudDetectionEventType.WORLDPAY_DDC_SUCCESS]: undefined;
45
- [FraudDetectionEventType.WORLDPAY_DDC_START]: undefined;
46
- [FraudDetectionEventType.WORLDPAY_JSC_ERROR]: undefined;
47
- [FraudDetectionEventType.WORLDPAY_JSC_SUCCESS]: undefined;
48
- [FraudDetectionEventType.WORLDPAY_JSC_START]: undefined;
49
- [FraudDetectionEventType.STRIPE_RADAR_ERROR]: undefined;
62
+ [FraudDetectionEventType.FRAUD_DETECTION_CHANNEL_CONFIG_ERROR]: FraudDetectionBaseData;
63
+ [FraudDetectionEventType.FRAUD_DETECTION_LOAD_ERROR]: FraudDetectionBaseData;
64
+ [FraudDetectionEventType.FRAUD_DETECTION_START]: FraudDetectionBaseData;
65
+ [FraudDetectionEventType.FRAUD_DETECTION_SUCCESS]: FraudDetectionBaseData;
66
+ [FraudDetectionEventType.FRAUD_DETECTION_ERROR]: FraudDetectionErrorData;
67
+ [FraudDetectionEventType.FRAUD_DETECTION_TIMEOUT]: FraudDetectionBaseData;
68
+ [FraudDetectionEventType.FRAUD_DETECTION_WARNING]: FraudDetectionBaseData & CommonEventData;
69
+ [ApplePayEventType.APPLE_PAY_LOAD_ERROR]: undefined;
70
+ [ApplePayEventType.APPLE_PAY_CAN_NOT_USE]: undefined;
71
+ [ApplePayEventType.APPLE_PAY_BUTTON_CLICKED]: undefined;
72
+ [ApplePayEventType.APPLE_PAY_VALIDATE_MERCHANT]: undefined;
73
+ [ApplePayEventType.APPLE_PAY_AUTHORIZED]: undefined;
74
+ [ApplePayEventType.APPLE_PAY_CANCELLED]: undefined;
75
+ [GooglePayEventType.GOOGLE_PAY_LOAD_ERROR]: undefined;
76
+ [GooglePayEventType.GOOGLE_PAY_CAN_NOT_USE]: undefined;
77
+ [GooglePayEventType.GOOGLE_PAY_BUTTON_CLICKED]: undefined;
78
+ [PaymentEventType.PAYMENT_SUCCESS]: PaymentBaseData;
79
+ [PaymentEventType.PAYMENT_FAILURE]: PaymentFailureEventData;
80
+ [PaymentEventType.PAYMENT_TIMEOUT]: PaymentBaseData;
81
+ [PaymentEventType.PAYMENT_EXPIRED]: PaymentBaseData;
50
82
  }
51
83
  export interface CommonEventData {
52
84
  message?: string;
53
85
  }
86
+ export interface FraudDetectionBaseData {
87
+ /** 当前渠道 */
88
+ channel: ChannelCode;
89
+ }
90
+ export interface FraudDetectionErrorData extends FraudDetectionBaseData {
91
+ /** 错误信息 */
92
+ message?: string;
93
+ }
94
+ export interface PaymentFailureEventData extends PaymentBaseData {
95
+ message?: string;
96
+ code?: string;
97
+ }
98
+ export interface PaymentBaseData {
99
+ paymentMethod?: PaymentMethod;
100
+ }
@@ -8,4 +8,4 @@ export declare const enum ECollMode {
8
8
  WJ = "WJ"
9
9
  }
10
10
  export type CollModeType = keyof typeof ECollMode;
11
- export type FraudDetectionEnv = PayKKaEnvType | FraudDetectionConfig;
11
+ export type FraudDetectionEnv = PayKKaEnvType;
@@ -91,6 +91,24 @@ export interface PayKKaEnvConfig {
91
91
  fraudDetection?: FraudDetectionEnv;
92
92
  }
93
93
  export type PayKKaEnvType = `${EPayKKaEnv}`;
94
+ export declare enum PaymentStatus {
95
+ /** 支付中或未支付 */
96
+ PROCESSING = "PROCESSING",
97
+ /** 支付成功 */
98
+ SUCCESS = "SUCCESS",
99
+ /** 支付失败 */
100
+ FAILURE = "FAILURE",
101
+ /** 支付授权成功 */
102
+ AUTHORIZED = "AUTHORIZED",
103
+ /** 支付过期 */
104
+ EXPIRED = "EXPIRED",
105
+ /** 支付取消 */
106
+ CANCELLED = "CANCELLED",
107
+ /** 3DS 认证中 */
108
+ IN_THREEDS = "IN_THREEDS",
109
+ /** 上一次 3DS 认证未完成 */
110
+ IN_PREVIOUS_THREEDS = "IN_PREVIOUS_THREEDS"
111
+ }
94
112
  export interface BasePaymentInfo {
95
113
  /** 会话 ID */
96
114
  sessionId?: string;
@@ -120,8 +138,10 @@ export interface BasePaymentInfo {
120
138
  payInfo?: {
121
139
  /** 三方认证 URL */
122
140
  threeDSUrl?: string;
123
- /** 支付 URL */
124
- paymentUrl?: string;
141
+ /** 目标 URL,可能是跳转渠道页的 url,也可能是请求的 url,取决于 requestMethod */
142
+ targetUrl?: string;
143
+ /** 请求方法 */
144
+ requestMethod?: string;
125
145
  /** 支付过期时间 */
126
146
  paymentExpiredAt?: string;
127
147
  /** 其他支付信息 */