@paykka/card-checkout-ui 0.9.2 → 0.11.4

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 (108) hide show
  1. package/dist/card-checkout-ui.js +16 -16
  2. package/dist/card-checkout-ui.umd.cjs +16 -16
  3. package/dist/es/api/index.js +1 -2
  4. package/dist/es/api/modules/index.js +1 -2
  5. package/dist/es/api/modules/risk/index.js +13 -0
  6. package/dist/es/api/modules/threeDS/index.js +1 -0
  7. package/dist/es/components/AccordionItem/AccordionItem.js +1 -0
  8. package/dist/es/components/AccountNameField/index.js +1 -0
  9. package/dist/es/components/AddressField/index.js +1 -0
  10. package/dist/es/components/AliPay/index.js +1 -1
  11. package/dist/es/components/ApplePay/index.js +2 -2
  12. package/dist/es/components/Boost/index.js +3 -1
  13. package/dist/es/components/Card/index.js +29 -8
  14. package/dist/es/components/CardBrands/index.js +1 -0
  15. package/dist/es/components/CardExpireDateField/index.js +1 -0
  16. package/dist/es/components/CardHolderNameField/index.js +1 -0
  17. package/dist/es/components/CardIBANField/index.js +1 -0
  18. package/dist/es/components/CardNo/index.js +1 -0
  19. package/dist/es/components/CardNumberField/index.js +13 -2
  20. package/dist/es/components/CardSecurityCodeField/index.js +1 -0
  21. package/dist/es/components/CardSelector/index.js +1 -0
  22. package/dist/es/components/CombinedCardInfo/index.js +4 -0
  23. package/dist/es/components/DropIn/index.js +2 -1
  24. package/dist/es/components/EmailField/EmailField.js +14 -15
  25. package/dist/es/components/EncryptedCard/index.js +1 -0
  26. package/dist/es/components/GooglePay/index.js +2 -2
  27. package/dist/es/components/GrabPay/index.js +3 -1
  28. package/dist/es/components/GuideCard/index.js +1 -0
  29. package/dist/es/components/LinePay/index.js +3 -1
  30. package/dist/es/components/MayBankQRPay/index.js +3 -1
  31. package/dist/es/components/NinePay/index.js +3 -1
  32. package/dist/es/components/RecurringTip/index.js +1 -0
  33. package/dist/es/components/SecuredFieldsProvider/index.js +2 -1
  34. package/dist/es/components/SecuredIframe/index.js +54 -2
  35. package/dist/es/components/Sepa/index.js +1 -1
  36. package/dist/es/components/ShopeePay/index.js +3 -1
  37. package/dist/es/components/SubmitButton/index.js +1 -0
  38. package/dist/es/components/TNGWallet/index.js +3 -1
  39. package/dist/es/components/ThreeDS/index.js +1 -0
  40. package/dist/es/components/WechatPay/index.js +1 -1
  41. package/dist/es/components/business/QRCodeModal/QRCodeModal.js +1 -0
  42. package/dist/es/components/business/QRCodeModal/index.js +1 -0
  43. package/dist/es/components/business/index.js +1 -0
  44. package/dist/es/components/index.js +1 -0
  45. package/dist/es/components/internal/Accordion/index.js +1 -0
  46. package/dist/es/components/internal/Button/Button.js +1 -0
  47. package/dist/es/components/internal/Button/index.js +1 -0
  48. package/dist/es/components/internal/CheckBox/CheckBox.js +1 -0
  49. package/dist/es/components/internal/CheckBox/index.js +1 -0
  50. package/dist/es/components/internal/Form/type.js +1 -0
  51. package/dist/es/components/internal/Info/Info.js +1 -0
  52. package/dist/es/components/internal/Info/index.js +1 -0
  53. package/dist/es/components/internal/Input/type.js +1 -0
  54. package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +1 -0
  55. package/dist/es/components/internal/LoadingCheck/index.js +1 -0
  56. package/dist/es/components/internal/Modal/Modal.js +1 -0
  57. package/dist/es/components/internal/QRCode/QRCode.js +1 -0
  58. package/dist/es/components/internal/QRCode/index.js +1 -0
  59. package/dist/es/components/internal/Select/Select.js +11 -9
  60. package/dist/es/components/internal/Select/SelectMenu.js +1 -0
  61. package/dist/es/components/internal/Select/SelectMenuItem.js +1 -0
  62. package/dist/es/components/wallets/GCash/GCash.js +15 -3
  63. package/dist/es/components/wallets/Paymaya/Paymaya.js +3 -1
  64. package/dist/es/core/PayKKaCheckout.js +7 -2
  65. package/dist/es/core/index.js +1 -0
  66. package/dist/es/core/query.js +1 -2
  67. package/dist/es/hooks/index.js +1 -0
  68. package/dist/es/hooks/useI18n.js +1 -0
  69. package/dist/es/hooks/usePayState.js +7 -2
  70. package/dist/es/i18n/locales/index.js +2 -1
  71. package/dist/es/i18n/locales/nl-NL.js +88 -0
  72. package/dist/es/index.js +2 -0
  73. package/dist/es/out/fraud-detection.js +39 -13
  74. package/dist/es/out/worldpay-ddc.js +143 -0
  75. package/dist/es/types/event.js +15 -0
  76. package/dist/es/types/fraud-detection.js +1 -0
  77. package/dist/es/types/message.js +3 -0
  78. package/dist/es/utils/iframe.js +1 -1
  79. package/dist/es/utils/reg-exp.js +4 -0
  80. package/dist/types/api/modules/index.d.ts +2 -0
  81. package/dist/types/api/modules/risk/index.d.ts +8 -0
  82. package/dist/types/api/modules/threeDS/index.d.ts +3 -0
  83. package/dist/types/components/CardNumberField/type.d.ts +7 -1
  84. package/dist/types/components/CombinedCardInfo/type.d.ts +1 -0
  85. package/dist/types/components/SecuredFieldsProvider/type.d.ts +1 -1
  86. package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +1 -0
  87. package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -1
  88. package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +13 -3
  89. package/dist/types/components/internal/Select/Select.d.ts +1 -17
  90. package/dist/types/components/internal/Select/type.d.ts +26 -1
  91. package/dist/types/components/wallets/GCash/type.d.ts +5 -0
  92. package/dist/types/core/error.d.ts +12 -1
  93. package/dist/types/hooks/usePayState.d.ts +5 -2
  94. package/dist/types/i18n/locales/index.d.ts +2 -0
  95. package/dist/types/i18n/locales/nl-NL.d.ts +71 -0
  96. package/dist/types/index.d.ts +1 -0
  97. package/dist/types/out/fraud-detection.d.ts +5 -1
  98. package/dist/types/out/types.d.ts +4 -0
  99. package/dist/types/out/worldpay-ddc-iframe.d.ts +1 -0
  100. package/dist/types/out/worldpay-ddc.d.ts +37 -0
  101. package/dist/types/types/event.d.ts +26 -0
  102. package/dist/types/types/fraud-detection.d.ts +3 -1
  103. package/dist/types/types/index.d.ts +13 -1
  104. package/dist/types/types/message.d.ts +21 -2
  105. package/dist/types/utils/iframe.d.ts +1 -1
  106. package/dist/types/utils/index.d.ts +1 -0
  107. package/dist/types/utils/reg-exp.d.ts +1 -0
  108. package/package.json +3 -1
