@alipay/ams-checkout 0.0.1757298389-dev.1 → 0.0.1757298389-dev.11

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 (33) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/component.popup.style.d.ts +1 -0
  3. package/esm/component/component.popup.style.js +1 -1
  4. package/esm/config/index.d.ts +7 -7
  5. package/esm/config/index.js +7 -7
  6. package/esm/constant/index.d.ts +47 -0
  7. package/esm/constant/index.js +50 -0
  8. package/esm/core/component/element/EventCenter/index.d.ts +29 -0
  9. package/esm/core/component/element/EventCenter/index.js +141 -0
  10. package/esm/core/component/element/elementContainerService/containerService.js +3 -2
  11. package/esm/core/component/element/elementController/index.d.ts +20 -2
  12. package/esm/core/component/element/elementController/index.js +463 -262
  13. package/esm/core/component/element/elementProcessor/addressProcessor.js +3 -3
  14. package/esm/core/component/element/elementProcessor/paymentProcessor.js +20 -14
  15. package/esm/core/component/element/index.d.ts +6 -1
  16. package/esm/core/component/element/index.js +5 -2
  17. package/esm/core/component/element/type.d.ts +35 -3
  18. package/esm/core/component/element/type.js +43 -1
  19. package/esm/core/component/element/util.d.ts +17 -4
  20. package/esm/core/component/element/util.js +45 -6
  21. package/esm/core/component/index.d.ts +4 -1
  22. package/esm/core/component/index.js +105 -2
  23. package/esm/foundation/service/log/keys.js +2 -0
  24. package/esm/foundation/service/requester/requester.js +2 -3
  25. package/esm/index.d.ts +10 -1
  26. package/esm/index.js +15 -1
  27. package/esm/plugin/component/index.d.ts +2 -0
  28. package/esm/plugin/component/index.js +23 -7
  29. package/esm/plugin/paypal/index.js +5 -2
  30. package/esm/types/index.d.ts +8 -1
  31. package/esm/util/spm-map.d.ts +2 -0
  32. package/esm/util/spm-map.js +2 -1
  33. package/package.json +2 -2
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);
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { IApplePayContactField } from '../plugin/applepay/interface';
9
9
  export type onChange = () => onCnageResult;
10
- export { ElementType, PaymentElementLayout, ThemeType, type IElementOptions } from '../core/component/oldElement/type';
10
+ export { ElementType, PaymentElementLayout, ThemeType, type IElementOptions, } from '../core/component/oldElement/type';
11
11
  interface onCnageResult {
12
12
  complete: boolean;
13
13
  addressValue: AddressItem[];
@@ -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';
@@ -591,6 +594,10 @@ export interface CashierSdkActionQueryResult {
591
594
  channelOrderId?: string;
592
595
  };
593
596
  errorActions?: Record<string, string>;
597
+ orderAmountView?: IAmountView;
598
+ paymentAmountView?: IAmountView;
599
+ paymentMethods?: IPaymentMethod[];
600
+ savedPaymentMethods?: IPaymentMethod[];
594
601
  }
595
602
  export interface CashierSdkActionQuerySessionResult extends IPaymentSessionMetaData {
596
603
  success: boolean;
@@ -7,6 +7,7 @@ export declare const ELEMENT_SPM_MAP: {
7
7
  auto_apple_pay_start: string;
8
8
  auto_apple_pay_failed: string;
9
9
  auto_apple_pay_success: string;
10
+ sdk_element_handleHeartBeat: string;
10
11
  };
11
12
  export declare const SPM_MAP: {
12
13
  sdk_event_mount_element: string;
@@ -17,6 +18,7 @@ export declare const SPM_MAP: {
17
18
  auto_apple_pay_start: string;
18
19
  auto_apple_pay_failed: string;
19
20
  auto_apple_pay_success: string;
21
+ sdk_element_handleHeartBeat: string;
20
22
  sdk_error_runtime_error: string;
21
23
  sdk_event_sdkQuery_failed: string;
22
24
  container_error_error_insert_js: string;
@@ -14,7 +14,8 @@ export var ELEMENT_SPM_MAP = {
14
14
  multiple_instance_error: 'a3753.b101271.c403950',
15
15
  auto_apple_pay_start: 'a3753.b107385.c398110',
16
16
  auto_apple_pay_failed: 'a3753.b107385.c398111',
17
- auto_apple_pay_success: 'a3753.b107385.c398112'
17
+ auto_apple_pay_success: 'a3753.b107385.c398112',
18
+ sdk_element_handleHeartBeat: 'a3753.b101271.c388217.d624449'
18
19
  };
19
20
  export var SPM_MAP = _objectSpread({
20
21
  sdk_error_runtime_error: 'a3753.b101271.c388188.d512342',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1757298389-dev.1",
3
+ "version": "0.0.1757298389-dev.11",
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": {