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

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';
@@ -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.elementProcessors[renderOptions.type].getValue.bind(this.elementProcessors[renderOptions.type]),
168
+ on: function on(event, callback) {
169
+ _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,37 @@ 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.webAppReady.name, function (data) {
301
+ if (_this4.elementContainerService.getContainerService(data.source)) {
302
+ renderCallback({
303
+ success: true
304
+ });
305
+ _this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
306
+ }
307
+ _this4.changeLoading(false);
308
+ });
288
309
  }
289
310
  }, {
290
311
  key: "sendRequestAndWaitWebLaunch",
291
312
  value: function sendRequestAndWaitWebLaunch(renderOptions) {
292
- var _this4 = this;
313
+ var _this5 = this;
293
314
  var type = renderOptions.type,
294
315
  options = _objectWithoutProperties(renderOptions, _excluded);
295
316
  var webLaunchPromise = this.elementContainerService.getContainerService(type).createWebLaunchPromise();
296
317
  Promise.all([webLaunchPromise, this.elementProcessors[type].obtainData()]).then(function (_ref3) {
297
- var _this4$elementContain;
318
+ var _this5$elementContain;
298
319
  var _ref4 = _slicedToArray(_ref3, 2),
299
320
  _webLaunchRes = _ref4[0],
300
321
  _obtainDataRes = _ref4[1];
301
- (_this4$elementContain = _this4.elementContainerService.getContainerService(type)) === null || _this4$elementContain === void 0 || _this4$elementContain.switchContainerStatus(IContainerStatus.READY);
322
+ (_this5$elementContain = _this5.elementContainerService.getContainerService(type)) === null || _this5$elementContain === void 0 || _this5$elementContain.switchContainerStatus(IContainerStatus.READY);
302
323
  var allReady = true;
303
- _this4.elementContainerService.getContainerServices().forEach(function (item) {
324
+ _this5.elementContainerService.getContainerServices().forEach(function (item) {
304
325
  if (!allReady) return;
305
326
  allReady = item.getContainerStatus() === IContainerStatus.READY;
306
327
  });
307
328
  if (allReady) {
308
- _this4.elementContainerService.getContainerServices().forEach(function (value, key) {
309
- _this4.sendReady(key, options);
329
+ _this5.elementContainerService.getContainerServices().forEach(function (value, key) {
330
+ _this5.sendReady(key, options);
310
331
  });
311
332
  }
312
333
  });
@@ -318,8 +339,8 @@ var ElementController = /*#__PURE__*/function () {
318
339
  var paymentResult = (_this$elementProcesso = this.elementProcessors[ElementType.payment]) === null || _this$elementProcesso === void 0 ? void 0 : _this$elementProcesso.getObtainDataRes();
319
340
  var paymentContext = this.elementContainer.getPaymentContext();
320
341
  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,
342
+ originActionQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originActionQueryResult,
343
+ originOneAccountQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originOneAccountQueryResult,
323
344
  paymentSessionData: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionId,
324
345
  sessionResult: (paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionObj) || {}
325
346
  });
@@ -329,55 +350,53 @@ var ElementController = /*#__PURE__*/function () {
329
350
  key: "updatePayment",
330
351
  value: function () {
331
352
  var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(paymentSessionData) {
332
- var _this5 = this;
353
+ var _this6 = this;
333
354
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
334
355
  while (1) switch (_context3.prev = _context3.next) {
335
356
  case 0:
336
357
  return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
337
358
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
338
- var prePaymentSessionData, data;
359
+ var prePaymentSessionData, data, LOCAL_MOCK;
339
360
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
340
361
  while (1) switch (_context2.prev = _context2.next) {
341
362
  case 0:
342
363
  if (checkCanUpdate({
343
- status: _this5.elementContainer.getStatus(),
344
- paymentContainerService: _this5.elementContainerService.getContainerService(ElementType.payment),
364
+ status: _this6.elementContainer.getStatus(),
365
+ paymentContainerService: _this6.elementContainerService.getContainerService(ElementType.payment),
345
366
  newPaymentSessionData: paymentSessionData,
346
- oldPaymentSessionData: _this5.options.sessionData
367
+ oldPaymentSessionData: _this6.options.sessionData
347
368
  })) {
348
369
  _context2.next = 2;
349
370
  break;
350
371
  }
351
372
  return _context2.abrupt("return", resolve(false));
352
373
  case 2:
353
- prePaymentSessionData = _this5.elementContainer.getPaymentContext().paymentSession;
354
- _this5.elementContainer.updatePaymentSessionData(paymentSessionData);
374
+ prePaymentSessionData = _this6.elementContainer.getPaymentContext().paymentSession;
375
+ _this6.elementContainer.updatePaymentSessionData(paymentSessionData);
355
376
  // 1、数据获取
356
377
  _context2.next = 6;
357
- return _this5.elementProcessors[ElementType.payment].obtainData();
378
+ return _this6.elementProcessors[ElementType.payment].obtainData();
358
379
  case 6:
359
380
  data = _context2.sent;
360
- // 2、发送update消息
361
- Object.values(_this5.elementProcessors).forEach(function (processor) {
381
+ LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1; // 2、发送update消息
382
+ Object.values(_this6.elementProcessors).forEach(function (processor) {
362
383
  processor.update({
363
384
  data: {
364
- // originActionQuery: data.originActionQuery,
365
- // originOneAccountQuery: data.originOneAccountQuery,
366
- originActionQuery: sdkActionUpdate,
367
- originOneAccountQuery: oneAccountUpdate
385
+ originActionQueryResult: LOCAL_MOCK ? sdkActionUpdate : data.originActionQueryResult,
386
+ originOneAccountQueryResult: LOCAL_MOCK ? oneAccountUpdate : data.originOneAccountQueryResult
368
387
  },
369
388
  paymentSessionData: paymentSessionData
370
389
  });
371
390
  });
372
391
  // 3、返回更新结果
373
- _this5.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
392
+ _this6.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
374
393
  // 若更新不成功,还原core.paymentContext信息
375
394
  if (!data.success) {
376
- _this5.elementContainer.updatePaymentSessionData(prePaymentSessionData);
395
+ _this6.elementContainer.updatePaymentSessionData(prePaymentSessionData);
377
396
  }
378
397
  return resolve(data.success || false);
379
398
  });
380
- case 9:
399
+ case 10:
381
400
  case "end":
382
401
  return _context2.stop();
383
402
  }
@@ -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.4",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",