@alipay/ams-checkout 0.0.1757298389-dev.0 → 0.0.1757298389-dev.10

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.
@@ -27,11 +27,11 @@ import PackageJson from "../../../../../package.json";
27
27
  import { EVENT } from "../../../../constant";
28
28
  import { ServiceProvider } from "../../../../foundation/service";
29
29
  import { ApplePaySdk, handleGooglePay, isSkipRenderPaymentMethod } from "../../../../plugin/component/channel";
30
- import { LogConfig, Logger } from "../../../../util/logger";
31
30
  import { queryParse } from "../../../../util";
31
+ import { LogConfig, Logger } from "../../../../util/logger";
32
32
  import { parseSessionData } from "../../index";
33
33
  import { oneAccount, sdkAction } from "../mock";
34
- import { generateIframeSrc as _generateIframeSrc, isElementPC, isElementPad } from "../util";
34
+ import { generateIframeSrc as _generateIframeSrc, isElementPad, isElementPC } from "../util";
35
35
  import BaseElementProcessor from "./baseElementProcessor";
36
36
  var logger = new Logger(LogConfig, true);
37
37
  var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
@@ -58,7 +58,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
58
58
  event: 'renderComponent',
59
59
  data: {
60
60
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
61
- paymentSessionData: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionId,
61
+ // 极简架构需要全量sessionData, 服务端与谦评估没得影响
62
+ paymentSessionData: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSession,
62
63
  queryResult: extraParam === null || extraParam === void 0 ? void 0 : extraParam.originActionQueryResult,
63
64
  envInfo: {
64
65
  screenHeight: screen.height,
@@ -242,18 +243,19 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
242
243
  value: function () {
243
244
  var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
244
245
  var _paymentSessionObj$co;
245
- var requestService, _this$elementContaine8, paymentSession, paymentSessionObj, displayInfo, merchantAppointParam, _this$options2, environment, locale, _ref4, paymentSessionConfig, hostSign, isConnect, LOCAL_MOCK, _queryParse, appType, terminalType, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
246
+ var requestService, _this$elementContaine8, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options2, environment, locale, _ref4, paymentSessionConfig, hostSign, isConnect, LOCAL_MOCK, _queryParse, appType, terminalType, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
246
247
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
247
248
  while (1) switch (_context2.prev = _context2.next) {
248
249
  case 0:
249
250
  requestService = ServiceProvider.getInstance(this.instanceId).getService('Requester');
250
251
  _this$elementContaine8 = this.elementContainer.getPaymentContext(), paymentSession = _this$elementContaine8.paymentSession, paymentSessionObj = _this$elementContaine8.paymentSessionObj, displayInfo = _this$elementContaine8.displayInfo;
251
- merchantAppointParam = displayInfo.merchantAppointParam;
252
+ _displayInfo = displayInfo;
253
+ debugProps = _displayInfo.debugProps;
252
254
  _this$options2 = this.options, environment = _this$options2.env.environment, locale = _this$options2.locale;
253
255
  _ref4 = paymentSessionObj || {}, paymentSessionConfig = _ref4.paymentSessionConfig;
254
256
  hostSign = paymentSession.split('&&')[1] || '';
255
257
  isConnect = paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect;
256
- LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1;
258
+ LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock);
257
259
  _queryParse = queryParse(this.getElementUrl()), appType = _queryParse.appType;
258
260
  terminalType = isElementPad() ? 'WEB' : appType ? 'APP' : isElementPC() ? 'WEB' : 'WAP';
259
261
  generateActionQueryPromise = function generateActionQueryPromise() {
@@ -267,7 +269,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
267
269
  }
268
270
  var sdkRequestData = {
269
271
  paymentSessionConfig: paymentSessionConfig,
270
- paymentSessionData: paymentSession
272
+ paymentSessionData: paymentSession,
273
+ extParams: {
274
+ // 必传,服务端用于根据前端传入locale判断是否使用用户偏好语言
275
+ isUserPreferredLocale: true
276
+ }
271
277
  };
272
278
  if (displayInfo !== null && displayInfo !== void 0 && (_displayInfo$merchant = displayInfo.merchantAppointParam) !== null && _displayInfo$merchant !== void 0 && _displayInfo$merchant.storedCard) {
273
279
  sdkRequestData.merchantAppointParam = displayInfo.merchantAppointParam;
@@ -322,9 +328,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
322
328
  });
323
329
  });
