@alipay/ams-checkout 0.0.1787898127-dev.20 → 0.0.1787898127-dev.21

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.
@@ -1,12 +1,16 @@
1
1
  var _excluded = ["onStatusChange"],
2
2
  _excluded2 = ["onBeforeConfirm"];
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
9
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
14
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
11
15
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
16
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -33,12 +37,13 @@ import { ERRORMESSAGE, PROMISE_CALLBACK_CODE } from "../../../../constant";
33
37
  import { BusManager, BusMessage } from "../../../bus";
34
38
  import { ApplePayActionEnum } from "../../../bus/interface";
35
39
  import { shouldQueryOneAccount } from "../../../utils/connectConfig";
36
- import { ApplePayHostService, awaitWrap, buildPageUrl, buildRecurringPaymentRequest, checkSessionData, debug, debugError, getDevReqConfig, getLocaleFromRenderData, getMetaData, MessageType, ModalPort, oneAccountQuery, openModal, OpenSDKError, parseHostSign, parseTrackerId, request, SDKBridge, sdkQuery, sdkTracker, showToast, themeColorMap } from "../../../../modern/tools";
40
+ import { ApplePayHostService, awaitWrap, buildPageUrl, buildRecurringPaymentRequest, checkSessionData, debug, debugError, getDevReqConfig, getLocaleFromRenderData, getMetaData, getModalMessageTrackData, installModalMessageMonitor, MessageType, ModalPort, oneAccountQuery, openModal, OpenSDKError, parseHostSign, parseTrackerId, request, SDKBridge, sdkQuery, sdkTracker, showToast, themeColorMap } from "../../../../modern/tools";
37
41
  import { getApplePayPaymentSession } from "../../../../service";
38
42
  import { device } from "../../../../util";
39
43
  import { BEFORE_CONFIRM_TIMEOUT_MS, executeWithTimeout, MERCHANT_CONFIRM_ABORT_CODE, MERCHANT_CONFIRM_TIMEOUT_CODE } from "../../../../util/beforeConfirm";
40
44
  import CallApp from "../../../../util/intl-callapp/es/main";
41
45
  import { LogConfig, Logger } from "../../../../util/logger";
46
+ import { getIdengineTimezone } from "../../../../util/timezone";
42
47
  import { v4 as uuid } from 'uuid';
43
48
  import { EventCallbackCode } from "../type";
44
49
  import { safeParse } from "../util";
@@ -46,12 +51,13 @@ import { adaptAppearance, adaptSubmitResult } from "./adapter";
46
51
 
47
52
  // ============================================================
48
53
  // 埋点 helper(不改 opensdk 源码,复用 sdkTracker 单例,trackId 已自动注入)
49
- // code 规约:7982 + 阶段后缀,与 opensdk internalTracker 对齐
50
- // 7982mount / 7982handshake / 7982element / 7982(异常无后缀)
54
+ // code 规约:7882 + 阶段后缀
55
+ // 7882mount / 7882handshake / 7882element / 7882(异常无后缀)
51
56
  // 只插入调用,不影响任何运行逻辑
52
57
  // ============================================================
53
58
 
54
- var TRACK_CODE_PREFIX = '7982';
59
+ var TRACK_CODE_PREFIX = '7882';
60
+ var MODERN_CONTROLLER_ELEMENT_TYPE = 'payment_v1';
55
61
 
56
62
  /**
57
63
  * 优先取 sessionData 解析出的 clientId;
@@ -75,14 +81,17 @@ var resolveMerchantId = function resolveMerchantId(parseData) {
75
81
  };
76
82
  // reportApiEnd 留为模块级,merchant_id 改为显式参数(由 runApi 从实例传入),
77
83
  // 避免原模块级 _merchantId 的多实例共享竞争。track/trackXxx 已改为实例方法读 this.merchantId。
78
- var reportApiEnd = function reportApiEnd(api, durationMs, merchantId) {
79
- var extra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
84
+ var reportApiEnd = function reportApiEnd(api, durationMs, merchantId, productScene) {
85
+ var extra = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
80
86
  try {
81
87
  sdkTracker.log(_objectSpread({
82
88
  code: "".concat(TRACK_CODE_PREFIX, "api"),
83
89
  msg: api,
84
90
  m1: durationMs,
85
- merchant_id: merchantId
91
+ merchant_id: merchantId,
92
+ product_scene: productScene,
93
+ element_type: MODERN_CONTROLLER_ELEMENT_TYPE,
94
+ idengine_timezone: getIdengineTimezone()
86
95
  }, extra));
87
96
  } catch (_unused2) {
88
97
  /* 埋点失败绝不影响主流程 */
