@alipay/ams-checkout 0.0.1697942541-dev.4 → 0.0.1697942541-dev.6

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,23 +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 APDID from '@alipay/jshield-apdid';
20
- import { marmptMap } from "../../config/index";
19
+ import { marmotMap } from "../../config/index";
21
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";
22
21
  import { queryPaymentInfo } from "../../service";
23
- import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
24
- import { getType, isJsonString, isPC, queryParse } from "../../util";
22
+ import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, SecuritySceneEnum, targetEnum } from "../../types";
23
+ import { getType, isJsonString, isPC } from "../../util";
25
24
  import { isLocalMock } from "../../util/mock";
26
- import { getAppname, getSecurityHost } from "../../util/security";
25
+ import { getApdidToken, getAppname, getSecurityHost, initSecuritySDK } from "../../util/security";
27
26
  import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
28
27
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
29
28
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
30
- import { createModal, insertStyleSheet, destroyModal } from "./popupWindow.style";
31
- var _ref = queryParse() || {},
32
- preinit = _ref.preinit,
33
- rebuild = _ref.rebuild,
34
- scene = _ref.scene,
35
- region = _ref.region;
29
+ import { createModal, destroyModal, insertStyleSheet } from "./popupWindow.style";
36
30
  window.changingPageHeight = window.innerHeight;
37
31
  var ComponentApp = /*#__PURE__*/function () {
38
32
  function ComponentApp() {
@@ -88,6 +82,29 @@ var ComponentApp = /*#__PURE__*/function () {
88
82
  this.AMSSDK = AMSSDK;
89
83
  this.subscribeFromSDK();
90
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
+ }
91
108
 
92
109
  /**
93
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
@@ -100,24 +117,86 @@ var ComponentApp = /*#__PURE__*/function () {
100
117
  }, {
101
118
  key: "initAPSecurity",
102
119
  value: function initAPSecurity() {
103
- var _this$_renderParams;
120
+ var _this$_renderParams2,
121
+ _this = this;
104
122
  if (componentSignEnum.CASHIER_PAYMENT_CARD !== this._componentSign) {
105
123
  return;
106
124
  }
107
- 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;
108
126
  if (!securityConfig) {
109
127
  return;
110
128
  }
111
129
  var appName = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName;
112
130
  var h5gateway = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway;
113
- if (preinit === 'true' || rebuild === 'true') {
114
- appName = getAppname(scene);
115
- h5gateway = getSecurityHost(region);
116
- }
117
- APDID.initToken(appName, {
118
- host: h5gateway
119
- }, function (success, tokenResult, msg) {
120
- 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.sence) && h5gateway === getSecurityHost(this.AMSSDK.securityConfig.region)) {
135
+ console.log("-----------Risk control project test: \u5DF2\u7ECF\u4E3B\u52A8\u521D\u59CB\u5316\uFF0C\u4E14\u914D\u7F6E\u4E0EsecurityConfig\u4E00\u81F4");
136
+ return;
137
+ }
138
+ console.log("-----------Risk control project test: \u5DF2\u7ECF\u4E3B\u52A8\u521D\u59CB\u5316\uFF0C\u4E0EsecurityConfig\u914D\u7F6E\u4E0D\u4E00\u81F4\uFF0C\u4F7F\u7528paymentSessionMetaData.securityConfig\u91CD\u65B0\u521D\u59CB\u5316");
139
+ }
140
+ this.AMSSDK.logger.logInfo({
141
+ title: 'sdk_event_securitySdkInit'
142
+ });
143
+ initSecuritySDK(appName, h5gateway, function () {
144
+ _this.AMSSDK.logger.logInfo({
145
+ title: 'sdk_event_securitySdkInitSuccess'
146
+ });
147
+ }, function () {
148
+ // TODO Distinguishing Call Scenarios of Security SDK Failures
149
+ _this.AMSSDK.logger.logError({
150
+ title: 'sdk_error_securitySdkInitFailed'
151
+ });
152
+ });
153
+ }
154
+ }, {
155
+ key: "logDeviceId",
156
+ value: function logDeviceId(deviceId, getDeviceIdStartTime) {
157
+ var time = "".concat(Date.now() - getDeviceIdStartTime);
158
+ if (deviceId) {
159
+ this.AMSSDK.logger.logInfo({
160
+ title: 'sdk_event_securitySdkGetTokenSuccess'
161
+ }, {
162
+ deviceId: deviceId,
163
+ time: time
164
+ }).send();
165
+ } else {
166
+ this.AMSSDK.logger.logInfo({
167
+ title: 'sdk_error_securitySdkGetTokenFailed'
168
+ }, {
169
+ deviceId: deviceId,
170
+ time: time
171
+ }).send();
172
+ }
173
+ }
174
+ }, {
175
+ key: "getDeviceIdAndLog",
176
+ value: function getDeviceIdAndLog() {
177
+ var _this2 = this;
178
+ return new Promise(function (resolve) {
179
+ // To avoid rendering being blocked, move the logic to the next event loop for processing
180
+ setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
181
+ var _this2$_renderParams;
182
+ var securityConfig, getDeviceIdStartTime, deviceId;
183
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
184
+ while (1) switch (_context.prev = _context.next) {
185
+ case 0:
186
+ 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;
187
+ getDeviceIdStartTime = Date.now();
188
+ _context.next = 4;
189
+ return getApdidToken(getAppname(SecuritySceneEnum.CARD), securityConfig);
190
+ case 4:
191
+ deviceId = _context.sent;
192
+ _this2.logDeviceId(deviceId, getDeviceIdStartTime);
193
+ resolve(deviceId);
194
+ case 7:
195
+ case "end":
196
+ return _context.stop();
197
+ }
198
+ }, _callee);
199
+ })), 0);
121
200
  });
