@alipay/ams-checkout 0.0.1697942541-dev.1 → 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,110 +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, _this3$_renderParams4;
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
- notRedirectAfterComplete: ((_this3$_renderParams3 = _this3._renderParams) === null || _this3$_renderParams3 === void 0 ? void 0 : _this3$_renderParams3.notRedirectAfterComplete) === true
218
- };
219
- /**
220
- * @description card
221
- */
222
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign || componentSignEnum.VAULTING_CARD === _this3._componentSign) {
223
- params.paymentMethodType = 'CARD';
224
- }
225
- var needDeviceId = false;
226
- var waitTime = '3000';
227
- var securityConfig = (_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 || (_this3$_renderParams4 = _this3$_renderParams4.paymentSessionMetaData) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.securityConfig;
228
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign && securityConfig) {
229
- var _this3$_renderParams5;
230
- var extendInfo = ((_this3$_renderParams5 = _this3._renderParams) === null || _this3$_renderParams5 === void 0 || (_this3$_renderParams5 = _this3$_renderParams5.paymentSessionMetaData) === null || _this3$_renderParams5 === void 0 ? void 0 : _this3$_renderParams5.extendInfo) || '';
231
- var info = JSON.parse(extendInfo);
232
- if ((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false') {
233
- needDeviceId = true;
234
- waitTime = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.tokenCollectTime;
235
- }
236
- }
237
301
 
238
- /**
239
- * @description easyPay
240
- */
241
- if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
242
- var _this3$_renderParams6;
243
- var _ref2 = params.paymentSessionConfig || {},
244
- _ref2$productSceneVer = _ref2.productSceneVersion,
245
- productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
246
- _ref2$productScene = _ref2.productScene,
247
- productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
248
- var _ref3 = ((_this3$_renderParams6 = _this3._renderParams) === null || _this3$_renderParams6 === void 0 ? void 0 : _this3$_renderParams6.paymentSessionMetaData) || {},
249
- _ref3$action = _ref3.action,
250
- _ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
251
- _ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
252
- autoDebitWithToken = _ref3$action2$autoDeb === void 0 ? false : _ref3$action2$autoDeb;
253
- if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
254
- // if EASY_PAY 2.0 , no need to query payment request
255
- return resolve({
256
- message: 'sdk no need to make query request',
257
- success: true
258
- });
259
- }
260
- }
261
- /**
262
- * @author tianqiang
263
- * @description autoDebit
264
- */
265
- if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
266
- var _this3$_renderParams7, _action$web, _action$wap;
267
- var action = ((_this3$_renderParams7 = _this3._renderParams) === null || _this3$_renderParams7 === void 0 || (_this3$_renderParams7 = _this3$_renderParams7.paymentSessionMetaData) === null || _this3$_renderParams7 === void 0 ? void 0 : _this3$_renderParams7.action) || {};
268
- 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;
269
- if (signType === 'SMS') {
270
- return resolve({
271
- message: 'sdk no need to make query request',
272
- success: true
273
- });
274
- }
275
- if (!signType || signType !== 'REDIRECT') {
276
- return resolve({
277
- success: false
278
- });
279
- }
280
- }
281
-
282
- // mock
283
- if (isLocalMock()) {
284
- return resolve({
285
- message: 'sdk no need to make query request',
286
- success: true
287
- });
288
- }
289
- queryPaymentInfo(params, {
290
- env: _this3.AMSSDK.options.env.environment,
291
- locale: _this3.AMSSDK.options.locale,
292
- needDeviceId: needDeviceId,
293
- waitTime: waitTime
294
- }).then(function (res) {
295
- _this3._performanceData.push({
296
- key: 'sdk_action_query_end',
297
- value: Date.now()
298
- });
299
- if (res !== null && res !== void 0 && res.success) {
300
- resolve(res);
301
- } else {
302
- resolve(res);
303
- }
304
- }).catch(function (err) {
305
- _this3.dispatchToSDK(EVENT.error.name, {
306
- code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
307
- });
308
- reject(err);
309
- });
310
- });
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
+ }());
311
421
  return this._actionQueryPromise;
312
422
  }