@@ -140,7 +149,7 @@ var normalizeApiInput = function normalizeApiInput(api, params) {
140
149
  // 统一包裹:捕获终态(resolve/reject)后上报,原值/原异常原样透传,不影响任何已有逻辑。
141
150
  // extraBuilder 供调用方注入实例上下文字段(如 paymentMethodType),其值覆盖 normalizeApiResult 结果。
142
151
  var runApi = /*#__PURE__*/function () {
143
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, fn, extraBuilder, inputExtra, merchantId) {
152
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, fn, extraBuilder, inputExtra, merchantId, productScene) {
144
153
  var startedAt, result;
145
154
  return _regeneratorRuntime().wrap(function _callee$(_context) {
146
155
  while (1) switch (_context.prev = _context.next) {
@@ -151,12 +160,12 @@ var runApi = /*#__PURE__*/function () {
151
160
  return fn();
152
161
  case 4:
153
162
  result = _context.sent;
154
- reportApiEnd(api, Date.now() - startedAt, merchantId, _objectSpread(_objectSpread(_objectSpread({}, inputExtra), normalizeApiResult(api, result)), extraBuilder === null || extraBuilder === void 0 ? void 0 : extraBuilder(false)));
163
+ reportApiEnd(api, Date.now() - startedAt, merchantId, productScene, _objectSpread(_objectSpread(_objectSpread({}, inputExtra), normalizeApiResult(api, result)), extraBuilder === null || extraBuilder === void 0 ? void 0 : extraBuilder(false)));
155
164
  return _context.abrupt("return", result);
156
165
  case 9:
157
166
  _context.prev = 9;
158
167
  _context.t0 = _context["catch"](1);
159
- reportApiEnd(api, Date.now() - startedAt, merchantId, _objectSpread(_objectSpread({}, inputExtra), {}, {
168
+ reportApiEnd(api, Date.now() - startedAt, merchantId, productScene, _objectSpread(_objectSpread({}, inputExtra), {}, {
160
169
  d1: 'error',
161
170
  d2: (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.code) || 'UNKNOWN'
162
171
  }, extraBuilder === null || extraBuilder === void 0 ? void 0 : extraBuilder(true)));
@@ -167,7 +176,7 @@ var runApi = /*#__PURE__*/function () {
167
176
  }
168
177
  }, _callee, null, [[1, 9]]);
169
178
  }));
170
- return function runApi(_x, _x2, _x3, _x4, _x5) {
179
+ return function runApi(_x, _x2, _x3, _x4, _x5, _x6) {
171
180
  return _ref.apply(this, arguments);
172
181
  };
173
182
  }();
@@ -269,6 +278,7 @@ var AMSMessageType = {
269
278
  */
270
279
  export var ModernElementController = /*#__PURE__*/function () {
271
280
  function ModernElementController(_ref2) {
281
+ var _this = this;
272
282
  var onStatusChange = _ref2.onStatusChange,
273
283
  options = _objectWithoutProperties(_ref2, _excluded);
274
284
  _classCallCheck(this, ModernElementController);
@@ -293,6 +303,8 @@ export var ModernElementController = /*#__PURE__*/function () {
293
303
  _defineProperty(this, "_merchantCurrency", null);
294
304
  /** 当前选中的支付方式类型(如 'APPLEPAY', 'CARD'),通过 paymentMethodChanged 事件更新 */
295
305
  _defineProperty(this, "currentPaymentMethodType", '');
306
+ /** Removes the passive host-window modal monitor for this controller. */
307
+ _defineProperty(this, "stopModalMessageMonitor", void 0);
296
308
  /** 提交进行中标志:submitPayment 执行期间为 true,用于拒绝并发重入,避免旧闭包串扰/重复拉起钱包 */
297
309
  _defineProperty(this, "isSubmitting", false);
298
310
  /**
@@ -300,6 +312,8 @@ export var ModernElementController = /*#__PURE__*/function () {
300
312
  * 实例隔离:多实例并发 mount 时各自持有,避免原模块级 _merchantId 的共享竞争。
301
313
  */
302
314
  _defineProperty(this, "merchantId", '');
315
+ /** session 中的真实业务场景,仅作为埋点公共维度,不参与业务判断。 */
316
+ _defineProperty(this, "productScene", '');
303
317
  this.options = options;
304
318
  this.onStatusChange = onStatusChange;
305
319
  if (options.sessionData) {
@@ -320,6 +334,12 @@ export var ModernElementController = /*#__PURE__*/function () {
320
334
  debug('INFO', direction === 'OUT' ? 'SDK_INTERNAL' : 'APP_RUNTIME', msg.type, msg.payload);
321
335
  }
322
336
  });
337
+ this.stopModalMessageMonitor = installModalMessageMonitor(function (data) {
338
+ return _this.trackElement('modal_lifecycle_monitor', getModalMessageTrackData(data));
339
+ }, function (event) {
340
+ var _this$iframe;
341
+ return event.source === ((_this$iframe = _this.iframe) === null || _this$iframe === void 0 ? void 0 : _this$iframe.contentWindow);
342
+ });
323
343
  }
324
344
  _createClass(ModernElementController, [{
325
345
  key: "track",
@@ -332,7 +352,10 @@ export var ModernElementController = /*#__PURE__*/function () {
332
352
  sdkTracker.log(_objectSpread({
333
353
  code: code,
334
354
  msg: msg,
335
- merchant_id: this.merchantId
355
+ merchant_id: this.merchantId,
356
+ product_scene: this.productScene,
357
+ element_type: MODERN_CONTROLLER_ELEMENT_TYPE,
358
+ idengine_timezone: getIdengineTimezone()
336
359
  }, extra));
337
360
  } catch (_unused3) {
338
361
  /* 埋点失败绝不影响主流程 */
@@ -362,11 +385,44 @@ export var ModernElementController = /*#__PURE__*/function () {
362
385
  var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
363
386
  this.track('error', msg, extra);
364
387
  }
388
+ }, {
389
+ key: "createRequestTracker",
390
+ value: function createRequestTracker() {
391
+ var _this2 = this;
392
+ try {
393
+ var requestTracker = Object.create(sdkTracker);
394
+ requestTracker.log = function () {
395
+ try {
396
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
397
+ args[_key2] = arguments[_key2];
398
+ }
399
+ var event = args[0],
400
+ rest = args.slice(1);
401
+ if (event && _typeof(event) === 'object') {
402
+ sdkTracker.log.apply(sdkTracker, [_objectSpread(_objectSpread({}, event), {}, {
403
+ merchant_id: _this2.merchantId,
404
+ product_scene: _this2.productScene,
405
+ element_type: MODERN_CONTROLLER_ELEMENT_TYPE,
406
+ idengine_timezone: getIdengineTimezone()
407
+ })].concat(_toConsumableArray(rest)));
408
+ return;
409
+ }
410
+ sdkTracker.log.apply(sdkTracker, args);
411
+ } catch (_unused4) {
412
+ /* 埋点失败绝不影响请求 */
413
+ }
414
+ };
415
+ return requestTracker;
416
+ } catch (_unused5) {
417
+ return sdkTracker;
418
+ }
419
+ }
365
420
  }, {
366
421
  key: "mount",
367
422
  value: function () {
368
423
  var _mount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderOptions, sdkSelector) {
369
- var _this = this;
424
+ var _this3 = this;
425
+ var _metaData$paymentSess, metaData;
370
426
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
371
427
  while (1) switch (_context2.prev = _context2.next) {
372
428
  case 0:
@@ -375,23 +431,25 @@ export var ModernElementController = /*#__PURE__*/function () {
375
431
  // 缺失/无效时会 throw,这里容错吞掉——失败的校验仍由后续 setup() 内的 checkSessionData
376
432
  // 抛出、走 mount_error 统一上报,不改变错误时序。
377
433
  try {
378
- this.merchantId = resolveMerchantId(checkSessionData(this.options.sessionData, 'ELEMENT_PAYMENT'));
379
- } catch (_unused4) {
434
+ metaData = checkSessionData(this.options.sessionData, 'ELEMENT_PAYMENT');
435
+ this.merchantId = resolveMerchantId(metaData);
436
+ this.productScene = (metaData === null || metaData === void 0 || (_metaData$paymentSess = metaData.paymentSessionConfig) === null || _metaData$paymentSess === void 0 ? void 0 : _metaData$paymentSess.productScene) || '';
437
+ } catch (_unused6) {
380
438
  /* setup 校验异常会统一上报 */
381
439
  }
382
440
  return _context2.abrupt("return", runApi('mount', function () {
383
- return _this.doMount(renderOptions, sdkSelector);
441
+ return _this3.doMount(renderOptions, sdkSelector);
384
442
  }, undefined, normalizeApiInput('mount', {
385
443
  renderOptions: renderOptions,
386
444
  sdkSelector: sdkSelector
387
- }), this.merchantId));
445
+ }), this.merchantId, this.productScene));
388
446
  case 2:
389
447
  case "end":
390
448
  return _context2.stop();
391
449
  }
392
450
  }, _callee2, this);
393
451
  }));
394
- function mount(_x6, _x7) {
452
+ function mount(_x7, _x8) {
395
453
  return _mount.apply(this, arguments);
396
454
  }
397
455
  return mount;
@@ -445,7 +503,7 @@ export var ModernElementController = /*#__PURE__*/function () {
445
503
  if (iframeOrigin && iframeOrigin !== 'null') {
446
504
  this.bridge.setOrigin(iframeOrigin);
447
505
  }
448
- } catch (_unused5) {
506
+ } catch (_unused7) {
449
507
  // URL 解析失败时保持默认 origin
450
508
  }
451
509
  } else {
@@ -538,7 +596,7 @@ export var ModernElementController = /*#__PURE__*/function () {
538
596
  }
539
597
  }, _callee3, this, [[8, 44]]);
540
598
  }));
