@alipay/ams-checkout 0.0.1788166152-dev.1 → 0.0.1788166152-dev.2
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/ams-checkout.js +3 -3
- package/dist/ams-checkout.min.js +1 -1
- package/dist/ams-checkout.min.js.map +1 -1
- package/esm/config/index.js +1 -1
- package/esm/core/component/ckp/index.js +21 -1
- package/esm/core/component/element/elementController/index.js +4 -3
- package/esm/core/component/element/modernElementController/adapter.js +3 -3
- package/esm/core/component/element/modernElementController/index.d.ts +6 -1
- package/esm/core/component/element/modernElementController/index.js +260 -189
- package/esm/core/component/element/type.d.ts +2 -2
- package/esm/foundation/service/log/keys.js +4 -0
- package/esm/index.d.ts +6 -7
- package/esm/index.js +9 -14
- package/esm/modern/core/component/element/modernElementController/index.d.ts +6 -1
- package/esm/modern/core/component/element/type.d.ts +2 -2
- package/esm/modern/index.js +1 -1
- package/esm/modern/loadAntomTracker.d.ts +7 -0
- package/esm/modern/loadAntomTracker.js +64 -0
- package/esm/modern/modern/loadAntomTracker.d.ts +7 -0
- package/esm/modern/modern/preload/preloadAntomElements.d.ts +1 -1
- package/esm/modern/modern/preload/startAntomPreload.d.ts +2 -0
- package/esm/modern/modern/sdk/applepay-core/ApplePayHostService.d.ts +1 -0
- package/esm/modern/modern/sdk/elements/CVVElement.d.ts +28 -23
- package/esm/modern/modern/sdk/elements/PaymentElement.d.ts +51 -12
- package/esm/modern/modern/sdk/elements/appearanceRules.d.ts +59 -0
- package/esm/modern/modern/sdk/elements/appearanceRulesDefaults.d.ts +2 -0
- package/esm/modern/modern/sdk/tools/expressElement/applePayHostToken.d.ts +6 -1
- package/esm/modern/modern/sdk/tools/expressElement/types.d.ts +25 -10
- package/esm/modern/modern/sdk/tools/getMetaData.d.ts +8 -1
- package/esm/modern/modern/sdk/tools/modalMessageMonitor.d.ts +41 -0
- package/esm/modern/modern/sdk/tools/paymentElement/applePayHostToken.d.ts +38 -0
- package/esm/modern/modern/sdk/tools/paymentElement/googlePayHostToken.d.ts +38 -0
- package/esm/modern/modern/sdk/tools/paymentElement/tracker.d.ts +16 -0
- package/esm/modern/modern/sdk/tools/paymentElement/walletHostListeners.d.ts +19 -0
- package/esm/modern/modern/sdk/tracking/elementTracker.d.ts +65 -0
- package/esm/modern/modern/sdk/types.d.ts +105 -10
- package/esm/modern/modern/tools.d.ts +3 -2
- package/esm/modern/preload/preloadAntomElements.d.ts +1 -1
- package/esm/modern/preload/sgPreconnection.d.ts +1 -1
- package/esm/modern/preload/startAntomPreload.d.ts +2 -0
- package/esm/modern/preload/startAntomPreload.js +9 -0
- package/esm/modern/sdk/elements/appearanceRules.d.ts +59 -0
- package/esm/modern/tools.js +1 -1
- package/esm/modern/util/timezone.d.ts +1 -0
- package/esm/modern/util/versionCompare.d.ts +1 -1
- package/esm/util/logger.js +1 -1
- package/esm/util/timezone.d.ts +1 -0
- package/esm/util/timezone.js +8 -0
- package/package.json +13 -13
- package/types.d.ts +576 -67
- package/types.untrimmed.d.ts +599 -67
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import { type BaseAppearance, type BaseElementAppConfig, BaseMainElement, type PickAppearance, type BaseElementConfig, type ErrorPayload } from '@antintl/opensdk-core';
|
|
2
|
-
import { type AntomTheme, type AntomBridgeWithNativeEventMap, type SubmitResult, type AntomVariables, type SubmitParams, type AntomLayouts } from '../types';
|
|
3
|
-
import type { CashierSdkActionQueryResult, OneAccountQueryResult, PaymentSessionConfig } from '../oneapi/iexpfront/definitions';
|
|
4
1
|
import { type RequestOptions } from '@antintl/antom-toolset';
|
|
2
|
+
import { type BaseElementAppConfig, type BaseElementConfig, BaseMainElement, type ErrorPayload } from '@antintl/opensdk-core';
|
|
3
|
+
import type { CashierSdkActionQueryResult, OneAccountQueryResult, PaymentSessionConfig } from '../oneapi/iexpfront/definitions';
|
|
5
4
|
import { type IPaymentSessionMetaData } from '../tools/getMetaData';
|
|
5
|
+
import { type GetApplePayTokenReply, type GetApplePayTokenRequest } from '../tools/paymentElement/applePayHostToken';
|
|
6
|
+
import { type GetGooglePayTokenReply, type GetGooglePayTokenRequest } from '../tools/paymentElement/googlePayHostToken';
|
|
7
|
+
import { type AntomBridgeWithNativeEventMap, type AntomLayouts, type AntomTheme, type AntomVariables, type AppearanceVariables, type SubmitParams, type SubmitResult } from '../types';
|
|
8
|
+
import { type AppearanceRuleSelector, type PickAntomAppearance } from './appearanceRules';
|
|
6
9
|
/**
|
|
7
|
-
* @description Payment element appearance
|
|
10
|
+
* @description Payment element appearance properties
|
|
8
11
|
*/
|
|
9
|
-
export type
|
|
12
|
+
export type PaymentAppearanceProps = {
|
|
10
13
|
displaySetting: 'showPaymentMethodListWhenSingleOption' | 'showCardBrandIcon' | 'showRadioWhenAccordionLayout' | 'showCardCVV';
|
|
11
14
|
theme: AntomTheme;
|
|
12
|
-
variables: AntomVariables;
|
|
15
|
+
variables: AppearanceVariables | AntomVariables;
|
|
13
16
|
layout: AntomLayouts;
|
|
14
|
-
|
|
17
|
+
rules: AppearanceRuleSelector<string>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @description Payment element appearance type
|
|
21
|
+
*/
|
|
22
|
+
export type PaymentAppearance = PickAntomAppearance<PaymentAppearanceProps>;
|
|
15
23
|
/**
|
|
16
24
|
* @description Payment element app config type
|
|
17
25
|
*/
|
|
18
|
-
export interface PaymentAppConfig extends
|
|
26
|
+
export interface PaymentAppConfig extends BaseElementAppConfig {
|
|
27
|
+
/** Payment appearance configuration including optional alias-only Rules. */
|
|
28
|
+
appearance?: PaymentAppearance;
|
|
19
29
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
* @description sessionData,无法通过updateConfig更新
|
|
31
|
+
*/
|
|
22
32
|
sessionData?: string;
|
|
23
33
|
/**
|
|
24
34
|
* @internal sdk所在hostname
|
|
@@ -133,6 +143,25 @@ export interface PaymentSubmitResult extends SubmitResult {
|
|
|
133
143
|
* @description Payment element events
|
|
134
144
|
*/
|
|
135
145
|
export interface PaymentElementEvents extends AntomBridgeWithNativeEventMap<PaymentAppConfig, PaymentSubmitParams, PaymentSubmitResult> {
|
|
146
|
+
/**
|
|
147
|
+
* webapp 委托 host(父 frame)拉起 Apple Pay 拿 token。
|
|
148
|
+
* payload 结构对齐 ModernElementController.GetApplePayTokenRequest(放 paymentMethod/shipping)。
|
|
149
|
+
*/
|
|
150
|
+
'OPENSDK@GET_APPLE_PAY_TOKEN': GetApplePayTokenRequest;
|
|
151
|
+
/** host 完成 Apple Pay token 获取后回包给 webapp */
|
|
152
|
+
'OPENSDK@GET_APPLE_PAY_TOKEN_REPLY': GetApplePayTokenReply;
|
|
153
|
+
/**
|
|
154
|
+
* webapp 委托 host(父 frame)拉起 Google Pay 拿 token。
|
|
155
|
+
* payload 结构对齐 ModernElementController.GetGooglePayTokenRequest(放 data.environment/paymentRequest)。
|
|
156
|
+
*/
|
|
157
|
+
'OPENSDK@GET_GOOGLE_PAY_TOKEN': GetGooglePayTokenRequest;
|
|
158
|
+
/** host 完成 Google Pay token 获取后回包给 webapp */
|
|
159
|
+
'OPENSDK@GET_GOOGLE_PAY_TOKEN_REPLY': GetGooglePayTokenReply;
|
|
160
|
+
/** WebApp notifies the host when the selected payment method changes. */
|
|
161
|
+
paymentMethodChanged: {
|
|
162
|
+
type: string;
|
|
163
|
+
name?: string;
|
|
164
|
+
};
|
|
136
165
|
}
|
|
137
166
|
/**
|
|
138
167
|
* @description Payment element config type
|
|
@@ -145,19 +174,29 @@ interface PaymentElementConfig extends BaseElementConfig<PaymentAppConfig> {
|
|
|
145
174
|
export declare class PaymentElement extends BaseMainElement<PaymentElementConfig, PaymentElementEvents> {
|
|
146
175
|
static elementType: string;
|
|
147
176
|
private _paymentInProgress;
|
|
177
|
+
private readonly paymentTracker;
|
|
178
|
+
private _mountStartedAt;
|
|
179
|
+
private _mountInProgress;
|
|
180
|
+
private _mountPhase;
|
|
181
|
+
private _destroyInProgress;
|
|
182
|
+
private readonly walletLogger;
|
|
148
183
|
constructor(name: string, config: PaymentElementConfig);
|
|
149
184
|
/**
|
|
150
185
|
* @internal
|
|
151
186
|
*/
|
|
152
187
|
setup(): Promise<Partial<PaymentAppConfig> | undefined>;
|
|
188
|
+
mount(container: HTMLElement): Promise<void>;
|
|
153
189
|
/**
|
|
154
|
-
* @description Update payment element configuration with amount validation
|
|
190
|
+
* @description Update payment element configuration with amount validation and appearance Rules support
|
|
155
191
|
*/
|
|
156
|
-
updateConfig(newConfig:
|
|
192
|
+
updateConfig(newConfig: Partial<PaymentAppConfig>): Promise<PaymentElementEvents['OPENSDK@UPDATE_CONFIG_REPLY']>;
|
|
157
193
|
/**
|
|
158
194
|
* @internal
|
|
159
195
|
*/
|
|
160
196
|
submit(data?: PaymentSubmitParams): Promise<PaymentSubmitResult>;
|
|
197
|
+
on<T extends keyof PaymentElementEvents>(event: T, handler: (payload: PaymentElementEvents[T]) => void): void;
|
|
198
|
+
unmount(): void;
|
|
199
|
+
destroy(): void;
|
|
161
200
|
protected focus(): void;
|
|
162
201
|
protected blur(): void;
|
|
163
202
|
protected clear(): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { PickAppearance } from '@antintl/opensdk-core';
|
|
2
|
+
/** Semantic states accepted by the merchant selector grammar. */
|
|
3
|
+
type AppearanceRuleState = 'hover' | 'focus' | 'focus-visible' | 'active' | 'disabled' | 'loading' | 'selected' | 'checked' | 'expanded' | 'invalid' | 'success' | 'error';
|
|
4
|
+
/** Controlled pseudo-class accepted by the merchant selector grammar. */
|
|
5
|
+
type AppearanceRulePseudoClass = 'autofill';
|
|
6
|
+
/** Controlled pseudo-element accepted by the merchant selector grammar. */
|
|
7
|
+
type AppearanceRulePseudoElement = 'placeholder' | 'selection';
|
|
8
|
+
/**
|
|
9
|
+
* Optional state or controlled pseudo suffix on one alias.
|
|
10
|
+
*/
|
|
11
|
+
export type AppearanceRuleScopeSuffix = '' | `:${AppearanceRuleState | AppearanceRulePseudoClass}` | `::${AppearanceRulePseudoElement}`;
|
|
12
|
+
/** One merchant alias with an optional semantic suffix. */
|
|
13
|
+
export type AppearanceRuleSelector<RuleAlias extends string> = `${RuleAlias}${AppearanceRuleScopeSuffix}`;
|
|
14
|
+
/** Paint-only property names exposed by the SDK contract. */
|
|
15
|
+
export type AppearancePaintProperty = 'color' | 'WebkitTextFillColor' | 'textDecorationColor' | 'textDecorationLine' | 'textDecorationStyle' | 'textShadow' | 'backgroundColor' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'borderRadius' | 'borderTopLeftRadius' | 'borderTopRightRadius' | 'borderBottomRightRadius' | 'borderBottomLeftRadius' | 'borderStyle' | 'boxShadow' | 'fill' | 'stroke' | 'fillOpacity' | 'strokeOpacity' | 'strokeWidth' | 'outlineColor' | 'outlineStyle' | 'outlineWidth' | 'outlineOffset' | 'caretColor' | 'accentColor';
|
|
16
|
+
/** Controlled layout longhands intersected with the concrete Part at runtime. */
|
|
17
|
+
export type AppearanceLayoutProperty = 'marginTop' | 'marginRight' | 'marginBottom' | 'marginLeft' | 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'height';
|
|
18
|
+
/** Exact official spacing Token accepted by controlled margin and padding. */
|
|
19
|
+
export type AppearanceSpacingToken = `var(--spacing-${'base' | 'none' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl'})`;
|
|
20
|
+
/** Runtime-constrained non-negative integer pixel value for spacing longhands. */
|
|
21
|
+
export type AppearanceSpacingValue = '0' | `${number}px` | AppearanceSpacingToken;
|
|
22
|
+
/** Paint declarations accepted before WebApp and Components runtime validation. */
|
|
23
|
+
type AppearancePaintDeclarations = Partial<Record<Exclude<AppearancePaintProperty, 'fillOpacity' | 'strokeOpacity' | 'strokeWidth' | 'textDecorationStyle' | 'outlineStyle'>, string> & Record<'fillOpacity' | 'strokeOpacity' | 'strokeWidth', string | number> & {
|
|
24
|
+
textDecorationStyle: '-moz-initial' | 'inherit' | 'initial' | 'revert' | 'revert-layer' | 'unset' | 'dashed' | 'dotted' | 'double' | 'solid' | 'wavy';
|
|
25
|
+
outlineStyle: '-moz-initial' | 'inherit' | 'initial' | 'revert' | 'revert-layer' | 'unset' | 'auto' | 'dashed' | 'dotted' | 'double' | 'groove' | 'inset' | 'none' | 'outset' | 'ridge' | 'solid';
|
|
26
|
+
}>;
|
|
27
|
+
/** Target-level layout declarations admitted before runtime capability intersection. */
|
|
28
|
+
export type AppearanceLayoutDeclarations = {
|
|
29
|
+
[Property in Exclude<AppearanceLayoutProperty, 'height'>]?: AppearanceSpacingValue;
|
|
30
|
+
} & {
|
|
31
|
+
/** Exact integer-pixel enum allocated by the target contract. */
|
|
32
|
+
readonly height?: `${number}px`;
|
|
33
|
+
};
|
|
34
|
+
/** Paint declarations plus controlled typography and target-level layout fields. */
|
|
35
|
+
type AppearanceRuleDeclarations = AppearancePaintDeclarations & AppearanceLayoutDeclarations & {
|
|
36
|
+
/** Single font family identifier admitted only for authorized targets at runtime. */
|
|
37
|
+
readonly fontFamily?: string;
|
|
38
|
+
/** Integer pixel size admitted only for authorized text targets at runtime. */
|
|
39
|
+
readonly fontSize?: `${number}px`;
|
|
40
|
+
/** Controlled font weight admitted only for authorized text targets at runtime. */
|
|
41
|
+
readonly fontWeight?: 400 | 500 | 600 | 700;
|
|
42
|
+
/** Controlled font style admitted only for authorized text targets at runtime. */
|
|
43
|
+
readonly fontStyle?: 'normal' | 'italic';
|
|
44
|
+
};
|
|
45
|
+
/** Builds an Antom appearance type with the restricted Rules declaration contract. */
|
|
46
|
+
export type PickAntomAppearance<T extends Record<string, any>> = PickAppearance<T, AppearanceRuleDeclarations>;
|
|
47
|
+
type AppearanceRulesAppConfig = {
|
|
48
|
+
appearance?: {
|
|
49
|
+
rules?: unknown;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Resets stored Rules before the core deep merge handles an explicit empty patch.
|
|
54
|
+
*
|
|
55
|
+
* @param currentConfig - Current complete SDK configuration.
|
|
56
|
+
* @param update - Merchant configuration patch being merged.
|
|
57
|
+
*/
|
|
58
|
+
export declare function prepareAppearanceRulesUpdate(currentConfig: AppearanceRulesAppConfig, update: AppearanceRulesAppConfig): void;
|
|
59
|
+
export {};
|
|
@@ -4,13 +4,18 @@ interface HandleApplePayTokenAtHostOptions {
|
|
|
4
4
|
requestId: string;
|
|
5
5
|
renderData: unknown;
|
|
6
6
|
appConfig?: ExpressAppConfig;
|
|
7
|
+
/** iframe 已转好的 major unit 金额(来自 resolvedAmount);host 委托直接消费,不再做 minor→major 转换。 */
|
|
8
|
+
walletAmount?: {
|
|
9
|
+
value: string;
|
|
10
|
+
currency: string;
|
|
11
|
+
};
|
|
7
12
|
sendReply: (payload: ApplePayTokenReply) => void;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
10
15
|
* 非 Safari PC 路径:host 只负责在顶层 document 拉起 ApplePaySession 并取 token。
|
|
11
16
|
* token 回到 express_element webapp 后,submit/2DS/3DS/polling 继续由 webapp 承接。
|
|
12
17
|
*/
|
|
13
|
-
export declare function handleApplePayTokenAtHost({ requestId, renderData, appConfig, sendReply, }: HandleApplePayTokenAtHostOptions): Promise<void>;
|
|
18
|
+
export declare function handleApplePayTokenAtHost({ requestId, renderData, appConfig, walletAmount, sendReply, }: HandleApplePayTokenAtHostOptions): Promise<void>;
|
|
14
19
|
export declare function buildRecurringPaymentRequest(sessionData: string, merchantInfo: {
|
|
15
20
|
countryCode?: string;
|
|
16
21
|
merchantName?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BaseElementAppConfig, BaseElementConfig, ErrorPayload } from '@antintl/opensdk-core';
|
|
2
|
+
import type { AppearanceRuleSelector, PickAntomAppearance } from '../../elements/appearanceRules';
|
|
2
3
|
import type { AntomBridgeWithNativeEventMap, PreloadTelemetryContext } from '../../types';
|
|
3
4
|
export declare const SUPPORTED_EXPRESS_METHODS: readonly ["paypal", "applePay", "googlePay", "alipay"];
|
|
4
5
|
export type ExpressPaymentMethod = (typeof SUPPORTED_EXPRESS_METHODS)[number];
|
|
@@ -7,11 +8,17 @@ export type ExpressSetupError = ErrorPayload & {
|
|
|
7
8
|
/** 服务端返回的 errorMessage 已完成国际化,可直接对客展示 */
|
|
8
9
|
mulityLanguageMapping?: boolean;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
/** Express element appearance properties. */
|
|
12
|
+
export type ExpressAppearanceProps = {
|
|
13
|
+
displaySetting: 'showCardBrandIcon';
|
|
12
14
|
theme: 'light' | 'dark';
|
|
13
15
|
layout: 'accordion' | 'tabs';
|
|
16
|
+
rules: AppearanceRuleSelector<string>;
|
|
14
17
|
};
|
|
18
|
+
/** Express element appearance configuration. */
|
|
19
|
+
type ExpressAppearance = PickAntomAppearance<ExpressAppearanceProps>;
|
|
20
|
+
/** Backward-compatible name for the Express appearance configuration. */
|
|
21
|
+
export type AppearanceSetting = ExpressAppearance;
|
|
15
22
|
/**
|
|
16
23
|
* @public
|
|
17
24
|
* @description PayPal button style configuration
|
|
@@ -29,6 +36,7 @@ export interface PayPalConfig {
|
|
|
29
36
|
channelMerchantAccountId?: string;
|
|
30
37
|
/** Button style (fine-grained override) */
|
|
31
38
|
style?: PayPalButtonStyle;
|
|
39
|
+
businessDivision?: string;
|
|
32
40
|
/** Callback to create PayPal order, no params, returns sessionData */
|
|
33
41
|
createOrder?: () => Promise<string>;
|
|
34
42
|
/** Callback when user changes shipping address, data is raw data returned by PayPal */
|
|
@@ -104,20 +112,21 @@ export interface ExpressCancelEvent {
|
|
|
104
112
|
* @public
|
|
105
113
|
* @description Express element app config type
|
|
106
114
|
*/
|
|
107
|
-
export interface ExpressAppConfig extends
|
|
115
|
+
export interface ExpressAppConfig extends BaseElementAppConfig {
|
|
116
|
+
/** Express appearance configuration. */
|
|
117
|
+
appearance?: ExpressAppearance;
|
|
108
118
|
/** payment SessionData */
|
|
109
119
|
sessionData?: string;
|
|
110
|
-
/** Business division (country/region) */
|
|
111
|
-
businessDivision?: string;
|
|
112
120
|
/**
|
|
113
121
|
* Amount & Currency
|
|
114
122
|
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
123
|
+
* For Apple Pay and Google Pay, `value` is a positive ASCII digit string in
|
|
124
|
+
* the payment session currency's minor unit; `currency` may be omitted.
|
|
125
|
+
* For example, USD 10.99 is passed as `{ value: '1099' }`.
|
|
126
|
+
* PayPal keeps its existing major-unit amount semantics and requires `currency`.
|
|
118
127
|
*/
|
|
119
128
|
amount?: {
|
|
120
|
-
currency
|
|
129
|
+
currency?: string;
|
|
121
130
|
value: string;
|
|
122
131
|
};
|
|
123
132
|
/** PayPal 配置 */
|
|
@@ -237,6 +246,11 @@ export interface ExpressElementEvents extends AntomBridgeWithNativeEventMap<Expr
|
|
|
237
246
|
'OPENSDK@GET_APPLE_PAY_TOKEN': {
|
|
238
247
|
requestId: string;
|
|
239
248
|
expressPaymentType: string;
|
|
249
|
+
/** iframe 已转好的 major unit 金额(来自 resolvedAmount);host 委托 Apple Pay 消费,不再做 minor→major 转换。 */
|
|
250
|
+
walletAmount?: {
|
|
251
|
+
value: string;
|
|
252
|
+
currency: string;
|
|
253
|
+
};
|
|
240
254
|
};
|
|
241
255
|
/** host 完成 Apple Pay token 获取后回包给 iframe,submit/3DS/polling 均由 webapp 完成 */
|
|
242
256
|
'OPENSDK@GET_APPLE_PAY_TOKEN_REPLY': {
|
|
@@ -260,3 +274,4 @@ export interface ExpressElementEvents extends AntomBridgeWithNativeEventMap<Expr
|
|
|
260
274
|
needReset: boolean;
|
|
261
275
|
};
|
|
262
276
|
}
|
|
277
|
+
export {};
|
|
@@ -108,7 +108,14 @@ export declare const getMetaData: (sessionData: string) => IPaymentSessionMetaDa
|
|
|
108
108
|
* Local debug switch used to force modernWeb in production during controlled rollout.
|
|
109
109
|
*/
|
|
110
110
|
export declare const MODERN_WEB_STORAGE_KEY = "antom-web-checkout-v2_modern_web";
|
|
111
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Resolves whether a session enables the selected modern Web flow.
|
|
113
|
+
*
|
|
114
|
+
* @param sessionData Opaque payment session data parsed by `getMetaData`.
|
|
115
|
+
* @param key Exact, case-sensitive `flowSwitchTags` entry to match.
|
|
116
|
+
* @returns The resolved modern-flow state and the non-production frontend source when present.
|
|
117
|
+
*/
|
|
118
|
+
export declare const isModernWeb: (sessionData: string | undefined, key?: string) => {
|
|
112
119
|
fromFrontend?: boolean;
|
|
113
120
|
modernWeb: boolean;
|
|
114
121
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
interface ModalMessageReport {
|
|
2
|
+
stage: string;
|
|
3
|
+
modalId: string;
|
|
4
|
+
scope: string;
|
|
5
|
+
origin: string;
|
|
6
|
+
elapsedMs: number;
|
|
7
|
+
modalState: string;
|
|
8
|
+
modalStyle: string;
|
|
9
|
+
iframePath: string;
|
|
10
|
+
visibilityState: string;
|
|
11
|
+
layerState: string;
|
|
12
|
+
sourceState: string;
|
|
13
|
+
sourceFrameIndex: number;
|
|
14
|
+
modalCount: number;
|
|
15
|
+
overlayCount: number;
|
|
16
|
+
}
|
|
17
|
+
/** Maps a modal lifecycle snapshot to the shared tracker field schema. */
|
|
18
|
+
export declare const getModalMessageTrackData: (data: ModalMessageReport) => {
|
|
19
|
+
d1: string;
|
|
20
|
+
d2: string;
|
|
21
|
+
d3: string;
|
|
22
|
+
d4: string;
|
|
23
|
+
d5: string;
|
|
24
|
+
d6: string;
|
|
25
|
+
d7: string;
|
|
26
|
+
d8: string;
|
|
27
|
+
d9: string;
|
|
28
|
+
d10: string;
|
|
29
|
+
d11: string;
|
|
30
|
+
m1: number;
|
|
31
|
+
m2: number;
|
|
32
|
+
m3: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Installs a passive host-window monitor for the modal bridge lifecycle.
|
|
36
|
+
* @param report Receives sanitized lifecycle snapshots.
|
|
37
|
+
* @param acceptOpen Restricts which OPEN_MODAL source starts this monitor.
|
|
38
|
+
* @returns A function that removes the listener and pending timers.
|
|
39
|
+
*/
|
|
40
|
+
export declare function installModalMessageMonitor(report: (data: ModalMessageReport) => void, acceptOpen?: (event: MessageEvent) => boolean): () => void;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Logger } from "../../../../util/logger";
|
|
2
|
+
import type { PaymentHostTracker } from './tracker';
|
|
3
|
+
/** webapp 传来的 OPENSDK@GET_APPLE_PAY_TOKEN payload 形态。 */
|
|
4
|
+
export interface GetApplePayTokenRequest {
|
|
5
|
+
paymentMethod?: {
|
|
6
|
+
paymentMethodDetail?: {
|
|
7
|
+
applePayProps?: {
|
|
8
|
+
paymentRequest?: unknown;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
shipping?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/** host 回传 webapp 的 OPENSDK@GET_APPLE_PAY_TOKEN_REPLY 形态(result 对齐老链路 {token,billingContact,shippingContact})。 */
|
|
15
|
+
export interface GetApplePayTokenReply {
|
|
16
|
+
success: boolean;
|
|
17
|
+
result?: {
|
|
18
|
+
token?: unknown;
|
|
19
|
+
billingContact?: unknown;
|
|
20
|
+
shippingContact?: unknown;
|
|
21
|
+
} | {
|
|
22
|
+
errorCode: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface HandleApplePayTokenAtHostOptions {
|
|
26
|
+
sessionData: string;
|
|
27
|
+
env: string;
|
|
28
|
+
payload: unknown;
|
|
29
|
+
logger: Logger;
|
|
30
|
+
tracker: PaymentHostTracker;
|
|
31
|
+
sendReply: (reply: GetApplePayTokenReply) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* host 端拉起 Apple Pay sheet 拿 token,拿到后通过 sendReply 回传给 webapp。
|
|
35
|
+
* 失败/取消也通过 sendReply 回传,webapp 侧自行决定是否走 doSubmit。
|
|
36
|
+
*/
|
|
37
|
+
export declare function handleApplePayTokenAtHost({ sessionData, env, payload, logger, tracker, sendReply, }: HandleApplePayTokenAtHostOptions): Promise<void>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PaymentHostTracker } from './tracker';
|
|
2
|
+
/** webapp 传来的 OPENSDK@GET_GOOGLE_PAY_TOKEN payload 形态。 */
|
|
3
|
+
export interface GetGooglePayTokenRequest {
|
|
4
|
+
actionName?: string;
|
|
5
|
+
data?: {
|
|
6
|
+
environment?: string;
|
|
7
|
+
paymentRequest?: unknown;
|
|
8
|
+
paymentMethod?: unknown;
|
|
9
|
+
paymentMethodDetail?: {
|
|
10
|
+
googlePayProps?: {
|
|
11
|
+
environment?: string;
|
|
12
|
+
paymentRequest?: unknown;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** host 回传 webapp 的 OPENSDK@GET_GOOGLE_PAY_TOKEN_REPLY 形态。 */
|
|
19
|
+
export interface GetGooglePayTokenReply {
|
|
20
|
+
success: boolean;
|
|
21
|
+
result?: unknown;
|
|
22
|
+
err?: {
|
|
23
|
+
statusCode?: string;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
type SendReply = (reply: GetGooglePayTokenReply) => void;
|
|
28
|
+
interface HandleGooglePayTokenAtHostOptions {
|
|
29
|
+
payload: unknown;
|
|
30
|
+
tracker: PaymentHostTracker;
|
|
31
|
+
sendReply: SendReply;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* host 端拉起 Google Pay 拿 token,通过 sendReply 回传给 webapp。
|
|
35
|
+
* 动态加载 GP SDK(若未加载)→ PaymentsClient.isReadyToPay → loadPaymentData。
|
|
36
|
+
*/
|
|
37
|
+
export declare function handleGooglePayTokenAtHost({ payload, tracker, sendReply }: HandleGooglePayTokenAtHostOptions): void;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ApiError, type ApiOutput, type ApiReport, type AsyncApiRunOptions, type ElementTracker, type ElementTrackerEnrichment, type SyncApiRunOptions } from '../../tracking/elementTracker';
|
|
2
|
+
export { normalizeElementEventName } from '../../tracking/elementTracker';
|
|
3
|
+
export type { ApiOutcome } from '../../tracking/elementTracker';
|
|
4
|
+
export type PaymentTrackerEnrichment = ElementTrackerEnrichment;
|
|
5
|
+
export type PaymentApiReport = ApiReport;
|
|
6
|
+
export type PaymentApiOutput = ApiOutput;
|
|
7
|
+
export type PaymentApiError = ApiError;
|
|
8
|
+
export type PaymentAsyncApiRunOptions<T> = AsyncApiRunOptions<T>;
|
|
9
|
+
export type PaymentSyncApiRunOptions<T> = SyncApiRunOptions<T>;
|
|
10
|
+
export type PaymentHostTracker = ElementTracker;
|
|
11
|
+
interface CreatePaymentHostTrackerOptions {
|
|
12
|
+
env?: string;
|
|
13
|
+
locale?: string;
|
|
14
|
+
elementInstanceId?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function createPaymentHostTracker(sessionData?: string, options?: CreatePaymentHostTrackerOptions): PaymentHostTracker;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Logger } from "../../../../util/logger";
|
|
2
|
+
import { type PaymentHostTracker } from './tracker';
|
|
3
|
+
/** BaseMainElement 的 on/send 收发接口(避免耦合具体 element 类)。 */
|
|
4
|
+
export interface WalletHostBridge {
|
|
5
|
+
on: (event: string, handler: (payload: unknown) => void) => void;
|
|
6
|
+
send: (event: string, payload: unknown) => void;
|
|
7
|
+
}
|
|
8
|
+
interface RegisterWalletHostListenersOptions {
|
|
9
|
+
bridge: WalletHostBridge;
|
|
10
|
+
sessionData: string | undefined;
|
|
11
|
+
env: string;
|
|
12
|
+
logger: Logger;
|
|
13
|
+
tracker?: PaymentHostTracker;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 注册 GP/AP host 监听。在 element setup() 内调用一次,生命周期与 element 一致。
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerWalletHostListeners({ bridge, sessionData, env, logger, tracker, }: RegisterWalletHostListenersOptions): void;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { sdkTracker } from '@antintl/opensdk-core';
|
|
2
|
+
import type { CashierSdkActionQueryResult } from '../oneapi/iexpfront/definitions';
|
|
3
|
+
import { type IPaymentSessionMetaData } from '../tools/getMetaData';
|
|
4
|
+
export type ApiOutcome = 'success' | 'fail' | 'cancelled' | 'processing' | 'error' | 'unknown';
|
|
5
|
+
export declare const normalizeElementEventName: (event: PropertyKey) => string;
|
|
6
|
+
export interface ElementTrackerEnrichment {
|
|
7
|
+
metaData?: IPaymentSessionMetaData;
|
|
8
|
+
renderData?: CashierSdkActionQueryResult;
|
|
9
|
+
locale?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ApiReport {
|
|
12
|
+
outcome: ApiOutcome;
|
|
13
|
+
durationMs: number;
|
|
14
|
+
errorCode?: string;
|
|
15
|
+
traceId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ApiOutput {
|
|
18
|
+
outcome: ApiOutcome;
|
|
19
|
+
errorCode?: string;
|
|
20
|
+
traceId?: string;
|
|
21
|
+
fields?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export interface ApiError {
|
|
24
|
+
code: string;
|
|
25
|
+
source: string;
|
|
26
|
+
traceId: string;
|
|
27
|
+
}
|
|
28
|
+
interface ApiRunOptions<T> {
|
|
29
|
+
msg: string;
|
|
30
|
+
inputFields?: () => Record<string, unknown>;
|
|
31
|
+
outputFields?: (result: T) => ApiOutput;
|
|
32
|
+
errorFields?: (error: ApiError) => Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface AsyncApiRunOptions<T> extends ApiRunOptions<T> {
|
|
35
|
+
action: () => Promise<T>;
|
|
36
|
+
}
|
|
37
|
+
export interface SyncApiRunOptions<T> extends ApiRunOptions<T> {
|
|
38
|
+
action: () => T;
|
|
39
|
+
}
|
|
40
|
+
export interface ElementTracker {
|
|
41
|
+
readonly merchantId: string;
|
|
42
|
+
readonly productScene: string;
|
|
43
|
+
readonly productSceneVersion: string;
|
|
44
|
+
readonly paymentMethodCategoryType: string;
|
|
45
|
+
readonly paymentMethodType: string;
|
|
46
|
+
readonly trackId: string;
|
|
47
|
+
readonly requestTracker: typeof sdkTracker;
|
|
48
|
+
enrich: (data: ElementTrackerEnrichment) => void;
|
|
49
|
+
setPaymentMethodType: (paymentMethodType?: string) => void;
|
|
50
|
+
trackMount: (msg: string, extra?: Record<string, unknown>) => void;
|
|
51
|
+
trackHandshake: (msg: string, extra?: Record<string, unknown>) => void;
|
|
52
|
+
trackElement: (msg: string, extra?: Record<string, unknown>) => void;
|
|
53
|
+
trackApi: (msg: string, report: ApiReport, extra?: Record<string, unknown>) => void;
|
|
54
|
+
trackError: (msg: string, extra?: Record<string, unknown>) => void;
|
|
55
|
+
runAsyncApi: <T>(options: AsyncApiRunOptions<T>) => Promise<T>;
|
|
56
|
+
runSyncApi: <T>(options: SyncApiRunOptions<T>) => T;
|
|
57
|
+
}
|
|
58
|
+
export interface CreateElementTrackerOptions {
|
|
59
|
+
elementType: string;
|
|
60
|
+
env?: string;
|
|
61
|
+
locale?: string;
|
|
62
|
+
elementInstanceId?: string;
|
|
63
|
+
}
|
|
64
|
+
export declare function createElementTracker(sessionData: string | undefined, options: CreateElementTrackerOptions): ElementTracker;
|
|
65
|
+
export {};
|