@alipay/ams-checkout 0.0.1744283958-dev.3 → 0.0.1744283958-dev.5

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.
@@ -213,6 +213,9 @@ export declare const EVENT: {
213
213
  updated: {
214
214
  name: string;
215
215
  };
216
+ webAppReady: {
217
+ name: string;
218
+ };
216
219
  };
217
220
  export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
218
221
  export declare const COMPONENT_SECTION_ID = "ams-component-section";
@@ -215,6 +215,9 @@ export var EVENT = {
215
215
  },
216
216
  updated: {
217
217
  name: 'updated'
218
+ },
219
+ webAppReady: {
220
+ name: 'webAppReady'
218
221
  }
219
222
  };
220
223
  export var COMPONENT_CONTAINER_ID = 'ams-component-container';
@@ -28,5 +28,6 @@ export declare class ContainerController {
28
28
  switchContainerStatus(status: IContainerStatus): void;
29
29
  getContainerStatus(): IContainerStatus;
30
30
  getEventService(): EventCenter;
31
+ destroy(): void;
31
32
  getContainerService(): ContainerService;
32
33
  }
@@ -103,6 +103,12 @@ export var ContainerController = /*#__PURE__*/function () {
103
103
  value: function getEventService() {
104
104
  return this.eventService;
105
105
  }
106
+ }, {
107
+ key: "destroy",
108
+ value: function destroy() {
109
+ this.eventService.destroy();
110
+ this.containerElement.remove();
111
+ }
106
112
  }, {
107
113
  key: "getContainerService",
108
114
  value: function getContainerService() {
@@ -33,6 +33,9 @@ export var ElementContainerService = /*#__PURE__*/function () {
33
33
  }, {
34
34
  key: "destroy",
35
35
  value: function destroy() {
36
+ this.containerServices.forEach(function (value) {
37
+ value.destroy();
38
+ });
36
39
  this.containerServices = new Map();
37
40
  }
38
41
  }, {
@@ -19,6 +19,7 @@ declare class ElementController {
19
19
  private sendRequestAndWaitWebLaunch;
20
20
  private sendReady;
21
21
  updatePayment(paymentSessionData: any): Promise<unknown>;
22
+ private destroyHandle;
22
23
  destroy(): void;
23
24
  }
24
25
  export default ElementController;
@@ -103,87 +103,96 @@ var ElementController = /*#__PURE__*/function () {
103
103
  key: "mount",
104
104
  value: function mount(renderOptions, sdkSelector, cashier) {
105
105
  var _this = this;
106
- var _checkCanMount = checkCanMount({
107
- sdkSelector: sdkSelector,
108
- status: this.elementContainer.getStatus(),
109
- containerService: this.elementContainerService.getContainerService(renderOptions.type)
110
- }),
111
- success = _checkCanMount.success,
112
- errorMsg = _checkCanMount.errorMsg;
113
- if (!success) {
114
- this.onEventCallback({
115
- code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
116
- message: errorMsg
117
- });
118
- return;
119
- }
120
- clearTimeout(this.initTimeout);
121
- this.initTimeout = null;
122
- this.initTimeout = setTimeout(function () {
106
+ return new Promise(function (resolve) {
107
+ var _checkCanMount = checkCanMount({
108
+ sdkSelector: sdkSelector,
109
+ status: _this.elementContainer.getStatus(),
110
+ containerService: _this.elementContainerService.getContainerService(renderOptions.type)
111
+ }),
112
+ success = _checkCanMount.success,
113
+ errorMsg = _checkCanMount.errorMsg;
114
+ if (!success) {
115
+ _this.onEventCallback({
116
+ code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
117
+ message: errorMsg
118
+ });
119
+ resolve({
120
+ success: false
121
+ });
122
+ return;
123
+ }
123
124
  clearTimeout(_this.initTimeout);
124
125
  _this.initTimeout = null;
125
- _this.changeLoading(false);
126
- _this.elementContainer.setStatus(IContainerStatus.READY);
127
- _this.elementContainerService.getContainerServices().forEach(function (value) {
128
- value.getContainerElement().remove();
126
+ _this.initTimeout = setTimeout(function () {
127
+ clearTimeout(_this.initTimeout);
128
+ _this.initTimeout = null;
129
+ _this.changeLoading(false);
130
+ _this.elementContainer.setStatus(IContainerStatus.READY);
131
+ _this.elementContainerService.getContainerServices().forEach(function (value) {
132
+ value.getContainerElement().remove();
133
+ });
134
+ _this.elementContainerService.destroy();
135
+ }, TIMEOUT_DURATION);
136
+ _this.changeLoading(true);
137
+ var startBizFlowData = {
138
+ paymentSession: _this.options.sessionData,
139
+ displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
140
+ appendAliasContainerId: true
141
+ })
142
+ };
143
+ if (cashier && renderOptions.sessionData) {
144
+ startBizFlowData.paymentSession = renderOptions.sessionData;
145
+ }
146
+ _this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
147
+ _this.onEventCallback({
148
+ code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
149
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
150
+ });
151
+ _this.changeLoading(false);
152
+ return;
129
153
  });
130
- _this.elementContainerService.destroy();
131
- }, TIMEOUT_DURATION);
132
- this.changeLoading(true);
133
- var startBizFlowData = {
134
- paymentSession: this.options.sessionData,
135
- displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
136
- appendAliasContainerId: true
137
- })
138
- };
139
- if (cashier && renderOptions.sessionData) {
140
- startBizFlowData.paymentSession = renderOptions.sessionData;
141
- }
142
- this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
143
- _this.onEventCallback({
144
- code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
145
- message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
154
+ _this.initElementProcessors(renderOptions.type);
155
+ _this.elementContainerService.mount({
156
+ type: renderOptions.type,
157
+ selector: sdkSelector,
158
+ processor: _this.elementProcessors[renderOptions.type],
159
+ options: renderOptions
146
160
  });
147
- _this.changeLoading(false);
148
- return;
149
- });
150
- this.initElementProcessors(renderOptions.type);
151
- this.elementContainerService.mount({
152
- type: renderOptions.type,
153
- selector: sdkSelector,
154
- processor: this.elementProcessors[renderOptions.type],
155
- options: renderOptions
156
- });
157
- this.elementProcessors[renderOptions.type].registerEventCenter(this.elementContainerService.getEventService(renderOptions.type));
158
- this.elementProcessors[renderOptions.type].beforeMount();
159
- this.sendRequestAndWaitWebLaunch(renderOptions);
160
- this.addEventListener();
161
- this.serviceMap.EventCenter.addIFrame(this.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
162
- return {
163
- getValue: this.elementProcessors[renderOptions.type].getValue.bind(this.elementProcessors[renderOptions.type]),
164
- on: function on(event, callback) {
165
- _this.elementProcessors[renderOptions.type].registerEventListener(event, callback);
161
+ _this.elementProcessors[renderOptions.type].registerEventCenter(_this.elementContainerService.getEventService(renderOptions.type));
162
+ _this.elementProcessors[renderOptions.type].beforeMount();
163
+ _this.sendRequestAndWaitWebLaunch(renderOptions);
164
+ function readyCallback(payload) {
165
+ var _this2 = this;
166
+ var resultData = _objectSpread({
167
+ getValue: this === null || this === void 0 ? void 0 : this.elementProcessors[renderOptions.type].getValue.bind(this === null || this === void 0 ? void 0 : this.elementProcessors[renderOptions.type]),
168
+ on: function on(event, callback) {
169
+ _this2 === null || _this2 === void 0 || _this2.elementProcessors[renderOptions.type].registerEventListener(event, callback);
170
+ }
171
+ }, payload);
172
+ resolve(resultData);
166
173
  }
167
- };
174
+ _this.addEventListener(readyCallback);
175
+ _this.serviceMap.EventCenter.addIFrame(_this.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
176
+ });
168
177
  }
169
178
  }, {
170
179
  key: "submitPayment",
171
180
  value: function submitPayment() {
172
- var _this2 = this;
181
+ var _this3 = this;
173
182
  this.changeLoading(true);
174
183
  new Promise( /*#__PURE__*/function () {
175
184
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
176
- var params, _this2$elementProcess, _result$data, _result$data2, result, _this2$elementProcess2, _result$data3, _result$data4, _result, _this2$elementProcess3;
185
+ var params, _this3$elementProcess, _result$data, _result$data2, result, _this3$elementProcess2, _result$data3, _result$data4, _result, _this3$elementProcess3;
177
186
  return _regeneratorRuntime().wrap(function _callee$(_context) {
178
187
  while (1) switch (_context.prev = _context.next) {
179
188
  case 0:
180
189
  params = {};
181
- if (!_this2.elementProcessors[ElementType.auth]) {
190
+ if (!_this3.elementProcessors[ElementType.auth]) {
182
191
  _context.next = 8;
183
192
  break;
184
193
  }
185
194
  _context.next = 4;
186
- return _this2.onValidateFunc((_this2$elementProcess = _this2.elementProcessors[ElementType.auth]) === null || _this2$elementProcess === void 0 ? void 0 : _this2$elementProcess.eventCenter, ElementPaymentMethod.AUTH_ELEMENT);
195
+ return _this3.onValidateFunc((_this3$elementProcess = _this3.elementProcessors[ElementType.auth]) === null || _this3$elementProcess === void 0 ? void 0 : _this3$elementProcess.eventCenter, ElementPaymentMethod.AUTH_ELEMENT);
187
196
  case 4:
188
197
  result = _context.sent;
189
198
  params.accountInfo = (_result$data = result.data) === null || _result$data === void 0 || (_result$data = _result$data.data) === null || _result$data === void 0 ? void 0 : _result$data.accountInfo;
@@ -193,12 +202,12 @@ var ElementController = /*#__PURE__*/function () {
193
202
  }
194
203
  return _context.abrupt("return", resolve(undefined));
195
204
  case 8:
196
- if (!_this2.elementProcessors[ElementType.address]) {
205
+ if (!_this3.elementProcessors[ElementType.address]) {
197
206
  _context.next = 15;
198
207
  break;
199
208
  }
200
209
  _context.next = 11;
201
- return _this2.onValidateFunc((_this2$elementProcess2 = _this2.elementProcessors[ElementType.address]) === null || _this2$elementProcess2 === void 0 ? void 0 : _this2$elementProcess2.eventCenter, ElementPaymentMethod.ADDRESS_ELEMENT);
210
+ return _this3.onValidateFunc((_this3$elementProcess2 = _this3.elementProcessors[ElementType.address]) === null || _this3$elementProcess2 === void 0 ? void 0 : _this3$elementProcess2.eventCenter, ElementPaymentMethod.ADDRESS_ELEMENT);
202
211
  case 11:
203
212
  _result = _context.sent;
204
213
  params.shipping = (_result$data3 = _result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.data;
@@ -208,13 +217,13 @@ var ElementController = /*#__PURE__*/function () {
208
217
  }
209
218
  return _context.abrupt("return", resolve(undefined));
210
219
  case 15:
211
- if (!_this2.elementProcessors[ElementType.payment]) {
220
+ if (!_this3.elementProcessors[ElementType.payment]) {
212
221
  _context.next = 25;
213
222
  break;
214
223
  }
215
224
  _context.prev = 16;
216
225
  _context.next = 19;
217
- return _this2.onValidateFunc((_this2$elementProcess3 = _this2.elementProcessors[ElementType.payment]) === null || _this2$elementProcess3 === void 0 ? void 0 : _this2$elementProcess3.eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
226
+ return _this3.onValidateFunc((_this3$elementProcess3 = _this3.elementProcessors[ElementType.payment]) === null || _this3$elementProcess3 === void 0 ? void 0 : _this3$elementProcess3.eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
218
227
  case 19:
219
228
  return _context.abrupt("return", resolve(undefined));
220
229
  case 22:
@@ -233,9 +242,9 @@ var ElementController = /*#__PURE__*/function () {
233
242
  return _ref2.apply(this, arguments);
234
243
  };
235
244
  }()).then(function () {
236
- _this2.changeLoading(false);
245
+ _this3.changeLoading(false);
237
246
  }, function () {
238
- _this2.changeLoading(false);
247
+ _this3.changeLoading(false);
239
248
  });
240
249
  }
241
250
  }, {
@@ -259,21 +268,24 @@ var ElementController = /*#__PURE__*/function () {
259
268
  }
260
269
  }, {
261
270
  key: "addEventListener",
262
- value: function addEventListener() {
263
- var _this3 = this;
271
+ value: function addEventListener(renderCallback) {
272
+ var _this4 = this;
264
273
  this.serviceMap.EventCenter.listen(ElementPaymentEvent.CALLBACK, function (data) {
265
- if (_this3.elementProcessors[data.source] && _this3.elementProcessors[data.source].eventListener[data.event]) {
266
- var _this3$elementProcess, _this3$elementProcess2;
267
- (_this3$elementProcess = (_this3$elementProcess2 = _this3.elementProcessors[data.source].eventListener)[data.event]) === null || _this3$elementProcess === void 0 || _this3$elementProcess.call(_this3$elementProcess2, data.data);
274
+ if (_this4.elementProcessors[data.source] && _this4.elementProcessors[data.source].eventListener[data.event]) {
275
+ var _this4$elementProcess, _this4$elementProcess2;
276
+ (_this4$elementProcess = (_this4$elementProcess2 = _this4.elementProcessors[data.source].eventListener)[data.event]) === null || _this4$elementProcess === void 0 || _this4$elementProcess.call(_this4$elementProcess2, data.data);
268
277
  }
269
278
  });
270
279
  this.serviceMap.EventCenter.listen(EVENT.sizeChanged.name, function (data) {
271
- clearTimeout(_this3.initTimeout);
272
- _this3.initTimeout = null;
273
- if (_this3.elementContainerService.getContainerService(data.source)) {
274
- _this3.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
280
+ clearTimeout(_this4.initTimeout);
281
+ _this4.initTimeout = null;
282
+ if (_this4.elementContainerService.getContainerService(data.source)) {
283
+ renderCallback({
284
+ success: true
285
+ });
286
+ _this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
275
287
  }
276
- _this3.changeLoading(false);
288
+ _this4.changeLoading(false);
277
289
  // 遍历containerService中的所有container查看是否所有状态都是IN_BIZ_FLOW
278
290
  // const allContainersInBizFlow = Object.values(this.elementContainerService.getContainerServices()).every(
279
291
  // (containerService) => containerService.getContainerStatus() === IContainerStatus.IN_BIZ_FLOW,
@@ -285,28 +297,41 @@ var ElementController = /*#__PURE__*/function () {
285
297
  this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
286
298
  handleRedirect(data);
287
299
  });
300
+ this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
301
+ _this4.elementContainer.setStatus(IContainerStatus.READY);
302
+ _this4.destroyHandle();
303
+ });
304
+ this.serviceMap.EventCenter.listen(EVENT.webAppReady.name, function (data) {
305
+ if (_this4.elementContainerService.getContainerService(data.source)) {
306
+ renderCallback({
307
+ success: true
308
+ });
309
+ _this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
310
+ }
311
+ _this4.changeLoading(false);
312
+ });
288
313
  }
289
314
  }, {
290
315
  key: "sendRequestAndWaitWebLaunch",
291
316
  value: function sendRequestAndWaitWebLaunch(renderOptions) {
292
- var _this4 = this;
317
+ var _this5 = this;
293
318
  var type = renderOptions.type,
294
319
  options = _objectWithoutProperties(renderOptions, _excluded);
295
320
  var webLaunchPromise = this.elementContainerService.getContainerService(type).createWebLaunchPromise();
296
321
  Promise.all([webLaunchPromise, this.elementProcessors[type].obtainData()]).then(function (_ref3) {
297
- var _this4$elementContain;
322
+ var _this5$elementContain;
298
323
  var _ref4 = _slicedToArray(_ref3, 2),
299
324
  _webLaunchRes = _ref4[0],
300
325
  _obtainDataRes = _ref4[1];
301
- (_this4$elementContain = _this4.elementContainerService.getContainerService(type)) === null || _this4$elementContain === void 0 || _this4$elementContain.switchContainerStatus(IContainerStatus.READY);
326
+ (_this5$elementContain = _this5.elementContainerService.getContainerService(type)) === null || _this5$elementContain === void 0 || _this5$elementContain.switchContainerStatus(IContainerStatus.READY);
302
327
  var allReady = true;
303
- _this4.elementContainerService.getContainerServices().forEach(function (item) {
328
+ _this5.elementContainerService.getContainerServices().forEach(function (item) {
304
329
  if (!allReady) return;
305
330
  allReady = item.getContainerStatus() === IContainerStatus.READY;
306
331
  });
307
332
  if (allReady) {
308
- _this4.elementContainerService.getContainerServices().forEach(function (value, key) {
309
- _this4.sendReady(key, options);
333
+ _this5.elementContainerService.getContainerServices().forEach(function (value, key) {
334
+ _this5.sendReady(key, options);
310
335
  });
311
336
  }
312
337
  });
@@ -318,8 +343,8 @@ var ElementController = /*#__PURE__*/function () {
318
343
  var paymentResult = (_this$elementProcesso = this.elementProcessors[ElementType.payment]) === null || _this$elementProcesso === void 0 ? void 0 : _this$elementProcesso.getObtainDataRes();
319
344
  var paymentContext = this.elementContainer.getPaymentContext();
320
345
  var params = _objectSpread(_objectSpread({}, options), {}, {
321
- originActionQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originActionQuery,
322
- originOneAccountQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originOneAccountQuery,
346
+ originActionQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originActionQueryResult,
347
+ originOneAccountQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originOneAccountQueryResult,
323
348
  paymentSessionData: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionId,
324
349
  sessionResult: (paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionObj) || {}
325
350
  });
@@ -329,55 +354,53 @@ var ElementController = /*#__PURE__*/function () {
329
354
  key: "updatePayment",
330
355
  value: function () {
331
356
  var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(paymentSessionData) {
332
- var _this5 = this;
357
+ var _this6 = this;
333
358
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
334
359
  while (1) switch (_context3.prev = _context3.next) {
335
360
  case 0:
336
361
  return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
337
362
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
338
- var prePaymentSessionData, data;
363
+ var prePaymentSessionData, data, LOCAL_MOCK;
339
364
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
340
365
  while (1) switch (_context2.prev = _context2.next) {
341
366
  case 0:
342
367
  if (checkCanUpdate({
343
- status: _this5.elementContainer.getStatus(),
344
- paymentContainerService: _this5.elementContainerService.getContainerService(ElementType.payment),
368
+ status: _this6.elementContainer.getStatus(),
369
+ paymentContainerService: _this6.elementContainerService.getContainerService(ElementType.payment),
345
370
  newPaymentSessionData: paymentSessionData,
346
- oldPaymentSessionData: _this5.options.sessionData
371
+ oldPaymentSessionData: _this6.options.sessionData
347
372
  })) {
348
373
  _context2.next = 2;
349
374
  break;
350
375
  }
351
376
  return _context2.abrupt("return", resolve(false));
352
377
  case 2:
353
- prePaymentSessionData = _this5.elementContainer.getPaymentContext().paymentSession;
354
- _this5.elementContainer.updatePaymentSessionData(paymentSessionData);
378
+ prePaymentSessionData = _this6.elementContainer.getPaymentContext().paymentSession;
379
+ _this6.elementContainer.updatePaymentSessionData(paymentSessionData);
355
380
  // 1、数据获取
356
381
  _context2.next = 6;
357
- return _this5.elementProcessors[ElementType.payment].obtainData();
382
+ return _this6.elementProcessors[ElementType.payment].obtainData();
358
383
  case 6:
359
384
  data = _context2.sent;
360
- // 2、发送update消息
361
- Object.values(_this5.elementProcessors).forEach(function (processor) {
385
+ LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1; // 2、发送update消息
386
+ Object.values(_this6.elementProcessors).forEach(function (processor) {
362
387
  processor.update({
363
388
  data: {
364
- // originActionQuery: data.originActionQuery,
365
- // originOneAccountQuery: data.originOneAccountQuery,
366
- originActionQuery: sdkActionUpdate,
367
- originOneAccountQuery: oneAccountUpdate
389
+ originActionQueryResult: LOCAL_MOCK ? sdkActionUpdate : data.originActionQueryResult,
390
+ originOneAccountQueryResult: LOCAL_MOCK ? oneAccountUpdate : data.originOneAccountQueryResult
368
391
  },
369
392
  paymentSessionData: paymentSessionData
370
393
  });
371
394
  });
372
395
  // 3、返回更新结果
373
- _this5.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
396
+ _this6.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
374
397
  // 若更新不成功,还原core.paymentContext信息
375
398
  if (!data.success) {
376
- _this5.elementContainer.updatePaymentSessionData(prePaymentSessionData);
399
+ _this6.elementContainer.updatePaymentSessionData(prePaymentSessionData);
377
400
  }
378
401
  return resolve(data.success || false);
379
402
  });
380
- case 9:
403
+ case 10:
381
404
  case "end":
382
405
  return _context2.stop();
383
406
  }
@@ -399,17 +422,21 @@ var ElementController = /*#__PURE__*/function () {
399
422
  return updatePayment;
400
423
  }()
401
424
  }, {
402
- key: "destroy",
403
- value: function destroy() {
425
+ key: "destroyHandle",
426
+ value: function destroyHandle() {
404
427
  this.elementContainer.destroy();
405
- this.elementContainer.setStatus(IContainerStatus.DESTROYED);
428
+ this.elementContainerService.destroy();
429
+ this.serviceMap.EventCenter.cleanIFrames();
406
430
  // popup未注册会报错,但element不需要感知popup是否被注册
407
431
  try {
408
432
  destroyModal(); // 关闭popup弹窗
409
433
  } catch (error) {}
410
- this.elementContainerService.getContainerServices().forEach(function (value) {
411
- value.getContainerElement().remove();
412
- });
434
+ }
435
+ }, {
436
+ key: "destroy",
437
+ value: function destroy() {
438
+ this.destroyHandle();
439
+ this.elementContainer.setStatus(IContainerStatus.DESTROYED);
413
440
  }
414
441
  }]);
415
442
  return ElementController;
@@ -113,8 +113,8 @@ var AuthProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
113
113
  paymentSessionData: paymentSessionData,
114
114
  sessionResult: parseData,
115
115
  sessionData: sessionData,
116
- originActionQueryResult: data.originActionQuery,
117
- originOneAccountQueryResult: data.originOneAccountQuery
116
+ originActionQueryResult: data.originActionQueryResult,
117
+ originOneAccountQueryResult: data.originOneAccountQueryResult
118
118
  }
119
119
  }
120
120
  });
@@ -57,7 +57,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
57
57
  data: {
58
58
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
59
59
  paymentSessionData: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionId,
60
- queryResult: extraParam === null || extraParam === void 0 ? void 0 : extraParam.originActionQuery,
60
+ queryResult: extraParam === null || extraParam === void 0 ? void 0 : extraParam.originActionQueryResult,
61
61
  envInfo: {
62
62
  screenHeight: screen.height,
63
63
  screenWidth: screen.width
@@ -230,7 +230,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
230
230
  value: function () {
231
231
  var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
232
232
  var _paymentSessionObj$co;
233
- var requestService, _this$elementContaine3, paymentSession, paymentSessionObj, _this$options2, environment, locale, _ref4, paymentSessionConfig, hostSign, isConnect, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQuery, originOneAccountQuery;
233
+ var requestService, _this$elementContaine3, paymentSession, paymentSessionObj, _this$options2, environment, locale, _ref4, paymentSessionConfig, hostSign, isConnect, LOCAL_MOCK, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
234
234
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
235
235
  while (1) switch (_context2.prev = _context2.next) {
236
236
  case 0:
@@ -240,12 +240,16 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
240
240
  _ref4 = paymentSessionObj || {}, paymentSessionConfig = _ref4.paymentSessionConfig;
241
241
  hostSign = paymentSession.split('&&')[1] || '';
242
242
  isConnect = paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect;
243
+ LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1;
243
244
  generateActionQueryPromise = function generateActionQueryPromise() {
244
245
  return new Promise(function (resolve, reject) {
245
- setTimeout(function () {
246
- resolve(sdkAction);
247
- }, 100);
248
- return;
246
+ if (LOCAL_MOCK) {
247
+ setTimeout(function () {
248
+ resolve(oneAccount);
249
+ resolve(sdkAction);
250
+ }, 100);
251
+ return;
252
+ }
249
253
  requestService.request({
250
254
  paymentSessionConfig: paymentSessionConfig,
251
255
  paymentSessionData: paymentSession
@@ -267,10 +271,12 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
267
271
  };
268
272
  generateOneAccountQueryPromise = function generateOneAccountQueryPromise() {
269
273
  return new Promise(function (resolve, reject) {
270
- setTimeout(function () {
271
- resolve(oneAccount);
272
- }, 100);
273
- return;
274
+ if (LOCAL_MOCK) {
275
+ setTimeout(function () {
276
+ resolve(oneAccount);
277
+ }, 100);
278
+ return;
279
+ }
274
280
  requestService.request({
275
281
  paymentSessionConfig: paymentSessionConfig,
276
282
  paymentSessionData: paymentSession,
@@ -292,22 +298,22 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
292
298
  });
293
299
  });
294
300
  };
295
- _context2.next = 10;
301
+ _context2.next = 11;
296
302
  return Promise.all(isConnect ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
297
- case 10:
303
+ case 11:
298
304
  _yield$Promise$all = _context2.sent;
299
305
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
300
- originActionQuery = _yield$Promise$all2[0];
301
- originOneAccountQuery = _yield$Promise$all2[1];
306
+ originActionQueryResult = _yield$Promise$all2[0];
307
+ originOneAccountQueryResult = _yield$Promise$all2[1];
302
308
  this.obtainDataRes = {
303
- originActionQuery: originActionQuery,
304
- originOneAccountQuery: originOneAccountQuery
309
+ originActionQueryResult: originActionQueryResult,
310
+ originOneAccountQueryResult: originOneAccountQueryResult
305
311
  };
306
312
  return _context2.abrupt("return", {
307
- originActionQuery: originActionQuery,
308
- originOneAccountQuery: originOneAccountQuery
313
+ originActionQueryResult: originActionQueryResult,
314
+ originOneAccountQueryResult: originOneAccountQueryResult
309
315
  });
310
- case 16:
316
+ case 17:
311
317
  case "end":
312
318
  return _context2.stop();
313
319
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1744283958-dev.3",
3
+ "version": "0.0.1744283958-dev.5",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",