122
201
  }
123
202
 
@@ -127,7 +206,7 @@ var ComponentApp = /*#__PURE__*/function () {
127
206
  }, {
128
207
  key: "appendIframeNodes",
129
208
  value: function appendIframeNodes(componentSign, renderParams) {
130
- var _this = this;
209
+ var _this3 = this;
131
210
  if (this._isInitComponent) {
132
211
  this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
133
212
  return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
@@ -139,6 +218,7 @@ var ComponentApp = /*#__PURE__*/function () {
139
218
  this._renderDisplayType = renderParams.renderDisplayType;
140
219
  var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
141
220
  this.initAPSecurity();
221
+ this.initLoggerMeta();
142
222
  this._performanceData.push({
143
223
  key: 'sdk_create_component',
144
224
  value: Date.now()
@@ -157,12 +237,21 @@ var ComponentApp = /*#__PURE__*/function () {
157
237
  createMockup();
158
238
  this.renderPopupLoading(renderParams);
159
239
  }
240
+ this.AMSSDK.logger.logInfo({
241
+ title: 'sdk_event_createComponent'
242
+ }).send();
160
243
  this.createApp(renderParams);
161
244
  return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
245
+ _this3.AMSSDK.logger.logInfo({
246
+ title: 'AMSSDK_BEGIN_CREATE_APP_SUCCESS'
247
+ }).send();
162
248
  return Promise.resolve();
163
249
  }).catch(function (error) {
164
- _this._isInitComponent = false;
165
- _this.cleanContainer();
250
+ _this3.AMSSDK.logger.logError({
251
+ title: 'AMSSDK_BEGIN_CREATE_APP_FAIL'
252
+ }).send();
253
+ _this3._isInitComponent = false;
254
+ _this3.cleanContainer();
166
255
  return Promise.reject(error);
167
256
  });
168
257
  }
@@ -188,14 +277,14 @@ var ComponentApp = /*#__PURE__*/function () {
188
277
  }, {
189
278
  key: "_createLoadAppPromise",
190
279
  value: function _createLoadAppPromise() {
191
- var _this2 = this;
280
+ var _this4 = this;
192
281
  return new Promise(function (resolve, reject) {
193
- _this2._loadAppPromiseResolve = resolve;
282
+ _this4._loadAppPromiseResolve = resolve;
194
283
  setTimeout(function () {
195
284
  reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
196
285
  }, LOADTIME_LIMIT);
197
286
  }).catch(function (error) {
198
- _this2.dispatchToSDK(EVENT.error.name, {
287
+ _this4.dispatchToSDK(EVENT.error.name, {
199
288
  code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
200
289
  message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
201
290
  });
@@ -209,115 +298,133 @@ var ComponentApp = /*#__PURE__*/function () {
209
298
  }, {
210
299
  key: "createActionQueryPromise",
211
300
  value: function createActionQueryPromise() {
212
- var _this3 = this;
301
+ var _this5 = this;
213
302
  this._performanceData.push({
214
303
  key: 'sdk_action_query_start',
215
304
  value: Date.now()
216
305
  });
217
- this._actionQueryPromise = new Promise(function (resolve, reject) {
218
- var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3, _this3$_renderParams4;
219
- var params = {
220
- paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.sessionData) || '',
221
- 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,
222
- notRedirectAfterComplete: ((_this3$_renderParams3 = _this3._renderParams) === null || _this3$_renderParams3 === void 0 ? void 0 : _this3$_renderParams3.notRedirectAfterComplete) === true
223
- };
224
- /**
225
- * @description card
226
- */
227
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign || componentSignEnum.VAULTING_CARD === _this3._componentSign) {
228
- params.paymentMethodType = 'CARD';
229
- }
230
- var needDeviceId = false;
231
- var waitTime = '3000';
232
- 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;
233
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign && securityConfig) {
234
- var _this3$_renderParams5;
235
- 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) || '';
236
- var info = JSON.parse(extendInfo);
237
- if ((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false') {
238
- needDeviceId = true;
239
- waitTime = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.tokenCollectTime;
240
- }
241
- }
242
306
 
243
- /**
244
- * @description easyPay
245
- */
246
- if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
247
- var _this3$_renderParams6;
248
- var _ref2 = params.paymentSessionConfig || {},
249
- _ref2$productSceneVer = _ref2.productSceneVersion,
250
- productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
251
- _ref2$productScene = _ref2.productScene,
252
- productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
253
- var _ref3 = ((_this3$_renderParams6 = _this3._renderParams) === null || _this3$_renderParams6 === void 0 ? void 0 : _this3$_renderParams6.paymentSessionMetaData) || {},
254
- _ref3$action = _ref3.action,
255
- _ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
256
- _ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
257
- autoDebitWithToken = _ref3$action2$autoDeb === void 0 ? false : _ref3$action2$autoDeb;
258
- if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
259
- // if EASY_PAY 2.0 , no need to query payment request
260
- return resolve({
261
- message: 'sdk no need to make query request',
262
- success: true
263
- });
264
- }
265
- }
266
- /**
267
- * @author tianqiang
268
- * @description autoDebit
269
- */
270
- if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
271
- var _this3$_renderParams7, _action$web, _action$wap;
272
- 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) || {};
273
- 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;
274
- if (signType === 'SMS') {
275
- return resolve({
276
- message: 'sdk no need to make query request',
277
- success: true
278
- });
279
- }
280
- if (!signType || signType !== 'REDIRECT') {
281
- return resolve({
282
- success: false
283
- });
284
- }
285
- }
286
-
287
- // mock
288
- if (isLocalMock()) {
289
- return resolve({
290
- message: 'sdk no need to make query request',
291
- success: true
292
- });
293
- }
294
- queryPaymentInfo(params, {
295
- env: _this3.AMSSDK.options.env.environment,
296
- locale: _this3.AMSSDK.options.locale,
297
- needDeviceId: needDeviceId,
298
- waitTime: waitTime
299
- }).then(function (res) {
300
- _this3._performanceData.push({
301
- key: 'sdk_action_query_end',
302
- value: Date.now()
303
- });
304
- if (res !== null && res !== void 0 && res.success) {
305
- resolve(res);
306
- } else {
307
- resolve(res);
308
- }
309
- }).catch(function (err) {
310
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
311
- return resolve({
312
- success: false
313
- });
314
- }
315
- _this3.dispatchToSDK(EVENT.error.name, {
316
- code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
317
- });
318
- reject(err);
319
- });
320
- });
307
+ // eslint-disable-next-line no-async-promise-executor
308
+ this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
309
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
310
+ var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
311
+ 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;
312
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
313
+ while (1) switch (_context2.prev = _context2.next) {
314
+ case 0:
315
+ envInfo = {
316
+ locale: _this5.AMSSDK.options.locale
317
+ };
318
+ params = {
319
+ paymentSessionData: _this5._renderParams && ((_this5$_renderParams = _this5._renderParams) === null || _this5$_renderParams === void 0 ? void 0 : _this5$_renderParams.sessionData) || '',
320
+ 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,
321
+ notRedirectAfterComplete: ((_this5$_renderParams3 = _this5._renderParams) === null || _this5$_renderParams3 === void 0 ? void 0 : _this5$_renderParams3.notRedirectAfterComplete) === true
322
+ };
323
+ /**
324
+ * @description card
325
+ */
326
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign) {
327
+ params.paymentMethodType = 'CARD';
328
+ }
329
+ 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;
330
+ if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign && securityConfig)) {
331
+ _context2.next = 12;
332
+ break;
333
+ }
334
+ 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) || '{}';
335
+ info = JSON.parse(extendInfo);
336
+ if (!((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false')) {
337
+ _context2.next = 12;
338
+ break;
339
+ }
340
+ // old card cardTokenPay: 'true'|| true null ; new card = 'false'
341
+ console.log("-----------Risk control project test: \u8BC6\u522B\u5230\u5361\u573A\u666F\uFF0C\u4E14\u662F\u5B58\u5361\u3002\u53BB\u83B7\u53D6deviceId");
342
+ _context2.next = 11;
343
+ return _this5.getDeviceIdAndLog();
344
+ case 11:
345
+ envInfo.deviceId = _context2.sent;
346
+ case 12:
347
+ if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
348
+ _context2.next = 17;
349
+ break;
350
+ }
351
+ _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;
352
+ _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;
353
+ if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
354
+ _context2.next = 17;
355
+ break;
356
+ }
357
+ return _context2.abrupt("return", resolve({
358
+ message: 'sdk no need to make query request',
359
+ success: true
360
+ }));
361
+ case 17:
362
+ if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
363
+ _context2.next = 24;
364
+ break;
365
+ }
366
+ 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) || {};
367
+ 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;
368
+ if (!(signType === 'SMS')) {
369
+ _context2.next = 22;
370
+ break;
371
+ }
372
+ return _context2.abrupt("return", resolve({
373
+ message: 'sdk no need to make query request',
374
+ success: true
375
+ }));
376
+ case 22:
377
+ if (!(!signType || signType !== 'REDIRECT')) {
378
+ _context2.next = 24;
379
+ break;
380
+ }
381
+ return _context2.abrupt("return", resolve({
382
+ success: false
383
+ }));
384
+ case 24:
385
+ if (!isLocalMock()) {
386
+ _context2.next = 26;
387
+ break;
388
+ }
389
+ return _context2.abrupt("return", resolve({
390
+ message: 'sdk no need to make query request',
391
+ success: true
392
+ }));
393
+ case 26:
394
+ queryPaymentInfo(params, {
395
+ env: _this5.AMSSDK.options.env.environment,
396
+ envInfo: envInfo
397
+ }, _this5.AMSSDK.logger).then(function (res) {
398
+ _this5._performanceData.push({
399
+ key: 'sdk_action_query_end',
400
+ value: Date.now()
401
+ });
402
+ if (res !== null && res !== void 0 && res.success) {
403
+ resolve(res);
404
+ } else {
405
+ resolve(res);
406
+ }
407
+ }).catch(function (err) {
408
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign) {
409
+ return resolve({
410
+ success: false
411
+ });
412
+ }
413
+ _this5.dispatchToSDK(EVENT.error.name, {
414
+ code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
415
+ });
416
+ reject(err);
417
+ });
418
+ case 27:
419
+ case "end":
420
+ return _context2.stop();
421
+ }
422
+ }, _callee2);
423
+ }));
424
+ return function (_x, _x2) {
425
+ return _ref2.apply(this, arguments);
426
+ };
427
+ }());
321
428
  return this._actionQueryPromise;
