@alipay/ams-checkout 1.24.0 → 1.25.0
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/component/channel.d.ts +19 -0
- package/esm/component/channel.js +87 -0
- package/esm/component/component.inline.style.d.ts +10 -0
- package/esm/component/component.inline.style.js +121 -0
- package/esm/component/component.popup.style.d.ts +23 -0
- package/esm/component/component.popup.style.js +190 -0
- package/esm/component/popupWindow.style.d.ts +11 -0
- package/esm/component/popupWindow.style.js +121 -0
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +3 -5
- package/esm/constant/index.js +4 -78
- package/esm/core/bus/interface.d.ts +0 -12
- package/esm/core/bus/interface.js +2 -16
- package/esm/core/component/address.d.ts +2 -2
- package/esm/core/component/appPreloadProcessing.js +0 -2
- package/esm/core/component/ckp/index.d.ts +3 -3
- package/esm/core/component/element/components/address.js +1 -1
- package/esm/core/component/element/components/auth.d.ts +1 -1
- package/esm/core/component/element/components/payment.js +1 -1
- package/esm/core/component/element/index.js +19 -19
- package/esm/core/component/element/type.d.ts +6 -0
- package/esm/core/component/index.d.ts +2 -2
- package/esm/core/component/index.js +2 -6
- package/esm/core/drop-in/index.d.ts +2 -2
- package/esm/core/instance/index.d.ts +5 -5
- package/esm/core/instance/index.js +1 -2
- package/esm/foundation/core/index.d.ts +5 -5
- package/esm/foundation/core/index.js +117 -52
- package/esm/foundation/index.d.ts +10 -7
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +8 -5
- package/esm/foundation/product-processor/easysafepay/deps.js +5 -2
- package/esm/foundation/product-processor/easysafepay/index.d.ts +6 -6
- package/esm/foundation/product-processor/easysafepay/index.js +192 -265
- package/esm/foundation/service/{event-bus → api-bus}/ability/callback.js +1 -1
- package/esm/foundation/service/{event-bus → api-bus}/ability/globalData.d.ts +1 -1
- package/esm/{core/bus → foundation/service/api-bus}/ability/globalData.js +2 -2
- package/esm/{core/bus → foundation/service/api-bus}/ability/request.d.ts +1 -1
- package/esm/{core/bus → foundation/service/api-bus}/ability/request.js +2 -2
- package/esm/foundation/service/{event-bus → api-bus}/ability/security.js +29 -19
- package/esm/foundation/service/{event-bus → api-bus}/ability/tracker.js +1 -1
- package/esm/foundation/service/{event-bus → api-bus}/busManager.js +1 -1
- package/esm/foundation/service/{event-bus → api-bus}/index.d.ts +2 -2
- package/esm/foundation/service/api-bus/interface.d.ts +48 -0
- package/esm/foundation/service/api-bus/interface.js +54 -0
- package/esm/foundation/service/container/index.d.ts +4 -2
- package/esm/foundation/service/container/index.js +47 -5
- package/esm/foundation/service/container/popup.js +1 -1
- package/esm/foundation/service/event-center.d.ts +6 -5
- package/esm/foundation/service/event-center.js +16 -17
- package/esm/foundation/service/global-data/index.d.ts +2 -2
- package/esm/foundation/service/global-data/index.js +4 -5
- package/esm/foundation/service/index.d.ts +2 -2
- package/esm/foundation/service/index.js +1 -1
- package/esm/foundation/service/log/index.d.ts +2 -2
- package/esm/foundation/service/log/index.js +1 -1
- package/esm/foundation/service/requester/deps.d.ts +1 -1
- package/esm/foundation/service/requester/requester.d.ts +2 -2
- package/esm/foundation/service/requester/requester.js +14 -11
- package/esm/foundation/service/security/index.d.ts +11 -9
- package/esm/foundation/service/security/index.js +114 -44
- package/esm/foundation/utils/payment_product_utils.d.ts +13 -0
- package/esm/foundation/utils/payment_product_utils.js +38 -0
- package/esm/foundation/utils/redirect_utils.d.ts +5 -0
- package/esm/foundation/utils/redirect_utils.js +209 -45
- package/esm/foundation/utils/system_events.js +0 -5
- package/esm/foundation/utils/web_app_url_utils.d.ts +11 -2
- package/esm/foundation/utils/web_app_url_utils.js +18 -3
- package/esm/index.d.ts +12 -12
- package/esm/index.js +31 -31
- package/esm/plugin/component/cashierApp.d.ts +3 -3
- package/esm/plugin/component/cashierApp.js +9 -10
- package/esm/plugin/component/component.inline.style.d.ts +1 -1
- package/esm/plugin/component/component.inline.style.js +2 -3
- package/esm/plugin/component/component.popup.style.d.ts +1 -10
- package/esm/plugin/component/component.popup.style.js +10 -28
- package/esm/plugin/component/index.d.ts +1 -1
- package/esm/plugin/component/index.js +64 -62
- package/esm/plugin/payment-element/utils.d.ts +1 -1
- package/esm/plugin/payment-element/utils.js +1 -2
- package/esm/plugin/type.d.ts +1 -1
- package/esm/types/index.d.ts +17 -11
- package/esm/types/index.js +7 -1
- package/esm/util/getBackScheme.js +95 -3
- package/esm/util/index.d.ts +1 -1
- package/esm/util/index.js +4 -3
- package/esm/util/security.d.ts +33 -0
- package/esm/{foundation/service/event-bus/ability/request.js → util/security.js} +153 -122
- package/package.json +1 -1
- package/esm/core/bus/ability/globalData.d.ts +0 -10
- package/esm/foundation/service/event-bus/ability/globalData.js +0 -89
- package/esm/foundation/service/event-bus/ability/request.d.ts +0 -10
- package/esm/foundation/types/index.d.ts +0 -4
- package/esm/foundation/types/index.js +0 -4
- package/esm/util/ua/index.d.ts +0 -2
- package/esm/util/ua/index.js +0 -2
- package/esm/util/ua/isAndroid.d.ts +0 -4
- package/esm/util/ua/isAndroid.js +0 -7
- package/esm/util/ua/isIOS.d.ts +0 -4
- package/esm/util/ua/isIOS.js +0 -7
- /package/esm/foundation/service/{event-bus → api-bus}/ability/callback.d.ts +0 -0
- /package/esm/foundation/service/{event-bus → api-bus}/ability/security.d.ts +0 -0
- /package/esm/foundation/service/{event-bus → api-bus}/ability/tracker.d.ts +0 -0
- /package/esm/foundation/service/{event-bus → api-bus}/busManager.d.ts +0 -0
- /package/esm/foundation/service/{event-bus → api-bus}/index.js +0 -0
@@ -16,21 +16,21 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
16
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
17
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
18
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
19
|
-
import { ChannelCustomize, DisplayTypeEnum,
|
20
|
-
|
21
|
-
// 缓存上次产品信息
|
22
|
-
var KEY_PREVIOUS_PRODUCT_INFO = 'antom_checkout_previous_ESP_ProductInfo';
|
19
|
+
import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil } from "./deps";
|
23
20
|
export var EasySafePayProcessor = /*#__PURE__*/function () {
|
24
21
|
function EasySafePayProcessor() {
|
25
22
|
_classCallCheck(this, EasySafePayProcessor);
|
26
23
|
_defineProperty(this, "paymentContext", void 0);
|
27
24
|
_defineProperty(this, "initConfig", void 0);
|
28
25
|
_defineProperty(this, "logger", void 0);
|
26
|
+
_defineProperty(this, "securityService", void 0);
|
29
27
|
_defineProperty(this, "instanceId", void 0);
|
28
|
+
// 服务端接口区域信息,请求时决定API域名
|
30
29
|
_defineProperty(this, "hostSign", void 0);
|
31
30
|
// 是否允许submitPay提前调用,在ESP非首次的性能优化场景使用
|
32
31
|
_defineProperty(this, "allowSubmitPayCallAhead", void 0);
|
33
32
|
_defineProperty(this, "channelBehavior", void 0);
|
33
|
+
_defineProperty(this, "SECURITY_SDK_INIT_TIMEOUT", 18000);
|
34
34
|
}
|
35
35
|
_createClass(EasySafePayProcessor, [{
|
36
36
|
key: "init",
|
@@ -38,6 +38,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
38
38
|
this.initConfig = config;
|
39
39
|
this.instanceId = instanceId;
|
40
40
|
this.logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
|
41
|
+
this.securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
|
41
42
|
this.preloadWebApp(config, this.instanceId, sdkMetaData);
|
42
43
|
}
|
43
44
|
}, {
|
@@ -74,17 +75,17 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
74
75
|
return _context.abrupt("return", this.buildRedirectResult(authUrlInfo));
|
75
76
|
case 12:
|
76
77
|
// 下面的场景是需要渲染UI的渠道, 打开WebUrl
|
77
|
-
webAppUrl = this.buildWebAppUrl();
|
78
|
+
webAppUrl = this.buildWebAppUrl(); // const webAppUrl = 'http://svc-9kvjxwjf68cptha8.cloudide.svc.et15-sqa.alipay.net:5173/src/component-app/index.html';
|
78
79
|
resultPayload = {
|
79
80
|
url: webAppUrl,
|
80
81
|
allowClickPopupOutsideClose: (_this$channelBehavior = this.channelBehavior) === null || _this$channelBehavior === void 0 ? void 0 : _this$channelBehavior.allowClickOutsideClose
|
81
82
|
};
|
82
|
-
|
83
|
+
ProductInfoCacheUtil.savePreviousProductInfo(ProductSceneEnum.EASY_PAY, {
|
83
84
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
84
85
|
hostSign: this.hostSign,
|
85
86
|
productSceneVersion: productSceneVersion
|
86
87
|
});
|
87
|
-
// 返回结果之前,发送
|
88
|
+
// 返回结果之前,发送 sessionData,并且等待Web应用启动的事件,内部是异步处理,不阻塞。
|
88
89
|
this.sendRequestAndWaitWebLaunch();
|
89
90
|
// 返回结果,RENDER,让外层去处理iframe加载等逻辑
|
90
91
|
return _context.abrupt("return", {
|
@@ -107,40 +108,46 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
107
108
|
value: function preloadWebApp(config, instanceId, sdkMetaData) {
|
108
109
|
// trigger preload
|
109
110
|
var containerService = ServiceProvider.getInstance(this.instanceId).getService('Container');
|
110
|
-
var
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
containerService.preload(containerId, webAppUrl);
|
111
|
+
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(config, instanceId, sdkMetaData),
|
112
|
+
taskId = _this$buildWebAppPrel.taskId,
|
113
|
+
webUrl = _this$buildWebAppPrel.webUrl;
|
114
|
+
containerService.preload(taskId, webUrl);
|
115
115
|
}
|
116
116
|
}, {
|
117
117
|
key: "buildWebAppPreloadUrl",
|
118
118
|
value: function buildWebAppPreloadUrl(initConfig, instanceId, sdkMetaData) {
|
119
|
-
var
|
119
|
+
var _this = this;
|
120
|
+
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(ProductSceneEnum.EASY_PAY, function (erorrMsg) {
|
121
|
+
if (erorrMsg) {
|
122
|
+
_this.logger.logError({
|
123
|
+
title: 'performance_optimization_get_previousChannel_error'
|
124
|
+
}, {
|
125
|
+
error: erorrMsg
|
126
|
+
});
|
127
|
+
}
|
128
|
+
});
|
120
129
|
var paymentMethodCategoryType = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.paymentMethodCategoryType;
|
121
|
-
var productSceneVersion = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.productSceneVersion;
|
130
|
+
var productSceneVersion = (previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.productSceneVersion) || '2.0';
|
131
|
+
var taskId = "ams-checkout-component-".concat(sdkMetaData.productScene, "_").concat(paymentMethodCategoryType);
|
122
132
|
var hostSign = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.hostSign;
|
123
|
-
var
|
133
|
+
var webUrl = WebAppUrlUtil.getWebAppUrl({
|
124
134
|
environment: initConfig.environment,
|
125
135
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
126
136
|
sdkMetaData: sdkMetaData,
|
137
|
+
isPreload: true,
|
127
138
|
productSceneVersion: productSceneVersion,
|
128
139
|
query: {
|
129
140
|
analyticsEnabled: initConfig.analytics.enabled,
|
130
|
-
displayType: DisplayTypeEnum.
|
141
|
+
displayType: DisplayTypeEnum.popup,
|
131
142
|
instanceId: instanceId,
|
132
|
-
isPreload: 'true',
|
133
143
|
locale: initConfig.locale,
|
134
144
|
hostSign: hostSign
|
135
145
|
}
|
136
146
|
});
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
}
|
141
|
-
webAppUrl = "".concat(webAppUrlInfo.path, "?").concat(webAppUrlInfo.locationSearch);
|
142
|
-
}
|
143
|
-
return webAppUrl;
|
147
|
+
return {
|
148
|
+
webUrl: webUrl,
|
149
|
+
taskId: taskId
|
150
|
+
};
|
144
151
|
}
|
145
152
|
}, {
|
146
153
|
key: "buildWebAppUrl",
|
@@ -150,26 +157,20 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
150
157
|
var paymentMethodCategoryType = (_paymentContext$payme3 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme3 === void 0 ? void 0 : _paymentContext$payme3.paymentMethodCategoryType;
|
151
158
|
var productSceneVersion = (_paymentContext$payme4 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme4 === void 0 ? void 0 : _paymentContext$payme4.productSceneVersion;
|
152
159
|
var hostSign = this.hostSign;
|
153
|
-
var
|
160
|
+
var webAppUrl = WebAppUrlUtil.getWebAppUrl({
|
154
161
|
environment: this.initConfig.environment,
|
155
162
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
156
163
|
sdkMetaData: paymentContext.sdkMetaData,
|
157
164
|
productSceneVersion: productSceneVersion,
|
165
|
+
isPreload: false,
|
158
166
|
query: {
|
159
167
|
analyticsEnabled: this.initConfig.analytics.enabled,
|
160
|
-
displayType: DisplayTypeEnum.
|
168
|
+
displayType: DisplayTypeEnum.popup,
|
161
169
|
instanceId: this.instanceId,
|
162
|
-
isPreload: 'true',
|
163
170
|
locale: this.initConfig.locale,
|
164
171
|
hostSign: hostSign
|
165
172
|
}
|
166
173
|
});
|
167
|
-
var webAppUrl;
|
168
|
-
if (webAppUrlInfo.path.indexOf('?') !== -1) {
|
169
|
-
webAppUrl = "".concat(webAppUrlInfo.path, "&").concat(webAppUrlInfo.locationSearch);
|
170
|
-
} else {
|
171
|
-
webAppUrl = "".concat(webAppUrlInfo.path, "?").concat(webAppUrlInfo.locationSearch);
|
172
|
-
}
|
173
174
|
return webAppUrl;
|
174
175
|
}
|
175
176
|
}, {
|
@@ -203,43 +204,35 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
203
204
|
}, {
|
204
205
|
key: "sendRequestAndWaitWebLaunch",
|
205
206
|
value: function sendRequestAndWaitWebLaunch() {
|
206
|
-
var
|
207
|
+
var _this2 = this;
|
207
208
|
var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
208
|
-
var
|
209
|
-
|
210
|
-
queryRes = _ref2[0],
|
211
|
-
submitRes = _ref2[1];
|
212
|
-
return {
|
213
|
-
queryRes: queryRes,
|
214
|
-
submitRes: submitRes
|
215
|
-
};
|
216
|
-
});
|
217
|
-
var webLaunchPromose = new Promise(function (resolve) {
|
218
|
-
eventCenter.listen('onlaunch', function (res) {
|
209
|
+
var webLaunchPromise = new Promise(function (resolve) {
|
210
|
+
eventCenter.listen('onLaunch', function (res) {
|
219
211
|
resolve(res);
|
220
212
|
});
|
221
213
|
});
|
222
214
|
|
223
215
|
// 等请求和 Web启动都Ready之后,发送renderComponent
|
224
|
-
Promise.all([
|
225
|
-
var
|
226
|
-
var
|
227
|
-
|
228
|
-
|
229
|
-
|
216
|
+
Promise.all([this.initSecuritySDK(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
|
217
|
+
var _this2$paymentContext, _this2$paymentContext2, _this2$paymentContext3, _this2$paymentContext4, _this2$paymentContext5, _this2$paymentContext6;
|
218
|
+
var _ref2 = _slicedToArray(_ref, 3),
|
219
|
+
_initSecurityRes = _ref2[0],
|
220
|
+
submitRes = _ref2[1],
|
221
|
+
_webLaunchRes = _ref2[2];
|
222
|
+
var logMetaData = _this2.logger.getLogConfig().mdata;
|
230
223
|
eventCenter.dispatchToApp({
|
231
224
|
event: 'renderComponent',
|
232
225
|
data: {
|
233
|
-
|
234
|
-
submitResult:
|
235
|
-
|
236
|
-
paymentSessionData: (_this$paymentContext2 = _this.paymentContext) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSession,
|
226
|
+
sessionResult: (_this2$paymentContext = _this2.paymentContext) === null || _this2$paymentContext === void 0 ? void 0 : _this2$paymentContext.paymentSessionObj,
|
227
|
+
submitResult: submitRes,
|
228
|
+
paymentSessionData: (_this2$paymentContext2 = _this2.paymentContext) === null || _this2$paymentContext2 === void 0 ? void 0 : _this2$paymentContext2.paymentSessionId,
|
237
229
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
238
|
-
renderDisplayType:
|
239
|
-
appearance: (
|
240
|
-
notRedirectAfterComplete: ((
|
241
|
-
|
242
|
-
|
230
|
+
renderDisplayType: _this2.paymentContext.displayInfo.type,
|
231
|
+
appearance: (_this2$paymentContext3 = _this2.paymentContext.displayInfo) === null || _this2$paymentContext3 === void 0 ? void 0 : _this2$paymentContext3.appearance,
|
232
|
+
notRedirectAfterComplete: ((_this2$paymentContext4 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext4 === void 0 ? void 0 : _this2$paymentContext4.notRedirectAfterComplete) === true,
|
233
|
+
isAppWebview: _this2.paymentContext.startBizFlowOptions.isAppWebview,
|
234
|
+
merchantAppointParam: (_this2$paymentContext5 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext5 === void 0 ? void 0 : _this2$paymentContext5.merchantAppointParam,
|
235
|
+
allowSubmitPayCallAhead: _this2.allowSubmitPayCallAhead,
|
243
236
|
envInfo: {
|
244
237
|
screenHeight: screen.height,
|
245
238
|
screenWidth: screen.width
|
@@ -248,7 +241,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
248
241
|
trackId: logMetaData.requestSeq,
|
249
242
|
platform: logMetaData.platform,
|
250
243
|
firstLogTime: logMetaData.firstLogTime
|
251
|
-
}, ((
|
244
|
+
}, ((_this2$paymentContext6 = _this2.paymentContext.paymentSessionObj) === null || _this2$paymentContext6 === void 0 ? void 0 : _this2$paymentContext6.paymentSessionConfig) || {}), {}, {
|
252
245
|
renderDisplayType: logMetaData.renderDisplayType,
|
253
246
|
sdkVersion: logMetaData.sdkVersion,
|
254
247
|
merchantId: logMetaData.merchantId,
|
@@ -260,244 +253,137 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
260
253
|
});
|
261
254
|
}
|
262
255
|
}, {
|
263
|
-
key: "
|
256
|
+
key: "processSubmitPay",
|
264
257
|
value: function () {
|
265
|
-
var
|
266
|
-
var _this$
|
267
|
-
var
|
258
|
+
var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
259
|
+
var _this$paymentContext, _this$paymentContext2, _this$paymentContext3, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$2;
|
260
|
+
var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, res;
|
268
261
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
269
262
|
while (1) switch (_context2.prev = _context2.next) {
|
270
|
-
case 0:
|
271
|
-
envInfo = {
|
272
|
-
locale: this.initConfig.locale
|
273
|
-
}; //
|
274
|
-
requestData = {
|
275
|
-
paymentSessionData: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSession) || '',
|
276
|
-
paymentSessionConfig: (_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 || (_this$paymentContext4 = _this$paymentContext4.paymentSessionObj) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.paymentSessionConfig,
|
277
|
-
notRedirectAfterComplete: ((_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.startBizFlowOptions.submitPayRequestExtra.notRedirectAfterComplete) === true
|
278
|
-
// merchantAppointParam: this._merchantAppointParam,
|
279
|
-
};
|
280
|
-
extendInfo = ((_this$paymentContext6 = this.paymentContext) === null || _this$paymentContext6 === void 0 || (_this$paymentContext6 = _this$paymentContext6.paymentSessionObj) === null || _this$paymentContext6 === void 0 ? void 0 : _this$paymentContext6.extendInfo) || '';
|
281
|
-
actionData = (_this$paymentContext7 = this.paymentContext) === null || _this$paymentContext7 === void 0 || (_this$paymentContext7 = _this$paymentContext7.paymentSessionObj) === null || _this$paymentContext7 === void 0 ? void 0 : _this$paymentContext7.action;
|
282
|
-
enableEasypayApiOptimize = false;
|
283
|
-
try {
|
284
|
-
extendInfoData = JSON.parse(extendInfo);
|
285
|
-
enableEasypayApiOptimize = extendInfoData.enableEasypayApiOptimize || false;
|
286
|
-
} catch (error) {
|
287
|
-
console.log(error);
|
288
|
-
}
|
289
|
-
if (!isLocalMock()) {
|
290
|
-
_context2.next = 8;
|
291
|
-
break;
|
292
|
-
}
|
293
|
-
return _context2.abrupt("return", {
|
294
|
-
message: 'sdk no need to make query request',
|
295
|
-
success: true
|
296
|
-
});
|
297
|
-
case 8:
|
298
|
-
if (!((_this$channelBehavior2 = this.channelBehavior) !== null && _this$channelBehavior2 !== void 0 && _this$channelBehavior2.usePaymentSessionAsQueryResult)) {
|
299
|
-
_context2.next = 10;
|
300
|
-
break;
|
301
|
-
}
|
302
|
-
return _context2.abrupt("return", {
|
303
|
-
autoDebitWithToken: actionData === null || actionData === void 0 ? void 0 : actionData.autoDebitWithToken,
|
304
|
-
amountConfirmRequired: actionData === null || actionData === void 0 ? void 0 : actionData.amountConfirmRequired,
|
305
|
-
success: true
|
306
|
-
});
|
307
|
-
case 10:
|
308
|
-
if (!(actionData.skipSdkQuery && enableEasypayApiOptimize)) {
|
309
|
-
_context2.next = 12;
|
310
|
-
break;
|
311
|
-
}
|
312
|
-
return _context2.abrupt("return", {
|
313
|
-
message: 'sdk no need to make query request',
|
314
|
-
success: true
|
315
|
-
});
|
316
|
-
case 12:
|
317
|
-
productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion; // ESP 2.0 无需Query
|
318
|
-
if (!(productSceneVersion === '2.0')) {
|
319
|
-
_context2.next = 15;
|
320
|
-
break;
|
321
|
-
}
|
322
|
-
return _context2.abrupt("return", {
|
323
|
-
message: 'sdk no need to make query request',
|
324
|
-
success: true
|
325
|
-
});
|
326
|
-
case 15:
|
327
|
-
_context2.next = 17;
|
328
|
-
return this.acquireApdidToken();
|
329
|
-
case 17:
|
330
|
-
envInfo.deviceId = _context2.sent;
|
331
|
-
// 打日志
|
332
|
-
this.logger.logInfo({
|
333
|
-
title: 'sdk_event_sdkQuery'
|
334
|
-
}, {
|
335
|
-
paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
|
336
|
-
// TODO: 安全合规考虑
|
337
|
-
requestBody: requestData
|
338
|
-
});
|
339
|
-
|
340
|
-
// 真正发请求
|
341
|
-
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
342
|
-
_context2.prev = 20;
|
343
|
-
_context2.next = 23;
|
344
|
-
return requester.request(requestData, {
|
345
|
-
env: this.initConfig.environment,
|
346
|
-
envInfo: envInfo,
|
347
|
-
hostSign: this.hostSign,
|
348
|
-
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
349
|
-
});
|
350
|
-
case 23:
|
351
|
-
res = _context2.sent;
|
352
|
-
this.logger.logInfo({
|
353
|
-
title: 'sdk_event_sdkQueryEnd'
|
354
|
-
}, {
|
355
|
-
paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
|
356
|
-
// TODO: 安全合规考虑
|
357
|
-
responseBody: res
|
358
|
-
});
|
359
|
-
_context2.next = 31;
|
360
|
-
break;
|
361
|
-
case 27:
|
362
|
-
_context2.prev = 27;
|
363
|
-
_context2.t0 = _context2["catch"](20);
|
364
|
-
this.logger.logError({
|
365
|
-
title: 'sdk_event_sdkQuery_failed'
|
366
|
-
}, {
|
367
|
-
paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
|
368
|
-
errorReason: _context2.t0
|
369
|
-
});
|
370
|
-
throw _context2.t0;
|
371
|
-
case 31:
|
372
|
-
case "end":
|
373
|
-
return _context2.stop();
|
374
|
-
}
|
375
|
-
}, _callee2, this, [[20, 27]]);
|
376
|
-
}));
|
377
|
-
function processPaymentQuery() {
|
378
|
-
return _processPaymentQuery.apply(this, arguments);
|
379
|
-
}
|
380
|
-
return processPaymentQuery;
|
381
|
-
}()
|
382
|
-
}, {
|
383
|
-
key: "processSubmitPay",
|
384
|
-
value: function () {
|
385
|
-
var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
386
|
-
var _this$paymentContext8, _this$paymentContext9, _this$paymentContext11, _this$channelBehavior3, _this$channelBehavior4, _this$paymentContext$5;
|
387
|
-
var submitParams, shouldSkipSubmitPayInSDK, _this$paymentContext10, _ref5, _ref5$productSceneVer, productSceneVersion, _ref5$productScene, productScene, _ref6, _ref6$action, _ref6$action2, _ref6$action2$enableS, enableSignAgreement, _ref6$action2$autoDeb, autoDebitWithToken, extParams, requester, res;
|
388
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
389
|
-
while (1) switch (_context3.prev = _context3.next) {
|
390
263
|
case 0:
|
391
264
|
submitParams = {
|
392
|
-
paymentSessionData: ((_this$
|
393
|
-
paymentSessionConfig: (_this$
|
265
|
+
paymentSessionData: ((_this$paymentContext = this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSessionId) || '',
|
266
|
+
paymentSessionConfig: (_this$paymentContext2 = this.paymentContext) === null || _this$paymentContext2 === void 0 || (_this$paymentContext2 = _this$paymentContext2.paymentSessionObj) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSessionConfig
|
394
267
|
};
|
395
|
-
|
396
|
-
|
397
|
-
// 新逻辑走 channelBehavior判断
|
398
|
-
shouldSkipSubmitPayInSDK = !this.channelBehavior.submitPayInSdk;
|
399
|
-
} else {
|
400
|
-
// TODO: 拉会找栎昂、甘颜一起对下
|
401
|
-
// 老逻辑,只要服务端标记不跳过sdkquery,就需要跳过submitpay
|
402
|
-
shouldSkipSubmitPayInSDK = !((_this$paymentContext10 = this.paymentContext) !== null && _this$paymentContext10 !== void 0 && (_this$paymentContext10 = _this$paymentContext10.paymentSessionObj) !== null && _this$paymentContext10 !== void 0 && (_this$paymentContext10 = _this$paymentContext10.action) !== null && _this$paymentContext10 !== void 0 && _this$paymentContext10.skipSdkQuery);
|
403
|
-
}
|
404
|
-
_ref5 = submitParams.paymentSessionConfig || {}, _ref5$productSceneVer = _ref5.productSceneVersion, productSceneVersion = _ref5$productSceneVer === void 0 ? '' : _ref5$productSceneVer, _ref5$productScene = _ref5.productScene, productScene = _ref5$productScene === void 0 ? '' : _ref5$productScene;
|
405
|
-
_ref6 = ((_this$paymentContext11 = this.paymentContext) === null || _this$paymentContext11 === void 0 ? void 0 : _this$paymentContext11.paymentSessionObj) || {}, _ref6$action = _ref6.action, _ref6$action2 = _ref6$action === void 0 ? {} : _ref6$action, _ref6$action2$enableS = _ref6$action2.enableSignAgreement, enableSignAgreement = _ref6$action2$enableS === void 0 ? false : _ref6$action2$enableS, _ref6$action2$autoDeb = _ref6$action2.autoDebitWithToken, autoDebitWithToken = _ref6$action2$autoDeb === void 0 ? false : _ref6$action2$autoDeb;
|
268
|
+
_ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
|
269
|
+
_ref4 = ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionObj) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$enableS = _ref4$action2.enableSignAgreement, enableSignAgreement = _ref4$action2$enableS === void 0 ? false : _ref4$action2$enableS, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
|
406
270
|
if (productSceneVersion === '2.0' && !autoDebitWithToken) {
|
407
271
|
///EasyPay 2.0 首次传signAgreement字段
|
408
272
|
submitParams['signAgreement'] = enableSignAgreement;
|
273
|
+
paymentMethodType = (_this$paymentContext$ = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$ === void 0 || (_this$paymentContext$ = _this$paymentContext$.paymentMethodInfoView) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.paymentMethodType;
|
274
|
+
isAppWebview = this.paymentContext.startBizFlowOptions.isAppWebview;
|
275
|
+
if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
|
276
|
+
backScheme = getBackScheme(undefined, this.logger);
|
277
|
+
if (backScheme && backScheme !== 'https') {
|
278
|
+
submitParams['h5FromApp'] = encodeURIComponent(backScheme);
|
279
|
+
}
|
280
|
+
}
|
409
281
|
}
|
410
|
-
|
411
|
-
|
412
|
-
if (
|
413
|
-
|
282
|
+
this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
|
283
|
+
//console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
|
284
|
+
if (this.allowSubmitPayCallAhead) {
|
285
|
+
_context2.next = 7;
|
414
286
|
break;
|
415
287
|
}
|
416
|
-
return
|
288
|
+
return _context2.abrupt("return", {
|
417
289
|
message: 'sdk no need to make submitPay request',
|
418
290
|
success: true
|
419
291
|
});
|
420
|
-
case
|
421
|
-
// 下面真实发请求
|
292
|
+
case 7:
|
293
|
+
requestBizId = uuid(); // 下面真实发请求
|
422
294
|
this.logger.logInfo({
|
423
295
|
title: 'sdk_event_submitPay'
|
424
296
|
}, {
|
425
297
|
paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
|
426
|
-
|
427
|
-
responseBody: submitParams
|
298
|
+
requestBizId: requestBizId
|
428
299
|
});
|
429
300
|
// 由渠道定制点来构建额外参数
|
430
|
-
extParams = ((_this$
|
301
|
+
extParams = ((_this$channelBehavior2 = this.channelBehavior) === null || _this$channelBehavior2 === void 0 || (_this$channelBehavior3 = _this$channelBehavior2.buildSubmitPayExtParams) === null || _this$channelBehavior3 === void 0 ? void 0 : _this$channelBehavior3.call(_this$channelBehavior2, {
|
431
302
|
instanceId: this.instanceId,
|
432
303
|
locale: this.initConfig.locale,
|
433
|
-
paymentMethodType: (_this$paymentContext$
|
434
|
-
paymentSessionData: this.paymentContext.
|
304
|
+
paymentMethodType: (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentMethodInfoView) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.paymentMethodType,
|
305
|
+
paymentSessionData: this.paymentContext.paymentSessionId,
|
435
306
|
env: this.initConfig.environment,
|
436
307
|
sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
|
437
308
|
})) || {};
|
309
|
+
extParams.complianceSDK = true;
|
438
310
|
submitParams.extParams = extParams;
|
439
311
|
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
312
|
+
_context2.prev = 13;
|
313
|
+
_context2.t0 = requester;
|
314
|
+
_context2.t1 = submitParams;
|
315
|
+
_context2.t2 = this.initConfig.environment;
|
316
|
+
_context2.next = 19;
|
444
317
|
return this.acquireApdidToken();
|
445
|
-
case
|
446
|
-
|
447
|
-
|
448
|
-
deviceId:
|
318
|
+
case 19:
|
319
|
+
_context2.t3 = _context2.sent;
|
320
|
+
_context2.t4 = {
|
321
|
+
deviceId: _context2.t3
|
449
322
|
};
|
450
|
-
|
451
|
-
|
452
|
-
env:
|
323
|
+
_context2.t5 = this.hostSign;
|
324
|
+
_context2.t6 = {
|
325
|
+
env: _context2.t2,
|
453
326
|
timeout: 15000,
|
454
|
-
envInfo:
|
455
|
-
hostSign:
|
327
|
+
envInfo: _context2.t4,
|
328
|
+
hostSign: _context2.t5,
|
456
329
|
needEnvInfo: true,
|
457
330
|
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
458
331
|
};
|
459
|
-
|
460
|
-
return
|
461
|
-
case
|
462
|
-
res =
|
332
|
+
_context2.next = 25;
|
333
|
+
return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t6);
|
334
|
+
case 25:
|
335
|
+
res = _context2.sent;
|
463
336
|
this.logger.logInfo({
|
464
337
|
title: 'sdk_event_submitPayEnd'
|
465
338
|
}, {
|
466
339
|
paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
|
467
|
-
|
340
|
+
requestBizId: requestBizId,
|
341
|
+
traceId: res.traceId
|
342
|
+
});
|
343
|
+
return _context2.abrupt("return", res);
|
344
|
+
case 30:
|
345
|
+
_context2.prev = 30;
|
346
|
+
_context2.t7 = _context2["catch"](13);
|
347
|
+
this.logger.logError({
|
348
|
+
title: 'sdk_event_submitPay_failed'
|
349
|
+
}, {
|
350
|
+
paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
|
351
|
+
errorReason: _context2.t7,
|
352
|
+
requestBizId: requestBizId,
|
353
|
+
traceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
|
468
354
|
});
|
469
|
-
|
470
|
-
case
|
355
|
+
throw _context2.t7;
|
356
|
+
case 34:
|
471
357
|
case "end":
|
472
|
-
return
|
358
|
+
return _context2.stop();
|
473
359
|
}
|
474
|
-
},
|
360
|
+
}, _callee2, this, [[13, 30]]);
|
475
361
|
}));
|
476
362
|
function processSubmitPay() {
|
477
363
|
return _processSubmitPay.apply(this, arguments);
|
478
364
|
}
|
479
365
|
return processSubmitPay;
|
480
|
-
}()
|
366
|
+
}()
|
481
367
|
}, {
|
482
368
|
key: "acquireApdidToken",
|
483
369
|
value: function () {
|
484
|
-
var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
485
|
-
var _this$paymentContext$
|
370
|
+
var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
371
|
+
var _this$paymentContext$3;
|
486
372
|
var securityService, productScene, deviceId;
|
487
|
-
return _regeneratorRuntime().wrap(function
|
488
|
-
while (1) switch (
|
373
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
374
|
+
while (1) switch (_context3.prev = _context3.next) {
|
489
375
|
case 0:
|
490
376
|
securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
|
491
|
-
productScene = (_this$paymentContext$
|
377
|
+
productScene = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$3 === void 0 || (_this$paymentContext$3 = _this$paymentContext$3.paymentSessionConfig) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.productScene;
|
492
378
|
deviceId = securityService.getDeviceId({
|
493
379
|
productScene: productScene
|
494
380
|
});
|
495
|
-
return
|
381
|
+
return _context3.abrupt("return", deviceId);
|
496
382
|
case 4:
|
497
383
|
case "end":
|
498
|
-
return
|
384
|
+
return _context3.stop();
|
499
385
|
}
|
500
|
-
},
|
386
|
+
}, _callee3, this);
|
501
387
|
}));
|
502
388
|
function acquireApdidToken() {
|
503
389
|
return _acquireApdidToken.apply(this, arguments);
|
@@ -505,32 +391,73 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
505
391
|
return acquireApdidToken;
|
506
392
|
}()
|
507
393
|
}, {
|
508
|
-
key: "
|
509
|
-
value: function
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
394
|
+
key: "initSecuritySDK",
|
395
|
+
value: function () {
|
396
|
+
var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
397
|
+
var _this$paymentContext$4, _this$paymentContext$5, productSceneVersion, nonCompliant, nonInitSecuritySDK, isFirstTimeToPay, shouldInitSecuritySDK;
|
398
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
399
|
+
while (1) switch (_context4.prev = _context4.next) {
|
400
|
+
case 0:
|
401
|
+
_context4.prev = 0;
|
402
|
+
productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
|
403
|
+
nonCompliant = (_this$paymentContext$4 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$4 === void 0 ? void 0 : _this$paymentContext$4.nonCompliant;
|
404
|
+
nonInitSecuritySDK = (_this$paymentContext$5 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$5 === void 0 ? void 0 : _this$paymentContext$5.nonInitSecuritySDK;
|
405
|
+
isFirstTimeToPay = !this.paymentContext.paymentSessionObj.action.autoDebitWithToken;
|
406
|
+
shouldInitSecuritySDK = false;
|
407
|
+
if (nonInitSecuritySDK) {
|
408
|
+
// 钱包不依赖风控
|
409
|
+
// console.log('[web-sdk][security-sdk] DO NOT init security sdk when nonInitSecuritySDK is true');
|
410
|
+
shouldInitSecuritySDK = false;
|
411
|
+
} else {
|
412
|
+
if (productSceneVersion === '1.0') {
|
413
|
+
// 1.0 不初始化 SecuritySDK
|
414
|
+
// console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 1.0');
|
415
|
+
shouldInitSecuritySDK = false;
|
416
|
+
} else if (productSceneVersion === '2.0') {
|
417
|
+
if (nonCompliant === true) {
|
418
|
+
// 未切流「隐私合规」
|
419
|
+
// console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and nonCompliant is true');
|
420
|
+
shouldInitSecuritySDK = true;
|
421
|
+
} else {
|
422
|
+
if (isFirstTimeToPay) {
|
423
|
+
// console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 2.0 and when first time to pay');
|
424
|
+
shouldInitSecuritySDK = false;
|
425
|
+
} else {
|
426
|
+
// 切流「隐私合规」且非首次支付
|
427
|
+
// console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and when not first time to pay');
|
428
|
+
shouldInitSecuritySDK = true;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
}
|
433
|
+
if (!shouldInitSecuritySDK) {
|
434
|
+
_context4.next = 10;
|
435
|
+
break;
|
436
|
+
}
|
437
|
+
_context4.next = 10;
|
438
|
+
return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
|
439
|
+
case 10:
|
440
|
+
this.logger.logInfo({
|
441
|
+
title: 'a3753.b101271.c388193.d514078'
|
442
|
+
}, {
|
443
|
+
riskSdkInfo: shouldInitSecuritySDK ? RiskSdkInfoEnum.NEED : RiskSdkInfoEnum.NO_NEED
|
444
|
+
});
|
445
|
+
_context4.next = 15;
|
446
|
+
break;
|
447
|
+
case 13:
|
448
|
+
_context4.prev = 13;
|
449
|
+
_context4.t0 = _context4["catch"](0);
|
450
|
+
case 15:
|
451
|
+
case "end":
|
452
|
+
return _context4.stop();
|
453
|
+
}
|
454
|
+
}, _callee4, this, [[0, 13]]);
|
514
455
|
}));
|
515
|
-
|
516
|
-
|
517
|
-
key: "getPreviousProductInfo",
|
518
|
-
value: function getPreviousProductInfo() {
|
519
|
-
var previousProductInfo = localStorage.getItem(KEY_PREVIOUS_PRODUCT_INFO);
|
520
|
-
if (previousProductInfo) {
|
521
|
-
try {
|
522
|
-
return JSON.parse(previousProductInfo);
|
523
|
-
} catch (error) {
|
524
|
-
console.log(error);
|
525
|
-
this.logger.logError({
|
526
|
-
title: 'performance_optimization_get_previousChannel_error'
|
527
|
-
}, {
|
528
|
-
error: error
|
529
|
-
});
|
530
|
-
}
|
456
|
+
function initSecuritySDK() {
|
457
|
+
return _initSecuritySDK.apply(this, arguments);
|
531
458
|
}
|
532
|
-
return
|
533
|
-
}
|
459
|
+
return initSecuritySDK;
|
460
|
+
}()
|
534
461
|
}]);
|
535
462
|
return EasySafePayProcessor;
|
536
463
|
}();
|