@alipay/ams-checkout 0.0.1697942541-dev.0 → 0.0.1697942541-dev.10

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.
@@ -16,21 +16,17 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
16
16
  */
17
17
  /* eslint-disable no-console */
18
18
  /* eslint-disable @typescript-eslint/no-explicit-any */
19
+ import { marmotMap } from "../../config/index";
19
20
  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
21
  import { queryPaymentInfo } from "../../service";
21
- import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
22
- import { getType, isJsonString, isPC, queryParse } from "../../util";
22
+ import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, SecuritySceneEnum, targetEnum, RedirectType } from "../../types";
23
+ import { getType, isJsonString, isPC } from "../../util";
23
24
  import { isLocalMock } from "../../util/mock";
25
+ import { getApdidToken, getAppname, getSecurityHost, initSecuritySDK } from "../../util/security";
24
26
  import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
25
27
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
26
28
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
27
- import APDID from '@alipay/jshield-apdid';
28
- import { getSecurityHost, getAppname } from "../../util/security";
29
- var _ref = queryParse() || {},
30
- preinit = _ref.preinit,
31
- rebuild = _ref.rebuild,
32
- scene = _ref.scene,
33
- region = _ref.region;
29
+ import { createModal, destroyModal, insertStyleSheet } from "./popupWindow.style";
34
30
  window.changingPageHeight = window.innerHeight;