313
423
  }, {
@@ -392,15 +502,11 @@ var ComponentApp = /*#__PURE__*/function () {
392
502
  }, {
393
503
  key: "listener",
394
504
  value: function listener(e) {
395
- if (e.origin !== this.appDomain) {
396
- return;
397
- }
505
+ if (e.origin !== this.appDomain) return;
398
506
  var isJson = isJsonString(e.data);
399
507
  if (isJson) {
400
508
  var data = JSON.parse(e.data);
401
- if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) {
402
- return;
403
- }
509
+ if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) return;
404
510
  this._handleAppMessage(data);
405
511
  } else {
406
512
  console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
@@ -423,7 +529,54 @@ var ComponentApp = /*#__PURE__*/function () {
423
529
  }
424
530
  });
425
531
  }
426
-
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
+ }()
427
580
  /**
428
581
  * @description Initialize subscription iframe message
429
582
  */
@@ -449,10 +602,32 @@ var ComponentApp = /*#__PURE__*/function () {
449
602
  }, {
450
603
  key: "_handleAppMessage",
451
604
  value: function _handleAppMessage(data) {
452
- 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];
453
606
  if (!eventKeyMap.includes(data.context.event)) {
454
607
  return;
455
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
+ }
456
631
  if (data.context.event === EVENT.dismissLoading.name) {
457
632
  var _data$context$data;
458
633
  this.dispatchToSDK(EVENT.eventCallback.name, {
@@ -500,6 +675,11 @@ var ComponentApp = /*#__PURE__*/function () {
500
675
  this.handleDeclareInfo(data.context.data);
501
676
  return;
502
677
  }
678
+ if (data.context.event === EVENT.eventCallback.name) {
679
+ this.AMSSDK.logger.logInfo({
680
+ title: 'sdk_event_event_callback'
681
+ }).send();
682
+ }
503
683
 
504
684
  // The plug-in communicates with the sdk after processing
505
685
  this.dispatchToSDK(data.context.event, data.context.data, data.context.eventCallbackId);
@@ -557,7 +737,7 @@ var ComponentApp = /*#__PURE__*/function () {
557
737
  }, {
558
738
  key: "handleRedirect",
559
739
  value: function handleRedirect(data) {
560
- var _this4 = this;
740
+ var _this6 = this;
561
741
  var _data = typeof data === 'string' ? {
562
742
  normalUrl: data
563
743
  } : {
@@ -566,23 +746,42 @@ var ComponentApp = /*#__PURE__*/function () {
566
746
  normalUrl: (data === null || data === void 0 ? void 0 : data.normalUrl) || '',
567
747
  target: data === null || data === void 0 ? void 0 : data.target
568
748
  };
749
+ this.AMSSDK.logger.logInfo({
750
+ title: 'sdk_event_call_url_start'
751
+ }, {
752
+ redirectInfo: JSON.stringify(_data)
753
+ }).send();
569
754
  var successCallback = function successCallback(type, url) {
570
- _this4.dispatchToSDK(EVENT.eventCallback.name, {
755
+ _this6.dispatchToSDK(EVENT.eventCallback.name, {
571
756
  code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
572
757
  message: "Successfully opened the app,".concat(type, ": ").concat(url)
573
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();
574
766
  };
575
- var failCallback = function failCallback() {
576
- _this4.dispatchToSDK(EVENT.eventCallback.name, {
767
+ var failCallback = function failCallback(type, url) {
768
+ _this6.dispatchToSDK(EVENT.eventCallback.name, {
577
769
  code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
578
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)
579
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();
580
779
  };
581
780
 
582
781
  // 支持 target: _blank,新开tab页打开
583
782
  if (_data.target === targetEnum.BLANK) {
584
- if (!_data.normalUrl) return failCallback();
585
- successCallback('normalUrl', _data.normalUrl);
783
+ if (!_data.normalUrl) return failCallback(RedirectType.NormalUrl, '');
784
+ successCallback(RedirectType.NormalUrl, _data.normalUrl);
586
785
  window.open(_data.normalUrl);
587
786
  return;
588
787
  }
@@ -590,28 +789,30 @@ var ComponentApp = /*#__PURE__*/function () {
590
789
  this.AMSSDK._redirect({
591
790
  applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
592
791
  }).then(function () {
593
- successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
792
+ successCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
594
793
  }).catch(function () {
595
- return _this4.AMSSDK._redirect({
794
+ failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
795
+ return _this6.AMSSDK._redirect({
596
796
  schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
597
797
  });
598
798
  }).then(function () {
599
- successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
799
+ successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
600
800
  }).catch(function () {
601
- return _this4.AMSSDK._redirect({
801
+ failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
802
+ return _this6.AMSSDK._redirect({
602
803
  normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
603
804
  });
604
805
  }).then(function () {
605
- successCallback('normalUrl', _data === null || _data === void 0 ? void 0 : _data.normalUrl);
806
+ successCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
606
807
  }).catch(function () {
607
- failCallback();
808
+ failCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
608
809
  });
609
810
  }
610
811
  }, {
611
812
  key: "handleDeclareInfo",
612
- value: function handleDeclareInfo(_ref4) {
613
- var _ref4$closeDialogData = _ref4.closeDialogData,
614
- 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;
615
816
  _handleDeclareInfo({
616
817
  closeDialogData: closeDialogData
617
818
  });
@@ -643,12 +844,21 @@ var ComponentApp = /*#__PURE__*/function () {
643
844
  }, {
644
845
  key: "dispatchToApp",
645
846
  value: function dispatchToApp(payload) {
847
+ var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
646
848
  var data = Object.assign({}, payload, {
647
849
  name: messageName.SDK_TO_APP,
648
850
  mode: this.AMSSDK.options.mode,
649
851
  appId: COMPONENTPLUGINID,
650
852
  instanceId: this.AMSSDK._instanceId
651
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
+ }
652
862
  if (this.app && this.app.contentWindow) {
653
863
  return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
654
864
  }
@@ -676,22 +886,22 @@ var ComponentApp = /*#__PURE__*/function () {
676
886
  }, {
677
887
  key: "sendRenderEvent",
678
888
  value: function () {
679
- var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
680
- var _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, _this$_renderParams5, _this$_renderParams6, res;
681
- return _regeneratorRuntime().wrap(function _callee$(_context) {
682
- 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) {
683
893
  case 0:
684
- _context.prev = 0;
894
+ _context4.prev = 0;
685
895
  if (this._actionQueryPromise) {
686
- _context.next = 3;
896
+ _context4.next = 3;
687
897
  break;
688
898
  }
689
- return _context.abrupt("return");
899
+ return _context4.abrupt("return");
690
900
  case 3:
691
- _context.next = 5;
901
+ _context4.next = 5;
692
902
  return this._actionQueryPromise;
693
903
  case 5:
694
- res = _context.sent;
904
+ res = _context4.sent;
695
905
  this._performanceData.push({
696
906
  key: 'sdk_render_component',
697
907
  value: Date.now()
@@ -701,12 +911,12 @@ var ComponentApp = /*#__PURE__*/function () {
701
911
  event: 'renderComponent',
702
912
  data: {
703
913
  queryResult: res,
704
- sessionResult: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionMetaData,
705
- 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,
706
916
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
707
- renderDisplayType: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.renderDisplayType,
708
- appearance: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.appearance,
709
- 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,
710
920
  envInfo: {
711
921
  screenHeight: screen.height,
712
922
  screenWidth: screen.width
@@ -723,16 +933,16 @@ var ComponentApp = /*#__PURE__*/function () {
723
933
  }
724
934
  });
725
935
  // eslint-disable-next-line no-empty
726
- _context.next = 13;
936
+ _context4.next = 13;
727
937
  break;
728
938
  case 11:
729
- _context.prev = 11;
730
- _context.t0 = _context["catch"](0);
939
+ _context4.prev = 11;
940
+ _context4.t0 = _context4["catch"](0);
731
941
  case 13:
732
942
  case "end":
733
- return _context.stop();
943
+ return _context4.stop();
734
944
  }
735
- }, _callee, this, [[0, 11]]);
945
+ }, _callee4, this, [[0, 11]]);
736
946
  }));
737
947
  function sendRenderEvent() {
738
948
  return _sendRenderEvent.apply(this, arguments);
@@ -746,7 +956,7 @@ var ComponentApp = /*#__PURE__*/function () {
746
956
  key: "cleanContainer",
747
957
  value: function cleanContainer() {
748
958
  var _document$getElementB4,
749
- _this5 = this;
959
+ _this7 = this;
750
960
  var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
751
961
  this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
752
962
  this._performanceData = [];
@@ -758,7 +968,7 @@ var ComponentApp = /*#__PURE__*/function () {
758
968
  mockup === null || mockup === void 0 || mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
759
969
  if (immediately) this.cleanElement();else {
760
970
  setTimeout(function () {
761
- _this5.cleanElement();
971
+ _this7.cleanElement();
762
972
  }, 300);
763
973
  }
764
974
  }