@@ -0,0 +1,71 @@
1
+ declare const _default: {
2
+ 'guideCard.redirectDescription': string;
3
+ 'guideCard.scanQRCode': string;
4
+ 'dropIn.card.label': string;
5
+ 'dropIn.otherPaymentMethod': string;
6
+ 'dropIn.boost.label': string;
7
+ 'dropIn.TNGWallet.label': string;
8
+ 'dropIn.shopeePay.label': string;
9
+ 'dropIn.mayBankQRPay.label': string;
10
+ 'dropIn.grabPay.label': string;
11
+ 'dropIn.linePay.label': string;
12
+ 'dropIn.ninePay.label': string;
13
+ 'dropIn.gcash.label': string;
14
+ 'dropIn.paymaya.label': string;
15
+ 'card.cardNumber.label': string;
16
+ 'card.cardNumber.incomplete': string;
17
+ 'card.cardNumber.invalid': string;
18
+ 'card.cardNumber.placeholder': string;
19
+ 'card.cardExpireDate.label': string;
20
+ 'card.cardExpireDate.placeholder': string;
21
+ 'card.cardExpireDate.incomplete': string;
22
+ 'card.cardExpireDate.expired': string;
23
+ 'card.cardSecurityCode.label': string;
24
+ 'card.cardSecurityCode.placeholder': string;
25
+ 'card.cardSecurityCode.incomplete': string;
26
+ 'card.cardHolderName.label': string;
27
+ 'card.cardHolderName.placeholder': string;
28
+ 'card.cardHolderName.incomplete': string;
29
+ 'card.cardSelector.change': string;
30
+ 'card.cardSelector.useOtherCard': string;
31
+ 'card.storeInfo': string;
32
+ 'card.info.label': string;
33
+ 'common.pay': string;
34
+ 'common.payProcessing': string;
35
+ 'common.paySuccess': string;
36
+ 'common.payTimeout': string;
37
+ 'common.pay3DSIncomplete': string;
38
+ 'common.queryTimeout': string;
39
+ 'common.generateQrCode': string;
40
+ 'common.recurringTip': string;
41
+ 'common.noData': string;
42
+ 'common.netError': string;
43
+ 'common.unknownError': string;
44
+ 'common.cancel': string;
45
+ 'common.confirm': string;
46
+ 'common.email.label': string;
47
+ 'common.email.incomplete': string;
48
+ 'common.email.incorrect': string;
49
+ 'common.accountName.label': string;
50
+ 'common.accountName.placeholder': string;
51
+ 'common.accountName.incomplete': string;
52
+ 'address.label': string;
53
+ 'address.country': string;
54
+ 'address.address1': string;
55
+ 'address.address2': string;
56
+ 'address.city': string;
57
+ 'address.postCode': string;
58
+ 'address.province': string;
59
+ 'address.area': string;
60
+ 'sepa.iban.label': string;
61
+ 'sepa.iban.placeholder': string;
62
+ 'sepa.iban.invalid': string;
63
+ 'threeDS.paymentIncomplete': string;
64
+ 'threeDS.completeFirst': string;
65
+ 'threeDS.authenticationSuccessful': string;
66
+ 'threeDS.authenticationFailed': string;
67
+ 'threeDS.returnToCheckout': string;
68
+ 'qrCode.expired': string;
69
+ 'qrCode.scanByGcash': string;
70
+ };
71
+ export default _default;
@@ -3,3 +3,4 @@ export { type ComponentInst, create, querySession, Session, PayKKaCheckout, PayK
3
3
  export { I18n, LocaleKey } from './i18n';
4
4
  export { setApiUrl, setCDNUrl, setFraudDetectionEnv, setCustomReqHeaders, setCustomLocale, setCheckoutConfig } from './config';
5
5
  export { getFingerprint, redirectToPayment } from './utils';
6
+ export { PaymentMethod } from './constant';
@@ -1,9 +1,13 @@
1
1
  import { type CollModeType, type envType } from '../types';
2
+ import type { FraudDetectionOptions } from './types';
2
3
  type FraudDetectionType = {
3
4
  fraudDetectionID: string;
5
+ getFraudDetectionId: (options?: {
6
+ bin?: string;
7
+ }) => Promise<string>;
4
8
  createFraudDetection: () => Promise<void>;
5
9
  };
6
10
  export default function getFraudDetectionInstance(env?: envType | {
7
11
  [k in CollModeType]?: string;
8
- }, mode?: CollModeType[]): FraudDetectionType;
12
+ }, mode?: CollModeType[], options?: FraudDetectionOptions): FraudDetectionType;
9
13
  export {};