35
31
  var ComponentApp = /*#__PURE__*/function () {
36
32
  function ComponentApp() {
@@ -41,6 +37,8 @@ var ComponentApp = /*#__PURE__*/function () {
41
37
  _defineProperty(this, "_performanceData", []);
42
38
  _defineProperty(this, "_loadAppPromiseResolve", null);
43
39
  _defineProperty(this, "_isInitComponent", void 0);
40
+ _defineProperty(this, "_threedData", void 0);
41
+ _defineProperty(this, "popupWindow", void 0);
44
42
  _defineProperty(this, "appDomain", void 0);
45
43
  _defineProperty(this, "createIframeNode", void 0);
46
44
  _defineProperty(this, "_selector", void 0);
@@ -84,6 +82,29 @@ var ComponentApp = /*#__PURE__*/function () {
84
82
  this.AMSSDK = AMSSDK;
85
83
  this.subscribeFromSDK();
86
84
  }
85
+ }, {
86
+ key: "initLoggerMeta",
87
+ value: function initLoggerMeta() {
88
+ var _this$_renderParams, _paymentSessionMetaDa;
89
+ console.log('this._renderParams', JSON.stringify(this._renderParams), null, 3);
90
+ var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
91
+ var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
92
+ this.AMSSDK.logger.setMedta({
93
+ platform: this.platform === platformEnum.desktop ? 'PC' : 'WAP',
94
+ // PC/WAP,
95
+ sdkVersion: this._appVersion,
96
+ instanceId: this.AMSSDK._instanceId,
97
+ storageId: this.AMSSDK._storageId,
98
+ // the better way to use md5 paymentSesionID
99
+ renderDisplayType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 ? void 0 : paymentSessionMetaData.renderDisplayType,
100
+ merchantId: paymentSessionMetaData === null || paymentSessionMetaData === void 0 ? void 0 : paymentSessionMetaData.clientId,
101
+ productScene: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productScene,
102
+ productSceneVersion: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productSceneVersion,
103
+ paymentMethodType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType,
104
+ paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType
105
+ });
106
+ this.AMSSDK.logger.setComponentStartTime(Date.now());
107
+ }
87
108
 
88
109
  /**
89
110
  * @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
@@ -96,24 +117,84 @@ var ComponentApp = /*#__PURE__*/function () {
96
117
  }, {
97
118
  key: "initAPSecurity",
98
119
  value: function initAPSecurity() {
99
- var _this$_renderParams;
120
+ var _this$_renderParams2,
121
+ _this = this;
100
122
  if (componentSignEnum.CASHIER_PAYMENT_CARD !== this._componentSign) {
101
123
  return;
102
124
  }
103
- var securityConfig = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 || (_this$_renderParams = _this$_renderParams.paymentSessionMetaData) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.securityConfig;
125
+ 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;
104
126
  if (!securityConfig) {
105
127
  return;
106
128
  }
107
129
  var appName = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName;
108
130
  var h5gateway = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway;
109
- if (preinit === 'true' || rebuild === 'true') {
110
- appName = getAppname(scene);
111
- h5gateway = getSecurityHost(region);
112
- }
113
- APDID.initToken(appName, {
114
- host: h5gateway
115
- }, function (success, tokenResult, msg) {
116
- console.log("initToken result tokenResult", JSON.stringify(tokenResult));
131
+
132
+ // if merchant have init securitySDK and same as service paymentSessionMetaData, no need init again
133
+ if (this.AMSSDK.securityConfig) {
134
+ if (appName === getAppname(this.AMSSDK.securityConfig.scene) && h5gateway === getSecurityHost(this.AMSSDK.securityConfig.region)) {
135
+ return;
136
+ }
137
+ }
138
+ this.AMSSDK.logger.logInfo({
139
+ title: 'sdk_event_securitySdkInit'
140
+ });
141
+ initSecuritySDK(appName, h5gateway, function () {
142
+ _this.AMSSDK.logger.logInfo({
143
+ title: 'sdk_event_securitySdkInitSuccess'
144
+ });
145
+ }, function () {
146
+ // TODO Distinguishing Call Scenarios of Security SDK Failures
147
+ _this.AMSSDK.logger.logError({
148
+ title: 'sdk_error_securitySdkInitFailed'
149
+ });
150
+ });
151
+ }
152
+ }, {
153
+ key: "logDeviceId",
154
+ value: function logDeviceId(deviceId, getDeviceIdStartTime) {
155
+ var time = "".concat(Date.now() - getDeviceIdStartTime);
156
+ if (deviceId) {
157
+ this.AMSSDK.logger.logInfo({
158
+ title: 'sdk_event_securitySdkGetTokenSuccess'
159
+ }, {
160
+ deviceId: deviceId,
161
+ time: time
162
+ }).send();
163
+ } else {
164
+ this.AMSSDK.logger.logInfo({
165
+ title: 'sdk_error_securitySdkGetTokenFailed'
166
+ }, {
167
+ deviceId: deviceId,
168
+ time: time
169
+ }).send();
170
+ }
171
+ }
172
+ }, {
173
+ key: "getDeviceIdAndLog",
174
+ value: function getDeviceIdAndLog() {
175
+ var _this2 = this;
176
+ return new Promise(function (resolve) {
177
+ // To avoid rendering being blocked, move the logic to the next event loop for processing
178
+ setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
179
+ var _this2$_renderParams;
180
+ var securityConfig, getDeviceIdStartTime, deviceId;
181
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
182
+ while (1) switch (_context.prev = _context.next) {
183
+ case 0:
184
+ 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
+ getDeviceIdStartTime = Date.now();
186
+ _context.next = 4;
187
+ return getApdidToken(getAppname(SecuritySceneEnum.CARD), securityConfig);
188
+ case 4:
189
+ deviceId = _context.sent;
190
+ _this2.logDeviceId(deviceId, getDeviceIdStartTime);
191
+ resolve(deviceId);
192
+ case 7:
193
+ case "end":
194
+ return _context.stop();
195
+ }
196
+ }, _callee);
197
+ })), 0);
117
198
  });
118
199
  }
119
200
 