324
330
  };
325
- _context2.next = 14;
331
+ _context2.next = 15;
326
332
  return Promise.all(isConnect ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
327
- case 14:
333
+ case 15:
328
334
  _yield$Promise$all = _context2.sent;
329
335
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
330
336
  originActionQueryResult = _yield$Promise$all2[0];
@@ -337,7 +343,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
337
343
  originActionQueryResult: originActionQueryResult,
338
344
  originOneAccountQueryResult: originOneAccountQueryResult
339
345
  });
340
- case 20:
346
+ case 21:
341
347
  case "end":
342
348
  return _context2.stop();
343
349
  }
@@ -7,6 +7,9 @@ export declare class ElementComponent {
7
7
  mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
8
8
  mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
9
9
  mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
10
+ validateFields(): Promise<{
11
+ isValid: boolean;
12
+ }>;
10
13
  submitPayment(): void;
11
14
  destroy(): void;
12
15
  }
@@ -49,6 +49,11 @@ export var ElementComponent = /*#__PURE__*/function () {
49
49
  appearance: this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.appearance
50
50
  }, renderOptions), sdkSelector);
51
51
  }
52
+ }, {
53
+ key: "validateFields",
54
+ value: function validateFields() {
55
+ return this.controller.validateFields();
56
+ }
52
57
  }, {
53
58
  key: "submitPayment",
54
59
  value: function submitPayment() {
@@ -10,7 +10,8 @@ export declare enum ElementPaymentEvent {
10
10
  CAPTURE_ASSET = "onCaptureAsset",
11
11
  SIGN_OUT = "onSignout",
12
12
  BLUR = "onBlur",
13
- VALIDATE = "submitPay",
13
+ SUBMIT_PAY = "submitPay",
14
+ VALIDATE = "onValidate",
14
15
  SUBMIT_RISK = "onSubmitRisk",
15
16
  AFTER_SUBMIT = "onAfterSubmit",
16
17
  SIZE_CHANGE = "onSizeChange",
@@ -126,6 +127,10 @@ export interface LinkAuthMountOptions extends BaseMountOptions {
126
127
  theme?: ThemeType;
127
128
  };
128
129
  }
130
+ type ToCamelCase<S extends string> = S extends `${infer First}-${infer Rest}` ? `${First}${Capitalize<ToCamelCase<Rest>>}` : S;
131
+ type CompatibleVariables<T extends Record<string, string>> = {
132
+ [K in keyof T as K | ToCamelCase<K & string>]: string;
133
+ };
129
134
  export interface PaymentMountOptions extends BaseMountOptions {
130
135
  type: ElementType.payment;
131
136
  appearance?: {
@@ -133,7 +138,7 @@ export interface PaymentMountOptions extends BaseMountOptions {
133
138
  layout?: {
134
139
  type: PaymentElementLayout;
135
140
  };
136
- variables?: {
141
+ variables?: Partial<CompatibleVariables<{
137
142
  'content-primary': string;
138
143
  'content-secondary': string;
139
144
  'content-tertiary': string;
@@ -158,7 +163,8 @@ export interface PaymentMountOptions extends BaseMountOptions {
158
163
  'radius-module': string;
159
164
  'radius-component': string;
160
165
  'radius-button': string;
161
- };
166
+ 'warpper-padding': string;
167
+ }>>;
162
168
  };
163
169
  notRedirectAfterComplete?: boolean;
164
170
  merchantAppointParam?: IMerchantAppointParam;
@@ -359,7 +365,7 @@ export interface IElementOptions {
359
365
  appearance?: {
360
366
  theme: ThemeType.Default | ThemeType.Night;
361
367
  };
362
- onEventCallback?: ({ code, message, result }: {
368
+ onEventCallback?: ({ code, message, result, }: {
363
369
  code: EventCallbackCode;
364
370
  message: string;
365
371
  result?: any;
@@ -10,7 +10,8 @@ export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
10
10
  ElementPaymentEvent["CAPTURE_ASSET"] = "onCaptureAsset";
11
11
  ElementPaymentEvent["SIGN_OUT"] = "onSignout";
12
12
  ElementPaymentEvent["BLUR"] = "onBlur";
13
- ElementPaymentEvent["VALIDATE"] = "submitPay";
13
+ ElementPaymentEvent["SUBMIT_PAY"] = "submitPay";
14
+ ElementPaymentEvent["VALIDATE"] = "onValidate";
14
15
  ElementPaymentEvent["SUBMIT_RISK"] = "onSubmitRisk";
15
16
  ElementPaymentEvent["AFTER_SUBMIT"] = "onAfterSubmit";
16
17
  ElementPaymentEvent["SIZE_CHANGE"] = "onSizeChange";
@@ -70,6 +71,11 @@ export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
70
71
  ELEMENT_ENVIRONMENT["SANDBOX"] = "SANDBOX";
71
72
  return ELEMENT_ENVIRONMENT;
72
73
  }({});
74
+
75
+ // 将短横线命名转为小驼峰
76
+
77
+ // 同时兼容短横线和小驼峰两种键名
78
+
73
79
  // export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
74
80
 
75
81
  export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbackName) {
@@ -10,7 +10,7 @@ export declare const formatElementOption: (options: IElementOptions) => {
10
10
  appearance?: {
11
11
  theme: import("./type").ThemeType.Default | import("./type").ThemeType.Night;
12
12
  };
13
- onEventCallback?: ({ code, message, result }: {
13
+ onEventCallback?: ({ code, message, result, }: {
14
14
  code: EventCallbackCode;
15
15
  message: string;
16
16
  result?: any;
@@ -1,5 +1,5 @@
1
1
  import ComponentApp from '../../plugin/component';
2
- import { ComponentSignEnum, IappendIframeNodesParams, IcreateComponent, IoptionsParams, IPaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
2
+ import { ComponentSignEnum, EventPayloadContext, IappendIframeNodesParams, IcreateComponent, IoptionsParams, IPaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum, ValidationResult } from '../../types';
3
3
  import CoreInstance from '../instance/index';
4
4
  export declare const getComponentSign: (params: IPaymentSessionMetaData) => ComponentSignEnum;
5
5
  export declare const parseSessionData: (sessionData: string) => [IPaymentSessionMetaData, string];
@@ -15,6 +15,7 @@ export declare class AMSComponent extends CoreInstance {
15
15
  channelType: ComponentSignEnum[];
16
16
  productSceneVersion: string;
17
17
  timer: any;
18
+ private _validateResolveMap;
18
19
  constructor(options: IAMSComponentOptions);
19
20
  private parameterInitAndCheck;
20
21
  private pluginAppendIframe;
@@ -52,4 +53,6 @@ export declare class AMSComponent extends CoreInstance {
52
53
  * @param data - Transfer information in the submission interface according to your requirements (optional)
53
54
  */
54
55
  submit(data?: Isubmit): Promise<unknown>;
56
+ protected _validateFields(): Promise<ValidationResult>;
57
+ protected _sendMessageToAPP(eventContext: EventPayloadContext): void;
55
58
  }
@@ -35,7 +35,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
35
  * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
36
36
  */
37
37
  import { v4 as uuid } from 'uuid';
38
- import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
38
+ import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT, SENDEVENT } from "../../constant";
39
+ import PreloadHelper from "../../foundation/utils/preload_helper";
39
40
  import { ApplePayBusSubscriber } from "../../plugin/applepay";
40
41
  import ComponentApp from "../../plugin/component";
41
42
  import { ExtendPlugin } from "../../plugin/const";
@@ -50,7 +51,6 @@ import { SecurityBusSubscriber } from "../bus/ability/security";
50
51
  import { TrackerBusSubscriber } from "../bus/ability/tracker";
51
52
  import CoreInstance from "../instance/index";
52
53
  import { loadChannelPneumaticControl } from "./appPreloadProcessing";
53
- import PreloadHelper from "../../foundation/utils/preload_helper";
54
54
  export var getComponentSign = function getComponentSign(params) {
55
55
  var _params$paymentSessio = params.paymentSessionConfig,
56
56
  _params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
@@ -140,6 +140,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
140
140
  _defineProperty(_assertThisInitialized(_this2), "channelType", void 0);
141
141
  _defineProperty(_assertThisInitialized(_this2), "productSceneVersion", void 0);
142
142
  _defineProperty(_assertThisInitialized(_this2), "timer", void 0);
143
+ _defineProperty(_assertThisInitialized(_this2), "_validateResolveMap", new Map());
143
144
  var ComponentPlugin = new ComponentApp({
144
145
  appVersion: options.appVersion
145
146
  });
@@ -526,6 +527,108 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
526
527
  }
527
528
  });
528
529
  }
530
+
531
+ // 预留给AMSVaulting复用
532
+ }, {
533
+ key: "_validateFields",
534
+ value: function _validateFields() {
535
+ var _this9 = this;
536
+ return new Promise(function (resolve) {
537
+ // 收银台应用渲染表单后,才允许发送校验消息,三端约定一致
538
+ if (!_this9._componentApp.shouldValidateFields()) {
539
+ resolve({
540
+ isValid: false
541
+ });
542
+ _this9.logger.logInfo({
543
+ title: 'sdk_event_validateFields'
544
+ }, {
545
+ processResult: 'notRenderComponent'
546
+ });
547
+ return;
548
+ }
549
+ var timeoutId;
550
+ var validationPromise = new Promise(function (validationResolve) {
551
+ var eventCallbackId = uuid();
552
+ _this9._validateResolveMap.set(eventCallbackId, validationResolve);
553
+ // 发送validateFields消息
554
+ _this9._sendMessageToAPP({
555
+ event: SENDEVENT.validateFields.name,
556
+ data: {},
557
+ eventCallbackId: eventCallbackId
558
+ });
559
+ var isValidationResult = function isValidationResult(data) {
560
+ return _typeof(data) === 'object' && data !== null && typeof data.isValid === 'boolean';
561
+ };
562
+ var callback = /*#__PURE__*/function () {
563
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload) {
564
+ var currentEventCallbackId, currentResolve, result;
565
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
566
+ while (1) switch (_context2.prev = _context2.next) {
567
+ case 0:
568
+ currentEventCallbackId = (payload === null || payload === void 0 ? void 0 : payload.eventCallbackId) || ''; // 事件一一对应,处理异步商户调用多次可能导致乱序的问题
569
+ currentResolve = _this9._validateResolveMap.get(currentEventCallbackId);
570
+ result = {
571
+ isValid: false
572
+ };
573
+ if (isValidationResult(payload === null || payload === void 0 ? void 0 : payload.data)) {
574
+ result = payload === null || payload === void 0 ? void 0 : payload.data;
575
+ }
576
+ _this9.logger.logInfo({
577
+ title: 'sdk_event_validateFields'
578
+ }, {
579
+ processResult: result.isValid ? 'true' : 'false'
580
+ });
581
+ // 收银台应用保证数据格式,三端SDK负责透传
582
+ if (!!currentResolve) {
583
+ currentResolve(result);
584
+ _this9._validateResolveMap.delete(currentEventCallbackId);
585
+ }
586
+ case 6:
587
+ case "end":
588
+ return _context2.stop();
589
+ }
590
+ }, _callee2);
591
+ }));
592
+ return function callback(_x2) {
593
+ return _ref5.apply(this, arguments);
594
+ };
595
+ }();
596
+ // 接收收银台应用的返回validateFieldsResult消息
597
+ // validateFieldsResultForward处理订阅eventCallbackId为空的问题
598
+ _this9._overrideSubscription(EVENT.validateFieldsResult.forwardName, callback, EVENT.validateFieldsResult.uniqueKey);
599
+ });
600
+
601
+ // 兜底场景,三端约定超时时间15秒,兼容cpf网络校验超时场景
602
+ var timeoutPromise = new Promise(function (timeoutResolve) {
603
+ timeoutId = setTimeout(function () {
604
+ _this9.logger.logInfo({
605
+ title: 'sdk_event_validateFields'
606
+ }, {
607
+ processResult: 'timeout'
608
+ });
609
+ timeoutResolve({
610
+ isValid: false
611
+ });
612
+ }, 15000);
613
+ });
614
+ Promise.race([validationPromise, timeoutPromise]).then(function (result) {
615
+ clearTimeout(timeoutId);
616
+ resolve(result);
617
+ }).catch(function () {
618
+ clearTimeout(timeoutId);
619
+ resolve({
620
+ isValid: false
621
+ });
622
+ });
623
+ });
624
+ }
625
+ }, {
626
+ key: "_sendMessageToAPP",
627
+ value: function _sendMessageToAPP(eventContext) {
628
+ this._componentApp.dispatchToApp({
629
+ context: eventContext
630
+ });
631
+ }
529
632
  }]);
530
633
  return AMSComponent;
531
634
  }(CoreInstance);
package/esm/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AddressComponent } from './core/component/address';
2
2
  import { ElementComponent } from './core/component/element';
3
3
  import { AMSComponent } from './core/component/index';
4
- import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions } from './types';
4
+ import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions, ValidationResult } from './types';
5
5
  export { AMSCheckoutPage } from './core/component/ckp';
