@alipay/ams-checkout 0.0.1697942541-dev.5 → 0.0.1697942541-dev.7
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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/core/instance/index.d.ts +13 -1
- package/esm/core/instance/index.js +75 -3
- package/esm/plugin/component/index.d.ts +6 -2
- package/esm/plugin/component/index.js +334 -172
- package/esm/request/index.d.ts +2 -1
- package/esm/request/index.js +57 -34
- package/esm/service/index.d.ts +9 -1
- package/esm/service/index.js +4 -3
- package/esm/types/index.d.ts +19 -8
- package/esm/types/index.js +5 -0
- package/esm/util/logger.d.ts +54 -0
- package/esm/util/logger.js +172 -0
- package/esm/util/security.d.ts +6 -3
- package/esm/util/security.js +98 -72
- package/package.json +1 -1
@@ -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
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
|
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,
|
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$
|
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$
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
console.log(
|
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
|
+
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
|
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
|
-
|
165
|
-
|
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
|
280
|
+
var _this4 = this;
|
192
281
|
return new Promise(function (resolve, reject) {
|
193
|
-
|
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
|
-
|
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
|
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
|
-
|
245
|
-
|
246
|
-
|
247
|
-
var
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
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,16 +539,51 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
436
539
|
}, {
|
437
540
|
key: "createPopupWindow",
|
438
541
|
value: function createPopupWindow(data) {
|
439
|
-
var _this$
|
542
|
+
var _this$_renderParams3;
|
440
543
|
this._threedData = data;
|
441
|
-
var sessionData = encodeURIComponent((_this$
|
544
|
+
var sessionData = encodeURIComponent((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData);
|
442
545
|
var threedPageUrl = "".concat(marmotMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&instanceId=").concat(this.AMSSDK._instanceId);
|
443
546
|
this.popupWindow = createModal({
|
444
547
|
device: this.platform,
|
445
548
|
url: threedPageUrl
|
446
549
|
});
|
447
550
|
}
|
448
|
-
|
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
|
+
}()
|
449
587
|
/**
|
450
588
|
* @description Initialize subscription iframe message
|
451
589
|
*/
|
@@ -471,10 +609,15 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
471
609
|
}, {
|
472
610
|
key: "_handleAppMessage",
|
473
611
|
value: function _handleAppMessage(data) {
|
474
|
-
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];
|
475
613
|
if (!eventKeyMap.includes(data.context.event)) {
|
476
614
|
return;
|
477
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
|
+
}
|
478
621
|
if (data.context.event === EVENT.closePopup.name) {
|
479
622
|
destroyModal();
|
480
623
|
return;
|
@@ -540,6 +683,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
540
683
|
this.handleDeclareInfo(data.context.data);
|
541
684
|
return;
|
542
685
|
}
|
686
|
+
if (data.context.event === EVENT.eventCallback.name) {
|
687
|
+
this.AMSSDK.logger.logInfo({
|
688
|
+
title: 'sdk_event_event_callback'
|
689
|
+
}).send();
|
690
|
+
}
|
543
691
|
|
544
692
|
// The plug-in communicates with the sdk after processing
|
545
693
|
this.dispatchToSDK(data.context.event, data.context.data, data.context.eventCallbackId);
|
@@ -597,7 +745,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
597
745
|
}, {
|
598
746
|
key: "handleRedirect",
|
599
747
|
value: function handleRedirect(data) {
|
600
|
-
var
|
748
|
+
var _this6 = this;
|
601
749
|
var _data = typeof data === 'string' ? {
|
602
750
|
normalUrl: data
|
603
751
|
} : {
|
@@ -606,17 +754,31 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
606
754
|
normalUrl: (data === null || data === void 0 ? void 0 : data.normalUrl) || '',
|
607
755
|
target: data === null || data === void 0 ? void 0 : data.target
|
608
756
|
};
|
757
|
+
// TODO Open the log classification of the app
|
609
758
|
var successCallback = function successCallback(type, url) {
|
610
|
-
|
759
|
+
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
611
760
|
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
612
761
|
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
613
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();
|
614
771
|
};
|
615
772
|
var failCallback = function failCallback() {
|
616
|
-
|
773
|
+
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
617
774
|
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
618
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)
|
619
776
|
});
|
777
|
+
_this6.AMSSDK.logger.logInfo({
|
778
|
+
title: 'sdk_error_call_url_failed'
|
779
|
+
}, {
|
780
|
+
redirectInfo: JSON.stringify(_data)
|
781
|
+
}).send();
|
620
782
|
};
|
621
783
|
|
622
784
|
// 支持 target: _blank,新开tab页打开
|
@@ -632,13 +794,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
632
794
|
}).then(function () {
|
633
795
|
successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
634
796
|
}).catch(function () {
|
635
|
-
return
|
797
|
+
return _this6.AMSSDK._redirect({
|
636
798
|
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
637
799
|
});
|
638
800
|
}).then(function () {
|
639
801
|
successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
640
802
|
}).catch(function () {
|
641
|
-
return
|
803
|
+
return _this6.AMSSDK._redirect({
|
642
804
|
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
643
805
|
});
|
644
806
|
}).then(function () {
|
@@ -649,9 +811,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
649
811
|
}
|
650
812
|
}, {
|
651
813
|
key: "handleDeclareInfo",
|
652
|
-
value: function handleDeclareInfo(
|
653
|
-
var
|
654
|
-
closeDialogData =
|
814
|
+
value: function handleDeclareInfo(_ref5) {
|
815
|
+
var _ref5$closeDialogData = _ref5.closeDialogData,
|
816
|
+
closeDialogData = _ref5$closeDialogData === void 0 ? {} : _ref5$closeDialogData;
|
655
817
|
_handleDeclareInfo({
|
656
818
|
closeDialogData: closeDialogData
|
657
819
|
});
|
@@ -683,15 +845,15 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
683
845
|
}, {
|
684
846
|
key: "dispatchToApp",
|
685
847
|
value: function dispatchToApp(payload) {
|
686
|
-
var
|
848
|
+
var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
687
849
|
var data = Object.assign({}, payload, {
|
688
850
|
name: messageName.SDK_TO_APP,
|
689
851
|
mode: this.AMSSDK.options.mode,
|
690
852
|
appId: COMPONENTPLUGINID,
|
691
853
|
instanceId: this.AMSSDK._instanceId
|
692
854
|
});
|
693
|
-
if (
|
694
|
-
return
|
855
|
+
if (targetElement && targetElement.contentWindow) {
|
856
|
+
return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
|
695
857
|
}
|
696
858
|
if (this.app && this.app.contentWindow) {
|
697
859
|
return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
@@ -720,22 +882,22 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
720
882
|
}, {
|
721
883
|
key: "sendRenderEvent",
|
722
884
|
value: function () {
|
723
|
-
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
724
|
-
var _this$
|
725
|
-
return _regeneratorRuntime().wrap(function
|
726
|
-
while (1) switch (
|
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) {
|
727
889
|
case 0:
|
728
|
-
|
890
|
+
_context4.prev = 0;
|
729
891
|
if (this._actionQueryPromise) {
|
730
|
-
|
892
|
+
_context4.next = 3;
|
731
893
|
break;
|
732
894
|
}
|
733
|
-
return
|
895
|
+
return _context4.abrupt("return");
|
734
896
|
case 3:
|
735
|
-
|
897
|
+
_context4.next = 5;
|
736
898
|
return this._actionQueryPromise;
|
737
899
|
case 5:
|
738
|
-
res =
|
900
|
+
res = _context4.sent;
|
739
901
|
this._performanceData.push({
|
740
902
|
key: 'sdk_render_component',
|
741
903
|
value: Date.now()
|
@@ -745,12 +907,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
745
907
|
event: 'renderComponent',
|
746
908
|
data: {
|
747
909
|
queryResult: res,
|
748
|
-
sessionResult: (_this$
|
749
|
-
paymentSessionData: (_this$
|
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,
|
750
912
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
751
|
-
renderDisplayType: (_this$
|
752
|
-
appearance: (_this$
|
753
|
-
notRedirectAfterComplete: ((_this$
|
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,
|
754
916
|
envInfo: {
|
755
917
|
screenHeight: screen.height,
|
756
918
|
screenWidth: screen.width
|
@@ -767,16 +929,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
767
929
|
}
|
768
930
|
});
|
769
931
|
// eslint-disable-next-line no-empty
|
770
|
-
|
932
|
+
_context4.next = 13;
|
771
933
|
break;
|
772
934
|
case 11:
|
773
|
-
|
774
|
-
|
935
|
+
_context4.prev = 11;
|
936
|
+
_context4.t0 = _context4["catch"](0);
|
775
937
|
case 13:
|
776
938
|
case "end":
|
777
|
-
return
|
939
|
+
return _context4.stop();
|
778
940
|
}
|
779
|
-
},
|
941
|
+
}, _callee4, this, [[0, 11]]);
|
780
942
|
}));
|
781
943
|
function sendRenderEvent() {
|
782
944
|
return _sendRenderEvent.apply(this, arguments);
|
@@ -790,7 +952,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
790
952
|
key: "cleanContainer",
|
791
953
|
value: function cleanContainer() {
|
792
954
|
var _document$getElementB4,
|
793
|
-
|
955
|
+
_this7 = this;
|
794
956
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
795
957
|
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
796
958
|
this._performanceData = [];
|
@@ -802,7 +964,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
802
964
|
mockup === null || mockup === void 0 || mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
|
803
965
|
if (immediately) this.cleanElement();else {
|
804
966
|
setTimeout(function () {
|
805
|
-
|
967
|
+
_this7.cleanElement();
|
806
968
|
}, 300);
|
807
969
|
}
|
808
970
|
}
|