322
429
  }
323
430
  }, {
@@ -402,15 +509,11 @@ var ComponentApp = /*#__PURE__*/function () {
402
509
  }, {
403
510
  key: "listener",
404
511
  value: function listener(e) {
405
- if (e.origin !== this.appDomain) {
406
- return;
407
- }
512
+ if (e.origin !== this.appDomain) return;
408
513
  var isJson = isJsonString(e.data);
409
514
  if (isJson) {
410
515
  var data = JSON.parse(e.data);
411
- if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) {
412
- return;
413
- }
516
+ if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) return;
414
517
  this._handleAppMessage(data);
415
518
  } else {
416
519
  console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
@@ -436,17 +539,51 @@ var ComponentApp = /*#__PURE__*/function () {
436
539
  }, {
437
540
  key: "createPopupWindow",
438
541
  value: function createPopupWindow(data) {
439
- var _this$_renderParams2;
542
+ var _this$_renderParams3;
440
543
  this._threedData = data;
441
- var sessionData = encodeURIComponent((_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.sessionData);
442
- // const threedPageUrl = `http://192.168.1.5:5173/src/component-app/threedPage/demo.html?scene=threedWrapperPage&sessionData=${sessionData}&instanceId=${this.AMSSDK._instanceId}`
443
- var threedPageUrl = "".concat(marmptMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&instanceId=").concat(this.AMSSDK._instanceId);
544
+ var sessionData = encodeURIComponent((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData);
545
+ var threedPageUrl = "".concat(marmotMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&instanceId=").concat(this.AMSSDK._instanceId);
444
546
  this.popupWindow = createModal({
445
547
  device: this.platform,
446
548
  url: threedPageUrl
447
549
  });
448
550
  }
449
-
551
+ }, {
552
+ key: "getDeviceIdAndCallback",
553
+ value: function () {
554
+ var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(eventContext) {
555
+ var deviceId;
556
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
557
+ while (1) switch (_context3.prev = _context3.next) {
558
+ case 0:
559
+ if (!(eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId)) {
560
+ _context3.next = 5;
561
+ break;
562
+ }
563
+ _context3.next = 3;
564
+ return this.getDeviceIdAndLog();
565
+ case 3:
566
+ deviceId = _context3.sent;
567
+ this.dispatchToApp({
568
+ context: {
569
+ event: 'appEventCallback',
570
+ eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
571
+ data: {
572
+ deviceId: deviceId
573
+ }
574
+ }
575
+ });
576
+ case 5:
577
+ case "end":
578
+ return _context3.stop();
579
+ }
580
+ }, _callee3, this);
581
+ }));
582
+ function getDeviceIdAndCallback(_x3) {
583
+ return _getDeviceIdAndCallback.apply(this, arguments);
584
+ }
585
+ return getDeviceIdAndCallback;
586
+ }()
450
587
  /**
451
588
  * @description Initialize subscription iframe message
452
589
  */
@@ -472,10 +609,15 @@ var ComponentApp = /*#__PURE__*/function () {
472
609
  }, {
473
610
  key: "_handleAppMessage",
474
611
  value: function _handleAppMessage(data) {
475
- 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];
612
+ 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];
476
613
  if (!eventKeyMap.includes(data.context.event)) {
477
614
  return;
478
615
  }
616
+ if (data.context.event === EVENT.getDeviceId.name) {
617
+ console.log("-----------Risk control project test: \u6536\u94F6\u53F0\u8C03\u7528\u83B7\u53D6deviceId");
618
+ this.getDeviceIdAndCallback(data.context);
619
+ return;
620
+ }
479
621
  if (data.context.event === EVENT.closePopup.name) {
480
622
  destroyModal();
481
623
  return;
@@ -541,6 +683,11 @@ var ComponentApp = /*#__PURE__*/function () {
541
683
  this.handleDeclareInfo(data.context.data);
542
684
  return;
543
685
  }
686
+ if (data.context.event === EVENT.eventCallback.name) {
687
+ this.AMSSDK.logger.logInfo({
688
+ title: 'sdk_event_event_callback'
689
+ }).send();
690
+ }
544
691
 
545
692
  // The plug-in communicates with the sdk after processing
546
693
  this.dispatchToSDK(data.context.event, data.context.data, data.context.eventCallbackId);
@@ -598,7 +745,7 @@ var ComponentApp = /*#__PURE__*/function () {
598
745
  }, {
599
746
  key: "handleRedirect",
600
747
  value: function handleRedirect(data) {
601
- var _this4 = this;
748
+ var _this6 = this;
602
749
  var _data = typeof data === 'string' ? {
603
750
  normalUrl: data
604
751
  } : {
@@ -607,17 +754,31 @@ var ComponentApp = /*#__PURE__*/function () {
607
754
  normalUrl: (data === null || data === void 0 ? void 0 : data.normalUrl) || '',
608
755
  target: data === null || data === void 0 ? void 0 : data.target
609
756
  };
757
+ // TODO Open the log classification of the app
610
758
  var successCallback = function successCallback(type, url) {
611
- _this4.dispatchToSDK(EVENT.eventCallback.name, {
759
+ _this6.dispatchToSDK(EVENT.eventCallback.name, {
612
760
  code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
613
761
  message: "Successfully opened the app,".concat(type, ": ").concat(url)
614
762
  });
763
+ _this6.AMSSDK.logger.logInfo({
764
+ title: 'sdk_event_call_url_success'
765
+ }, {
766
+ redirectInfo: JSON.stringify({
767
+ type: type,
768
+ url: url
769
+ })
770
+ }).send();
615
771
  };
616
772
  var failCallback = function failCallback() {
617
- _this4.dispatchToSDK(EVENT.eventCallback.name, {
773
+ _this6.dispatchToSDK(EVENT.eventCallback.name, {
618
774
  code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
619
775
  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)
620
776
  });
777
+ _this6.AMSSDK.logger.logInfo({
778
+ title: 'sdk_error_call_url_failed'
779
+ }, {
780
+ redirectInfo: JSON.stringify(_data)
781
+ }).send();
621
782
  };
622
783
 
623
784
  // 支持 target: _blank,新开tab页打开
@@ -633,13 +794,13 @@ var ComponentApp = /*#__PURE__*/function () {
633
794
  }).then(function () {
634
795
  successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
635
796
  }).catch(function () {
636
- return _this4.AMSSDK._redirect({
797
+ return _this6.AMSSDK._redirect({
637
798
  schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
638
799
  });
639
800
  }).then(function () {
640
801
  successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
641
802
  }).catch(function () {
642
- return _this4.AMSSDK._redirect({
803
+ return _this6.AMSSDK._redirect({
643
804
  normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
644
805
  });
645
806
  }).then(function () {
@@ -650,9 +811,9 @@ var ComponentApp = /*#__PURE__*/function () {
650
811
  }
651
812
  }, {
652
813
  key: "handleDeclareInfo",
653
- value: function handleDeclareInfo(_ref4) {
654
- var _ref4$closeDialogData = _ref4.closeDialogData,
655
- closeDialogData = _ref4$closeDialogData === void 0 ? {} : _ref4$closeDialogData;
814
+ value: function handleDeclareInfo(_ref5) {
815
+ var _ref5$closeDialogData = _ref5.closeDialogData,
816
+ closeDialogData = _ref5$closeDialogData === void 0 ? {} : _ref5$closeDialogData;
656
817
  _handleDeclareInfo({
657
818
  closeDialogData: closeDialogData
658
819
  });
@@ -684,15 +845,15 @@ var ComponentApp = /*#__PURE__*/function () {
684
845
  }, {
685
846
  key: "dispatchToApp",
686
847
  value: function dispatchToApp(payload) {
687
- var element = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
848
+ var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
688
849
  var data = Object.assign({}, payload, {
689
850
  name: messageName.SDK_TO_APP,
690
851
  mode: this.AMSSDK.options.mode,
691
852
  appId: COMPONENTPLUGINID,
692
853
  instanceId: this.AMSSDK._instanceId
693
854
  });
694
- if (element && element.contentWindow) {
695
- return element.contentWindow.postMessage(JSON.stringify(data), '*');
855
+ if (targetElement && targetElement.contentWindow) {
856
+ return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
696
857
  }
697
858
  if (this.app && this.app.contentWindow) {
698
859
  return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
@@ -721,22 +882,22 @@ var ComponentApp = /*#__PURE__*/function () {
721
882
  }, {
722
883
  key: "sendRenderEvent",
723
884
  value: function () {
724
- var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
725
- var _this$_renderParams3, _this$_renderParams4, _this$_renderParams5, _this$_renderParams6, _this$_renderParams7, res;
726
- return _regeneratorRuntime().wrap(function _callee$(_context) {
727
- while (1) switch (_context.prev = _context.next) {
885
+ var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
886
+ var _this$_renderParams4, _this$_renderParams5, _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, res;
887
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
888
+ while (1) switch (_context4.prev = _context4.next) {
728
889
  case 0:
729
- _context.prev = 0;
890
+ _context4.prev = 0;
730
891
  if (this._actionQueryPromise) {
731
- _context.next = 3;
892
+ _context4.next = 3;
732
893
  break;
733
894
  }
734
- return _context.abrupt("return");
895
+ return _context4.abrupt("return");
735
896
  case 3:
736
- _context.next = 5;
897
+ _context4.next = 5;
737
898
  return this._actionQueryPromise;
738
899
  case 5:
739
- res = _context.sent;
900
+ res = _context4.sent;
740
901
  this._performanceData.push({
741
902
  key: 'sdk_render_component',
742
903
  value: Date.now()
@@ -746,12 +907,12 @@ var ComponentApp = /*#__PURE__*/function () {
746
907
  event: 'renderComponent',
747
908
  data: {
748
909
  queryResult: res,
749
- sessionResult: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.paymentSessionMetaData,
750
- paymentSessionData: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.sessionData,
910
+ sessionResult: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionMetaData,
911
+ paymentSessionData: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData,
751
912
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
752
- renderDisplayType: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.renderDisplayType,
753
- appearance: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.appearance,
754
- notRedirectAfterComplete: ((_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.notRedirectAfterComplete) === true,
913
+ renderDisplayType: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.renderDisplayType,
914
+ appearance: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.appearance,
915
+ notRedirectAfterComplete: ((_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.notRedirectAfterComplete) === true,
755
916
  envInfo: {
756
917
  screenHeight: screen.height,
757
918
  screenWidth: screen.width
@@ -768,16 +929,16 @@ var ComponentApp = /*#__PURE__*/function () {
768
929
  }
769
930
  });
770
931
  // eslint-disable-next-line no-empty
771
- _context.next = 13;
932
+ _context4.next = 13;
772
933
  break;
773
934
  case 11:
774
- _context.prev = 11;
775
- _context.t0 = _context["catch"](0);
935
+ _context4.prev = 11;
936
+ _context4.t0 = _context4["catch"](0);
776
937
  case 13:
777
938
  case "end":
778
- return _context.stop();
939
+ return _context4.stop();
779
940
  }
780
- }, _callee, this, [[0, 11]]);
941
+ }, _callee4, this, [[0, 11]]);
781
942
  }));
782
943
  function sendRenderEvent() {
783
944
  return _sendRenderEvent.apply(this, arguments);
@@ -791,7 +952,7 @@ var ComponentApp = /*#__PURE__*/function () {
791
952
  key: "cleanContainer",
792
953
  value: function cleanContainer() {
793
954
  var _document$getElementB4,
794
- _this5 = this;
955
+ _this7 = this;
795
956
  var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
796
957
  this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
797
958
  this._performanceData = [];
@@ -803,7 +964,7 @@ var ComponentApp = /*#__PURE__*/function () {
803
964
  mockup === null || mockup === void 0 || mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
804
965
  if (immediately) this.cleanElement();else {
805
966
  setTimeout(function () {
806
- _this5.cleanElement();
967
+ _this7.cleanElement();
807
968
  }, 300);
808
969
  }
809
970
  }