541
- function doMount(_x8, _x9) {
599
+ function doMount(_x9, _x10) {
542
600
  return _doMount.apply(this, arguments);
543
601
  }
544
602
  return doMount;
@@ -557,8 +615,9 @@ export var ModernElementController = /*#__PURE__*/function () {
557
615
  key: "setup",
558
616
  value: (function () {
559
617
  var _setup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(renderOptions) {
560
- var _parseData$connectFac,
561
- _this2 = this,
618
+ var _parseData$paymentSes,
619
+ _parseData$connectFac,
620
+ _this4 = this,
562
621
  _parseData$paymentMet,
563
622
  _sdkQueryResult$data;
564
623
  var sessionData, parseData, lastEnv, isConnect, shouldQueryOneAccountFlag, paymentSessionConfig, genSdkQueryPromise, genOneAccountQueryPromise, promises, cancelDestroyCallback, destroyPromise, queryPromise, _yield$Promise$race$f, _yield$Promise$race$f2, sdkQueryResult, oneAccountQueryResult, _sdkQueryResult$error, _sdkQueryResult$error2, _oneAccountQueryResul, _oneAccountQueryResul2, preferredLocale, locale, renderDataError;
@@ -572,18 +631,20 @@ export var ModernElementController = /*#__PURE__*/function () {
572
631
  sessionData = this.options.sessionData; // checkSessionData 失败会 throw AntomSDKError(SESSION_DATA_INVALID),
573
632
  // 冒泡到 mount 的 catch 由 mount_error 统一上报,此处无需额外处理
574
633
  parseData = checkSessionData(sessionData, 'ELEMENT_PAYMENT');
634
+ this.merchantId || (this.merchantId = resolveMerchantId(parseData));
635
+ this.productScene = (parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionConfig) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.productScene) || '';
575
636
  lastEnv = this.options.environment === 'sandbox' ? 'sandbox' : 'prod';
576
637
  this.options.environment;
577
638
 
578
639
  // 初始化 request 全局配置,使 sdkQuery 能正确发起请求
579
- // tracker: sdkTracker —— 接入 HTTP 层自动埋点(B 套),上报每个请求的成败/RTT/错误码
580
- // 与 antom.ts 入口对齐;不传则 sdkQuery/submitPay/inquiry 等网络细节不可观测
640
+ // 实例级 tracker wrapper 接入 HTTP 自动埋点,并仅在日志中补齐 controller 公共维度。
641
+ // 不传 tracker 则 sdkQuery/submitPay/inquiry 等网络细节不可观测。
581
642
  request.setGlobalOptions(_objectSpread(_objectSpread({
582
643
  hostSign: parseHostSign(sessionData),
583
644
  env: lastEnv
584
645
  }, getDevReqConfig()), {}, {
585
- sdkVersion: "0.0.1787898127-dev.20" || '',
586
- tracker: sdkTracker
646
+ sdkVersion: "0.0.1787898127-dev.21" || '',
647
+ tracker: this.createRequestTracker()
587
648
  }));
588
649
  isConnect = !!(parseData !== null && parseData !== void 0 && (_parseData$connectFac = parseData.connectFactor) !== null && _parseData$connectFac !== void 0 && _parseData$connectFac.enableConnect);
589
650
  shouldQueryOneAccountFlag = shouldQueryOneAccount(isConnect, parseData === null || parseData === void 0 ? void 0 : parseData.extendInfo);
@@ -595,14 +656,14 @@ export var ModernElementController = /*#__PURE__*/function () {
595
656
  isUserPreferredLocale: true
596
657
  },
597
658
  merchantAppointParam: (_renderOptions$mercha = renderOptions.merchantAppointParam) !== null && _renderOptions$mercha !== void 0 && _renderOptions$mercha.storedCard ? renderOptions.merchantAppointParam : undefined,
598
- notRedirectAfterComplete: _this2.notRedirectAfterComplete,
659
+ notRedirectAfterComplete: _this4.notRedirectAfterComplete,
599
660
  // sdk需要传入该字段
600
661
  paymentSessionConfig: parseData === null || parseData === void 0 ? void 0 : parseData.paymentSessionConfig,
601
662
  paymentSessionData: sessionData
602
663
  }, {
603
664
  // 传商户初始化的 locale,服务端据此返回对应语言(缺失则回落用户偏好/en_US)
604
665
  envInfo: {
605
- locale: _this2.options.locale
666
+ locale: _this4.options.locale
606
667
  }
607
668
  }).catch(recoverSdkQueryBusinessResponse));
608
669
  };
@@ -618,14 +679,14 @@ export var ModernElementController = /*#__PURE__*/function () {
618
679
  promises = shouldQueryOneAccountFlag ? [genSdkQueryPromise(), genOneAccountQueryPromise()] : [genSdkQueryPromise(), undefined];
619
680
  cancelDestroyCallback = function cancelDestroyCallback() {};
620
681
  destroyPromise = new Promise(function (_, reject) {
621
- cancelDestroyCallback = _this2.onDestroy(function () {
682
+ cancelDestroyCallback = _this4.onDestroy(function () {
622
683
  return reject(getDestroyedError());
623
684
  });
624
685
  });
625
686
  queryPromise = Promise.all(promises);
626
- _context4.next = 19;
687
+ _context4.next = 21;
627
688
  return Promise.race([queryPromise, destroyPromise]).finally(cancelDestroyCallback);
628
- case 19:
689
+ case 21:
629
690
  _yield$Promise$race$f = _context4.sent;
630
691
  _yield$Promise$race$f2 = _slicedToArray(_yield$Promise$race$f, 2);
631
692
  sdkQueryResult = _yield$Promise$race$f2[0];
@@ -680,7 +741,7 @@ export var ModernElementController = /*#__PURE__*/function () {
680
741
  // 新sdk字段
681
742
  locale: locale,
682
743
  // 新sdk字段
683
- sdkVersion: "0.0.1787898127-dev.20" || '',
744
+ sdkVersion: "0.0.1787898127-dev.21" || '',
684
745
  // 新sdk字段
685
746
  merchantId: (sdkQueryResult === null || sdkQueryResult === void 0 || (_sdkQueryResult$data = sdkQueryResult.data) === null || _sdkQueryResult$data === void 0 ? void 0 : _sdkQueryResult$data.merchantId) || '',
686
747
  // 新sdk字段
@@ -690,13 +751,13 @@ export var ModernElementController = /*#__PURE__*/function () {
690
751
  env: lastEnv
691
752
  }, getDevReqConfig())
692
753
  });
693
- case 29:
754
+ case 31:
694
755
  case "end":
695
756
  return _context4.stop();
696
757
  }
697
758
  }, _callee4, this);