@@ -123,7 +204,7 @@ var ComponentApp = /*#__PURE__*/function () {
123
204
  }, {
124
205
  key: "appendIframeNodes",
125
206
  value: function appendIframeNodes(componentSign, renderParams) {
126
- var _this = this;
207
+ var _this3 = this;
127
208
  if (this._isInitComponent) {
128
209
  this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
129
210
  return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
@@ -135,6 +216,7 @@ var ComponentApp = /*#__PURE__*/function () {
135
216
  this._renderDisplayType = renderParams.renderDisplayType;
136
217
  var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
137
218
  this.initAPSecurity();
219
+ this.initLoggerMeta();
138
220
  this._performanceData.push({
139
221
  key: 'sdk_create_component',
140
222
  value: Date.now()
@@ -145,6 +227,7 @@ var ComponentApp = /*#__PURE__*/function () {
145
227
  if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
146
228
  var container = createInlineBaseElement(this._selector);
147
229
  if (container) this.renderInlineLoading(renderParams, container);
230
+ insertStyleSheet();
148
231
  }
149
232
  if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
150
233
  createBaseElement(this.platform, this.closeBtnFunc.bind(this));
@@ -154,10 +237,13 @@ var ComponentApp = /*#__PURE__*/function () {
154
237
  }
155
238
  this.createApp(renderParams);
156
239
  return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
240
+ _this3.AMSSDK.logger.logInfo({
241
+ title: 'sdk_event_successfully_created_app_process'
242
+ }).send();
157
243
  return Promise.resolve();
158
244
  }).catch(function (error) {
159
- _this._isInitComponent = false;
160
- _this.cleanContainer();
245
+ _this3._isInitComponent = false;
246
+ _this3.cleanContainer();
161
247
  return Promise.reject(error);
162
248
  });
163
249
  }
@@ -183,17 +269,20 @@ var ComponentApp = /*#__PURE__*/function () {
183
269
  }, {
184
270
  key: "_createLoadAppPromise",
185
271
  value: function _createLoadAppPromise() {
186
- var _this2 = this;
272
+ var _this4 = this;
187
273
  return new Promise(function (resolve, reject) {
188
- _this2._loadAppPromiseResolve = resolve;
274
+ _this4._loadAppPromiseResolve = resolve;
189
275
  setTimeout(function () {
190
276
  reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
191
277
  }, LOADTIME_LIMIT);
192
278
  }).catch(function (error) {
193
- _this2.dispatchToSDK(EVENT.error.name, {
279
+ _this4.dispatchToSDK(EVENT.error.name, {
194
280
  code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
195
281
  message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
196
282
  });
283
+ _this4.AMSSDK.logger.logError({
284
+ title: 'sdk_error_web_app_timeout'
285
+ }).send();
197
286
  return Promise.reject(error);
198
287
  });
199
288
  }
@@ -204,109 +293,131 @@ var ComponentApp = /*#__PURE__*/function () {
204
293
  }, {
205
294
  key: "createActionQueryPromise",
206
295
  value: function createActionQueryPromise() {
207
- var _this3 = this;
296
+ var _this5 = this;
208
297
  this._performanceData.push({
209
298
  key: 'sdk_action_query_start',
210
299
  value: Date.now()
211
300
  });
212
- this._actionQueryPromise = new Promise(function (resolve, reject) {
213
- var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
214
- var params = {
215
- paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.sessionData) || '',
216
- paymentSessionConfig: (_this3$_renderParams2 = _this3._renderParams) === null || _this3$_renderParams2 === void 0 || (_this3$_renderParams2 = _this3$_renderParams2.paymentSessionMetaData) === null || _this3$_renderParams2 === void 0 ? void 0 : _this3$_renderParams2.paymentSessionConfig
217
- };
218
- /**
219
- * @description card
220
- */
221
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign || componentSignEnum.VAULTING_CARD === _this3._componentSign) {
222
- params.paymentMethodType = 'CARD';
223
- }
224
- var needDeviceId = false;
225
- var waitTime = '3000';
226
- var securityConfig = (_this3$_renderParams3 = _this3._renderParams) === null || _this3$_renderParams3 === void 0 || (_this3$_renderParams3 = _this3$_renderParams3.paymentSessionMetaData) === null || _this3$_renderParams3 === void 0 ? void 0 : _this3$_renderParams3.securityConfig;
227
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign && securityConfig) {
228
- var _this3$_renderParams4;
229
- var extendInfo = ((_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 || (_this3$_renderParams4 = _this3$_renderParams4.paymentSessionMetaData) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.extendInfo) || '';
230
- var info = JSON.parse(extendInfo);
231
- if ((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false') {
232
- needDeviceId = true;
233
- waitTime = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.tokenCollectTime;
234
- }
235
- }
236
301
 
237
- /**
238
- * @description easyPay
239
- */
240
- if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
241
- var _this3$_renderParams5;
242
- var _ref2 = params.paymentSessionConfig || {},
243
- _ref2$productSceneVer = _ref2.productSceneVersion,
244
- productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
245
- _ref2$productScene = _ref2.productScene,
246
- productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
247
- var _ref3 = ((_this3$_renderParams5 = _this3._renderParams) === null || _this3$_renderParams5 === void 0 ? void 0 : _this3$_renderParams5.paymentSessionMetaData) || {},
248
- _ref3$action = _ref3.action,
249
- _ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
250
- _ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
251
- autoDebitWithToken = _ref3$action2$autoDeb === void 0 ? false : _ref3$action2$autoDeb;
252
- if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
253
- // if EASY_PAY 2.0 , no need to query payment request
254
- return resolve({
255
- message: 'sdk no need to make query request',
256
- success: true
257
- });
258
- }
259
- }
260
- /**
261
- * @author tianqiang
262
- * @description autoDebit
263
- */
264
- if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
265
- var _this3$_renderParams6, _action$web, _action$wap;
266
- var action = ((_this3$_renderParams6 = _this3._renderParams) === null || _this3$_renderParams6 === void 0 || (_this3$_renderParams6 = _this3$_renderParams6.paymentSessionMetaData) === null || _this3$_renderParams6 === void 0 ? void 0 : _this3$_renderParams6.action) || {};
267
- var 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;
268
- if (signType === 'SMS') {
269
- return resolve({
270
- message: 'sdk no need to make query request',
271
- success: true
272
- });
273
- }
274
- if (!signType || signType !== 'REDIRECT') {
275
- return resolve({
276
- success: false
277
- });
278
- }
279
- }
280
-
281
- // mock
282
- if (isLocalMock()) {
283
- return resolve({
284
- message: 'sdk no need to make query request',
285
- success: true
286
- });
287
- }
288
- queryPaymentInfo(params, {
289
- env: _this3.AMSSDK.options.env.environment,
290
- locale: _this3.AMSSDK.options.locale,
291
- needDeviceId: needDeviceId,
292
- waitTime: waitTime
293
- }).then(function (res) {
294
- _this3._performanceData.push({
295
- key: 'sdk_action_query_end',
296
- value: Date.now()
297
- });
298
- if (res !== null && res !== void 0 && res.success) {
299
- resolve(res);
300
- } else {
301
- resolve(res);
302
- }
303
- }).catch(function (err) {
304
- _this3.dispatchToSDK(EVENT.error.name, {
305
- code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
306
- });
307
- reject(err);
308
- });
309
- });
302
+ // eslint-disable-next-line no-async-promise-executor
303
+ this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
304
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
305
+ var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
306
+ 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;
307
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
308
+ while (1) switch (_context2.prev = _context2.next) {
309
+ case 0:
310
+ envInfo = {
311
+ locale: _this5.AMSSDK.options.locale
312
+ };
313
+ params = {
314
+ paymentSessionData: _this5._renderParams && ((_this5$_renderParams = _this5._renderParams) === null || _this5$_renderParams === void 0 ? void 0 : _this5$_renderParams.sessionData) || '',
315
+ paymentSessionConfig: (_this5$_renderParams2 = _this5._renderParams) === null || _this5$_renderParams2 === void 0 || (_this5$_renderParams2 = _this5$_renderParams2.paymentSessionMetaData) === null || _this5$_renderParams2 === void 0 ? void 0 : _this5$_renderParams2.paymentSessionConfig,
316
+ notRedirectAfterComplete: ((_this5$_renderParams3 = _this5._renderParams) === null || _this5$_renderParams3 === void 0 ? void 0 : _this5$_renderParams3.notRedirectAfterComplete) === true
317
+ };
318
+ /**
319
+ * @description card
320
+ */
321
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign) {
322
+ params.paymentMethodType = 'CARD';
323
+ }
324
+ 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;
325
+ if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign && securityConfig)) {
326
+ _context2.next = 11;
327
+ break;
328
+ }
329
+ 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) || '{}';
330
+ info = JSON.parse(extendInfo);
331
+ if (!((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false')) {
332
+ _context2.next = 11;
333
+ break;
334
+ }
335
+ _context2.next = 10;
336
+ return _this5.getDeviceIdAndLog();
337
+ case 10:
338
+ envInfo.deviceId = _context2.sent;
339
+ case 11:
340
+ if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
341
+ _context2.next = 16;
342
+ break;
343
+ }
344
+ _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;
345
+ _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;
346
+ if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
347
+ _context2.next = 16;
348
+ break;
349
+ }
350
+ return _context2.abrupt("return", resolve({
351
+ message: 'sdk no need to make query request',
352
+ success: true
353
+ }));
354
+ case 16:
355
+ if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
356
+ _context2.next = 23;
357
+ break;
358
+ }
359
+ 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) || {};
360
+ 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;
361
+ if (!(signType === 'SMS')) {
362
+ _context2.next = 21;
363
+ break;
364
+ }
365
+ return _context2.abrupt("return", resolve({
366
+ message: 'sdk no need to make query request',
367
+ success: true
368
+ }));
369
+ case 21:
370
+ if (!(!signType || signType !== 'REDIRECT')) {
371
+ _context2.next = 23;
372
+ break;
373
+ }
374
+ return _context2.abrupt("return", resolve({
375
+ success: false
376
+ }));
377
+ case 23:
378
+ if (!isLocalMock()) {
379
+ _context2.next = 25;
380
+ break;
381
+ }
382
+ return _context2.abrupt("return", resolve({
383
+ message: 'sdk no need to make query request',
384
+ success: true
385
+ }));
386
+ case 25:
387
+ queryPaymentInfo(params, {
388
+ env: _this5.AMSSDK.options.env.environment,
389
+ envInfo: envInfo
390
+ }, _this5.AMSSDK.logger).then(function (res) {
391
+ _this5._performanceData.push({
392
+ key: 'sdk_action_query_end',
393
+ value: Date.now()
394
+ });
395
+ if (res !== null && res !== void 0 && res.success) {
396
+ resolve(res);
397
+ } else {
398
+ resolve(res);
399
+ }
400
+ }).catch(function (err) {
401
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign) {
402
+ return resolve({
403
+ success: false
404
+ });
405
+ }
406
+ _this5.dispatchToSDK(EVENT.error.name, {
407
+ code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
408
+ });
409
+ reject(err);
410
+ });
411
+ case 26:
412
+ case "end":
413
+ return _context2.stop();
414
+ }
415
+ }, _callee2);
416
+ }));
417
+ return function (_x, _x2) {
418
+ return _ref2.apply(this, arguments);
419
+ };
420
+ }());
310
421
  return this._actionQueryPromise;