6
6
  export * from './types';
7
7
  export declare class AMSCheckout extends AMSComponent {
@@ -14,6 +14,15 @@ export declare class AMSAutoDebitPay extends AMSCheckout {
14
14
  export declare class AMSCashierPayment extends AMSCheckout {
15
15
  constructor(options: IoptionsParams);
16
16
  static preload(options?: IPreloadOptions): void;
17
+ /**
18
+ * Form validation function
19
+ * If the form is currently displayed:
20
+ * - Successful validation: isValid is true
21
+ * - Failed validation: isValid is false, and error messages are displayed on the form page
22
+ * If not on the form display page, isValid returns false
23
+ * @returns {Promise<ValidationResult>} Returns a Promise containing the validation result
24
+ */
25
+ validateFields(): Promise<ValidationResult>;
17
26
  }
18
27
  export declare class AMSVaulting extends AMSCheckout {
19
28
  constructor(options: IoptionsParams);
package/esm/index.js CHANGED
@@ -111,7 +111,21 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout2) {
111
111
  }
112
112
  return _super3.call(this, _options, currentChannelType);
113
113
  }
114
- _createClass(AMSCashierPayment, null, [{
114
+ _createClass(AMSCashierPayment, [{
115
+ key: "validateFields",
116
+ value:
117
+ /**
118
+ * Form validation function
119
+ * If the form is currently displayed:
120
+ * - Successful validation: isValid is true
121
+ * - Failed validation: isValid is false, and error messages are displayed on the form page
122
+ * If not on the form display page, isValid returns false
123
+ * @returns {Promise<ValidationResult>} Returns a Promise containing the validation result
124
+ */
125
+ function validateFields() {
126
+ return this._validateFields();
127
+ }
128
+ }], [{
115
129
  key: "preload",
116
130
  value: function preload() {
117
131
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
@@ -28,6 +28,7 @@ export default class ComponentApp {
28
28
  private _isAppWebview;
29
29
  _merchantAppointParam: IMerchantAppointParam;
30
30
  private _webAppHeartBeatTimeoutFn;
31
+ private _hasRenderComponent;
31
32
  constructor(componentOption?: {
32
33
  appVersion?: string;
33
34
  });
@@ -126,5 +127,6 @@ export default class ComponentApp {
126
127
  private showRetentionPopup;
127
128
  private hideRetentionPopupFunc;
128
129
  private submitForm;
130
+ shouldValidateFields(): boolean;
129
131
  }
130
132
  export {};
@@ -23,7 +23,7 @@ import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK
23
23
  import { ElementPaymentMethod } from "../../core/component/oldElement/type";
24
24
  import { queryPaymentInfo, submitPayInfo } from "../../service";
25
25
  import { ComponentSignEnum, DisplayTypeEnum, eventCodeEnum, MessageName, PlatformEnum, ProductSceneEnum, RedirectType, TargetEnum } from "../../types";
26
- import { getType, isJsonString, isPC } from "../../util";
26
+ import { getType, isJsonString, isPC, device } from "../../util";
27
27
  import { getBackScheme } from "../../util/getBackScheme";
28
28
  import { isLocalMock } from "../../util/mock";
29
29
  import { matchVersion } from "../../util/versionCompare";
@@ -62,6 +62,7 @@ var ComponentApp = /*#__PURE__*/function () {
62
62
  _defineProperty(this, "_isAppWebview", void 0);
63
63
  _defineProperty(this, "_merchantAppointParam", void 0);
64
64
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
65
+ _defineProperty(this, "_hasRenderComponent", false);
65
66
  this._appVersion = componentOption.appVersion;
66
67
  this._isInitComponent = false;
67
68
  this._selector = "#".concat(COMPONENT_SECTION_ID);
@@ -71,7 +72,7 @@ var ComponentApp = /*#__PURE__*/function () {
71
72
  this.createPreloadIframeNode = function () {
72
73
  return Promise.resolve();
73
74
  };
74
- this.platform = isPC() ? PlatformEnum.desktop : PlatformEnum.mobile;
75
+ this.platform = device.isMobile ? PlatformEnum.mobile : PlatformEnum.desktop;
75
76
  this._isRetention = true;
76
77
  this._appLocationSearch = '';
77
78
  this._performanceData.push({
@@ -673,6 +674,7 @@ var ComponentApp = /*#__PURE__*/function () {
673
674
  message: res === null || res === void 0 ? void 0 : res.errorMessage
674
675
  };
675
676
  _this5.dispatchToSDK(EVENT.error.name, createComponentError);
677
+ _this5.dispatchToSDK(EVENT.eventCallback.name, createComponentError);
676
678
  if ((res === null || res === void 0 || (_res$errorActions = res.errorActions) === null || _res$errorActions === void 0 ? void 0 : _res$errorActions.showType) === 'NONE') {
677
679
  // 抛错销毁SDK,不展示错误页面
678
680
  reject(createComponentError);
@@ -684,6 +686,7 @@ var ComponentApp = /*#__PURE__*/function () {
684
686
  if (ComponentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign) {
685
687
  // 通用操作:抛CREATECOMPONENT_ERROR错误码给商户,商户升级到新版本需要处理CREATECOMPONENT_ERROR逻辑
686
688
  _this5.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.NETWORK_REQUEST_ERROR);
689
+ _this5.dispatchToSDK(EVENT.eventCallback.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.NETWORK_REQUEST_ERROR);
687
690
  }
688
691
  if ([ComponentSignEnum.CASHIER_PAYMENT_CARD, ComponentSignEnum.VAULTING_CARD, ComponentSignEnum.CASHIER_PAYMENT_APM].includes(_this5._componentSign)) {
689
692
  return resolve({
@@ -1407,6 +1410,12 @@ var ComponentApp = /*#__PURE__*/function () {
1407
1410
  });
1408
1411
  return;
1409
1412
  }
1413
+ if (data.context.event === EVENT.validateFieldsResult.name) {
1414
+ // 将validateFieldsResult事件转发到subsribe处理,解决subsribe拿不到eventCallbackId的问题
1415
+ this.AMSSDK._eventCenter.emit(EVENT.validateFieldsResult.forwardName, data.context);
1416
+ return;
1417
+ }
1418
+
1410
1419
  // log event before sending the callback
1411
1420
  this.logEventCallback(data, 'sdk_event_event_callback');
1412
1421
  try {
@@ -1842,6 +1851,7 @@ var ComponentApp = /*#__PURE__*/function () {
1842
1851
  return this._actionSubmitPromise;
1843
1852
  case 9:
1844
1853
  submitRes = _context8.sent;
1854
+ this._hasRenderComponent = true;
1845
1855
  this._performanceData.push({
1846
1856
  key: 'sdk_render_component',
1847
1857
  value: Date.now()
@@ -1897,16 +1907,16 @@ var ComponentApp = /*#__PURE__*/function () {
1897
1907
  }
1898
1908
  });
1899
1909
  // eslint-disable-next-line no-empty
1900
- _context8.next = 18;
1910
+ _context8.next = 19;
1901
1911
  break;
1902
- case 16:
1903
- _context8.prev = 16;
1912
+ case 17:
1913
+ _context8.prev = 17;
1904
1914
  _context8.t0 = _context8["catch"](0);
1905
- case 18:
1915
+ case 19:
1906
1916
  case "end":
1907
1917
  return _context8.stop();
1908
1918
  }
1909
- }, _callee8, this, [[0, 16]]);
1919
+ }, _callee8, this, [[0, 17]]);
1910
1920
  }));
1911
1921
  function sendRenderEvent() {
1912
1922
  return _sendRenderEvent.apply(this, arguments);
@@ -1933,6 +1943,7 @@ var ComponentApp = /*#__PURE__*/function () {
1933
1943
  this._performanceData = [];
1934
1944
  this._isInitComponent = false;
1935
1945
  this.app = null;
1946
+ this._hasRenderComponent = false;
1936
1947
  if (immediately) this.cleanElement();else {
1937
1948
  setTimeout(function () {
1938
1949
  _this10.cleanElement();
@@ -2019,6 +2030,11 @@ var ComponentApp = /*#__PURE__*/function () {
2019
2030
  form.submit();
2020
2031
  }, 0);
2021
2032
  }
2033
+ }, {
2034
+ key: "shouldValidateFields",
2035
+ value: function shouldValidateFields() {
2036
+ return this._hasRenderComponent;
2037
+ }
2022
2038
  }]);
2023
2039
  return ComponentApp;
2024
2040
  }();
@@ -82,7 +82,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
82
82
  }
83
83
  return Promise.resolve(paypalPluginProps);
84
84
  });
85
- // 加载paypal资源
85
+ // 加载paypal资源 TODO
86
86
  _defineProperty(_assertThisInitialized(_this), "loadPaypalResource", function (paypalPluginProps) {
87
87
  return new Promise(function (resolve, reject) {
88
88
  var _paypalPluginProps$ap;
@@ -265,6 +265,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
265
265
  return _ref6.apply(this, arguments);
266
266
  };
267
267
  }());
268
+ // TODO
268
269
  _defineProperty(_assertThisInitialized(_this), "destroyComponent", /*#__PURE__*/function () {
269
270
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(context, message) {
270
271
  var data;
@@ -373,7 +374,9 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
373
374
  }
374
375
  }, {
375
376
  key: "onMessage",
376
- value: function onMessage(context, message) {
377
+ value:
378
+ // TODO
379
+ function onMessage(context, message) {
377
380
  switch (message.getAction()) {
378
381
  case PaypalActionEnum.mountComponent:
379
382
  this.renderPaypalButton(context, message);
@@ -40,6 +40,9 @@ export interface IoptionsParams {
40
40
  mode?: string;
41
41
  securityRegion?: 'US' | 'SG' | 'DE';
42
42
  }
43
+ export interface ValidationResult {
44
+ isValid: boolean;
45
+ }
43
46
  export interface IPreloadOptions {
44
47
  environment?: string;
45
48
  securityRegion?: 'US' | 'SG' | 'DE';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1757298389-dev.0",
3
+ "version": "0.0.1757298389-dev.10",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",
@@ -21,7 +21,7 @@
21
21
  "dev": "father dev",
22
22
  "format": "prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"",
23
23
  "lint": "eslint ./src",
24
- "test": "jest --silent",
24
+ "test": "jest --coverage --silent",
25
25
  "tsc": "tsc --noEmit"
26
26
  },
27
27
  "commitlint": {