@@ -0,0 +1,4 @@
1
+ import type { FraudDetectionEventType } from '../types/event';
2
+ export type FraudDetectionOptions = {
3
+ onEvent?: (event: FraudDetectionEventType) => void;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { FraudDetectionOptions } from './types';
2
+ /**
3
+ * reference: https://docs.worldpay.com/apis/wpg/directintegration/cardinalsecuretest
4
+ * worldpay ddc,单例模式,此处 SessionId 指的是 fraudDetectionId
5
+ * 1. 前端调用后端接口返回 JWT
6
+ * 2. 前端将 JWT 和 bin 传给 iframe
7
+ * 3. iframe 提交数据到 Worldpay
8
+ * 4. Worldpay 返回 SessionId
9
+ * 5. 前端支付时将 SessionId 传给后端
10
+ */
11
+ export declare class WorldpayDDC {
12
+ private static instance;
13
+ private iframe;
14
+ private jwt;
15
+ private listener;
16
+ private timer;
17
+ private fraudDetectionId;
18
+ private p;
19
+ private options?;
20
+ constructor(options?: FraudDetectionOptions);
21
+ /**
22
+ * 获取 fraudDetectionId,每次支付的时候都要调用
23
+ * @param bin 最好是完整卡号,至少得是 6 位卡 bin
24
+ */
25
+ getFraudDetectionId(bin: string): Promise<string>;
26
+ private requestFraudDetectionId;
27
+ private sendJWTAndBin;
28
+ /**
29
+ * 监听 worldpay 返回的 fraudDetectionId
30
+ * 由于可能会多次调用,所以需要先移除之前的监听
31
+ * 如果 worldpay 一直没有返回信息,则 10s 后清除监听,并返回空字符串
32
+ */
33
+ private listenFraudDetectionId;
34
+ private clearListener;
35
+ private getJWT;
36
+ private initIframe;
37
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 事件类型
3
+ * 适用于埋点上报
4
+ */
5
+ export type EventType = FraudDetectionEventType;
6
+ /** fraud detection 事件类型 */
7
+ export declare enum FraudDetectionEventType {
8
+ /** fraud detection 数据转换报错 */
9
+ 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 开始获取 */
15
+ STRIPE_RADAR_START = "stripeRadar:start",
16
+ /** stripe radar 成功 */
17
+ STRIPE_RADAR_SUCCESS = "stripeRadar:success",
18
+ /** worldpay ddc 开始获取 */
19
+ WORLDPAY_DDC_START = "worldpayDDC:start",
20
+ /** worldpay ddc 获取 sessionId 报错 */
21
+ WORLDPAY_DDC_ERROR = "worldpayDDC:error",
22
+ /** worldpay ddc 超时 */
23
+ WORLDPAY_DDC_TIMEOUT = "worldpayDDC:timeout",
24
+ /** worldpay ddc 成功 */
25
+ WORLDPAY_DDC_SUCCESS = "worldpayDDC:success"
26
+ }
@@ -1,7 +1,9 @@
1
1
  export type envType = 'eu' | 'hk' | 'us';
2
2
  export declare const enum ECollMode {
3
3
  /** Stripe Radar */
4
- SR = "SR"
4
+ SR = "SR",
5
+ /** Worldpay DDC */
6
+ WP = "WP"
5
7
  }
6
8
  export type CollModeType = keyof typeof ECollMode;
7
9
  export type FraudDetectionEnv = envType | {
@@ -4,8 +4,10 @@ import type { PayKKaCheckout, PayKKaError, Session } from '../core';
4
4
  import type { FraudDetectionEnv } from './fraud-detection';
5
5
  import type { FormValidateError } from '../components/internal/Form';
6
6
  import type { PaymentMethod } from '../constant';
7
+ import type { EventType } from './event';
7
8
  export * from './fraud-detection';
8
9
  export * from './message';
10
+ export * from './event';
9
11
  export type CustomAttributes<T extends EventTarget, K extends keyof HTMLAttributes<T> = 'style' | 'className'> = Pick<HTMLAttributes<T>, K>;
10
12
  /** 收银台初始化参数 */
11
13
  export interface PayKKaInitConfiguration {
@@ -21,7 +23,7 @@ export interface PayKKaInitConfiguration {
21
23
  /** 定义 3DS 所需配置 */
22
24
  threeDSFrame?: ThreeDSFrameConfig;
23
25
  /** 收银台已经获取到可用支付方式时调用 */
24
- onPaymentMethodsReady?: (methods: string[]) => void;
26
+ onPaymentMethodsReady?: (methods: PaymentMethod[]) => void;
25
27
  /** 收银台创建时报错触发 */
26
28
  onInitError?: (error: PayKKaError) => void;
27
29
  /**
@@ -38,6 +40,16 @@ export interface PayKKaInitConfiguration {
38
40
  onTimeout?: () => void;
39
41
  /** 收银台已过期时触发 */
40
42
  onExpired?: () => void;
43
+ /**
44
+ * @internal
45
+ * 各种发生在收银台生命周期中的事件
46
+ */
47
+ onEvent?: (type: EventType, data?: any) => void;
48
+ /**
49
+ * @internal
50
+ * 欺诈检测错误回调
51
+ */
52
+ onFraudDetectionError?: (error: PayKKaError) => void;
41
53
  /**
42
54
  * @internal
43
55
  * 环境配置,优先级大于 env 参数
@@ -4,7 +4,7 @@ import type { EncryptCardRes } from '../api/modules/encrypted-card/type';
4
4
  import type { EFieldType, FieldIframeConfig } from '../components/SecuredFieldsProvider';
5
5
  import type { FormValidationStatus } from '../components/internal/Form';
6
6
  import type { LocaleKeyType } from '../i18n';
7
- export declare enum MessageAction {
7
+ export declare const enum MessageAction {
8
8
  /** 通知 iframe 初始化 input */
9
9
  INIT = "init",
10
10
  /** 表单 iframe DOM 已加载 */
@@ -54,7 +54,16 @@ export declare enum MessageAction {
54
54
  /** 通知组件 3DS 结果页加载 */
55
55
  THREE_DS_STATUS_INIT = "threeDSStatusInit",
56
56
  /** 向 3DS 状态页传递配置 */
57
- THREE_DS_STATUS_CONFIG = "threeDSStatusConfig"
57
+ THREE_DS_STATUS_CONFIG = "threeDSStatusConfig",
58
+ /** 开启测试模式 */
59
+ DEBUG_MODE = "debugMode",
60
+ /**
61
+ * worldpay DDC
62
+ */
63
+ /** 通知组件 DDC 结果 */
64
+ DDC_RESULT = "ddcResult",
65
+ /** 通知 DDC iframe jwt 和 bin 信息 */
66
+ DDC_JWT_BIN = "ddcJwtBin"
58
67
  }
59
68
  export type Message<T extends MessageAction> = {
60
69
  action: T;
@@ -82,6 +91,9 @@ type MessageMapping = {
82
91
  [MessageAction.CHECK_THREE_DS]: CheckThreeDSMessage;
83
92
  [MessageAction.THREE_DS_STATUS_INIT]: {};
84
93
  [MessageAction.THREE_DS_STATUS_CONFIG]: ThreeDSStatusConfigMessage;
94
+ [MessageAction.DEBUG_MODE]: {};
95
+ [MessageAction.DDC_RESULT]: DDCResultMessage;
96
+ [MessageAction.DDC_JWT_BIN]: DDCJwtBinMessage;
85
97
  };
86
98
  export interface InitMessage {
87
99
  config?: FieldIframeConfig;
@@ -168,4 +180,11 @@ export interface CheckThreeDSMessage {
168
180
  export interface ThreeDSStatusConfigMessage {
169
181
  locale?: LocaleKeyType;
170
182
  }
183
+ export interface DDCResultMessage {
184
+ sessionId: string;
185
+ }
186
+ export interface DDCJwtBinMessage {
187
+ jwt: string;
188
+ bin: string;
189
+ }
171
190
  export {};
@@ -1,2 +1,2 @@
1
1
  export declare const createIframe: (src: string) => HTMLIFrameElement;
2
- export declare const postMessageToIframe: (data: Recordable, iframe: Window, targetOrigin?: string) => void;
2
+ export declare const postMessageToIframe: (data: Recordable | string, iframe: Window, targetOrigin?: string) => void;
@@ -15,6 +15,7 @@ export * from './array';
15
15
  export * from './detect';
16
16
  export * from './date';
17
17
  export * from './object';
18
+ export * from './reg-exp';
18
19
  export declare function getIf<T>(value: T, condition: boolean): T | undefined;
19
20
  /**
20
21
  * 将一个数值限制在指定的范围内
@@ -0,0 +1 @@
1
+ export declare const EMAIL_REG = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paykka/card-checkout-ui",
3
- "version": "0.9.2",
3
+ "version": "0.11.4",
4
4
  "type": "module",
5
5
  "main": "dist/paykka-card-checkout-ui.umd.js",
6
6
  "module": "dist/es/index.js",
@@ -44,7 +44,9 @@
44
44
  "@preact/signals": "^1.3.0",
45
45
  "@types/applepayjs": "^14.0.9",
46
46
  "@types/googlepay": "^0.7.6",
47
+ "@types/qrcode": "^1.5.5",
47
48
  "preact": "^10.24.3",
49
+ "qrcode": "^1.5.4",
48
50
  "ts-toolbelt": "^9.6.0",
49
51
  "unfetch": "^5.0.0",
50
52
  "vue-tsc": "^2.1.10"