311
422
  }
312
423
  }, {
@@ -391,15 +502,11 @@ var ComponentApp = /*#__PURE__*/function () {
391
502
  }, {
392
503
  key: "listener",
393
504
  value: function listener(e) {
394
- if (e.origin !== this.appDomain) {
395
- return;
396
- }
505
+ if (e.origin !== this.appDomain) return;
397
506
  var isJson = isJsonString(e.data);
398
507
  if (isJson) {
399
508
  var data = JSON.parse(e.data);
400
- if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) {
401
- return;
402
- }
509
+ if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) return;
403
510
  this._handleAppMessage(data);
404
511
  } else {
405
512
  console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
@@ -422,7 +529,54 @@ var ComponentApp = /*#__PURE__*/function () {
422
529
  }
423
530
  });
424
531
  }
425
-
532
+ }, {
533
+ key: "createPopupWindow",
534
+ value: function createPopupWindow(data) {
535
+ var _this$_renderParams3;
536
+ this._threedData = data;
537
+ var sessionData = encodeURIComponent((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData);
538
+ var threedPageUrl = "".concat(marmotMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&instanceId=").concat(this.AMSSDK._instanceId);
539
+ this.popupWindow = createModal({
540
+ device: this.platform,
541
+ url: threedPageUrl
542
+ });
543
+ }
544
+ }, {
545
+ key: "getDeviceIdAndCallback",
546
+ value: function () {
547
+ var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(eventContext) {
548
+ var deviceId;
549
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
550
+ while (1) switch (_context3.prev = _context3.next) {
551
+ case 0:
552
+ if (!(eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId)) {
553
+ _context3.next = 5;
554
+ break;
555
+ }
556
+ _context3.next = 3;
557
+ return this.getDeviceIdAndLog();
558
+ case 3:
559
+ deviceId = _context3.sent;
560
+ this.dispatchToApp({
561
+ context: {
562
+ event: 'appEventCallback',
563
+ eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
564
+ data: {
565
+ deviceId: deviceId
566
+ }
567
+ }
568
+ });
569
+ case 5:
570
+ case "end":
571
+ return _context3.stop();
572
+ }
573
+ }, _callee3, this);
574
+ }));
575
+ function getDeviceIdAndCallback(_x3) {
576
+ return _getDeviceIdAndCallback.apply(this, arguments);
577
+ }
578
+ return getDeviceIdAndCallback;
579
+ }()
426
580
  /**
427
581
  * @description Initialize subscription iframe message
428
582
  */
