@alipay/ams-checkout 0.0.1751356895-dev.1 → 0.0.1751510477-dev.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.
@@ -2,10 +2,13 @@ export declare const createCustomSheet: (curTheme?: 'dark' | 'light') => void;
2
2
  export declare const renderPopupLoading: (container: HTMLDivElement, curTheme: 'dark' | 'light') => void;
3
3
  export declare const removePopupLoading: (isShowMockup?: boolean) => void;
4
4
  export declare const insertStyleSheet: () => void;
5
- export declare const createModal: ({ device, url, widthPadding, loadingConfig }: {
5
+ export declare function createCloseIcon(onClose: () => void): HTMLDivElement;
6
+ export declare const createModal: ({ device, url, widthPadding, loadingConfig, showCloseOnLoading, onCloseOnLoading }: {
6
7
  device: any;
7
8
  url: any;
8
9
  widthPadding: any;
9
10
  loadingConfig: any;
11
+ showCloseOnLoading: any;
12
+ onCloseOnLoading: any;
10
13
  }) => Promise<HTMLIFrameElement>;
11
14
  export declare const destroyModal: () => void;
@@ -47,6 +47,27 @@ export var insertStyleSheet = function insertStyleSheet() {
47
47
  style.innerHTML = modalStyles;
48
48
  document.head.appendChild(style);
49
49
  };
50
+ export function createCloseIcon(onClose) {
51
+ var closeIcon = document.createElement('div');
52
+ closeIcon.style.position = 'absolute';
53
+ closeIcon.style.right = '16px';
54
+ closeIcon.style.top = '23px';
55
+ closeIcon.style.cursor = 'pointer';
56
+ var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
57
+ svg.setAttribute('width', '16');
58
+ svg.setAttribute('height', '16');
59
+ svg.setAttribute('viewBox', '0 0 16 16');
60
+ svg.setAttribute('fill', 'none');
61
+ var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
62
+ path.setAttribute('fill-rule', 'evenodd');
63
+ path.setAttribute('clip-rule', 'evenodd');
64
+ path.setAttribute('d', 'M13.0449 2.99894L12.9494 2.91165L12.8685 2.85222L12.7802 2.7996C12.3611 2.57499 11.8556 2.64328 11.5228 2.9763L7.99909 6.50088L4.48854 2.99028L4.44701 2.95034C4.0098 2.57169 3.38048 2.57202 2.99838 2.9525L2.92363 3.03297L2.85175 3.12897L2.79916 3.21735C2.57471 3.63642 2.64292 4.14198 2.9757 4.47491L6.50186 8.00046L2.95226 11.5518C2.57141 11.9917 2.57173 12.6211 2.95197 13.0033L3.0324 13.078L3.12837 13.15L3.21674 13.2026C3.63573 13.4272 4.14123 13.3589 4.47407 13.0259L7.99909 9.49935L11.5474 13.0494C11.9944 13.4368 12.6238 13.4235 13.0212 13.0259L13.0922 12.9471L13.1559 12.8595C13.4298 12.4403 13.3789 11.8852 13.0211 11.5272L9.497 8.00115L13.0052 4.4915L13.07 4.4225C13.4304 4.00477 13.4199 3.37582 13.0449 2.99894Z');
65
+ path.setAttribute('fill', '#ABB9CC');
66
+ svg.appendChild(path);
67
+ closeIcon.appendChild(svg);
68
+ closeIcon.onclick = onClose;
69
+ return closeIcon;
70
+ }
50
71
  var modalDevice = 'desktop';
51
72
  // 插入弹窗
52
73
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -54,7 +75,9 @@ export var createModal = function createModal(_ref) {
54
75
  var device = _ref.device,
55
76
  url = _ref.url,
56
77
  widthPadding = _ref.widthPadding,
57
- loadingConfig = _ref.loadingConfig;
78
+ loadingConfig = _ref.loadingConfig,
79
+ showCloseOnLoading = _ref.showCloseOnLoading,
80
+ onCloseOnLoading = _ref.onCloseOnLoading;
58
81
  return new Promise(function (resolve, reject) {
59
82
  try {
60
83
  modalDevice = device;
@@ -87,6 +110,15 @@ export var createModal = function createModal(_ref) {
87
110
  modal.style.backgroundColor = backgroundPrimary;
88
111
  iframe.style.backgroundColor = backgroundPrimary;
89
112
  }
113
+
114
+ // 弹窗渲染loading时关闭按钮逻辑
115
+ if (showCloseOnLoading) {
116
+ var closeIcon = createCloseIcon(onCloseOnLoading);
117
+ modal.appendChild(closeIcon);
118
+ iframe.addEventListener('load', function () {
119
+ modal.removeChild(closeIcon);
120
+ });
121
+ }
90
122
  modal.appendChild(iframe);
91
123
  var body = document.getElementsByTagName('body')[0];
92
124
  body.appendChild(overlay);
@@ -238,6 +238,13 @@ export declare const EVENT: {
238
238
  inputFocus: {
239
239
  name: string;
240
240
  };
241
+ /**
242
+ * 通过SDK转发web应用消息给其他web应用(用于iframe之间消息互通)
243
+ * TODO 推荐使用BusManager
244
+ */
245
+ messageForward: {
246
+ name: string;
247
+ };
241
248
  };
242
249
  export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
243
250
  export declare const COMPONENT_SECTION_ID = "ams-component-section";
@@ -239,6 +239,13 @@ export var EVENT = {
239
239
  },
240
240
  inputFocus: {
241
241
  name: 'onInputFocus'
242
+ },
243
+ /**
244
+ * 通过SDK转发web应用消息给其他web应用(用于iframe之间消息互通)
245
+ * TODO 推荐使用BusManager
246
+ */
247
+ messageForward: {
248
+ name: 'onMessageForward'
242
249
  }
243
250
  };
244
251
  export var COMPONENT_CONTAINER_ID = 'ams-component-container';
@@ -20,19 +20,19 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
20
20
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
21
21
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
22
22
  import { cleanMockup, removeRetentionPopup } from "../../../../component/component.popup.style";
23
+ import { destroyModal } from "../../../../component/popupWindow.style";
23
24
  import { ERRORMESSAGE, EVENT } from "../../../../constant";
24
25
  import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
25
26
  import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
26
27
  import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
27
28
  import { IElementStatus } from "../../../../foundation";
28
29
  import { AntomSDKCore } from "../../../../foundation/core";
29
- import { destroyModal } from "../../../../component/popupWindow.style";
30
30
  import { ElementProcessor } from "../../../../foundation/product-processor/element";
31
31
  import { ProductSceneEnum } from "../../../../types";
32
32
  import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
33
33
  import { IContainerStatus } from "../elementContainerService/containerService";
34
34
  import { oneAccountUpdate, sdkActionUpdate } from "../mock";
35
- import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode } from "../type";
35
+ import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, MountElementType } from "../type";
36
36
  import { checkCanMount, checkCanUpdate, handleRedirect, showToast } from "../util";
37
37
  var TIMEOUT_DURATION = 10000;
38
38
  var ElementController = /*#__PURE__*/function () {
@@ -100,10 +100,14 @@ var ElementController = /*#__PURE__*/function () {
100
100
  value: function onEventCallback(_ref) {
101
101
  var _this$options, _this$options$onEvent;
102
102
  var code = _ref.code,
103
- message = _ref.message;
103
+ _ref$message = _ref.message,
104
+ message = _ref$message === void 0 ? '' : _ref$message,
105
+ _ref$result = _ref.result,
106
+ result = _ref$result === void 0 ? undefined : _ref$result;
104
107
  this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 || (_this$options$onEvent = _this$options.onEventCallback) === null || _this$options$onEvent === void 0 || _this$options$onEvent.call(_this$options, {
105
108
  code: code,
106
- message: message
109
+ message: message,
110
+ result: result
107
111
  });
108
112
  }
109
113
  }, {
@@ -278,11 +282,9 @@ var ElementController = /*#__PURE__*/function () {
278
282
  key: "addEventListener",
279
283
  value: function addEventListener(renderCallback) {
280
284
  var _this4 = this;
281
- this.serviceMap.EventCenter.listen(ElementPaymentEvent.CALLBACK, function (data) {
282
- if (_this4.elementProcessors[data.source] && _this4.elementProcessors[data.source].eventListener[data.event]) {
283
- var _this4$elementProcess, _this4$elementProcess2;
284
- (_this4$elementProcess = (_this4$elementProcess2 = _this4.elementProcessors[data.source].eventListener)[data.event]) === null || _this4$elementProcess === void 0 || _this4$elementProcess.call(_this4$elementProcess2, data.data);
285
- }
285
+ this.serviceMap.EventCenter.listen(ElementPaymentEvent.ON_EVENT_CALLBACK, function (data) {
286
+ var _this4$onEventCallbac;
287
+ (_this4$onEventCallbac = _this4.onEventCallback) === null || _this4$onEventCallbac === void 0 || _this4$onEventCallbac.call(_this4, data);
286
288
  });
287
289
  this.serviceMap.EventCenter.listen(EVENT.sizeChanged.name, function (data) {
288
290
  clearTimeout(_this4.initTimeout);
@@ -323,9 +325,15 @@ var ElementController = /*#__PURE__*/function () {
323
325
  this.serviceMap.EventCenter.listen(EVENT.showToast.name, function (data) {
324
326
  showToast(data);
325
327
  });
326
- this.serviceMap.EventCenter.listen(ElementPaymentEvent.SEND_MUITI_APP_EVENT_TO_SDK, function (result) {
327
- var _this4$options$onEven, _this4$options;
328
- (_this4$options$onEven = (_this4$options = _this4.options).onEventCallback) === null || _this4$options$onEven === void 0 || _this4$options$onEven.call(_this4$options, result.data);
328
+ this.serviceMap.EventCenter.listen(EVENT.messageForward.name, function (data) {
329
+ var source = MountElementType[data.source];
330
+ var target = MountElementType[data.target];
331
+ if (_this4.elementProcessors[source] && _this4.elementProcessors[target]) {
332
+ _this4.elementProcessors[target].eventCenter.dispatchToApp({
333
+ event: data.event,
334
+ data: data
335
+ });
336
+ }
329
337
  });
330
338
  }
331
339
  }, {
@@ -362,11 +370,11 @@ var ElementController = /*#__PURE__*/function () {
362
370
  var paymentSessionObj = paymentContext.paymentSessionObj;
363
371
  var isConnect = paymentSessionObj.connectFactor.enableConnect && ((_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
364
372
  if (!(paymentResult !== null && paymentResult !== void 0 && (_paymentResult$origin = paymentResult.originActionQueryResult) !== null && _paymentResult$origin !== void 0 && _paymentResult$origin.success) && isConnect) {
365
- var _this$options$onEvent2, _this$options2;
373
+ var _this$onEventCallback;
366
374
  clearTimeout(this.initTimeout);
367
375
  this.changeLoading(false);
368
376
  this.initTimeout = null;
369
- (_this$options$onEvent2 = (_this$options2 = this.options).onEventCallback) === null || _this$options$onEvent2 === void 0 || _this$options$onEvent2.call(_this$options2, {
377
+ (_this$onEventCallback = this.onEventCallback) === null || _this$onEventCallback === void 0 || _this$onEventCallback.call(this, {
370
378
  code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
371
379
  message: 'Component initialization exception.'
372
380
  });
@@ -2,6 +2,9 @@ import { ActionForm, ConnectErrorCode, IAmount, IAmountView, IMerchantAppointPar
2
2
  import AddressProcessor from './elementProcessor/addressProcessor';
3
3
  import AuthProcessor from './elementProcessor/authProcessor';
4
4
  import PaymentProcessor from './elementProcessor/paymentProcessor';
5
+ /**
6
+ * element 消息事件名
7
+ */
5
8
  export declare enum ElementPaymentEvent {
6
9
  RENDER_COMPONENT = "renderComponent",
7
10
  CAPTURE_ASSET = "onCaptureAsset",
@@ -18,7 +21,8 @@ export declare enum ElementPaymentEvent {
18
21
  */
19
22
  SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
20
23
  LOG = "log",
21
- HANDLE_PAYMENT = "handlePayment"
24
+ HANDLE_PAYMENT = "handlePayment",
25
+ ON_EVENT_CALLBACK = "onEventCallback"
22
26
  }
23
27
  export declare enum ElementPaymentMethod {
24
28
  CONTAINER_ELEMENT = "CONTAINER_ELEMENT",
@@ -26,6 +30,19 @@ export declare enum ElementPaymentMethod {
26
30
  ADDRESS_ELEMENT = "ADDRESS_ELEMENT",
27
31
  PAYMENT_ELEMENT = "PAYMENT_ELEMENT"
28
32
  }
33
+ export declare enum ElementType {
34
+ auth = "auth",
35
+ address = "address",
36
+ payment = "payment"
37
+ }
38
+ export declare const MountElementType: {
39
+ auth: ElementPaymentMethod;
40
+ address: ElementPaymentMethod;
41
+ payment: ElementPaymentMethod;
42
+ AUTH_ELEMENT: ElementType;
43
+ ADDRESS_ELEMENT: ElementType;
44
+ PAYMENT_ELEMENT: ElementType;
45
+ };
29
46
  export declare enum ThemeType {
30
47
  NostalgicGray = "nostalgicGray",
31
48
  Default = "default",
@@ -34,27 +51,22 @@ export declare enum ThemeType {
34
51
  GamingPurple = "gamingPurple",
35
52
  AgateGreen = "agateGreen"
36
53
  }
37
- export declare enum ElementType {
38
- auth = "auth",
39
- address = "address",
40
- payment = "payment"
41
- }
42
54
  export declare enum PaymentElementLayout {
43
55
  Tabs = "tabs",
44
56
  Accordion = "Accordion"
45
57
  }
46
- export declare enum MountElementType {
47
- auth = "AUTH_ELEMENT",
48
- address = "ADDRESS_ELEMENT",
49
- payment = "PAYMENT_ELEMENT"
50
- }
51
58
  export declare const addressTheme: {
52
59
  default: string;
53
60
  night: string;
54
61
  };
55
62
  export declare enum EventCallbackCode {
56
63
  SDK_CREATE_COMPONENT_ERROR = "SDK_CREATE_COMPONENT_ERROR",
57
- SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR"
64
+ SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR",
65
+ SDK_PAYMENT_ERROR = "SDK_PAYMENT_ERROR",
66
+ SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
67
+ SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL",
68
+ SDK_PAYMENT_SUCCESSFUL = "SDK_PAYMENT_SUCCESSFUL",
69
+ SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING"
58
70
  }
59
71
  export declare enum ELEMENT_ENVIRONMENT {
60
72
  DEV = "DEV",
@@ -163,12 +175,14 @@ export interface LinkAuthMountResult extends BaseMountResult {
163
175
  }
164
176
  export interface PaymentMountResult extends BaseMountResult {
165
177
  }
166
- export interface EventCallbackData<T = {}> {
178
+ /**
179
+ * connect element之间通信的类型格式
180
+ */
181
+ export interface ConnectElementMessageDataType<T = {}> {
167
182
  source?: ElementPaymentMethod;
168
183
  target?: ElementPaymentMethod;
169
- success?: boolean;
170
184
  data?: T;
171
- event?: AddressEventCallbackName;
185
+ event?: ElementPaymentEvent;
172
186
  }
173
187
  export interface ValidateResult<T = {}> {
174
188
  success: boolean;
@@ -2,6 +2,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
4
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
+ /**
6
+ * element 消息事件名
7
+ */
5
8
  export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
6
9
  ElementPaymentEvent["RENDER_COMPONENT"] = "renderComponent";
7
10
  ElementPaymentEvent["CAPTURE_ASSET"] = "onCaptureAsset";
@@ -16,6 +19,7 @@ export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
16
19
  ElementPaymentEvent["SEND_MUITI_APP_EVENT_TO_SDK"] = "sendMuitiAppEventToSdk";
17
20
  ElementPaymentEvent["LOG"] = "log";
18
21
  ElementPaymentEvent["HANDLE_PAYMENT"] = "handlePayment";
22
+ ElementPaymentEvent["ON_EVENT_CALLBACK"] = "onEventCallback";
19
23
  return ElementPaymentEvent;
20
24
  }({});
21
25
  export var ElementPaymentMethod = /*#__PURE__*/function (ElementPaymentMethod) {
@@ -25,6 +29,13 @@ export var ElementPaymentMethod = /*#__PURE__*/function (ElementPaymentMethod) {
25
29
  ElementPaymentMethod["PAYMENT_ELEMENT"] = "PAYMENT_ELEMENT";
26
30
  return ElementPaymentMethod;
27
31
  }({});
32
+ export var ElementType = /*#__PURE__*/function (ElementType) {
33
+ ElementType["auth"] = "auth";
34
+ ElementType["address"] = "address";
35
+ ElementType["payment"] = "payment";
36
+ return ElementType;
37
+ }({});
38
+ export var MountElementType = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ElementType.auth, ElementPaymentMethod.AUTH_ELEMENT), ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT), ElementType.payment, ElementPaymentMethod.PAYMENT_ELEMENT), ElementPaymentMethod.AUTH_ELEMENT, ElementType.auth), ElementPaymentMethod.ADDRESS_ELEMENT, ElementType.address), ElementPaymentMethod.PAYMENT_ELEMENT, ElementType.payment);
28
39
  export var ThemeType = /*#__PURE__*/function (ThemeType) {
29
40
  ThemeType["NostalgicGray"] = "nostalgicGray";
30
41
  ThemeType["Default"] = "default";
@@ -34,27 +45,20 @@ export var ThemeType = /*#__PURE__*/function (ThemeType) {
34
45
  ThemeType["AgateGreen"] = "agateGreen";
35
46
  return ThemeType;
36
47
  }({});
37
- export var ElementType = /*#__PURE__*/function (ElementType) {
38
- ElementType["auth"] = "auth";
39
- ElementType["address"] = "address";
40
- ElementType["payment"] = "payment";
41
- return ElementType;
42
- }({});
43
48
  export var PaymentElementLayout = /*#__PURE__*/function (PaymentElementLayout) {
44
49
  PaymentElementLayout["Tabs"] = "tabs";
45
50
  PaymentElementLayout["Accordion"] = "Accordion";
46
51
  return PaymentElementLayout;
47
52
  }({});
48
- export var MountElementType = /*#__PURE__*/function (MountElementType) {
49
- MountElementType["auth"] = "AUTH_ELEMENT";
50
- MountElementType["address"] = "ADDRESS_ELEMENT";
51
- MountElementType["payment"] = "PAYMENT_ELEMENT";
52
- return MountElementType;
53
- }({});
54
53
  export var addressTheme = _defineProperty(_defineProperty({}, ThemeType.Default, 'LIGHT'), ThemeType.Night, 'NIGHT');
55
54
  export var EventCallbackCode = /*#__PURE__*/function (EventCallbackCode) {
56
55
  EventCallbackCode["SDK_CREATE_COMPONENT_ERROR"] = "SDK_CREATE_COMPONENT_ERROR";
57
56
  EventCallbackCode["SDK_CREATEPAYMENT_PARAMETER_ERROR"] = "SDK_CREATEPAYMENT_PARAMETER_ERROR";
57
+ EventCallbackCode["SDK_PAYMENT_ERROR"] = "SDK_PAYMENT_ERROR";
58
+ EventCallbackCode["SDK_PAYMENT_FAIL"] = "SDK_PAYMENT_FAIL";
59
+ EventCallbackCode["SDK_PAYMENT_CANCEL"] = "SDK_PAYMENT_CANCEL";
60
+ EventCallbackCode["SDK_PAYMENT_SUCCESSFUL"] = "SDK_PAYMENT_SUCCESSFUL";
61
+ EventCallbackCode["SDK_PAYMENT_PROCESSING"] = "SDK_PAYMENT_PROCESSING";
58
62
  return EventCallbackCode;
59
63
  }({});
60
64
  export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
@@ -73,6 +77,10 @@ export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbac
73
77
  return AddressEventCallbackName;
74
78
  }({});
75
79
 
80
+ /**
81
+ * connect element之间通信的类型格式
82
+ */
83
+
76
84
  // export type IMountResult = AddressMountResult | LinkAuthMountResult | PaymentMountResult;
77
85
  var AccountStatusEnum = /*#__PURE__*/function (AccountStatusEnum) {
78
86
  AccountStatusEnum["EFFECTIVE"] = "EFFECTIVE";
@@ -35,5 +35,7 @@ export declare class ContainerService implements Service {
35
35
  private changeCloseBtnVisibility;
36
36
  private handleMaskCloseBtnShow;
37
37
  private handleCloseButtonTheme;
38
+ private handlePopupWindow;
39
+ private handlePopWindow;
38
40
  getWebApp(): HTMLIFrameElement;
39
41
  }
@@ -195,19 +195,7 @@ export var ContainerService = /*#__PURE__*/function () {
195
195
  });
196
196
  });
197
197
  this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
198
- var _this$displayInfo2;
199
- if (data.paymentElementOldModel) return;
200
- insertStyleSheet();
201
- _this.popupManager.popup(_objectSpread({
202
- platform: (_this$displayInfo2 = _this.displayInfo) === null || _this$displayInfo2 === void 0 ? void 0 : _this$displayInfo2.platform
203
- }, data)).then(function () {
204
- _this.eventCenter.addIFrame(_this.popupManager.popupApp);
205
- }).catch(function (error) {
206
- _this.logService.logError({
207
- title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
208
- }, error);
209
- _this.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
210
- });
198
+ _this.handlePopupWindow(data);
211
199
  });
212
200
  this.eventCenter.listen(EVENT.popWindow.name, function () {
213
201
  _this.popupManager.pop();
@@ -266,9 +254,9 @@ export var ContainerService = /*#__PURE__*/function () {
266
254
  }, {
267
255
  key: "handleSizeChanged",
268
256
  value: function handleSizeChanged(data) {
269
- var _this$displayInfo3 = this.displayInfo,
270
- appendAliasContainerId = _this$displayInfo3.appendAliasContainerId,
271
- selector = _this$displayInfo3.selector;
257
+ var _this$displayInfo2 = this.displayInfo,
258
+ appendAliasContainerId = _this$displayInfo2.appendAliasContainerId,
259
+ selector = _this$displayInfo2.selector;
272
260
  var cashierId = appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat((selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1)) : COMPONENT_CONTAINER_ID;
273
261
  if (!this.webApp || !this.displayInfo) {
274
262
  return;
@@ -329,9 +317,9 @@ export var ContainerService = /*#__PURE__*/function () {
329
317
  key: "focusScrollFixed",
330
318
  value: function focusScrollFixed(focus) {
331
319
  // 获取iframe dom元素
332
- var _this$displayInfo4 = this.displayInfo,
333
- appendAliasContainerId = _this$displayInfo4.appendAliasContainerId,
334
- selector = _this$displayInfo4.selector;
320
+ var _this$displayInfo3 = this.displayInfo,
321
+ appendAliasContainerId = _this$displayInfo3.appendAliasContainerId,
322
+ selector = _this$displayInfo3.selector;
335
323
  var cashierId = appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat((selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1)) : COMPONENT_CONTAINER_ID;
336
324
  if (!this.webApp || !this.displayInfo) {
337
325
  return;
@@ -422,6 +410,41 @@ export var ContainerService = /*#__PURE__*/function () {
422
410
  maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.remove("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
423
411
  }
424
412
  }
413
+
414
+ // SDK主动打开弹框
415
+ }, {
416
+ key: "handlePopupWindow",
417
+ value: function handlePopupWindow(data) {
418
+ var _this$displayInfo4,
419
+ _this3 = this;
420
+ if (data.paymentElementOldModel) return;
421
+ insertStyleSheet();
422
+ this.popupManager.popup(_objectSpread({
423
+ platform: (_this$displayInfo4 = this.displayInfo) === null || _this$displayInfo4 === void 0 ? void 0 : _this$displayInfo4.platform,
424
+ showCloseOnLoading: data.showCloseOnLoading,
425
+ onCloseOnLoading: function onCloseOnLoading() {
426
+ return _this3.handlePopWindow(data);
427
+ }
428
+ }, data)).then(function () {
429
+ _this3.eventCenter.addIFrame(_this3.popupManager.popupApp);
430
+ }).catch(function (error) {
431
+ _this3.logService.logError({
432
+ title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
433
+ }, error);
434
+ _this3.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
435
+ });
436
+ }
437
+
438
+ // SDK主动关闭弹框
439
+ }, {
440
+ key: "handlePopWindow",
441
+ value: function handlePopWindow(data) {
442
+ this.popupManager.pop();
443
+ this.eventCenter.dispatchToApp({
444
+ event: EVENT.popWindow.name,
445
+ data: data
446
+ });
447
+ }
425
448
  }, {
426
449
  key: "getWebApp",
427
450
  value: function getWebApp() {
@@ -1,4 +1,12 @@
1
1
  import { PlatformEnum } from '../../../types';
2
+ export type IPopUpParams = {
3
+ url: string;
4
+ widthPadding: number;
5
+ heightPadding: number;
6
+ platform: PlatformEnum;
7
+ showCloseOnLoading: boolean;
8
+ onCloseOnLoading: () => void;
9
+ };
2
10
  /**
3
11
  * @author 谦彧 <zhangmian.zm@alipay.com>
4
12
  * @date 2024/9/22
@@ -7,11 +15,6 @@ export declare class PopupManager {
7
15
  private popupUrlQuery;
8
16
  popupApp: HTMLIFrameElement;
9
17
  setPopupUrlQuery(queryParams: string): void;
10
- popup(data: {
11
- url: string;
12
- widthPadding: number;
13
- heightPadding: number;
14
- platform: PlatformEnum;
15
- }): Promise<void>;
18
+ popup(data: IPopUpParams): Promise<void>;
16
19
  pop(): void;
17
20
  }
@@ -53,7 +53,9 @@ export var PopupManager = /*#__PURE__*/function () {
53
53
  widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
54
54
  device: data === null || data === void 0 ? void 0 : data.platform,
55
55
  url: pageUrl,
56
- loadingConfig: undefined
56
+ loadingConfig: undefined,
57
+ showCloseOnLoading: data.showCloseOnLoading,
58
+ onCloseOnLoading: data.onCloseOnLoading
57
59
  });
58
60
  case 11:
59
61
  this.popupApp = _context.sent;
@@ -103,23 +103,8 @@ export var handleGooglePay = function handleGooglePay(data) {
103
103
  }
104
104
  }
105
105
  });
106
- // 使用GooglePay官方API判断设备是否支持,目前WebView场景有bug,不支持的WebView仍然显示支持
107
- // UA判断方案和isReadyToPay方案PD决策使用【isReadyToPay方案】
108
- // PD已反馈给Google,Google已确认bug待修复
109
- paymentsClient.isReadyToPay(paymentRequest).then(function (response) {
110
- if (response.result) {
111
- // 设备支持 GooglePay,继续拉起
112
- reject({
113
- errorCode: 'GOOGLE_PAY_NOT_SUPPORTED'
114
- });
115
- } else {
116
- // 抛错给收银台,目前errorCode未消费
117
- reject({
118
- errorCode: 'GOOGLE_PAY_NOT_SUPPORTED'
119
- });
120
- }
121
- }).then(function (paymentData) {
122
- // 获取到googlePay token后返回消息给app
106
+ // 获取到googlePay token后返回消息给app
107
+ paymentsClient.loadPaymentData(paymentRequest).then(function (paymentData) {
123
108
  if (paymentData) {
124
109
  resolve(paymentData);
125
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1751356895-dev.1",
3
+ "version": "0.0.1751510477-dev.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",