698
759
  }));
699
- function setup(_x10) {
760
+ function setup(_x11) {
700
761
  return _setup.apply(this, arguments);
701
762
  }
702
763
  return setup;
@@ -793,20 +854,20 @@ export var ModernElementController = /*#__PURE__*/function () {
793
854
  }, {
794
855
  key: "bindBridgeEvents",
795
856
  value: function bindBridgeEvents() {
796
- var _this3 = this;
857
+ var _this5 = this;
797
858
  this.bridge.on(MessageType.HEIGHT_UPDATE, function (height) {
798
- if (_this3.iframe) _this3.iframe.style.height = "".concat(height, "px");
859
+ if (_this5.iframe) _this5.iframe.style.height = "".concat(height, "px");
799
860
  });
800
861
  this.bridge.on(AMSMessageType.SHOWTOAST, function (payload, _ports, meta) {
801
- var _this3$iframe, _this3$modalIframe;
802
- if (meta && meta.source !== ((_this3$iframe = _this3.iframe) === null || _this3$iframe === void 0 ? void 0 : _this3$iframe.contentWindow) && meta.source !== ((_this3$modalIframe = _this3.modalIframe) === null || _this3$modalIframe === void 0 ? void 0 : _this3$modalIframe.contentWindow)) {
862
+ var _this5$iframe, _this5$modalIframe;
863
+ if (meta && meta.source !== ((_this5$iframe = _this5.iframe) === null || _this5$iframe === void 0 ? void 0 : _this5$iframe.contentWindow) && meta.source !== ((_this5$modalIframe = _this5.modalIframe) === null || _this5$modalIframe === void 0 ? void 0 : _this5$modalIframe.contentWindow)) {
803
864
  return;
804
865
  }
805
866
  showToast(payload);
806
867
  });
807
868
  this.bridge.on(MessageType.REDIRECT, function (payload, _ports, meta) {
808
- var _this3$iframe2, _this3$modalIframe2;
809
- if (meta && meta.source !== ((_this3$iframe2 = _this3.iframe) === null || _this3$iframe2 === void 0 ? void 0 : _this3$iframe2.contentWindow) && meta.source !== ((_this3$modalIframe2 = _this3.modalIframe) === null || _this3$modalIframe2 === void 0 ? void 0 : _this3$modalIframe2.contentWindow)) {
869
+ var _this5$iframe2, _this5$modalIframe2;
870
+ if (meta && meta.source !== ((_this5$iframe2 = _this5.iframe) === null || _this5$iframe2 === void 0 ? void 0 : _this5$iframe2.contentWindow) && meta.source !== ((_this5$modalIframe2 = _this5.modalIframe) === null || _this5$modalIframe2 === void 0 ? void 0 : _this5$modalIframe2.contentWindow)) {
810
871
  return;
811
872
  }
812
873
  var url = payload.url,
@@ -815,7 +876,7 @@ export var ModernElementController = /*#__PURE__*/function () {
815
876
  schemaUrl = payload.schemaUrl,
816
877
  destroy = payload.destroy;
817
878
  // d1=mode(redirect/replace) d2=跳转类型 d3=兜底url d4=appLinkUrl d5=schemaUrl d6=是否销毁
818
- _this3.trackElement('redirect', {
879
+ _this5.trackElement('redirect', {
819
880
  d1: mode || 'redirect',
820
881
  d2: appLinkUrl ? 'app_link' : schemaUrl ? 'schema' : 'url',
821
882
  d3: url || '',
@@ -824,7 +885,7 @@ export var ModernElementController = /*#__PURE__*/function () {
824
885
  d6: destroy ? '1' : '0'
825
886
  });
826
887
  if (destroy) {
827
- _this3.destroy();
888
+ _this5.destroy();
828
889
  }
829
890
  function fallbackJump() {
830
891
  if (mode === 'replace') {
@@ -838,7 +899,7 @@ export var ModernElementController = /*#__PURE__*/function () {
838
899
  var app = new CallApp({
839
900
  resultJudgmentTime: 2000,
840
901
  fallback: function fallback() {
841
- _this3.trackElement('redirect_fallback', {
902
+ _this5.trackElement('redirect_fallback', {
842
903
  d1: 'callapp_failed',
843
904
  d2: url || ''
844
905
  });
@@ -853,7 +914,7 @@ export var ModernElementController = /*#__PURE__*/function () {
853
914
  fallbackJump();
854
915
  }
855
916
  } catch (error) {
856
- _this3.trackError('redirect_error', {
917
+ _this5.trackError('redirect_error', {
857
918
  d1: 'callapp_exception',
858
919
  d2: (error === null || error === void 0 ? void 0 : error.message) || '',
859
920
  d3: url || ''
@@ -862,34 +923,34 @@ export var ModernElementController = /*#__PURE__*/function () {
862
923
  }
863
924
  });
864
925
  this.bridge.on(MessageType.OPEN_MODAL, function (payload, _ports, meta) {
865
- var _this3$iframe3;
866
- if (meta && meta.source !== ((_this3$iframe3 = _this3.iframe) === null || _this3$iframe3 === void 0 ? void 0 : _this3$iframe3.contentWindow)) {
926
+ var _this5$iframe3;
927
+ if (meta && meta.source !== ((_this5$iframe3 = _this5.iframe) === null || _this5$iframe3 === void 0 ? void 0 : _this5$iframe3.contentWindow)) {
867
928
  return;
868
929
  }
869
- _this3.handleOpenModal(payload);
870
- _this3.bridge.once(MessageType.CLOSE_MODAL, function () {
871
- _this3.handleCloseModal();
930
+ _this5.handleOpenModal(payload);
931
+ _this5.bridge.once(MessageType.CLOSE_MODAL, function () {
932
+ _this5.handleCloseModal();
872
933
  });
873
934
  });
874
935
  this.bridge.on(MessageType.DESTROY_ELEMENT, function (_payload, _ports, meta) {
875
- var _this3$iframe4;
876
- if (meta && meta.source !== ((_this3$iframe4 = _this3.iframe) === null || _this3$iframe4 === void 0 ? void 0 : _this3$iframe4.contentWindow)) {
936
+ var _this5$iframe4;
937
+ if (meta && meta.source !== ((_this5$iframe4 = _this5.iframe) === null || _this5$iframe4 === void 0 ? void 0 : _this5$iframe4.contentWindow)) {
877
938
  return;
878
939
  }
879
- _this3.destroy();
940
+ _this5.destroy();
880
941
  });
881
942
 
882
943
  // skipRenderPaymentMethod 场景:webapp 委托 SDK 全权拉起 ApplePay,fire-and-forget
883
944
  // 走 plugin/applepay 标准链路(onEventCallback 自动通知商户)
884
945
  this.bridge.on(AMSMessageType.HANDLE_PAYMENT, function () {
885
- _this3.handleHandlePayment();
946
+ _this5.handleHandlePayment();
886
947
  });
887
948
 
888
949
  // Apple Pay beforeConfirm:在 submitPayment 内通过 bridge.once 监听,此处不再注册
889
950
 
890
951
  // 支付方式变化:iframe 通知 SDK 当前选中的支付方式类型
891
952
  this.bridge.on(AMSMessageType.PAYMENT_METHOD_CHANGED, function (payload) {
892
- _this3.currentPaymentMethodType = (payload === null || payload === void 0 ? void 0 : payload.type) || '';
953
+ _this5.currentPaymentMethodType = (payload === null || payload === void 0 ? void 0 : payload.type) || '';
893
954
  });
894
955
  }
895
956
 
@@ -903,7 +964,7 @@ export var ModernElementController = /*#__PURE__*/function () {
903
964
  value: (function () {
904
965
  var _handleGetApplePayToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(payload, onBeforeConfirm) {
905
966
  var _paymentMethod,
906
- _this4 = this;
967
+ _this6 = this;
907
968
  var sessionData, applePayProps, paymentRequest, merchantCapabilities, merchantInfo, paymentAmount, supportedNetworks, version, requiredBillingContactFields, requiredShippingContactFields, finalAmount, finalCurrency, capturedResult, recurringRequest, service, _capturedResult, errCode;
908
969
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
909
970
  while (1) switch (_context7.prev = _context7.next) {
@@ -975,7 +1036,7 @@ export var ModernElementController = /*#__PURE__*/function () {
975
1036
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
976
1037
  while (1) switch (_context5.prev = _context5.next) {
977
1038
  case 0:
978
- _this4.trackElement('applepay_validate_start', {
1039
+ _this6.trackElement('applepay_validate_start', {
979
1040
  d1: 'merchant_validate'
980
1041
  });
981
1042
  _context5.next = 3;
@@ -984,7 +1045,7 @@ export var ModernElementController = /*#__PURE__*/function () {
984
1045
  paymentSessionData: sessionData,
985
1046
  merchantDomain: window.location.hostname
986
1047
  }, {
987
- env: _this4.options.environment,
1048
+ env: _this6.options.environment,
988
1049
  envInfo: {
989
1050
  deviceId: ''
990
1051
  }
@@ -995,12 +1056,12 @@ export var ModernElementController = /*#__PURE__*/function () {
995
1056
  _context5.next = 7;
996
1057
  break;
997
1058
  }
998
- _this4.trackElement('applepay_validate_success', {
1059
+ _this6.trackElement('applepay_validate_success', {
999
1060
  d1: 'got_session'
1000
1061
  });
1001
1062
  return _context5.abrupt("return", typeof res.merchantSessionObject === 'string' ? JSON.parse(res.merchantSessionObject) : res.merchantSessionObject);
1002
1063
  case 7:
1003
- _this4.trackError('applepay_merchant_validate_failed', {
1064
+ _this6.trackError('applepay_merchant_validate_failed', {
1004
1065
  d1: 'VALIDATION_FAILED',
1005
1066
  d2: (res === null || res === void 0 ? void 0 : res.errorMessage) || 'Merchant validation failed'
1006
1067
  });
@@ -1013,7 +1074,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1013
1074
  }
1014
1075
  }, _callee5);
1015
1076
  }));
1016
- function validateMerchant(_x13) {
1077
+ function validateMerchant(_x14) {
1017
1078
  return _validateMerchant.apply(this, arguments);
1018
1079
  }
1019
1080
  return validateMerchant;
@@ -1043,7 +1104,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1043
1104
  isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS;
1044
1105
  shouldContinue = !isTimeout && !!rawResult;
1045
1106
  if (isTimeout) {
1046
- _this4.trackError('sdk_before_confirm_timeout', {
1107
+ _this6.trackError('sdk_before_confirm_timeout', {
1047
1108
  d1: 'applePay_chrome_modern'
1048
1109
  });
1049
1110
  }
@@ -1071,7 +1132,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1071
1132
  billingContact: billingContact,
1072
1133
  shippingContact: shippingContact
1073
1134
  };
1074
- _this4.trackElement('applepay_authorized', {
1135
+ _this6.trackElement('applepay_authorized', {
1075
1136
  d1: token ? 'has_token' : 'no_token'
1076
1137
  });
1077
1138
  return _context6.abrupt("return", {
@@ -1084,7 +1145,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1084
1145
  }
1085
1146
  }, _callee6, null, [[2, 16]]);
1086
1147
  }));
1087
- function onAuthorized(_x14) {
1148
+ function onAuthorized(_x15) {
1088
1149
  return _onAuthorized.apply(this, arguments);
1089
1150
  }
1090
1151
  return onAuthorized;
@@ -1133,7 +1194,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1133
1194
  }
1134
1195
  }, _callee7, this, [[15, 22]]);
1135
1196
  }));
1136
- function handleGetApplePayToken(_x11, _x12) {
1197
+ function handleGetApplePayToken(_x12, _x13) {
1137
1198
  return _handleGetApplePayToken.apply(this, arguments);
1138
1199
  }
1139
1200
  return handleGetApplePayToken;
@@ -1158,7 +1219,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1158
1219
  key: "handleGetGooglePayToken",
1159
1220
  value: function handleGetGooglePayToken(payload) {
1160
1221
  var _data$paymentMethodDe,
1161
- _this5 = this,
1222
+ _this7 = this,
1162
1223
  _google;
1163
1224
  var data = payload === null || payload === void 0 ? void 0 : payload.data;
1164
1225
  var googlePayProps = data === null || data === void 0 || (_data$paymentMethodDe = data.paymentMethodDetail) === null || _data$paymentMethodDe === void 0 ? void 0 : _data$paymentMethodDe.googlePayProps;
@@ -1202,10 +1263,10 @@ export var ModernElementController = /*#__PURE__*/function () {
1202
1263
  };
1203
1264
  }).then(function (paymentData) {
1204
1265
  if (paymentData) {
1205
- _this5.trackElement('googlepay_token_success', {
1266
+ _this7.trackElement('googlepay_token_success', {
1206
1267
  d1: 'has_token'
1207
1268
  });
1208
- _this5.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1269
+ _this7.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1209
1270
  success: true,
1210
1271
  result: paymentData
1211
1272
  });
@@ -1213,16 +1274,16 @@ export var ModernElementController = /*#__PURE__*/function () {
1213
1274
  }).catch(function (err) {
1214
1275
  var statusCode = (err === null || err === void 0 ? void 0 : err.statusCode) || 'GOOGLE_PAY_PAYMENT_FAILED';
1215
1276
  if (statusCode === 'CANCELED') {
1216
- _this5.trackElement('googlepay_cancel', {
1277
+ _this7.trackElement('googlepay_cancel', {
1217
1278
  d1: 'user_cancel'
1218
1279
  });
1219
1280
  } else {
1220
- _this5.trackError('googlepay_token_failed', {
1281
+ _this7.trackError('googlepay_token_failed', {
1221
1282
  d1: statusCode,
1222
1283
  d2: (err === null || err === void 0 ? void 0 : err.statusMessage) || ''
1223
1284
  });
1224
1285
  }
1225
- _this5.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1286
+ _this7.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1226
1287
  success: false,
1227
1288
  err: _objectSpread({
1228
1289
  statusCode: statusCode
@@ -1254,10 +1315,10 @@ export var ModernElementController = /*#__PURE__*/function () {
1254
1315
  loadAndPay();
1255
1316
  };
1256
1317
  script.onerror = function () {
1257
- _this5.trackError('googlepay_script_load_failed', {
1318
+ _this7.trackError('googlepay_script_load_failed', {
1258
1319
  d1: 'script_error'
1259
1320
  });
1260
- _this5.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1321
+ _this7.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1261
1322
  success: false,
1262
1323
  err: {
1263
1324
  statusCode: 'GOOGLE_PAY_NOT_SUPPORTED'
@@ -1306,7 +1367,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1306
1367
  }, {
1307
1368
  key: "handleBeforeConfirmInternal",
1308
1369
  value: function handleBeforeConfirmInternal(onBeforeConfirm) {
1309
- var _this6 = this;
1370
+ var _this8 = this;
1310
1371
  if (!onBeforeConfirm) {
1311
1372
  logger.logInfo({
1312
1373
  title: 'sdk_before_confirm_skip'
@@ -1343,7 +1404,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1343
1404
  }, {
1344
1405
  shouldContinue: shouldContinue
1345
1406
  });
1346
- _this6.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, _objectSpread({
1407
+ _this8.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, _objectSpread({
1347
1408
  success: true,
1348
1409
  result: !!shouldContinue
1349
1410
  }, isTimeout ? {
@@ -1356,7 +1417,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1356
1417
  errorMessage: String((error === null || error === void 0 ? void 0 : error.message) || error).slice(0, 200),
1357
1418
  path: 'modernController_bridge'
1358
1419
  });
1359
- _this6.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, {
1420
+ _this8.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, {
1360
1421
  success: false,
1361
1422
  result: false
1362
1423
  });
@@ -1370,12 +1431,12 @@ export var ModernElementController = /*#__PURE__*/function () {
1370
1431
  }, {
1371
1432
  key: "waitForReadyHandshake",
1372
1433
  value: function waitForReadyHandshake() {
1373
- var _this7 = this;
1434
+ var _this9 = this;
1374
1435
  return new Promise(function (resolve, reject) {
1375
1436
  var cancelDestroyCallback = function cancelDestroyCallback() {};
1376
1437
  var timer = setTimeout(function () {
1377
1438
  cancelDestroyCallback();
1378
- _this7.trackError('ready_handshake_timeout', {
1439
+ _this9.trackError('ready_handshake_timeout', {
1379
1440
  d1: String(MOUNT_TIMEOUT)
1380
1441
  });
1381
1442
  reject({
@@ -1383,16 +1444,16 @@ export var ModernElementController = /*#__PURE__*/function () {
1383
1444
  message: 'An error occurred; the transaction cannot be initiated.'
1384
1445
  });
1385
1446
  }, MOUNT_TIMEOUT);
1386
- cancelDestroyCallback = _this7.onDestroy(function () {
1447
+ cancelDestroyCallback = _this9.onDestroy(function () {
1387
1448
  clearTimeout(timer);
1388
1449
  reject(getDestroyedError());
1389
1450
  });
1390
- _this7.bridge.once(MessageType.READY_HANDSHAKE, function () {
1391
- var _this7$iframe;
1451
+ _this9.bridge.once(MessageType.READY_HANDSHAKE, function () {
1452
+ var _this9$iframe;
1392
1453
  clearTimeout(timer);
1393
1454
  cancelDestroyCallback();
1394
- if (!((_this7$iframe = _this7.iframe) !== null && _this7$iframe !== void 0 && _this7$iframe.contentWindow)) {
1395
- _this7.trackError('iframe_contentwindow_unavailable', {
1455
+ if (!((_this9$iframe = _this9.iframe) !== null && _this9$iframe !== void 0 && _this9$iframe.contentWindow)) {
1456
+ _this9.trackError('iframe_contentwindow_unavailable', {
1396
1457
  d1: 'after_ready_handshake'
1397
1458
  });
1398
1459
  reject({
@@ -1401,9 +1462,9 @@ export var ModernElementController = /*#__PURE__*/function () {
1401
1462
  });
1402
1463
  return;
1403
1464
  }
1404
- _this7.bridge.setTarget(_this7.iframe.contentWindow);
1405
- _this7.trackHandshake('ready_handshake_received', {
1406
- m1: _this7._mountStartTime ? Date.now() - _this7._mountStartTime : 0
1465
+ _this9.bridge.setTarget(_this9.iframe.contentWindow);
1466
+ _this9.trackHandshake('ready_handshake_received', {
1467
+ m1: _this9._mountStartTime ? Date.now() - _this9._mountStartTime : 0
1407
1468
  });
1408
1469
  resolve();
1409
1470
  });
@@ -1428,12 +1489,12 @@ export var ModernElementController = /*#__PURE__*/function () {
1428
1489
  }, {
1429
1490
  key: "waitForHandshakeAck",
1430
1491
  value: function waitForHandshakeAck() {
1431
- var _this8 = this;
1492
+ var _this10 = this;
1432
1493
  return new Promise(function (resolve, reject) {
1433
1494
  var cancelDestroyCallback = function cancelDestroyCallback() {};
1434
1495
  var timer = setTimeout(function () {
1435
1496
  cancelDestroyCallback();
1436
- _this8.trackError('handshake_ack_timeout', {
1497
+ _this10.trackError('handshake_ack_timeout', {
1437
1498
  d1: String(MOUNT_TIMEOUT)
1438
1499
  });
1439
1500
  reject({
@@ -1441,15 +1502,15 @@ export var ModernElementController = /*#__PURE__*/function () {
1441
1502
  message: 'An error occurred; the transaction cannot be initiated.'
1442
1503
  });
1443
1504
  }, MOUNT_TIMEOUT);
1444
- cancelDestroyCallback = _this8.onDestroy(function () {
1505
+ cancelDestroyCallback = _this10.onDestroy(function () {
1445
1506
  clearTimeout(timer);
1446
1507
  reject(getDestroyedError());
1447
1508
  });
1448
- _this8.bridge.once(MessageType.HANDSHAKE_ACK, function () {
1509
+ _this10.bridge.once(MessageType.HANDSHAKE_ACK, function () {
1449
1510
  clearTimeout(timer);
1450
1511
  cancelDestroyCallback();
1451
- _this8.trackHandshake('handshake_ack_received', {
1452
- m1: _this8._mountStartTime ? Date.now() - _this8._mountStartTime : 0
1512
+ _this10.trackHandshake('handshake_ack_received', {
1513
+ m1: _this10._mountStartTime ? Date.now() - _this10._mountStartTime : 0
1453
1514
  });
1454
1515
  resolve();
1455
1516
  });
@@ -1459,24 +1520,24 @@ export var ModernElementController = /*#__PURE__*/function () {
1459
1520
  key: "submitPayment",
1460
1521
  value: function () {
1461
1522
  var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
1462
- var _this9 = this;
1523
+ var _this11 = this;
1463
1524
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1464
1525
  while (1) switch (_context8.prev = _context8.next) {
1465
1526
  case 0:
1466
1527
  return _context8.abrupt("return", runApi('submitPayment', function () {
1467
- return _this9.doSubmitPayment(params);
1528
+ return _this11.doSubmitPayment(params);
1468
1529
  }, function () {
1469
- return _this9.currentPaymentMethodType ? {
1470
- d4: _this9.currentPaymentMethodType
1530
+ return _this11.currentPaymentMethodType ? {
1531
+ d4: _this11.currentPaymentMethodType
1471
1532
  } : {};
1472
- }, normalizeApiInput('submitPayment', params), this.merchantId));
1533
+ }, normalizeApiInput('submitPayment', params), this.merchantId, this.productScene));
1473
1534
  case 1:
1474
1535
  case "end":
1475
1536
  return _context8.stop();
1476
1537
  }
1477
1538
  }, _callee8, this);
1478
1539
  }));
1479
- function submitPayment(_x15) {
1540
+ function submitPayment(_x16) {
1480
1541
  return _submitPayment.apply(this, arguments);
1481
1542
  }
1482
1543
  return submitPayment;
@@ -1485,7 +1546,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1485
1546
  key: "doSubmitPayment",
1486
1547
  value: function () {
1487
1548
  var _doSubmitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
1488
- var _this10 = this;
1549
+ var _this12 = this;
1489
1550
  var _this$options$loading7, _this$options$loading8, isApplePay, _ref6, onBeforeConfirm, serializableParams, startTime, _yield$executeWithTim2, shouldContinue, timedOut, isTimeout, hasBeforeConfirmForApplePay, hasAmount, hasCurrency, cleanups, _result$error5, resultPromise, result, _this$options$loading9, _this$options$loading10;
1490
1551
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1491
1552
  while (1) switch (_context9.prev = _context9.next) {
@@ -1638,20 +1699,20 @@ export var ModernElementController = /*#__PURE__*/function () {
1638
1699
  resultPromise = new Promise(function (resolve) {
1639
1700
  // 先注册事件监听,再发送 SUBMIT,避免 webapp 快速响应导致消息丢失
1640
1701
  // PC 非 Safari:webapp 委托 SDK 拉起 Apple Pay 拿 token
1641
- cleanups.push(_this10.bridge.once(AMSMessageType.GET_APPLE_PAY_TOKEN, function (payload) {
1642
- _this10.handleGetApplePayToken(payload, onBeforeConfirm).then(function () {
1702
+ cleanups.push(_this12.bridge.once(AMSMessageType.GET_APPLE_PAY_TOKEN, function (payload) {
1703
+ _this12.handleGetApplePayToken(payload, onBeforeConfirm).then(function () {
1643
1704
  // token 已回传 webapp,继续等 SUBMIT_REPLY
1644
1705
  });
1645
1706
  }));
1646
1707
  // Web element GP:webapp 委托 SDK/父 frame 调 loadPaymentData 拿 token
1647
- cleanups.push(_this10.bridge.once(AMSMessageType.GET_GOOGLE_PAY_TOKEN, function (payload) {
1648
- _this10.handleGetGooglePayToken(payload);
1708
+ cleanups.push(_this12.bridge.once(AMSMessageType.GET_GOOGLE_PAY_TOKEN, function (payload) {
1709
+ _this12.handleGetGooglePayToken(payload);
1649
1710
  }));
1650
1711
  // Safari:webapp 请求执行商户 onBeforeConfirm 回调
1651
- cleanups.push(_this10.bridge.once(AMSMessageType.BEFORE_CONFIRM, function () {
1652
- _this10.handleBeforeConfirmInternal(onBeforeConfirm || null);
1712
+ cleanups.push(_this12.bridge.once(AMSMessageType.BEFORE_CONFIRM, function () {
1713
+ _this12.handleBeforeConfirmInternal(onBeforeConfirm || null);
1653
1714
  }));
1654
- cleanups.push(_this10.bridge.once(MessageType.SUBMIT_REPLY, resolve));
1715
+ cleanups.push(_this12.bridge.once(MessageType.SUBMIT_REPLY, resolve));
1655
1716
  }); // 监听注册完成后再发送 SUBMIT,确保不会遗漏快速响应
1656
1717
  this.send(MessageType.SUBMIT, _objectSpread(_objectSpread({}, serializableParams), {}, {
1657
1718
  redirect: this.notRedirectAfterComplete ? 'if_required' : 'always',
@@ -1682,7 +1743,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1682
1743
  cleanups.forEach(function (fn) {
1683
1744
  try {
1684
1745
  fn();
1685
- } catch (_unused7) {
1746
+ } catch (_unused9) {
1686
1747
  /* ignore cleanup error */
1687
1748
  }
1688
1749
  });
@@ -1698,7 +1759,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1698
1759
  }
1699
1760
  }, _callee9, this, [[7,, 60, 63], [12, 26], [42, 52, 56, 60]]);
1700
1761
  }));
1701
- function doSubmitPayment(_x16) {
1762
+ function doSubmitPayment(_x17) {
1702
1763
  return _doSubmitPayment.apply(this, arguments);
1703
1764
  }
1704
1765
  return doSubmitPayment;
@@ -1707,13 +1768,13 @@ export var ModernElementController = /*#__PURE__*/function () {
1707
1768
  key: "validateFields",
1708
1769
  value: function () {
1709
1770
  var _validateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1710
- var _this11 = this;
1771
+ var _this13 = this;
1711
1772
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1712
1773
  while (1) switch (_context10.prev = _context10.next) {
1713
1774
  case 0:
1714
1775
  return _context10.abrupt("return", runApi('validateFields', function () {
1715
- return _this11.doValidateFields();
1716
- }, undefined, undefined, this.merchantId));
1776
+ return _this13.doValidateFields();
1777
+ }, undefined, undefined, this.merchantId, this.productScene));
1717
1778
  case 1:
1718
1779
  case "end":
1719
1780
  return _context10.stop();
@@ -1729,7 +1790,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1729
1790
  key: "doValidateFields",
1730
1791
  value: function () {
1731
1792
  var _doValidateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1732
- var _this12 = this;
1793
+ var _this14 = this;
1733
1794
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1734
1795
  while (1) switch (_context11.prev = _context11.next) {
1735
1796
  case 0:
@@ -1747,17 +1808,17 @@ export var ModernElementController = /*#__PURE__*/function () {
1747
1808
  this.send(AMSMessageType.VALIDATE);
1748
1809
  return _context11.abrupt("return", new Promise(function (resolve) {
1749
1810
  var timer = setTimeout(function () {
1750
- _this12.trackError('validate_fields_timeout', {
1811
+ _this14.trackError('validate_fields_timeout', {
1751
1812
  d1: '15000'
1752
1813
  });
1753
1814
  resolve({
1754
1815
  isValid: false
1755
1816
  });
1756
1817
  }, 15000);
1757
- _this12.bridge.once(AMSMessageType.VALIDATE_REPLY, function (payload) {
1818
+ _this14.bridge.once(AMSMessageType.VALIDATE_REPLY, function (payload) {
1758
1819
  clearTimeout(timer);
1759
1820
  var isValid = !!(payload !== null && payload !== void 0 && payload.isValid);
1760
- _this12.trackElement('validate_result', {
1821
+ _this14.trackElement('validate_result', {
1761
1822
  d1: isValid ? 'valid' : 'invalid'
1762
1823
  });
1763
1824
  resolve(payload || {
@@ -1790,7 +1851,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1790
1851
  }
1791
1852
  }, _callee12);
1792
1853
  }));
1793
- function updatePayment(_x17) {
1854
+ function updatePayment(_x18) {
1794
1855
  return _updatePayment.apply(this, arguments);
1795
1856
  }
1796
1857
  return updatePayment;
@@ -1803,16 +1864,17 @@ export var ModernElementController = /*#__PURE__*/function () {
1803
1864
  }, {
1804
1865
  key: "destroy",
1805
1866
  value: function destroy() {
1806
- var _this$iframe;
1867
+ var _this$iframe2;
1807
1868
  this.trackElement('destroy', {
1808
1869
  d1: this.status
1809
1870
  });
1810
1871
  if (this.status === 'initialized' || this.status === 'destroyed') {
1811
1872
  return;
1812
1873
  }
1874
+ this.stopModalMessageMonitor();
1813
1875
  this.handleCloseModal();
1814
1876
  this.bridge.destroy();
1815
- if ((_this$iframe = this.iframe) !== null && _this$iframe !== void 0 && _this$iframe.parentNode) this.iframe.parentNode.removeChild(this.iframe);
1877
+ if ((_this$iframe2 = this.iframe) !== null && _this$iframe2 !== void 0 && _this$iframe2.parentNode) this.iframe.parentNode.removeChild(this.iframe);
1816
1878
  this.iframe = null;
1817
1879
  this.setStatus('destroyed');
1818
1880
  this.runDestroyCallbacks();
@@ -1821,8 +1883,8 @@ export var ModernElementController = /*#__PURE__*/function () {
1821
1883
  }, {
1822
1884
  key: "cleanup",
1823
1885
  value: function cleanup() {
1824
- var _this$iframe2;
1825
- if ((_this$iframe2 = this.iframe) !== null && _this$iframe2 !== void 0 && _this$iframe2.parentNode) this.iframe.parentNode.removeChild(this.iframe);
1886
+ var _this$iframe3;
1887
+ if ((_this$iframe3 = this.iframe) !== null && _this$iframe3 !== void 0 && _this$iframe3.parentNode) this.iframe.parentNode.removeChild(this.iframe);
1826
1888
  this.iframe = null;
1827
1889
  this.setStatus('initialized');
1828
1890
  this.cachedSend = [];
@@ -1840,7 +1902,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1840
1902
  }, {
1841
1903
  key: "onDestroy",
1842
1904
  value: function onDestroy(callback) {
1843
- var _this13 = this;
1905
+ var _this15 = this;
1844
1906
  if (this.status === 'destroyed') {
1845
1907
  callback();
1846
1908
  return function () {
@@ -1849,7 +1911,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1849
1911
  }
1850
1912
  this.destroyCallbacks.push(callback);
1851
1913
  return function () {
1852
- _this13.destroyCallbacks = _this13.destroyCallbacks.filter(function (item) {
1914
+ _this15.destroyCallbacks = _this15.destroyCallbacks.filter(function (item) {
1853
1915
  return item !== callback;
1854
1916
  });
1855
1917
  };
@@ -1889,12 +1951,12 @@ export var ModernElementController = /*#__PURE__*/function () {
1889
1951
  }, {
1890
1952
  key: "flushCachedMessages",
1891
1953
  value: function flushCachedMessages() {
1892
- var _this14 = this;
1954
+ var _this16 = this;
1893
1955
  if (this.cachedSend.length > 0) {
1894
1956
  this.cachedSend.forEach(function (_ref7) {
1895
1957
  var type = _ref7.type,
1896
1958
  payload = _ref7.payload;
1897
- _this14.bridge.send(type, payload);
1959
+ _this16.bridge.send(type, payload);
1898
1960
  });
1899
1961
  this.cachedSend = [];
1900
1962
  }
@@ -1917,7 +1979,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1917
1979
  var _payload$appearance,
1918
1980
  _themeColorMap$appear,
1919
1981
  _payload$appearance2,
1920
- _this15 = this;
1982
+ _this17 = this;
1921
1983
  // 清理已存在的 modal
1922
1984
  this.handleCloseModal();
1923
1985
  var mode = device.isMobile ? 'mobile' : 'desktop';
@@ -1973,7 +2035,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1973
2035
  destroy = _openModal.destroy;
1974
2036
  var offReady = modalBridge.once(MessageType.MODAL_TRANSFER_READY, function (_payload, _ports, meta) {
1975
2037
  if (meta && meta.source !== iframe.contentWindow) return;
1976
- _this15.trackElement('modal_loaded', {
2038
+ _this17.trackElement('modal_loaded', {
1977
2039
  d1: payload.url
1978
2040
  });
1979
2041
  // 确保 target 已设置(如果 load 事件尚未触发,在此设置)
@@ -1984,7 +2046,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1984
2046
  if (iframeOrigin && iframeOrigin !== 'null') {
1985
2047
  modalBridge.setOrigin(iframeOrigin);
1986
2048
  }
1987
- } catch (_unused8) {
2049
+ } catch (_unused10) {
1988
2050
  // URL 解析失败时保持默认 origin
1989
2051
  }
1990
2052
  // 如果 payload 有 appearance,通过 TRANSFER_MODAL_APPEARANCE 消息发送给 modal
@@ -2002,13 +2064,13 @@ export var ModernElementController = /*#__PURE__*/function () {
2002
2064
  this.modalIframe = iframe;
2003
2065
  this.modalDestroy = function () {
2004
2066
  if (payload.closeConfirm) {
2005
- _this15.trackElement('modal_close_confirm', {
2067
+ _this17.trackElement('modal_close_confirm', {
2006
2068
  d1: 'confirm_resolved'
2007
2069
  });
2008
2070
  }
2009
2071
  destroy();
2010
2072
  offReady();
2011
- _this15.modalIframe = null;
2073
+ _this17.modalIframe = null;
2012
2074
  };
2013
2075
  }
2014
2076