@paykka/card-checkout-ui 0.5.17 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card-checkout-ui.js +22 -0
- package/dist/card-checkout-ui.umd.cjs +19 -5
- package/dist/es/api/index.js +0 -2
- package/dist/es/api/modules/checkout/index.js +1 -15
- package/dist/es/api/modules/checkout/map.js +22 -4
- package/dist/es/api/modules/encrypted-card/index.js +54 -0
- package/dist/es/api/modules/get-browser-params.js +2 -2
- package/dist/es/api/modules/index.js +0 -2
- package/dist/es/components/AccountNameField/index.js +2 -3
- package/dist/es/components/AddressField/index.js +4 -7
- package/dist/es/components/AliPay/index.js +13 -12
- package/dist/es/components/ApplePay/index.js +75 -19
- package/dist/es/components/Card/index.js +335 -143
- package/dist/es/components/CardBrands/index.js +0 -2
- package/dist/es/components/CardExpireDateField/index.js +6 -6
- package/dist/es/components/CardHolderNameField/index.js +5 -5
- package/dist/es/components/CardIBANField/index.js +2 -3
- package/dist/es/components/CardNo/index.js +0 -2
- package/dist/es/components/CardNumberField/index.js +32 -20
- package/dist/es/components/CardSecurityCodeField/index.js +6 -6
- package/dist/es/components/CardSelector/index.js +1 -3
- package/dist/es/components/CombinedCardInfo/index.js +99 -0
- package/dist/es/components/EmailField/EmailField.js +2 -3
- package/dist/es/components/EncryptedCard/index.js +408 -0
- package/dist/es/components/GooglePay/index.js +108 -36
- package/dist/es/components/RecurringTip/index.js +0 -2
- package/dist/es/components/SecuredFieldsProvider/index.js +230 -1
- package/dist/es/components/SecuredIframe/index.js +192 -22
- package/dist/es/components/Sepa/index.js +36 -32
- package/dist/es/components/SubmitButton/index.js +0 -2
- package/dist/es/components/ThreeDS/index.js +94 -0
- package/dist/es/components/WechatPay/index.js +31 -30
- package/dist/es/components/index.js +4 -2
- package/dist/es/components/internal/Button/Button.js +0 -2
- package/dist/es/components/internal/Button/index.js +0 -2
- package/dist/es/components/internal/CheckBox/CheckBox.js +0 -2
- package/dist/es/components/internal/CheckBox/index.js +0 -2
- package/dist/es/components/internal/Form/FormItem.js +28 -24
- package/dist/es/components/internal/Form/index.js +1 -0
- package/dist/es/components/internal/Form/type.js +13 -1
- package/dist/es/components/internal/Info/Info.js +0 -2
- package/dist/es/components/internal/Info/index.js +0 -2
- package/dist/es/components/internal/Input/Input.js +11 -13
- package/dist/es/components/internal/Input/index.js +1 -0
- package/dist/es/components/internal/Input/type.js +11 -1
- package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -2
- package/dist/es/components/internal/LoadingCheck/index.js +0 -2
- package/dist/es/components/internal/Modal/Modal.js +40 -0
- package/dist/es/components/internal/Modal/modal2.js +1 -0
- package/dist/es/components/internal/Select/Select.js +2 -2
- package/dist/es/components/internal/Select/SelectMenu.js +0 -2
- package/dist/es/components/internal/Select/SelectMenuItem.js +0 -2
- package/dist/es/components/internal/icons/Icon3DSFail.js +3 -0
- package/dist/es/components/internal/icons/Icon3DSInfo.js +62 -0
- package/dist/es/components/internal/icons/Icon3DSSuccess.js +3 -0
- package/dist/es/config.js +12 -8
- package/dist/es/constant.js +13 -2
- package/dist/es/core/PayKKaCheckout.js +116 -0
- package/dist/es/core/Session.js +7 -6
- package/dist/es/core/environment.js +26 -0
- package/dist/es/core/error.js +21 -0
- package/dist/es/core/index.js +0 -2
- package/dist/es/core/query.js +1 -8
- package/dist/es/hooks/index.js +0 -2
- package/dist/es/hooks/useBreakpoints.js +57 -0
- package/dist/es/hooks/useI18n.js +0 -1
- package/dist/es/hooks/usePayState.js +20 -33
- package/dist/es/i18n/index.js +0 -2
- package/dist/es/i18n/locales/de-DE.js +11 -1
- package/dist/es/i18n/locales/en-GB.js +11 -1
- package/dist/es/i18n/locales/es-ES.js +11 -1
- package/dist/es/i18n/locales/fr-FR.js +11 -1
- package/dist/es/i18n/locales/index.js +8 -6
- package/dist/es/i18n/locales/ja-JP.js +11 -1
- package/dist/es/i18n/locales/ko-KR.js +11 -1
- package/dist/es/i18n/locales/pt-PT.js +11 -1
- package/dist/es/i18n/locales/ru-RU.js +11 -1
- package/dist/es/i18n/locales/zh-CN.js +11 -1
- package/dist/es/i18n/locales/zh-HK.js +11 -1
- package/dist/es/i18n/locales/zh-TW.js +11 -1
- package/dist/es/i18n/util.js +11 -8
- package/dist/es/index.js +15 -2
- package/dist/es/out/fraud-detection.js +99 -0
- package/dist/es/style.css +194 -4
- package/dist/es/types/{radar.js → fraud-detection.js} +1 -1
- package/dist/es/types/index.js +49 -1
- package/dist/es/types/message.js +28 -0
- package/dist/es/utils/card-brand/brands.js +21 -45
- package/dist/es/utils/card-brand/index.js +3 -2
- package/dist/es/utils/iframe.js +23 -0
- package/dist/es/utils/index.js +11 -1
- package/dist/es/utils/load.js +14 -0
- package/dist/es/utils/style.js +84 -0
- package/dist/style.css +1 -1
- package/dist/types/api/modules/checkout/map.d.ts +1 -0
- package/dist/types/api/modules/checkout/type.d.ts +14 -1
- package/dist/types/api/modules/encrypted-card/index.d.ts +6 -0
- package/dist/types/api/modules/encrypted-card/type.d.ts +31 -0
- package/dist/types/api/modules/get-browser-params.d.ts +3 -3
- package/dist/types/components/AddressField/type.d.ts +1 -0
- package/dist/types/components/AliPay/type.d.ts +4 -4
- package/dist/types/components/ApplePay/type.d.ts +19 -7
- package/dist/types/components/ApplePay/utils.d.ts +3 -0
- package/dist/types/components/Card/type.d.ts +64 -6
- package/dist/types/components/CardExpireDateField/type.d.ts +1 -0
- package/dist/types/components/CardHolderNameField/type.d.ts +1 -1
- package/dist/types/components/CardNumberField/type.d.ts +3 -0
- package/dist/types/components/CardSecurityCodeField/type.d.ts +1 -0
- package/dist/types/components/CombinedCardInfo/CombinedCardInfo.d.ts +5 -0
- package/dist/types/components/CombinedCardInfo/index.d.ts +2 -0
- package/dist/types/components/CombinedCardInfo/type.d.ts +16 -0
- package/dist/types/components/EncryptedCard/EncryptedCard.d.ts +4 -0
- package/dist/types/components/EncryptedCard/index.d.ts +4 -0
- package/dist/types/components/EncryptedCard/output.d.ts +9 -0
- package/dist/types/components/EncryptedCard/type.d.ts +85 -0
- package/dist/types/components/GooglePay/type.d.ts +20 -8
- package/dist/types/components/GooglePay/utils.d.ts +2 -0
- package/dist/types/components/SecuredFieldsProvider/index.d.ts +1 -0
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +29 -100
- package/dist/types/components/SecuredFieldsProvider/utils/index.d.ts +1 -1
- package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +7 -2
- package/dist/types/components/Sepa/type.d.ts +4 -4
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/ThreeDSAuth.d.ts +3 -0
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/index.d.ts +2 -0
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +17 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +2 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/index.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +5 -0
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +3 -0
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/output.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +6 -0
- package/dist/types/components/ThreeDS/index.d.ts +1 -0
- package/dist/types/components/WechatPay/type.d.ts +4 -4
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/internal/Form/FormItem.d.ts +1 -1
- package/dist/types/components/internal/Form/type.d.ts +7 -0
- package/dist/types/components/internal/Input/Input.d.ts +1 -1
- package/dist/types/components/internal/Input/type.d.ts +7 -0
- package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
- package/dist/types/components/internal/Loading/index.d.ts +1 -0
- package/dist/types/components/internal/Modal/Modal.d.ts +5 -0
- package/dist/types/components/internal/Modal/index.d.ts +0 -0
- package/dist/types/components/internal/Modal/type.d.ts +20 -0
- package/dist/types/components/internal/icons/Icon3DSFail.d.ts +2 -0
- package/dist/types/components/internal/icons/Icon3DSInfo.d.ts +2 -0
- package/dist/types/components/internal/icons/Icon3DSSuccess.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +3 -0
- package/dist/types/config.d.ts +7 -3
- package/dist/types/constant.d.ts +7 -2
- package/dist/types/core/PayKKaCheckout.d.ts +28 -0
- package/dist/types/core/Session.d.ts +1 -1
- package/dist/types/core/context.d.ts +1 -0
- package/dist/types/core/environment.d.ts +4 -0
- package/dist/types/core/error.d.ts +16 -0
- package/dist/types/core/index.d.ts +2 -0
- package/dist/types/core/query.d.ts +2 -2
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useBreakpoints.d.ts +15 -0
- package/dist/types/hooks/usePayState.d.ts +6 -25
- package/dist/types/i18n/locales/de-DE.d.ts +8 -0
- package/dist/types/i18n/locales/en-GB.d.ts +8 -0
- package/dist/types/i18n/locales/es-ES.d.ts +8 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +8 -0
- package/dist/types/i18n/locales/index.d.ts +2 -2
- package/dist/types/i18n/locales/ja-JP.d.ts +8 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +8 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +8 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +8 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +8 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +8 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +8 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/out/fraud-detection.d.ts +9 -0
- package/dist/types/types/{radar.d.ts → fraud-detection.d.ts} +3 -2
- package/dist/types/types/index.d.ts +100 -1
- package/dist/types/types/message.d.ts +170 -0
- package/dist/types/utils/card-brand/brands.d.ts +4 -18
- package/dist/types/utils/card-brand/index.d.ts +10 -9
- package/dist/types/utils/format.d.ts +0 -1
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/load.d.ts +7 -0
- package/dist/types/utils/style.d.ts +29 -0
- package/package.json +63 -63
- package/dist/card-checkout-ui.iife.js +0 -8
- package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +0 -222
- package/dist/es/out/radar.js +0 -123
- package/dist/types/out/radar.d.ts +0 -14
- /package/dist/types/{components/SecuredFieldsProvider/utils → utils}/iframe.d.ts +0 -0
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import type { CardBrand } from '../../types';
|
|
1
2
|
import type { FormItemProps, FormValidationStatus } from '../internal/Form';
|
|
2
3
|
import type { InputProps } from '../internal/Input';
|
|
3
4
|
export interface CardNumberFieldProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput'> {
|
|
4
5
|
supportedCardBrands?: string[];
|
|
5
6
|
security: boolean;
|
|
7
|
+
showLabel?: boolean;
|
|
6
8
|
}
|
|
7
9
|
export interface CardNumberFieldRef {
|
|
8
10
|
focus: () => void;
|
|
9
11
|
blur: () => void;
|
|
10
12
|
resetValidation: (status: FormValidationStatus, errorTip?: string) => void;
|
|
11
13
|
binValueChanged: (binValue: string) => void;
|
|
14
|
+
brandChanged: (brand?: CardBrand) => void;
|
|
12
15
|
getCardBrand: () => Recordable;
|
|
13
16
|
}
|
|
@@ -2,6 +2,7 @@ import type { FormItemProps, FormValidationStatus } from '../internal/Form';
|
|
|
2
2
|
import type { InputProps } from '../internal/Input';
|
|
3
3
|
export interface CardSecurityCodeFieldProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput'> {
|
|
4
4
|
security: boolean;
|
|
5
|
+
showLabel?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export interface CardSecurityCodeFieldRef {
|
|
7
8
|
focus: () => void;
|
|
@@ -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,16 @@
|
|
|
1
|
+
import type { CardBrand } from '../../types';
|
|
2
|
+
import type { FormItemProps, FormValidationStatus } from '../internal/Form';
|
|
3
|
+
import type { InputProps } from '../internal/Input';
|
|
4
|
+
export interface CombinedCardInfoProps extends Pick<FormItemProps, 'onValidationStatusChange' | 'className' | 'style'>, Pick<InputProps, 'onInput'> {
|
|
5
|
+
supportedCardBrands?: string[];
|
|
6
|
+
security: boolean;
|
|
7
|
+
showLabel?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CombinedCardInfoRef {
|
|
10
|
+
focus: () => void;
|
|
11
|
+
blur: () => void;
|
|
12
|
+
resetValidation: (status: FormValidationStatus, errorTip?: string) => void;
|
|
13
|
+
binValueChanged: (binValue: string) => void;
|
|
14
|
+
brandChanged: (brand?: CardBrand) => void;
|
|
15
|
+
getCardBrand: () => Recordable;
|
|
16
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type EncryptedCardProps, type EncryptedCardRef } from './type';
|
|
2
|
+
export declare const EncryptedCard: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<EncryptedCardProps> & {
|
|
3
|
+
ref?: import("preact").Ref<EncryptedCardRef> | undefined;
|
|
4
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type EncryptedCardProps } from './type';
|
|
2
|
+
export default class PayKKaEncryptedCard {
|
|
3
|
+
constructor();
|
|
4
|
+
static init(props: EncryptedCardProps): import("./type").EncryptedCardRef | undefined;
|
|
5
|
+
static setEnv(env: {
|
|
6
|
+
apiUrl: string;
|
|
7
|
+
cdnUrl: string;
|
|
8
|
+
}): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { EncryptCardRes } from '../../api/modules/encrypted-card/type';
|
|
2
|
+
import type { LocaleKeyType } from '../../i18n';
|
|
3
|
+
import type { CardBrand, ElementStylesConfig } from '../../types';
|
|
4
|
+
import type { FieldType } from '../SecuredFieldsProvider/type';
|
|
5
|
+
import type { FormValidationStatus } from '../internal/Form';
|
|
6
|
+
export interface EncryptedCardProps {
|
|
7
|
+
/** 商户 id */
|
|
8
|
+
merchantId: string;
|
|
9
|
+
/** clientKey,需要商户进行配置 */
|
|
10
|
+
clientKey: string;
|
|
11
|
+
/** 国际化语言 */
|
|
12
|
+
locale?: LocaleKeyType;
|
|
13
|
+
/**
|
|
14
|
+
* 自定义有效的卡品牌数组
|
|
15
|
+
* 待初始化时请求后端接口验证身份后也会拿到卡品牌,然后两者取交集
|
|
16
|
+
* 如果不传,则直接取后端返回的卡品牌
|
|
17
|
+
*/
|
|
18
|
+
brands?: CardBrand[];
|
|
19
|
+
/** 自定义 输入框、label 和 错误提示文字 的样式 */
|
|
20
|
+
styles?: ElementStylesConfig;
|
|
21
|
+
/** 是否展示 label,展示 label 时可设置相关样式 */
|
|
22
|
+
showLabel?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 卡 bin 信息改变触发
|
|
25
|
+
* 包含卡号前 1-6 位的值
|
|
26
|
+
* 如果用户删除卡号,或卡号不足 6 位,则卡 bin 信息为空
|
|
27
|
+
*/
|
|
28
|
+
onBinChanged?: (binInfo: {
|
|
29
|
+
binValue: string;
|
|
30
|
+
brand?: CardBrand;
|
|
31
|
+
}) => void;
|
|
32
|
+
/** 只要检测到了卡品牌变化,就会调用,无论用户输入了几位卡号 */
|
|
33
|
+
onBrand?: (brand?: CardBrand) => void;
|
|
34
|
+
/** 卡信息加密成功后触发 */
|
|
35
|
+
onCardEncrypted?: (encryptedInfo: EncryptCardRes) => void;
|
|
36
|
+
/** 卡信息加密失败后触发 */
|
|
37
|
+
onCardEncryptionFailed?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* 进行了 client key 的校验后调用(此时还未渲染表单)
|
|
40
|
+
* status 为 true 表示通过校验,为 false 表示未通过
|
|
41
|
+
* res 为校验结果,包含可用的卡品牌(交集)
|
|
42
|
+
*/
|
|
43
|
+
onReady?: (status: boolean, res?: {
|
|
44
|
+
brands: CardBrand[];
|
|
45
|
+
}) => void;
|
|
46
|
+
/** 表单 iframe 激活后触发 */
|
|
47
|
+
onActivated?: (fieldType: FieldType) => void;
|
|
48
|
+
/**
|
|
49
|
+
* 当输入字段获得焦点时触发
|
|
50
|
+
* fieldType 表示哪个表单项
|
|
51
|
+
*/
|
|
52
|
+
onFocus?: (fieldType: FieldType) => void;
|
|
53
|
+
/**
|
|
54
|
+
* 当输入字段失去焦点时触发
|
|
55
|
+
* fieldType 表示哪个表单项
|
|
56
|
+
*/
|
|
57
|
+
onBlur?: (fieldType: FieldType) => void;
|
|
58
|
+
/**
|
|
59
|
+
* 通知表单项验证信息
|
|
60
|
+
* fieldType 表示哪个表单项
|
|
61
|
+
* status 可以是错误,成功或未验证
|
|
62
|
+
*/
|
|
63
|
+
onValidationChanged?: (validationInfo: {
|
|
64
|
+
fieldType: FieldType;
|
|
65
|
+
status: FormValidationStatus;
|
|
66
|
+
}) => void;
|
|
67
|
+
/** 是否为沙盒环境 */
|
|
68
|
+
sandbox?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface EncryptedCardRef {
|
|
71
|
+
/** 调用该方法开始表单验证和加密流程 */
|
|
72
|
+
encrypt: () => void;
|
|
73
|
+
}
|
|
74
|
+
/** 包在加密表单最外面的元素id */
|
|
75
|
+
export declare const ENCRYPTED_CARD_WRAPPER_ID = "encryptedCardWrapper";
|
|
76
|
+
/** 包在表单元素外面的元素自定义属性名 */
|
|
77
|
+
export declare const ENCRYPTED_CARD_ITEM_ATTR = "data-eci";
|
|
78
|
+
/** 表单项类型 */
|
|
79
|
+
export declare enum EEncryptedCardType {
|
|
80
|
+
CARD = "card",
|
|
81
|
+
CARD_NUMBER = "cardNumber",
|
|
82
|
+
CVV = "securityCode",
|
|
83
|
+
EXPIRE_DATE = "expiryDate"
|
|
84
|
+
}
|
|
85
|
+
export type EncryptedCardItemType = keyof typeof EEncryptedCardType;
|
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { PayKKaError } from '../../core';
|
|
2
|
+
import type { CoreProps, PaymentSuccessData } from '../../types';
|
|
3
|
+
export interface GooglePayProps extends CoreProps {
|
|
4
|
+
/** 支付授权成功后触发 */
|
|
5
5
|
onSubmit?: () => void;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/** 支付成功后触发 */
|
|
7
|
+
onSuccess?: (data: PaymentSuccessData) => void;
|
|
8
|
+
/** SDK 加载回调,status 为 true 表示加载成功,false 表示加载失败 */
|
|
9
|
+
onLoad?: (status: boolean) => void;
|
|
10
|
+
/** 支付失败时触发 */
|
|
11
|
+
onError?: (error: PayKKaError) => void;
|
|
12
|
+
/** 支付超时时触发 */
|
|
8
13
|
onTimeout?: (source: 'retry' | 'channel') => void;
|
|
14
|
+
/** 收银台已过期时触发 */
|
|
9
15
|
onExpired?: () => void;
|
|
10
|
-
|
|
16
|
+
/** 交易被风控拦截时触发 */
|
|
11
17
|
onAuthorized?: () => void;
|
|
18
|
+
/** 交易需要 3DS 验证时触发,url 为 3DS 验证链接,incomplete 为 false 表示目前要开始进行 3DS 验证,为 true 表示上一次 3DS 验证还未完成 */
|
|
12
19
|
onThreeDS?: (url: string, incomplete: boolean) => void;
|
|
20
|
+
/** 当前设备环境是否可用于 Google Pay 支付 */
|
|
21
|
+
onCanUse?: (canUse: boolean) => void;
|
|
22
|
+
/**
|
|
23
|
+
* 内部使用
|
|
24
|
+
*/
|
|
13
25
|
/** 点击 GooglePay 按钮 */
|
|
14
26
|
onBtnClick?: () => void;
|
|
15
|
-
onCanUse?: (canUse: boolean) => void;
|
|
16
27
|
}
|
|
17
28
|
export interface GooglePayRef {
|
|
29
|
+
/** 3DS 验证流程结束后可调用该方法轮询收银台支付状态 */
|
|
18
30
|
checkThreeDS: () => void;
|
|
19
31
|
}
|
|
@@ -1,51 +1,45 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode } from 'preact/compat';
|
|
2
2
|
import type { SessionMode } from '../../constant';
|
|
3
3
|
import type { I18n } from '../../i18n';
|
|
4
|
-
import type {
|
|
5
|
-
import type { FormValidationStatus } from '../internal/Form';
|
|
4
|
+
import type { EncryptCardMessage, InputStylesConfig, Message, MessageAction } from '../../types';
|
|
6
5
|
export interface SecuredFieldsProviderProps extends SecuredFieldsCallback {
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
sessionMode: SessionMode;
|
|
9
6
|
i18n: I18n;
|
|
10
7
|
supportedCardBrands: string[];
|
|
8
|
+
sessionMode?: SessionMode;
|
|
9
|
+
/** 包裹的子元素,如果传了targetElement,就不需要传这个 */
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
targetElement?: HTMLElement;
|
|
12
|
+
style?: InputStylesConfig;
|
|
11
13
|
}
|
|
12
14
|
export interface SecuredFieldsProviderRef {
|
|
13
15
|
payment: (formData: any) => void;
|
|
16
|
+
encryptCard: (encryptInfo: EncryptCardMessage) => void;
|
|
14
17
|
reload: () => void;
|
|
18
|
+
validate: () => void;
|
|
19
|
+
setConfig: (config: {
|
|
20
|
+
style?: InputStylesConfig;
|
|
21
|
+
}) => void;
|
|
15
22
|
}
|
|
16
23
|
export interface SecuredFieldsCallback {
|
|
17
|
-
onFocus
|
|
18
|
-
onBinValue
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
onFocus?: (data: Message<MessageAction.FOCUS>) => void;
|
|
25
|
+
onBinValue?: (data: Message<MessageAction.BIN_VALUE>) => void;
|
|
26
|
+
onBrand?: (data: Message<MessageAction.BRAND>) => void;
|
|
27
|
+
onAuthorized?: (data: Message<MessageAction.AUTHORIZED>) => void;
|
|
28
|
+
onActivated?: (data: Message<MessageAction.ACTIVATED>) => void;
|
|
29
|
+
onAfterPayment?: (data: Message<MessageAction.AFTER_PAYMENT>) => void;
|
|
30
|
+
onPaymentError?: (data: Message<MessageAction.PAYMENT_ERROR>) => void;
|
|
31
|
+
onPaymentTimeout?: (data: Message<MessageAction.PAYMENT_TIMEOUT>) => void;
|
|
32
|
+
onValidStatusChanged?: (data: Message<MessageAction.VALID_STATUS_CHANGED>) => void;
|
|
33
|
+
onCardEncrypted?: (data: Message<MessageAction.CARD_ENCRYPTED>) => void;
|
|
34
|
+
onCardEncryptionFailed?: (data: Message<MessageAction.CARD_ENCRYPTION_FAILED>) => void;
|
|
35
|
+
onValidated?: (data: Message<MessageAction.VALIDATED>) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare enum EFieldType {
|
|
25
38
|
CARD_NUMBER = "CARD_NUMBER",
|
|
26
39
|
CVV = "CVV",
|
|
27
40
|
EXPIRE_DATE = "EXPIRE_DATE"
|
|
28
41
|
}
|
|
29
|
-
export
|
|
30
|
-
/** 通知 iframe 初始化 input */
|
|
31
|
-
INIT = "init",
|
|
32
|
-
/** 是否聚焦 */
|
|
33
|
-
FOCUS = "focus",
|
|
34
|
-
/** 卡 bin 信息 */
|
|
35
|
-
BIN_VALUE = "binValue",
|
|
36
|
-
/** 传递验证通过信息(附带值) */
|
|
37
|
-
VALID_WITH_VALUE = "validWithValue",
|
|
38
|
-
/** 通知隐藏iframe进行支付 */
|
|
39
|
-
PAYMENT = "payment",
|
|
40
|
-
/** 通知表单组件支付响应信息 */
|
|
41
|
-
AFTER_PAYMENT = "afterPayment",
|
|
42
|
-
/** 通知表单组件支付错误信息 */
|
|
43
|
-
PAYMENT_ERROR = "paymentError",
|
|
44
|
-
/** 通知表单组件支付超时 */
|
|
45
|
-
PAYMENT_TIMEOUT = "paymentTimeout",
|
|
46
|
-
/** 通知表单项验证信息 */
|
|
47
|
-
VALID_STATUS_CHANGED = "validStatusChanged"
|
|
48
|
-
}
|
|
42
|
+
export type FieldType = keyof typeof EFieldType;
|
|
49
43
|
export interface SecuredFieldConfig extends FieldIframeConfig, SecuredFieldsCallback {
|
|
50
44
|
rootNode: HTMLElement;
|
|
51
45
|
fieldNode: HTMLElement;
|
|
@@ -54,77 +48,12 @@ export interface SecuredFieldConfig extends FieldIframeConfig, SecuredFieldsCall
|
|
|
54
48
|
hiddenIframe: HTMLIFrameElement;
|
|
55
49
|
}
|
|
56
50
|
export interface FieldIframeConfig {
|
|
57
|
-
fieldType:
|
|
51
|
+
fieldType: EFieldType;
|
|
58
52
|
placeholder: string;
|
|
59
|
-
style: CSSProperties;
|
|
60
53
|
hiddenIframeName: string;
|
|
61
54
|
supportedCardBrands: string[];
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* message data
|
|
65
|
-
*/
|
|
66
|
-
export type Message<T extends MessageAction> = {
|
|
67
|
-
action: T;
|
|
68
|
-
} & MessageMapping[T];
|
|
69
|
-
type MessageMapping = {
|
|
70
|
-
[MessageAction.INIT]: InitMessage;
|
|
71
|
-
[MessageAction.FOCUS]: FocusMessage;
|
|
72
|
-
[MessageAction.BIN_VALUE]: BinValueMessage;
|
|
73
|
-
[MessageAction.VALID_WITH_VALUE]: ValidWithValueMessage;
|
|
74
|
-
[MessageAction.PAYMENT]: PaymentMessage;
|
|
75
|
-
[MessageAction.AFTER_PAYMENT]: AfterPaymentMessage;
|
|
76
|
-
[MessageAction.PAYMENT_ERROR]: PaymentErrorMessage;
|
|
77
|
-
[MessageAction.PAYMENT_TIMEOUT]: PaymentTimeoutMessage;
|
|
78
|
-
[MessageAction.VALID_STATUS_CHANGED]: ValidStatusChangedMessage;
|
|
79
|
-
};
|
|
80
|
-
export interface InitMessage {
|
|
81
|
-
config?: FieldIframeConfig;
|
|
82
|
-
/** 是否隐藏,如不隐藏则为表单iframe */
|
|
83
|
-
hidden: boolean;
|
|
84
|
-
apiUrl?: string;
|
|
85
|
-
cdnUrl?: string;
|
|
86
|
-
}
|
|
87
|
-
export interface FocusMessage {
|
|
88
|
-
focus: boolean;
|
|
89
|
-
fieldType: FieldType;
|
|
90
|
-
}
|
|
91
|
-
export interface InvalidMessage {
|
|
92
|
-
errorTip: string;
|
|
93
|
-
fieldType: FieldType;
|
|
94
|
-
}
|
|
95
|
-
export interface ValidMessage {
|
|
96
|
-
fieldType: FieldType;
|
|
97
|
-
}
|
|
98
|
-
export interface BinValueMessage {
|
|
99
|
-
binValue: string;
|
|
100
|
-
fieldType: FieldType;
|
|
101
|
-
}
|
|
102
|
-
export interface ValidWithValueMessage {
|
|
103
|
-
value: string;
|
|
104
|
-
fieldType: FieldType;
|
|
105
|
-
}
|
|
106
|
-
export interface PaymentMessage {
|
|
107
|
-
formData: any;
|
|
108
|
-
locale: string;
|
|
109
|
-
}
|
|
110
|
-
export interface AfterPaymentMessage {
|
|
111
|
-
response: PayRes;
|
|
112
|
-
}
|
|
113
|
-
export interface PaymentErrorMessage {
|
|
114
|
-
error: {
|
|
115
|
-
message: string;
|
|
116
|
-
code: string;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
export interface ValidStatusChangedMessage {
|
|
120
|
-
status: FormValidationStatus;
|
|
121
|
-
errorTip?: string;
|
|
122
|
-
fieldType: FieldType;
|
|
123
|
-
}
|
|
124
|
-
export interface PaymentTimeoutMessage {
|
|
125
|
-
message?: string;
|
|
55
|
+
style?: InputStylesConfig;
|
|
126
56
|
}
|
|
127
57
|
export declare const SECURED_FILED_ATTR = "data-sf";
|
|
128
58
|
export declare const SECURED_IFRAME_CLASS_NAME = "secured-iframe";
|
|
129
59
|
export declare const HIDDEN_IFRAME_NAME = "hidden-pay-iframe";
|
|
130
|
-
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './fields';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './securedFields';
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import {
|
|
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;
|
|
5
6
|
initSecuredInput: (options: {
|
|
6
|
-
fieldType:
|
|
7
|
+
fieldType: EFieldType;
|
|
7
8
|
supportedCardBrands: string[];
|
|
8
9
|
sendMessage: (message: Message<MessageAction>) => void;
|
|
9
10
|
}) => void;
|
|
10
11
|
getConfigByFieldType: () => {
|
|
11
12
|
maxLength: number;
|
|
13
|
+
inputMode: string;
|
|
12
14
|
onInput: (event: Event) => void;
|
|
13
15
|
validator: () => boolean;
|
|
14
16
|
};
|
|
17
|
+
getCurrCardBrand: (realValue: string) => import("../../utils/card-brand/brands").CardBrandConfig | undefined;
|
|
18
|
+
brand: "VISA" | "MASTER_CARD" | "JCB" | "AMEX" | "DINERS_CLUB" | "DISCOVER" | undefined;
|
|
19
|
+
validate: () => boolean | void;
|
|
15
20
|
};
|
|
@@ -1,10 +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 {
|
|
3
|
-
sessionId: string;
|
|
4
|
-
clientKey?: string;
|
|
4
|
+
export interface SepaProps extends CoreProps {
|
|
5
5
|
onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
|
|
6
6
|
onSuccess?: (returnUrl?: string) => void;
|
|
7
|
-
onError?: (error:
|
|
7
|
+
onError?: (error: PayKKaError) => void;
|
|
8
8
|
onTimeout?: () => void;
|
|
9
9
|
onAuthorized?: () => void;
|
|
10
10
|
onExpired?: () => void;
|
|
@@ -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 @@
|
|
|
1
|
+
export * from './ThreeDSIframe';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/ThreeDSAuth';
|
|
@@ -1,11 +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 {
|
|
4
|
-
sessionId: string;
|
|
5
|
-
clientKey?: string;
|
|
5
|
+
export interface WechatPayProps extends CoreProps {
|
|
6
6
|
onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
|
|
7
7
|
onSuccess?: (...args: any[]) => void;
|
|
8
|
-
onError?: (error:
|
|
8
|
+
onError?: (error: PayKKaError) => void;
|
|
9
9
|
onTimeout?: (source: 'retry' | 'channel') => void;
|
|
10
10
|
onExpired?: () => void;
|
|
11
11
|
onSubmitResponse?: (payRes: PayRes) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './form-item.scss';
|
|
2
|
-
import type
|
|
2
|
+
import { type FormItemProps, type FormItemRef } from './type';
|
|
3
3
|
export declare const FormItem: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<FormItemProps> & {
|
|
4
4
|
ref?: import("preact").Ref<FormItemRef> | undefined;
|
|
5
5
|
}>;
|
|
@@ -38,6 +38,7 @@ export interface FormItemProps extends CustomAttributes<HTMLDivElement> {
|
|
|
38
38
|
triggersOfEmptyValue?: FormRuleTrigger[];
|
|
39
39
|
onValidationStatusChange?: (status: FormValidationStatus) => void;
|
|
40
40
|
showErrorMessage?: boolean;
|
|
41
|
+
showLabel?: boolean;
|
|
41
42
|
}
|
|
42
43
|
export interface FormItemRef {
|
|
43
44
|
validate: (value: string, options: {
|
|
@@ -48,3 +49,9 @@ export interface FormItemRef {
|
|
|
48
49
|
getValidateResult: () => FormValidationResult;
|
|
49
50
|
resetValidation: (status?: FormValidationStatus, errors?: FormValidateError[]) => FormValidationResult;
|
|
50
51
|
}
|
|
52
|
+
export declare const formItemBEM: {
|
|
53
|
+
bem: (el?: Nil | (string | Recordable<any>) | (Nil | (string | Recordable<any>))[], mods?: Nil | (string | Recordable<any>) | (Nil | (string | Recordable<any>))[]) => string;
|
|
54
|
+
bemWithoutEl: (el?: Nil | (string | Recordable<any>) | (Nil | (string | Recordable<any>))[], mods?: Nil | (string | Recordable<any>) | (Nil | (string | Recordable<any>))[]) => string;
|
|
55
|
+
};
|
|
56
|
+
export declare const formItemLabelClassName: string;
|
|
57
|
+
export declare const formItemErrorMessageClassName: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './input.scss';
|
|
2
|
-
import type
|
|
2
|
+
import { type InputProps, type InputRef } from './type';
|
|
3
3
|
export declare const Input: import("preact").FunctionalComponent<import("preact/compat").PropsWithoutRef<InputProps> & {
|
|
4
4
|
ref?: import("preact").Ref<InputRef> | undefined;
|
|
5
5
|
}>;
|
|
@@ -5,7 +5,9 @@ export interface InputProps extends HTMLAttributes<HTMLInputElement>, CustomAttr
|
|
|
5
5
|
status?: 'error' | 'success';
|
|
6
6
|
placeholder?: string;
|
|
7
7
|
rightIcon?: ReactNode;
|
|
8
|
+
leftIcon?: ReactNode;
|
|
8
9
|
inputClassName?: string;
|
|
10
|
+
showStatus?: boolean;
|
|
9
11
|
onCompositionStart?: (e: CompositionEvent) => void;
|
|
10
12
|
}
|
|
11
13
|
export interface InputRef {
|
|
@@ -13,3 +15,8 @@ export interface InputRef {
|
|
|
13
15
|
focus: () => void;
|
|
14
16
|
blur: () => void;
|
|
15
17
|
}
|
|
18
|
+
export declare const inputBEM: {
|
|
19
|
+
bem: (el?: Nil | (string | Recordable<any>) | (Nil | (string | Recordable<any>))[], mods?: Nil | (string | Recordable<any>) | (Nil | (string | Recordable<any>))[]) => string;
|
|
20
|
+
bemWithoutEl: (el?: Nil | (string | Recordable<any>) | (Nil | (string | Recordable<any>))[], mods?: Nil | (string | Recordable<any>) | (Nil | (string | Recordable<any>))[]) => string;
|
|
21
|
+
};
|
|
22
|
+
export declare const inputWrapperClassName: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Loading: () => import("preact").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Loading';
|
|
File without changes
|
|
@@ -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
|
+
}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { type LocaleKeyType } from "./i18n";
|
|
2
|
-
import { type
|
|
2
|
+
import { type FraudDetectionEnv } from "./types";
|
|
3
3
|
export declare let apiUrl: string;
|
|
4
4
|
export declare let cdnOrigin: any;
|
|
5
5
|
export declare let cdnDir: any;
|
|
6
6
|
export declare let cdnUrl: string;
|
|
7
|
-
export declare let
|
|
7
|
+
export declare let fraudDetectionEnv: FraudDetectionEnv | undefined;
|
|
8
8
|
export declare let customReqHeaders: Recordable;
|
|
9
9
|
export declare let customLocale: LocaleKeyType | undefined;
|
|
10
|
+
export declare let hidePaymentButton: boolean;
|
|
10
11
|
export declare function setApiUrl(url: string): void;
|
|
11
12
|
export declare function setCDNUrl(url: string): void;
|
|
12
|
-
export declare function
|
|
13
|
+
export declare function setFraudDetectionEnv(env: FraudDetectionEnv): void;
|
|
13
14
|
export declare function setCustomReqHeaders(headers: Recordable): void;
|
|
14
15
|
export declare function setCustomLocale(locale: LocaleKeyType): void;
|
|
16
|
+
export declare function setCheckoutConfig(params: {
|
|
17
|
+
hidePaymentButton?: boolean;
|
|
18
|
+
}): void;
|