@@ -448,10 +602,32 @@ var ComponentApp = /*#__PURE__*/function () {
448
602
  }, {
449
603
  key: "_handleAppMessage",
450
604
  value: function _handleAppMessage(data) {
451
- 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];
605
+ 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];
452
606
  if (!eventKeyMap.includes(data.context.event)) {
453
607
  return;
454
608
  }
609
+ if (data.context.event === EVENT.getDeviceId.name) {
610
+ this.getDeviceIdAndCallback(data.context);
611
+ return;
612
+ }
613
+ if (data.context.event === EVENT.closePopup.name) {
614
+ destroyModal();
615
+ return;
616
+ }
617
+ if (data.context.event === EVENT.threedReady.name) {
618
+ this.dispatchToApp({
619
+ context: {
620
+ event: 'renderThreedPage',
621
+ data: this._threedData
622
+ }
623
+ }, this.popupWindow);
624
+ return;
625
+ }
626
+ if (data.context.event === EVENT.popupWindow.name) {
627
+ var _data$context;
628
+ this.createPopupWindow((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
629
+ return;
630
+ }
455
631
  if (data.context.event === EVENT.dismissLoading.name) {
456
632
  var _data$context$data;
457
633
  this.dispatchToSDK(EVENT.eventCallback.name, {
@@ -499,6 +675,11 @@ var ComponentApp = /*#__PURE__*/function () {
499
675
  this.handleDeclareInfo(data.context.data);
500
676
  return;
501
677
  }
678
+ if (data.context.event === EVENT.eventCallback.name) {
679
+ this.AMSSDK.logger.logInfo({
680
+ title: 'sdk_event_event_callback'
681
+ }).send();
682
+ }
502
683
 
503
684
  // The plug-in communicates with the sdk after processing
504
685
  this.dispatchToSDK(data.context.event, data.context.data, data.context.eventCallbackId);
@@ -556,7 +737,7 @@ var ComponentApp = /*#__PURE__*/function () {
556
737
  }, {
557
738
  key: "handleRedirect",
558
739
  value: function handleRedirect(data) {
559
- var _this4 = this;
740
+ var _this6 = this;
560
741
  var _data = typeof data === 'string' ? {
561
742
  normalUrl: data
562
743
  } : {
@@ -565,23 +746,42 @@ var ComponentApp = /*#__PURE__*/function () {
565
746
  normalUrl: (data === null || data === void 0 ? void 0 : data.normalUrl) || '',
566
747
  target: data === null || data === void 0 ? void 0 : data.target
567
748
  };
749
+ this.AMSSDK.logger.logInfo({
750
+ title: 'sdk_event_call_url_start'
751
+ }, {
752
+ redirectInfo: JSON.stringify(_data)
753
+ }).send();
568
754
  var successCallback = function successCallback(type, url) {
569
- _this4.dispatchToSDK(EVENT.eventCallback.name, {
755
+ _this6.dispatchToSDK(EVENT.eventCallback.name, {
570
756
  code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
571
757
  message: "Successfully opened the app,".concat(type, ": ").concat(url)
572
758
  });
759
+ _this6.AMSSDK.logger.logInfo({
760
+ title: 'sdk_event_call_url_success'
761
+ }, {
762
+ redirectInfo: JSON.stringify(_data),
763
+ openType: type,
764
+ url: url
765
+ }).send();
573
766
  };
574
- var failCallback = function failCallback() {
575
- _this4.dispatchToSDK(EVENT.eventCallback.name, {
767
+ var failCallback = function failCallback(type, url) {
768
+ _this6.dispatchToSDK(EVENT.eventCallback.name, {
576
769
  code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
577
770
  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)
578
771
  });
772
+ _this6.AMSSDK.logger.logInfo({
773
+ title: 'sdk_error_call_url_failed'
774
+ }, {
775
+ redirectInfo: JSON.stringify(_data),
776
+ openType: type,
777
+ url: url
778
+ }).send();
579
779
  };
580
780
 
581
781
  // 支持 target: _blank,新开tab页打开
582
782
  if (_data.target === targetEnum.BLANK) {
583
- if (!_data.normalUrl) return failCallback();
584
- successCallback('normalUrl', _data.normalUrl);
783
+ if (!_data.normalUrl) return failCallback(RedirectType.NormalUrl, '');
784
+ successCallback(RedirectType.NormalUrl, _data.normalUrl);
585
785
  window.open(_data.normalUrl);
586
786
  return;
587
787
  }
@@ -589,28 +789,30 @@ var ComponentApp = /*#__PURE__*/function () {
589
789
  this.AMSSDK._redirect({
590
790
  applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
591
791
  }).then(function () {
592
- successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
792
+ successCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
593
793
  }).catch(function () {
594
- return _this4.AMSSDK._redirect({
794
+ failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
795
+ return _this6.AMSSDK._redirect({
595
796
  schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
596
797
  });
597
798
  }).then(function () {
598
- successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
799
+ successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
599
800
  }).catch(function () {
600
- return _this4.AMSSDK._redirect({
801
+ failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
802
+ return _this6.AMSSDK._redirect({
601
803
  normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
602
804
  });
603
805
  }).then(function () {
604
- successCallback('normalUrl', _data === null || _data === void 0 ? void 0 : _data.normalUrl);
806
+ successCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
605
807
  }).catch(function () {
606
- failCallback();
808
+ failCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
607
809
  });
608
810
  }
609
811
  }, {
610
812
  key: "handleDeclareInfo",
611
- value: function handleDeclareInfo(_ref4) {
612
- var _ref4$closeDialogData = _ref4.closeDialogData,
613
- closeDialogData = _ref4$closeDialogData === void 0 ? {} : _ref4$closeDialogData;
813
+ value: function handleDeclareInfo(_ref5) {
814
+ var _ref5$closeDialogData = _ref5.closeDialogData,
815
+ closeDialogData = _ref5$closeDialogData === void 0 ? {} : _ref5$closeDialogData;
614
816
  _handleDeclareInfo({
615
817
  closeDialogData: closeDialogData
616
818
  });
@@ -642,12 +844,21 @@ var ComponentApp = /*#__PURE__*/function () {
642
844
  }, {
643
845
  key: "dispatchToApp",
644
846
  value: function dispatchToApp(payload) {
847
+ var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
645
848
  var data = Object.assign({}, payload, {
646
849
  name: messageName.SDK_TO_APP,
647
850
  mode: this.AMSSDK.options.mode,
648
851
  appId: COMPONENTPLUGINID,
649
852
  instanceId: this.AMSSDK._instanceId
650
853
  });
854
+ this.AMSSDK.logger.logInfo({
855
+ title: 'sdk_event_send_message_to_web'
856
+ }, {
857
+ event: data === null || data === void 0 ? void 0 : data.context.event
858
+ }).send();
859
+ if (targetElement && targetElement.contentWindow) {
860
+ return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
861
+ }
651
862
  if (this.app && this.app.contentWindow) {
652
863
  return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
653
864
  }
@@ -675,22 +886,22 @@ var ComponentApp = /*#__PURE__*/function () {
675
886
  }, {
676
887
  key: "sendRenderEvent",
677
888
  value: function () {
678
- var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
679
- var _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, _this$_renderParams5, _this$_renderParams6, res;
680
- return _regeneratorRuntime().wrap(function _callee$(_context) {
681
- while (1) switch (_context.prev = _context.next) {
889
+ var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
890
+ var _this$_renderParams4, _this$_renderParams5, _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, res;
891
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
892
+ while (1) switch (_context4.prev = _context4.next) {
682
893
  case 0:
683
- _context.prev = 0;
894
+ _context4.prev = 0;
684
895
  if (this._actionQueryPromise) {
685
- _context.next = 3;
896
+ _context4.next = 3;
686
897
  break;
687
898
  }
688
- return _context.abrupt("return");
899
+ return _context4.abrupt("return");
689
900
  case 3:
690
- _context.next = 5;
901
+ _context4.next = 5;
691
902
  return this._actionQueryPromise;
692
903
  case 5:
693
- res = _context.sent;
904
+ res = _context4.sent;
694
905
  this._performanceData.push({
695
906
  key: 'sdk_render_component',
696
907
  value: Date.now()
@@ -700,12 +911,12 @@ var ComponentApp = /*#__PURE__*/function () {
700
911
  event: 'renderComponent',
701
912
  data: {
702
913
  queryResult: res,
703
- sessionResult: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionMetaData,
704
- paymentSessionData: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData,
914
+ sessionResult: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionMetaData,
915
+ paymentSessionData: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData,
705
916
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
706
- renderDisplayType: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.renderDisplayType,
707
- appearance: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.appearance,
708
- notRedirectAfterComplete: ((_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.notRedirectAfterComplete) === true,
917
+ renderDisplayType: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.renderDisplayType,
918
+ appearance: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.appearance,
919
+ notRedirectAfterComplete: ((_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.notRedirectAfterComplete) === true,
709
920
  envInfo: {
710
921
  screenHeight: screen.height,
711
922
  screenWidth: screen.width
@@ -722,16 +933,16 @@ var ComponentApp = /*#__PURE__*/function () {
722
933
  }
723
934
  });
724
935
  // eslint-disable-next-line no-empty
725
- _context.next = 13;
936
+ _context4.next = 13;
726
937
  break;
727
938
  case 11:
728
- _context.prev = 11;
729
- _context.t0 = _context["catch"](0);
939
+ _context4.prev = 11;
940
+ _context4.t0 = _context4["catch"](0);
730
941
  case 13:
731
942
  case "end":
732
- return _context.stop();
943
+ return _context4.stop();
733
944
  }
734
- }, _callee, this, [[0, 11]]);
945
+ }, _callee4, this, [[0, 11]]);
735
946
  }));
736
947
  function sendRenderEvent() {
737
948
  return _sendRenderEvent.apply(this, arguments);
@@ -745,7 +956,7 @@ var ComponentApp = /*#__PURE__*/function () {
745
956
  key: "cleanContainer",
746
957
  value: function cleanContainer() {
747
958
  var _document$getElementB4,
748
- _this5 = this;
959
+ _this7 = this;
749
960
  var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
750
961
  this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
751
962
  this._performanceData = [];
@@ -757,7 +968,7 @@ var ComponentApp = /*#__PURE__*/function () {
757
968
  mockup === null || mockup === void 0 || mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
758
969
  if (immediately) this.cleanElement();else {
759
970
  setTimeout(function () {
760
- _this5.cleanElement();
971
+ _this7.cleanElement();
761
972
  }, 300);
762
973
  }
763
974
  }