@alipay/ams-checkout 1.6.0 → 1.6.1

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.
@@ -17,11 +17,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
17
17
  /* eslint-disable @typescript-eslint/no-explicit-any */
18
18
  import { marmotMap } from "../../config/index";
19
19
  import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
20
- import { queryPaymentInfo } from "../../service";
21
- import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, SecuritySceneEnum, targetEnum } from "../../types";
20
+ import { queryPaymentInfo, submitPayInfo } from "../../service";
21
+ import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
22
22
  import { getType, isJsonString, isPC } from "../../util";
23
23
  import { isLocalMock } from "../../util/mock";
24
- import { getApdidToken, getAppname, getSecurityHost, initSecuritySDK } from "../../util/security";
25
24
  import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
26
25
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
27
26
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
@@ -44,11 +43,13 @@ var ComponentApp = /*#__PURE__*/function () {
44
43
  _defineProperty(this, "_appVersion", void 0);
45
44
  _defineProperty(this, "_isRetention", void 0);
46
45
  _defineProperty(this, "_actionQueryPromise", null);
46
+ _defineProperty(this, "_actionSubmitPromise", null);
47
47
  _defineProperty(this, "_renderParams", null);
48
48
  _defineProperty(this, "_componentSign", componentSignEnum.NONE);
49
49
  _defineProperty(this, "_appLocationSearch", void 0);
50
50
  _defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
51
- this._appVersion = '1.6.0';
51
+ _defineProperty(this, "_multipleCallbackEvents", void 0);
52
+ this._appVersion = '1.6.1';
52
53
  this._isInitComponent = false;
53
54
  this._selector = "#".concat(COMPONENT_SECTION_ID);
54
55
  this.createIframeNode = function () {
@@ -85,7 +86,6 @@ var ComponentApp = /*#__PURE__*/function () {
85
86
  key: "initLoggerMeta",
86
87
  value: function initLoggerMeta() {
87
88
  var _this$_renderParams, _paymentSessionMetaDa;
88
- console.log('this._renderParams', JSON.stringify(this._renderParams), null, 3);
89
89
  var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
90
90
  var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
91
91
  this.AMSSDK.logger.setMedta({
@@ -114,39 +114,39 @@ var ComponentApp = /*#__PURE__*/function () {
114
114
  this.createIframeNode = renderFunc;
115
115
  }
116
116
  }, {
117
- key: "initAPSecurity",
118
- value: function initAPSecurity() {
117
+ key: "initSecurity",
118
+ value: function initSecurity() {
119
119
  var _this$_renderParams2,
120
120
  _this = this;
121
- if (componentSignEnum.CASHIER_PAYMENT_CARD !== this._componentSign) {
122
- return;
123
- }
124
- var securityConfig = (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionMetaData) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.securityConfig;
125
- if (!securityConfig) {
126
- return;
127
- }
128
- var appName = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName;
129
- var h5gateway = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway;
130
-
131
- // if merchant have init securitySDK and same as service paymentSessionMetaData, no need init again
132
- if (this.AMSSDK.securityConfig) {
133
- if (appName === getAppname(this.AMSSDK.securityConfig.scene) && h5gateway === getSecurityHost(this.AMSSDK.securityConfig.region)) {
134
- return;
135
- }
121
+ var product = (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionMetaData) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionConfig) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.productScene;
122
+ if (componentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
123
+ this.AMSSDK.logger.logInfo({
124
+ title: 'sdk_event_security_unneeded_scenarios'
125
+ }, {
126
+ product: product
127
+ });
136
128
  }
137
- this.AMSSDK.logger.logInfo({
138
- title: 'sdk_event_securitySdkInit'
129
+ var securitySDK = this.AMSSDK._getSecuritySDKByProductScene({
130
+ product: product
139
131
  });
140
- initSecuritySDK(appName, h5gateway, function () {
141
- _this.AMSSDK.logger.logInfo({
142
- title: 'sdk_event_securitySdkInitSuccess'
132
+ if (!securitySDK) {
133
+ this.AMSSDK.logger.logInfo({
134
+ title: 'sdk_event_securitySdkInit'
143
135
  });
144
- }, function () {
145
- // TODO Distinguishing Call Scenarios of Security SDK Failures
146
- _this.AMSSDK.logger.logError({
147
- title: 'sdk_error_securitySdkInitFailed'
136
+ this.AMSSDK._newSecuritySDKByScene({
137
+ product: product
138
+ }, function () {
139
+ _this.AMSSDK.logger.logInfo({
140
+ title: 'sdk_event_securitySdkInitSuccess'
141
+ });
142
+ }, function () {
143
+ _this.AMSSDK.logger.logError({
144
+ title: 'sdk_error_securitySdkInitFailed'
145
+ }, {
146
+ sign: 'SDK internal initialization'
147
+ });
148
148
  });
149
- });
149
+ }
150
150
  }
151
151
  }, {
152
152
  key: "logDeviceId",
@@ -172,23 +172,47 @@ var ComponentApp = /*#__PURE__*/function () {
172
172
  key: "getDeviceIdAndLog",
173
173
  value: function getDeviceIdAndLog() {
174
174
  var _this2 = this;
175
+ var deviceIdParameter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
176
+ var isPolling = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
175
177
  return new Promise(function (resolve) {
176
178
  // To avoid rendering being blocked, move the logic to the next event loop for processing
177
179
  setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
178
180
  var _this2$_renderParams;
179
- var securityConfig, getDeviceIdStartTime, deviceId;
181
+ var productScene, getDeviceIdStartTime, securitySDK, deviceId;
180
182
  return _regeneratorRuntime().wrap(function _callee$(_context) {
181
183
  while (1) switch (_context.prev = _context.next) {
182
184
  case 0:
183
- securityConfig = (_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionMetaData) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.securityConfig;
185
+ productScene = (_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionMetaData) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionConfig) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.productScene;
184
186
  getDeviceIdStartTime = Date.now();
185
- _context.next = 4;
186
- return getApdidToken(getAppname(SecuritySceneEnum.CARD), securityConfig);
187
- case 4:
188
- deviceId = _context.sent;
187
+ securitySDK = _this2.AMSSDK._getSecuritySDKByProductScene({
188
+ product: (deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.productScene) || productScene
189
+ });
190
+ deviceId = '';
191
+ if (!securitySDK) {
192
+ _context.next = 16;
193
+ break;
194
+ }
195
+ if (!(isPolling && parseInt(deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.tokenCollectTime) > 0)) {
196
+ _context.next = 11;
197
+ break;
198
+ }
199
+ _context.next = 8;
200
+ return securitySDK.pollingGetApdidToken(deviceIdParameter);
201
+ case 8:
202
+ _context.t0 = _context.sent;
203
+ _context.next = 14;
204
+ break;
205
+ case 11:
206
+ _context.next = 13;
207
+ return securitySDK.getApdidToken();
208
+ case 13:
209
+ _context.t0 = _context.sent;
210
+ case 14:
211
+ deviceId = _context.t0;
189
212
  _this2.logDeviceId(deviceId, getDeviceIdStartTime);
213
+ case 16:
190
214
  resolve(deviceId);
191
- case 7:
215
+ case 17:
192
216
  case "end":
193
217
  return _context.stop();
194
218
  }
@@ -214,7 +238,7 @@ var ComponentApp = /*#__PURE__*/function () {
214
238
  if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
215
239
  this._renderDisplayType = renderParams.renderDisplayType;
216
240
  var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
217
- this.initAPSecurity();
241
+ this.initSecurity();
218
242
  this.initLoggerMeta();
219
243
  this._performanceData.push({
220
244
  key: 'sdk_create_component',
@@ -235,12 +259,12 @@ var ComponentApp = /*#__PURE__*/function () {
235
259
  this.renderPopupLoading(renderParams);
236
260
  }
237
261
  this.createApp(renderParams);
238
- return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
239
- _this3.AMSSDK.logger.logInfo({
240
- title: 'sdk_event_successfully_created_app_process'
241
- }).send();
262
+ return Promise.all([this.createActionQueryPromise(), this.createSubmitPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
242
263
  return Promise.resolve();
243
264
  }).catch(function (error) {
265
+ _this3.AMSSDK.logger.logError({
266
+ title: 'sdk_error_created_app_process_failed'
267
+ }).send();
244
268
  _this3._isInitComponent = false;
245
269
  _this3.cleanContainer();
246
270
  return Promise.reject(error);
@@ -302,7 +326,7 @@ var ComponentApp = /*#__PURE__*/function () {
302
326
  this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
303
327
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
304
328
  var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
305
- var envInfo, params, securityConfig, _this5$_renderParams5, extendInfo, info, _this5$_renderParams6, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams7, _action$web, _action$wap, action, signType;
329
+ var envInfo, params, _this5$_renderParams5, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams6, _action$web, _action$wap, action, signType;
306
330
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
307
331
  while (1) switch (_context2.prev = _context2.next) {
308
332
  case 0:
@@ -315,74 +339,80 @@ var ComponentApp = /*#__PURE__*/function () {
315
339
  notRedirectAfterComplete: ((_this5$_renderParams3 = _this5._renderParams) === null || _this5$_renderParams3 === void 0 ? void 0 : _this5$_renderParams3.notRedirectAfterComplete) === true
316
340
  };
317
341
  /**
318
- * @description card
342
+ * @description Simulated or unnecessary scenarios
319
343
  */
320
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign) {
321
- params.paymentMethodType = 'CARD';
322
- }
323
- securityConfig = (_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 || (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.securityConfig;
324
- if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign && securityConfig)) {
325
- _context2.next = 11;
344
+ if (!(isLocalMock() || (_this5$_renderParams4 = _this5._renderParams) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.action) !== null && _this5$_renderParams4 !== void 0 && _this5$_renderParams4.skipSdkQuery)) {
345
+ _context2.next = 4;
326
346
  break;
327
347
  }
328
- extendInfo = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.extendInfo) || '{}';
329
- info = JSON.parse(extendInfo);
330
- if (!((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false')) {
331
- _context2.next = 11;
348
+ return _context2.abrupt("return", resolve({
349
+ message: 'sdk no need to make query request',
350
+ success: true
351
+ }));
352
+ case 4:
353
+ if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
354
+ _context2.next = 9;
332
355
  break;
333
356
  }
334
- _context2.next = 10;
357
+ params.paymentMethodType = 'CARD';
358
+ _context2.next = 8;
335
359
  return _this5.getDeviceIdAndLog();
336
- case 10:
360
+ case 8:
337
361
  envInfo.deviceId = _context2.sent;
338
- case 11:
362
+ case 9:
339
363
  if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
340
- _context2.next = 16;
364
+ _context2.next = 17;
341
365
  break;
342
366
  }
343
367
  _ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
344
- _ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
368
+ _ref4 = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
345
369
  if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
346
- _context2.next = 16;
370
+ _context2.next = 14;
347
371
  break;
348
372
  }
349
373
  return _context2.abrupt("return", resolve({
350
374
  message: 'sdk no need to make query request',
351
375
  success: true
352
376
  }));
377
+ case 14:
378
+ _context2.next = 16;
379
+ return _this5.getDeviceIdAndLog();
353
380
  case 16:
381
+ envInfo.deviceId = _context2.sent;
382
+ case 17:
354
383
  if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
355
- _context2.next = 23;
384
+ _context2.next = 27;
356
385
  break;
357
386
  }
358
- action = ((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 || (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.action) || {};
387
+ action = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 || (_this5$_renderParams6 = _this5$_renderParams6.paymentSessionMetaData) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.action) || {};
359
388
  signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
360
389
  if (!(signType === 'SMS')) {
361
- _context2.next = 21;
390
+ _context2.next = 22;
362
391
  break;
363
392
  }
364
393
  return _context2.abrupt("return", resolve({
365
394
  message: 'sdk no need to make query request',
366
395
  success: true
367
396
  }));
368
- case 21:
397
+ case 22:
369
398
  if (!(!signType || signType !== 'REDIRECT')) {
370
- _context2.next = 23;
399
+ _context2.next = 24;
371
400
  break;
372
401
  }
373
402
  return _context2.abrupt("return", resolve({
374
403
  success: false
375
404
  }));
376
- case 23:
377
- if (!isLocalMock()) {
378
- _context2.next = 25;
379
- break;
380
- }
381
- return _context2.abrupt("return", resolve({
382
- message: 'sdk no need to make query request',
383
- success: true
384
- }));
385
- case 25:
405
+ case 24:
406
+ _context2.next = 26;
407
+ return _this5.getDeviceIdAndLog();
408
+ case 26:
409
+ envInfo.deviceId = _context2.sent;
410
+ case 27:
411
+ _this5.AMSSDK.logger.logInfo({
412
+ title: 'sdk_event_sdkQuery'
413
+ }, {
414
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
415
+ }).send();
386
416
  queryPaymentInfo(params, {
387
417
  env: _this5.AMSSDK.options.env.environment,
388
418
  envInfo: envInfo
@@ -406,8 +436,14 @@ var ComponentApp = /*#__PURE__*/function () {
406
436
  code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
407
437
  });
408
438
  reject(err);
439
+ }).finally(function () {
440
+ _this5.AMSSDK.logger.logInfo({
441
+ title: 'sdk_event_sdkQueryEnd'
442
+ }, {
443
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
444
+ }).send();
409
445
  });
410
- case 26:
446
+ case 29:
411
447
  case "end":
412
448
  return _context2.stop();
413
449
  }
@@ -419,6 +455,90 @@ var ComponentApp = /*#__PURE__*/function () {
419
455
  }());
420
456
  return this._actionQueryPromise;
421
457
  }
458
+ }, {
459
+ key: "createSubmitPromise",
460
+ value: function createSubmitPromise() {
461
+ var _this$_renderParams3,
462
+ _this$_renderParams4,
463
+ _this6 = this;
464
+ this._performanceData.push({
465
+ key: 'sdk_submit_start',
466
+ value: Date.now()
467
+ });
468
+ var params = {
469
+ paymentSessionData: this._renderParams && ((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData) || '',
470
+ paymentSessionConfig: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionMetaData) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionConfig
471
+ };
472
+
473
+ // eslint-disable-next-line no-async-promise-executor
474
+ this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
475
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
476
+ var _this6$_renderParams;
477
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
478
+ while (1) switch (_context3.prev = _context3.next) {
479
+ case 0:
480
+ if (!(!((_this6$_renderParams = _this6._renderParams) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.paymentSessionMetaData) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.action) !== null && _this6$_renderParams !== void 0 && _this6$_renderParams.skipSdkQuery) || componentSignEnum.EASY_PAY_WALLET !== _this6._componentSign)) {
481
+ _context3.next = 2;
482
+ break;
483
+ }
484
+ return _context3.abrupt("return", resolve({
485
+ message: 'sdk no need to make submitPay request',
486
+ success: true
487
+ }));
488
+ case 2:
489
+ _this6.AMSSDK.logger.logInfo({
490
+ title: 'sdk_event_submitPay'
491
+ }, {
492
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
493
+ }).send();
494
+ _context3.t0 = submitPayInfo;
495
+ _context3.t1 = params;
496
+ _context3.t2 = _this6.AMSSDK.options.env.environment;
497
+ _context3.next = 8;
498
+ return _this6.getDeviceIdAndLog();
499
+ case 8:
500
+ _context3.t3 = _context3.sent;
501
+ _context3.t4 = {
502
+ deviceId: _context3.t3
503
+ };
504
+ _context3.t5 = {
505
+ env: _context3.t2,
506
+ timeout: 15000,
507
+ envInfo: _context3.t4
508
+ };
509
+ _context3.t6 = _this6.AMSSDK.logger;
510
+ (0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6).then(function (res) {
511
+ _this6._performanceData.push({
512
+ key: 'sdk_submit_end',
513
+ value: Date.now()
514
+ });
515
+ if (res !== null && res !== void 0 && res.success) {
516
+ resolve(res);
517
+ } else {
518
+ resolve(res);
519
+ }
520
+ }).catch(function () {
521
+ resolve({
522
+ success: false
523
+ });
524
+ }).finally(function () {
525
+ _this6.AMSSDK.logger.logInfo({
526
+ title: 'sdk_event_submitPayEnd'
527
+ }, {
528
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
529
+ }).send();
530
+ });
531
+ case 13:
532
+ case "end":
533
+ return _context3.stop();
534
+ }
535
+ }, _callee3);
536
+ }));
537
+ return function (_x3) {
538
+ return _ref5.apply(this, arguments);
539
+ };
540
+ }());
541
+ }
422
542
  }, {
423
543
  key: "cleanElement",
424
544
  value: function cleanElement() {
@@ -535,9 +655,9 @@ var ComponentApp = /*#__PURE__*/function () {
535
655
  }, {
536
656
  key: "createPopupWindow",
537
657
  value: function createPopupWindow(data) {
538
- var _this$_renderParams3;
658
+ var _this$_renderParams5;
539
659
  this._threedData = data;
540
- var sessionData = encodeURIComponent((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData);
660
+ var sessionData = encodeURIComponent((_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData);
541
661
  var threedPageUrl = "".concat(marmotMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&").concat(this._appLocationSearch);
542
662
  this.popupWindow = createModal({
543
663
  device: this.platform,
@@ -547,19 +667,19 @@ var ComponentApp = /*#__PURE__*/function () {
547
667
  }, {
548
668
  key: "getDeviceIdAndCallback",
549
669
  value: function () {
550
- var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(eventContext) {
670
+ var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(eventContext) {
551
671
  var deviceId;
552
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
553
- while (1) switch (_context3.prev = _context3.next) {
672
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
673
+ while (1) switch (_context4.prev = _context4.next) {
554
674
  case 0:
555
675
  if (!(eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId)) {
556
- _context3.next = 5;
676
+ _context4.next = 5;
557
677
  break;
558
678
  }
559
- _context3.next = 3;
560
- return this.getDeviceIdAndLog();
679
+ _context4.next = 3;
680
+ return this.getDeviceIdAndLog(eventContext === null || eventContext === void 0 ? void 0 : eventContext.data, true);
561
681
  case 3:
562
- deviceId = _context3.sent;
682
+ deviceId = _context4.sent;
563
683
  this.dispatchToApp({
564
684
  context: {
565
685
  event: 'appEventCallback',
@@ -571,11 +691,11 @@ var ComponentApp = /*#__PURE__*/function () {
571
691
  });
572
692
  case 5:
573
693
  case "end":
574
- return _context3.stop();
694
+ return _context4.stop();
575
695
  }
576
- }, _callee3, this);
696
+ }, _callee4, this);
577
697
  }));
578
- function getDeviceIdAndCallback(_x3) {
698
+ function getDeviceIdAndCallback(_x4) {
579
699
  return _getDeviceIdAndCallback.apply(this, arguments);
580
700
  }
581
701
  return getDeviceIdAndCallback;
@@ -605,7 +725,7 @@ var ComponentApp = /*#__PURE__*/function () {
605
725
  }, {
606
726
  key: "_handleAppMessage",
607
727
  value: function _handleAppMessage(data) {
608
- var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name, EVENT.popupWindow.name, EVENT.threedReady.name, EVENT.closePopup.name, EVENT.getDeviceId.name];
728
+ var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name, EVENT.popupWindow.name, EVENT.threedReady.name, EVENT.closePopup.name, EVENT.getDeviceId.name, EVENT.declareEventCallbackInfo.name];
609
729
  if (!eventKeyMap.includes(data.context.event)) {
610
730
  return;
611
731
  }
@@ -678,6 +798,10 @@ var ComponentApp = /*#__PURE__*/function () {
678
798
  this.handleDeclareInfo(data.context.data);
679
799
  return;
680
800
  }
801
+ if (data.context.event === EVENT.declareEventCallbackInfo.name) {
802
+ this._multipleCallbackEvents = data.context.data;
803
+ return;
804
+ }
681
805
  if (data.context.event === EVENT.eventCallback.name) {
682
806
  this.AMSSDK.logger.logInfo({
683
807
  title: 'sdk_event_event_callback'
@@ -740,7 +864,7 @@ var ComponentApp = /*#__PURE__*/function () {
740
864
  }, {
741
865
  key: "handleRedirect",
742
866
  value: function handleRedirect(data) {
743
- var _this6 = this;
867
+ var _this7 = this;
744
868
  var _data = typeof data === 'string' ? {
745
869
  normalUrl: data
746
870
  } : {
@@ -755,11 +879,11 @@ var ComponentApp = /*#__PURE__*/function () {
755
879
  redirectInfo: JSON.stringify(_data)
756
880
  }).send();
757
881
  var successCallback = function successCallback(type, url) {
758
- _this6.dispatchToSDK(EVENT.eventCallback.name, {
882
+ _this7.dispatchToSDK(EVENT.eventCallback.name, {
759
883
  code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
760
884
  message: "Successfully opened the app,".concat(type, ": ").concat(url)
761
885
  });
762
- _this6.AMSSDK.logger.logInfo({
886
+ _this7.AMSSDK.logger.logInfo({
763
887
  title: 'sdk_event_call_url_success'
764
888
  }, {
765
889
  redirectInfo: JSON.stringify(_data),
@@ -768,11 +892,11 @@ var ComponentApp = /*#__PURE__*/function () {
768
892
  }).send();
769
893
  };
770
894
  var failCallback = function failCallback(type, url) {
771
- _this6.dispatchToSDK(EVENT.eventCallback.name, {
772
- code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
895
+ _this7.dispatchToSDK(EVENT.eventCallback.name, {
896
+ code: eventCodeEnum.SDK_CALL_URL_ERROR,
773
897
  message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
774
898
  });
775
- _this6.AMSSDK.logger.logInfo({
899
+ _this7.AMSSDK.logger.logInfo({
776
900
  title: 'sdk_error_call_url_failed'
777
901
  }, {
778
902
  redirectInfo: JSON.stringify(_data),
@@ -795,14 +919,14 @@ var ComponentApp = /*#__PURE__*/function () {
795
919
  successCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
796
920
  }).catch(function () {
797
921
  failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
798
- return _this6.AMSSDK._redirect({
922
+ return _this7.AMSSDK._redirect({
799
923
  schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
800
924
  });
801
925
  }).then(function () {
802
926
  successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
803
927
  }).catch(function () {
804
928
  failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
805
- return _this6.AMSSDK._redirect({
929
+ return _this7.AMSSDK._redirect({
806
930
  normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
807
931
  });
808
932
  }).then(function () {
@@ -813,13 +937,31 @@ var ComponentApp = /*#__PURE__*/function () {
813
937
  }
814
938
  }, {
815
939
  key: "handleDeclareInfo",
816
- value: function handleDeclareInfo(_ref5) {
817
- var _ref5$closeDialogData = _ref5.closeDialogData,
818
- closeDialogData = _ref5$closeDialogData === void 0 ? {} : _ref5$closeDialogData;
940
+ value: function handleDeclareInfo(_ref6) {
941
+ var _ref6$closeDialogData = _ref6.closeDialogData,
942
+ closeDialogData = _ref6$closeDialogData === void 0 ? {} : _ref6$closeDialogData;
819
943
  _handleDeclareInfo({
820
944
  closeDialogData: closeDialogData
821
945
  });
822
946
  }
947
+ }, {
948
+ key: "handleDeclarePopWindowCallback",
949
+ value: function handleDeclarePopWindowCallback() {
950
+ var eventInfoName = 'popWindowEventInfo';
951
+ if (this._multipleCallbackEvents && eventInfoName in this._multipleCallbackEvents) {
952
+ var eventInfo = this._multipleCallbackEvents[eventInfoName];
953
+ if (eventInfo.enableCallback) {
954
+ this.dispatchToSDK(EVENT.eventCallback.name, {
955
+ code: eventInfo.eventName,
956
+ result: {
957
+ result: eventInfo.eventResult
958
+ }
959
+ });
960
+ }
961
+ } else {
962
+ console.log("not valid ".concat(eventInfoName, " in "), this._multipleCallbackEvents);
963
+ }
964
+ }
823
965
  }, {
824
966
  key: "handleCloseBtnShow",
825
967
  value: function handleCloseBtnShow(showClose) {
@@ -889,22 +1031,26 @@ var ComponentApp = /*#__PURE__*/function () {
889
1031
  }, {
890
1032
  key: "sendRenderEvent",
891
1033
  value: function () {
892
- var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
893
- var _this$_renderParams4, _this$_renderParams5, _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, res;
894
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
895
- while (1) switch (_context4.prev = _context4.next) {
1034
+ var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
1035
+ var _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, res, submitRes;
1036
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1037
+ while (1) switch (_context5.prev = _context5.next) {
896
1038
  case 0:
897
- _context4.prev = 0;
898
- if (this._actionQueryPromise) {
899
- _context4.next = 3;
1039
+ _context5.prev = 0;
1040
+ if (!(!this._actionQueryPromise || !this._actionSubmitPromise)) {
1041
+ _context5.next = 3;
900
1042
  break;
901
1043
  }
902
- return _context4.abrupt("return");
1044
+ return _context5.abrupt("return");
903
1045
  case 3:
904
- _context4.next = 5;
1046
+ _context5.next = 5;
905
1047
  return this._actionQueryPromise;
906
1048
  case 5:
907
- res = _context4.sent;
1049
+ res = _context5.sent;
1050
+ _context5.next = 8;
1051
+ return this._actionSubmitPromise;
1052
+ case 8:
1053
+ submitRes = _context5.sent;
908
1054
  this._performanceData.push({
909
1055
  key: 'sdk_render_component',
910
1056
  value: Date.now()
@@ -914,12 +1060,13 @@ var ComponentApp = /*#__PURE__*/function () {
914
1060
  event: 'renderComponent',
915
1061
  data: {
916
1062
  queryResult: res,
917
- sessionResult: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionMetaData,
918
- paymentSessionData: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData,
1063
+ submitResult: submitRes,
1064
+ sessionResult: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentSessionMetaData,
1065
+ paymentSessionData: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.sessionData,
919
1066
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
920
- renderDisplayType: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.renderDisplayType,
921
- appearance: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.appearance,
922
- notRedirectAfterComplete: ((_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.notRedirectAfterComplete) === true,
1067
+ renderDisplayType: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.renderDisplayType,
1068
+ appearance: (_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.appearance,
1069
+ notRedirectAfterComplete: ((_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.notRedirectAfterComplete) === true,
923
1070
  envInfo: {
924
1071
  screenHeight: screen.height,
925
1072
  screenWidth: screen.width
@@ -936,16 +1083,16 @@ var ComponentApp = /*#__PURE__*/function () {
936
1083
  }
937
1084
  });
938
1085
  // eslint-disable-next-line no-empty
939
- _context4.next = 13;
1086
+ _context5.next = 16;
940
1087
  break;
941
- case 11:
942
- _context4.prev = 11;
943
- _context4.t0 = _context4["catch"](0);
944
- case 13:
1088
+ case 14:
1089
+ _context5.prev = 14;
1090
+ _context5.t0 = _context5["catch"](0);
1091
+ case 16:
945
1092
  case "end":
946
- return _context4.stop();
1093
+ return _context5.stop();
947
1094
  }
948
- }, _callee4, this, [[0, 11]]);
1095
+ }, _callee5, this, [[0, 14]]);
949
1096
  }));
950
1097
  function sendRenderEvent() {
951
1098
  return _sendRenderEvent.apply(this, arguments);
@@ -959,7 +1106,7 @@ var ComponentApp = /*#__PURE__*/function () {
959
1106
  key: "cleanContainer",
960
1107
  value: function cleanContainer() {
961
1108
  var _document$getElementB4,
962
- _this7 = this;
1109
+ _this8 = this;
963
1110
  var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
964
1111
  this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
965
1112
  this._performanceData = [];
@@ -971,7 +1118,7 @@ var ComponentApp = /*#__PURE__*/function () {
971
1118
  mockup === null || mockup === void 0 || mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
972
1119
  if (immediately) this.cleanElement();else {
973
1120
  setTimeout(function () {
974
- _this7.cleanElement();
1121
+ _this8.cleanElement();
975
1122
  }, 300);
976
1123
  }
977
1124
  }
@@ -994,6 +1141,7 @@ var ComponentApp = /*#__PURE__*/function () {
994
1141
  if (this._isRetention) this.showRetentionPopup();else {
995
1142
  this.cleanContainer();
996
1143
  this.dispatchToSDK(EVENT.close.name, {});
1144
+ this.handleDeclarePopWindowCallback();
997
1145
  }
998
1146
  }
999
1147
  }, {
@@ -1002,6 +1150,7 @@ var ComponentApp = /*#__PURE__*/function () {
1002
1150
  this.dispatchToSDK(EVENT.close.name, {});
1003
1151
  this.hideRetentionPopupFunc();
1004
1152
  this.cleanContainer();
1153
+ this.handleDeclarePopWindowCallback();
1005
1154
  }
1006
1155
  }, {
1007
1156
  key: "removeRetentionPopup",