@alipay/ams-checkout 0.0.1745808793-dev.1 → 0.0.1745808793-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +3 -1
  3. package/esm/component/channel.js +24 -42
  4. package/esm/config/index.d.ts +7 -7
  5. package/esm/config/index.js +7 -7
  6. package/esm/constant/easysafepay.d.ts +16 -0
  7. package/esm/constant/easysafepay.js +19 -0
  8. package/esm/constant/index.d.ts +1 -0
  9. package/esm/constant/index.js +1 -0
  10. package/esm/core/component/element/elementContainerService/containerService.js +2 -2
  11. package/esm/core/component/element/elementController/index.js +15 -9
  12. package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +3 -0
  13. package/esm/core/component/element/elementProcessor/baseElementProcessor.js +11 -0
  14. package/esm/core/component/element/elementProcessor/paymentProcessor.js +15 -8
  15. package/esm/core/component/element/index.js +6 -1
  16. package/esm/core/component/element/util.d.ts +6 -0
  17. package/esm/core/component/element/util.js +27 -0
  18. package/esm/core/instance/index.d.ts +1 -1
  19. package/esm/foundation/core/index.d.ts +3 -0
  20. package/esm/foundation/core/index.js +33 -4
  21. package/esm/foundation/index.d.ts +6 -0
  22. package/esm/foundation/product-processor/easysafepay/deps.d.ts +1 -1
  23. package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -0
  24. package/esm/foundation/product-processor/easysafepay/index.js +219 -113
  25. package/esm/foundation/service/container/index.d.ts +1 -0
  26. package/esm/foundation/service/container/index.js +20 -2
  27. package/esm/foundation/utils/web_app_url_utils.d.ts +30 -5
  28. package/esm/foundation/utils/web_app_url_utils.js +127 -42
  29. package/esm/plugin/component/channel.d.ts +3 -1
  30. package/esm/plugin/component/channel.js +10 -12
  31. package/esm/plugin/component/index.js +45 -42
  32. package/esm/plugin/type.d.ts +1 -1
  33. package/esm/types/index.d.ts +17 -0
  34. package/esm/types/index.js +6 -0
  35. package/package.json +3 -2
@@ -15,14 +15,13 @@ import { cleanMockup, createMockup, createRetentionPopup, handleDeclareInfo, hid
15
15
  import { insertStyleSheet } from "../../component/popupWindow.style";
16
16
  import { sdkVersion } from "../../config";
17
17
  import { COMPONENT_CLOSE_MASK_BLOCK_ID, EVENT, LOADING_ID } from "../../constant";
18
- import { DisplayTypeEnum, eventCodeEnum } from "../../types";
18
+ import { DisplayTypeEnum, eventCodeEnum, EventLoggingEventId } from "../../types";
19
19
  import { DisplayInfo, IElementStatus } from "../index";
20
20
  import { ServiceProvider } from "../service";
21
21
  import { getGrayscaleId } from "../utils/gray_scale_utils";
22
22
  import { convertPaymentSession, getWebAppVersion, saveWebAppVersion } from "../utils/payment_context_utils";
23
23
  import { redirect } from "../utils/redirect_utils";
24
24
  import { parseWebAppMatchConfig } from "../utils/web_app_url_utils";
25
-
26
25
  /**
27
26
  * @author 谦彧 <zhangmian.zm@alipay.com>
28
27
  * @date 2024/9/17
@@ -37,8 +36,11 @@ export var AntomSDKCore = /*#__PURE__*/function () {
37
36
  _defineProperty(this, "sdkMetaData", void 0);
38
37
  _defineProperty(this, "productProcessors", {});
39
38
  _defineProperty(this, "enablePopWindowEventCallback", false);
39
+ _defineProperty(this, "eventLogging", void 0);
40
40
  _defineProperty(this, "status", IElementStatus.UNINIT);
41
+ _defineProperty(this, "logger", void 0);
41
42
  this.status = IElementStatus.INITING;
43
+ this.logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
42
44
  }
43
45
  _createClass(AntomSDKCore, [{
44
46
  key: "getStatus",
@@ -220,6 +222,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
220
222
  eventCenter.listen(EVENT.declareEventCallbackInfo.name, function (data) {
221
223
  if (data !== null && data !== void 0 && data.popWindowEventInfo) {
222
224
  _this.enablePopWindowEventCallback = data.popWindowEventInfo.enableCallback;
225
+ _this.eventLogging = data.eventLogging;
223
226
  }
224
227
  });
225
228
 
@@ -365,7 +368,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
365
368
  showRetentionPopup();
366
369
  return;
367
370
  } else {
368
- _this2.handleClose(isOnCloseEvent);
371
+ _this2.handleClose(isOnCloseEvent, 'behavior');
369
372
  }
370
373
  };
371
374
 
@@ -391,9 +394,10 @@ export var AntomSDKCore = /*#__PURE__*/function () {
391
394
  if (displayType == DisplayTypeEnum.popup) {
392
395
  createRetentionPopup(platform, function () {
393
396
  hideRetentionPopup();
397
+ _this2.handleRemain();
394
398
  }, function () {
395
399
  hideRetentionPopup();
396
- _this2.handleClose();
400
+ _this2.handleClose(false, 'retention');
397
401
  });
398
402
  createMockup({
399
403
  platform: platform,
@@ -404,13 +408,38 @@ export var AntomSDKCore = /*#__PURE__*/function () {
404
408
  return;
405
409
  }
406
410
  }
411
+ }, {
412
+ key: "handleRemain",
413
+ value: function handleRemain() {
414
+ if (this.eventLogging && this.eventLogging.enableLogging) {
415
+ this.logger.logInfo({
416
+ code: this.eventLogging.eventName
417
+ }, {
418
+ eventId: EventLoggingEventId.ContinuePaying,
419
+ eventName: this.eventLogging.eventName,
420
+ eventAlias: this.eventLogging.eventAlias,
421
+ userPath: this.eventLogging.userPath
422
+ });
423
+ }
424
+ }
407
425
  }, {
408
426
  key: "handleClose",
409
427
  value: function handleClose() {
410
428
  var isOnCloseEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
429
+ var source = arguments.length > 1 ? arguments[1] : undefined;
411
430
  var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
412
431
  eventCenter.emit(EVENT.closeCallback.name, {});
413
432
  if (this.enablePopWindowEventCallback && !isOnCloseEvent) {
433
+ if (this.eventLogging && this.eventLogging.enableLogging) {
434
+ this.logger.logInfo({
435
+ code: this.eventLogging.eventName
436
+ }, {
437
+ eventId: source === 'behavior' ? EventLoggingEventId.OnlyClose : EventLoggingEventId.LeaveAnyWay,
438
+ eventName: this.eventLogging.eventName,
439
+ eventAlias: this.eventLogging.eventAlias,
440
+ userPath: this.eventLogging.userPath
441
+ });
442
+ }
414
443
  eventCenter.emit(EVENT.eventCallback.name, {
415
444
  code: eventCodeEnum.SDK_PAYMENT_CANCEL,
416
445
  result: {
@@ -76,6 +76,12 @@ export interface SDKMetaData {
76
76
  webAppVersion: string;
77
77
  greyscaleId?: number;
78
78
  }
79
+ export interface EventLogging {
80
+ enableLogging: boolean;
81
+ eventName: string;
82
+ eventAlias: any;
83
+ userPath: string;
84
+ }
79
85
  export interface InitContext {
80
86
  initOptions: IoptionsParams;
81
87
  sdkMetaData: SDKMetaData;
@@ -4,7 +4,7 @@ export type { BizFlowStartBehavior, PaymentContext, ProductProcessor, RedirectBe
4
4
  export * as ChannelCustomize from '../../../component/channel';
5
5
  export type { IChannelBehavior } from '../../../component/channel';
6
6
  export { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum, RiskSdkInfoEnum } from '../../../types';
7
- export type { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, IoptionsParams, } from '../../../types';
7
+ export type { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSdkActionQuerySessionResult, CashierSubmitPayRequest, CashierSubmitPayResult, IoptionsParams, } from '../../../types';
8
8
  export { isPC } from '../../../util';
9
9
  export { getBackScheme } from '../../utils/redirect_utils';
10
10
  export { isLocalMock } from '../../../util/mock';
@@ -7,6 +7,7 @@ export declare class EasySafePayProcessor implements ProductProcessor {
7
7
  private eventCenter;
8
8
  private instanceId;
9
9
  private hostSign;
10
+ private allowQueryCall;
10
11
  private allowSubmitPayCallAhead;
11
12
  private channelBehavior?;
12
13
  private SECURITY_SDK_INIT_TIMEOUT;
@@ -21,6 +22,7 @@ export declare class EasySafePayProcessor implements ProductProcessor {
21
22
  * start waiting web launch, then send renderComponent event
22
23
  * */
23
24
  private sendRequestAndWaitWebLaunch;
25
+ private processQuery;
24
26
  private processSubmitPay;
25
27
  private acquireApdidToken;
26
28
  private initSecuritySDK;
@@ -18,6 +18,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
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
19
  import PreloadHelper from "../../../foundation/utils/preload_helper";
20
20
  import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, PaymentMethodCategoryTypeEnum, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil, EVENT, eventCodeEnum } from "./deps";
21
+ import { isEmpty } from "../../../util";
22
+ import { getDoubleFaUrlFromSession } from "../../utils/web_app_url_utils";
21
23
  export var EasySafePayProcessor = /*#__PURE__*/function () {
22
24
  function EasySafePayProcessor() {
23
25
  _classCallCheck(this, EasySafePayProcessor);
@@ -29,6 +31,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
29
31
  _defineProperty(this, "instanceId", void 0);
30
32
  // 服务端接口区域信息,请求时决定API域名
31
33
  _defineProperty(this, "hostSign", void 0);
34
+ _defineProperty(this, "allowQueryCall", void 0);
32
35
  // 是否允许submitPay提前调用,在ESP非首次的性能优化场景使用
33
36
  _defineProperty(this, "allowSubmitPayCallAhead", void 0);
34
37
  _defineProperty(this, "channelBehavior", void 0);
@@ -52,7 +55,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
52
55
  key: "startBizFlow",
53
56
  value: function () {
54
57
  var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentContext) {
55
- var _paymentContext$payme2, _this$channelBehavior;
58
+ var _paymentContext$payme2, _paymentContext$start, _this$channelBehavior;
56
59
  var _paymentContext$payme, productSceneVersion, paymentMethodCategoryType, autoDebitWithToken, requireFastSdk, authUrlInfo, isFirstTimeToPay, webAppUrl, resultPayload;
57
60
  return _regeneratorRuntime().wrap(function _callee$(_context) {
58
61
  while (1) switch (_context.prev = _context.next) {
@@ -60,9 +63,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
60
63
  // 放在最前面的逻辑
61
64
  // 在PC场景下,几乎所有渠道都是没有拉端的逻辑的,所以需要改成1.0, 这个是历史原因
62
65
  if (isPC()) {
63
- // 非TOSS渠道,在PC场景需要改成1.0
66
+ // 非TOSS渠道,在PC场景需要改成1.0/needAccountConfirmPage=false
64
67
  if ('BANKTRANSFER_QUICKPAY' !== ((_paymentContext$payme = paymentContext.paymentSessionObj) === null || _paymentContext$payme === void 0 || (_paymentContext$payme = _paymentContext$payme.paymentMethodInfoView) === null || _paymentContext$payme === void 0 ? void 0 : _paymentContext$payme.paymentMethodType)) {
65
68
  paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion = '1.0';
69
+ paymentContext.paymentSessionObj.needAccountConfirmPage = false;
66
70
  }
67
71
  }
68
72
  this.paymentContext = paymentContext;
@@ -72,10 +76,11 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
72
76
  autoDebitWithToken = paymentContext.paymentSessionObj.action.autoDebitWithToken;
73
77
  requireFastSdk = paymentContext.paymentSessionObj.action.requireFastSdk;
74
78
  authUrlInfo = ((_paymentContext$payme2 = paymentContext.paymentSessionObj) === null || _paymentContext$payme2 === void 0 ? void 0 : _paymentContext$payme2.authUrlInfo) || {};
75
- this.channelBehavior = ChannelCustomize.getChannelBehavior(paymentContext.paymentSessionObj);
79
+ this.channelBehavior = ChannelCustomize.getChannelBehavior(((_paymentContext$start = paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _paymentContext$start === void 0 ? void 0 : _paymentContext$start.notRedirectAfterComplete) === true, paymentContext.paymentSessionObj);
80
+
76
81
  // 首次支付
77
- isFirstTimeToPay = !autoDebitWithToken; // 处理ESP1.0极速外跳支付场景
78
- if (!(productSceneVersion === '1.0' && isFirstTimeToPay && requireFastSdk)) {
82
+ isFirstTimeToPay = !autoDebitWithToken; // 处理ESP极速外跳支付场景
83
+ if (!(isFirstTimeToPay && requireFastSdk)) {
79
84
  _context.next = 12;
80
85
  break;
81
86
  }
@@ -183,42 +188,48 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
183
188
  });
184
189
 
185
190
  // 等请求和 Web启动都Ready之后,发送renderComponent
186
- Promise.all([this.initSecuritySDK(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
187
- var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext$4;
188
- var _ref2 = _slicedToArray(_ref, 3),
191
+ Promise.all([this.initSecuritySDK(), this.processQuery(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
192
+ var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext3, _this$paymentContext$4;
193
+ var _ref2 = _slicedToArray(_ref, 4),
189
194
  _initSecurityRes = _ref2[0],
190
- submitRes = _ref2[1],
191
- _webLaunchRes = _ref2[2];
195
+ queryRes = _ref2[1],
196
+ submitRes = _ref2[2],
197
+ _webLaunchRes = _ref2[3];
192
198
  var logMetaData = _this.logger.getLogConfig().mdata;
199
+ var data = {
200
+ sessionResult: (_this$paymentContext = _this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSessionObj,
201
+ submitResult: submitRes,
202
+ paymentSessionData: (_this$paymentContext2 = _this.paymentContext) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSessionId,
203
+ heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
204
+ renderDisplayType: _this.paymentContext.displayInfo.type,
205
+ appearance: (_this$paymentContext$ = _this.paymentContext.displayInfo) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.appearance,
206
+ notRedirectAfterComplete: ((_this$paymentContext$2 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.notRedirectAfterComplete) === true,
207
+ isAppWebview: _this.paymentContext.startBizFlowOptions.isAppWebview,
208
+ merchantAppointParam: (_this$paymentContext$3 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.merchantAppointParam,
209
+ allowSubmitPayCallAhead: _this.allowSubmitPayCallAhead,
210
+ doubleFaUrl: getDoubleFaUrlFromSession((_this$paymentContext3 = _this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionObj, _this.initConfig.environment),
211
+ envInfo: {
212
+ screenHeight: screen.height,
213
+ screenWidth: screen.width
214
+ },
215
+ logMetaData: _objectSpread(_objectSpread({
216
+ trackId: logMetaData.requestSeq,
217
+ platform: logMetaData.platform,
218
+ firstLogTime: logMetaData.firstLogTime
219
+ }, ((_this$paymentContext$4 = _this.paymentContext.paymentSessionObj) === null || _this$paymentContext$4 === void 0 ? void 0 : _this$paymentContext$4.paymentSessionConfig) || {}), {}, {
220
+ renderDisplayType: logMetaData.renderDisplayType,
221
+ sdkVersion: logMetaData.sdkVersion,
222
+ merchantId: logMetaData.merchantId,
223
+ instanceId: logMetaData.instanceId,
224
+ paymentMethodType: logMetaData.paymentMethodType
225
+ })
226
+ };
227
+ if (queryRes) {
228
+ data.queryResult = queryRes;
229
+ }
193
230
  _this.eventCenter.dispatchToApp({
194
231
  event: 'renderComponent',
195
- data: {
196
- sessionResult: (_this$paymentContext = _this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSessionObj,
197
- submitResult: submitRes,
198
- paymentSessionData: (_this$paymentContext2 = _this.paymentContext) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSessionId,
199
- heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
200
- renderDisplayType: _this.paymentContext.displayInfo.type,
201
- appearance: (_this$paymentContext$ = _this.paymentContext.displayInfo) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.appearance,
202
- notRedirectAfterComplete: ((_this$paymentContext$2 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.notRedirectAfterComplete) === true,
203
- isAppWebview: _this.paymentContext.startBizFlowOptions.isAppWebview,
204
- merchantAppointParam: (_this$paymentContext$3 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.merchantAppointParam,
205
- allowSubmitPayCallAhead: _this.allowSubmitPayCallAhead,
206
- envInfo: {
207
- screenHeight: screen.height,
208
- screenWidth: screen.width
209
- },
210
- logMetaData: _objectSpread(_objectSpread({
211
- trackId: logMetaData.requestSeq,
212
- platform: logMetaData.platform,
213
- firstLogTime: logMetaData.firstLogTime
214
- }, ((_this$paymentContext$4 = _this.paymentContext.paymentSessionObj) === null || _this$paymentContext$4 === void 0 ? void 0 : _this$paymentContext$4.paymentSessionConfig) || {}), {}, {
215
- renderDisplayType: logMetaData.renderDisplayType,
216
- sdkVersion: logMetaData.sdkVersion,
217
- merchantId: logMetaData.merchantId,
218
- instanceId: logMetaData.instanceId,
219
- paymentMethodType: logMetaData.paymentMethodType
220
- })
221
- }
232
+ data: data
222
233
  });
223
234
  }).catch(function (error) {
224
235
  _this.eventCenter.emit(EVENT.destroy.name, {});
@@ -231,24 +242,122 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
231
242
  });
232
243
  }
233
244
  }, {
234
- key: "processSubmitPay",
245
+ key: "processQuery",
235
246
  value: function () {
236
- var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
237
- var _this$paymentContext3, _this$paymentContext4, _this$paymentContext5, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$6;
238
- var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$5, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, _this$paymentContext$7, res;
247
+ var _processQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
248
+ var _this$paymentContext4, _this$paymentContext5, _this$paymentContext6, _this$paymentContext$5, _this$paymentContext7, _this$paymentContext8;
249
+ var queryParams, extendInfo, needAccountConfirmPage, isFirstTimeToPay, needQueryRender, extendInfoData, requestBizId, requester, _this$paymentContext$6, res;
239
250
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
240
251
  while (1) switch (_context2.prev = _context2.next) {
252
+ case 0:
253
+ queryParams = {
254
+ paymentSessionData: ((_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.paymentSessionId) || '',
255
+ paymentSessionConfig: (_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 || (_this$paymentContext5 = _this$paymentContext5.paymentSessionObj) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.paymentSessionConfig
256
+ };
257
+ extendInfo = (_this$paymentContext6 = this.paymentContext) === null || _this$paymentContext6 === void 0 ? void 0 : _this$paymentContext6.paymentSessionObj.extendInfo;
258
+ needAccountConfirmPage = (_this$paymentContext$5 = (_this$paymentContext7 = this.paymentContext) === null || _this$paymentContext7 === void 0 ? void 0 : _this$paymentContext7.paymentSessionObj.needAccountConfirmPage) !== null && _this$paymentContext$5 !== void 0 ? _this$paymentContext$5 : true;
259
+ isFirstTimeToPay = !((_this$paymentContext8 = this.paymentContext) !== null && _this$paymentContext8 !== void 0 && (_this$paymentContext8 = _this$paymentContext8.paymentSessionObj.action) !== null && _this$paymentContext8 !== void 0 && _this$paymentContext8.autoDebitWithToken);
260
+ needQueryRender = true;
261
+ try {
262
+ extendInfoData = JSON.parse(extendInfo);
263
+ needQueryRender = isEmpty(extendInfoData.needQueryRender) || extendInfoData.needQueryRender === true;
264
+ } catch (error) {
265
+ console.log(error);
266
+ }
267
+ this.allowQueryCall = needQueryRender && isFirstTimeToPay && needAccountConfirmPage;
268
+ if (this.allowQueryCall) {
269
+ _context2.next = 9;
270
+ break;
271
+ }
272
+ return _context2.abrupt("return", null);
273
+ case 9:
274
+ requestBizId = uuid();
275
+ this.logger.logInfo({
276
+ title: 'sdk_event_sdkQuery'
277
+ }, {
278
+ config: JSON.stringify(queryParams.paymentSessionConfig),
279
+ requestId: requestBizId
280
+ });
281
+ requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
282
+ _context2.prev = 12;
283
+ _context2.t0 = requester;
284
+ _context2.t1 = _objectSpread(_objectSpread({}, queryParams), {}, {
285
+ actionType: 'init',
286
+ integrationType: 'SDK',
287
+ sdkVersion: (_this$paymentContext$6 = this.paymentContext.sdkMetaData.sdkVersion) !== null && _this$paymentContext$6 !== void 0 ? _this$paymentContext$6 : '1.0.0'
288
+ });
289
+ _context2.t2 = this.initConfig.environment;
290
+ _context2.t3 = this.SDK_REQUEST_TIMEOUT;
291
+ _context2.next = 19;
292
+ return this.acquireApdidToken();
293
+ case 19:
294
+ _context2.t4 = _context2.sent;
295
+ _context2.t5 = {
296
+ deviceId: _context2.t4
297
+ };
298
+ _context2.t6 = this.hostSign;
299
+ _context2.t7 = {
300
+ env: _context2.t2,
301
+ timeout: _context2.t3,
302
+ envInfo: _context2.t5,
303
+ hostSign: _context2.t6,
304
+ needEnvInfo: true,
305
+ 'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
306
+ };
307
+ _context2.next = 25;
308
+ return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t7);
309
+ case 25:
310
+ res = _context2.sent;
311
+ this.logger.logInfo({
312
+ title: 'sdk_event_sdkQueryEnd'
313
+ }, {
314
+ config: JSON.stringify(queryParams.paymentSessionConfig),
315
+ requestId: requestBizId,
316
+ rpcTraceId: res.traceId
317
+ });
318
+ return _context2.abrupt("return", res);
319
+ case 30:
320
+ _context2.prev = 30;
321
+ _context2.t8 = _context2["catch"](12);
322
+ this.logger.logError({
323
+ title: 'sdk_event_sdkQuery_failed'
324
+ }, {
325
+ config: JSON.stringify(queryParams.paymentSessionConfig),
326
+ errorMessage: JSON.stringify(_context2.t8),
327
+ requestId: requestBizId,
328
+ rpcTraceId: _context2.t8 === null || _context2.t8 === void 0 ? void 0 : _context2.t8.traceId
329
+ });
330
+ return _context2.abrupt("return", null);
331
+ case 34:
332
+ case "end":
333
+ return _context2.stop();
334
+ }
335
+ }, _callee2, this, [[12, 30]]);
336
+ }));
337
+ function processQuery() {
338
+ return _processQuery.apply(this, arguments);
339
+ }
340
+ return processQuery;
341
+ }()
342
+ }, {
343
+ key: "processSubmitPay",
344
+ value: function () {
345
+ var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
346
+ var _this$paymentContext9, _this$paymentContext10, _this$paymentContext11, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$8, _this$paymentContext12;
347
+ var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$7, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, _this$paymentContext$9, res;
348
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
349
+ while (1) switch (_context3.prev = _context3.next) {
241
350
  case 0:
242
351
  submitParams = {
243
- paymentSessionData: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionId) || '',
244
- 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
352
+ paymentSessionData: ((_this$paymentContext9 = this.paymentContext) === null || _this$paymentContext9 === void 0 ? void 0 : _this$paymentContext9.paymentSessionId) || '',
353
+ paymentSessionConfig: (_this$paymentContext10 = this.paymentContext) === null || _this$paymentContext10 === void 0 || (_this$paymentContext10 = _this$paymentContext10.paymentSessionObj) === null || _this$paymentContext10 === void 0 ? void 0 : _this$paymentContext10.paymentSessionConfig
245
354
  };
246
355
  _ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
247
- _ref4 = ((_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.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;
356
+ _ref4 = ((_this$paymentContext11 = this.paymentContext) === null || _this$paymentContext11 === void 0 ? void 0 : _this$paymentContext11.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;
248
357
  if (productSceneVersion === '2.0' && !autoDebitWithToken) {
249
358
  ///EasyPay 2.0 首次传signAgreement字段
250
359
  submitParams['signAgreement'] = enableSignAgreement;
251
- paymentMethodType = (_this$paymentContext$5 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$5 === void 0 || (_this$paymentContext$5 = _this$paymentContext$5.paymentMethodInfoView) === null || _this$paymentContext$5 === void 0 ? void 0 : _this$paymentContext$5.paymentMethodType;
360
+ paymentMethodType = (_this$paymentContext$7 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$7 === void 0 || (_this$paymentContext$7 = _this$paymentContext$7.paymentMethodInfoView) === null || _this$paymentContext$7 === void 0 ? void 0 : _this$paymentContext$7.paymentMethodType;
252
361
  isAppWebview = this.paymentContext.startBizFlowOptions.isAppWebview;
253
362
  if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
254
363
  backScheme = getBackScheme(undefined, this.logger);
@@ -260,10 +369,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
260
369
  this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
261
370
  //console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
262
371
  if (this.allowSubmitPayCallAhead) {
263
- _context2.next = 7;
372
+ _context3.next = 7;
264
373
  break;
265
374
  }
266
- return _context2.abrupt("return", {
375
+ return _context3.abrupt("return", {
267
376
  message: 'sdk no need to make submitPay request',
268
377
  success: true
269
378
  });
@@ -279,44 +388,46 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
279
388
  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, {
280
389
  instanceId: this.instanceId,
281
390
  locale: this.initConfig.locale,
282
- paymentMethodType: (_this$paymentContext$6 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$6 === void 0 || (_this$paymentContext$6 = _this$paymentContext$6.paymentMethodInfoView) === null || _this$paymentContext$6 === void 0 ? void 0 : _this$paymentContext$6.paymentMethodType,
391
+ paymentMethodType: (_this$paymentContext$8 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$8 === void 0 || (_this$paymentContext$8 = _this$paymentContext$8.paymentMethodInfoView) === null || _this$paymentContext$8 === void 0 ? void 0 : _this$paymentContext$8.paymentMethodType,
283
392
  paymentSessionData: this.paymentContext.paymentSessionId,
393
+ paymentSessionObj: this.paymentContext.paymentSessionObj,
284
394
  env: this.initConfig.environment,
285
- sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
395
+ sdkVersion: this.paymentContext.sdkMetaData.sdkVersion,
396
+ notRedirectAfterComplete: ((_this$paymentContext12 = this.paymentContext) === null || _this$paymentContext12 === void 0 || (_this$paymentContext12 = _this$paymentContext12.startBizFlowOptions) === null || _this$paymentContext12 === void 0 || (_this$paymentContext12 = _this$paymentContext12.submitPayRequestExtra) === null || _this$paymentContext12 === void 0 ? void 0 : _this$paymentContext12.notRedirectAfterComplete) === true
286
397
  })) || {}; // 二次支付不再需要该参数
287
398
  if (!autoDebitWithToken) {
288
399
  extParams.complianceSDK = true;
289
400
  }
290
401
  submitParams.extParams = extParams;
291
402
  requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
292
- _context2.prev = 13;
293
- _context2.t0 = requester;
294
- _context2.t1 = _objectSpread(_objectSpread({}, submitParams), {}, {
403
+ _context3.prev = 13;
404
+ _context3.t0 = requester;
405
+ _context3.t1 = _objectSpread(_objectSpread({}, submitParams), {}, {
295
406
  integrationType: 'SDK',
296
- sdkVersion: (_this$paymentContext$7 = this.paymentContext.sdkMetaData.sdkVersion) !== null && _this$paymentContext$7 !== void 0 ? _this$paymentContext$7 : '1.0.0'
407
+ sdkVersion: (_this$paymentContext$9 = this.paymentContext.sdkMetaData.sdkVersion) !== null && _this$paymentContext$9 !== void 0 ? _this$paymentContext$9 : '1.0.0'
297
408
  });
298
- _context2.t2 = this.initConfig.environment;
299
- _context2.t3 = this.SDK_REQUEST_TIMEOUT;
300
- _context2.next = 20;
409
+ _context3.t2 = this.initConfig.environment;
410
+ _context3.t3 = this.SDK_REQUEST_TIMEOUT;
411
+ _context3.next = 20;
301
412
  return this.acquireApdidToken();
302
413
  case 20:
303
- _context2.t4 = _context2.sent;
304
- _context2.t5 = {
305
- deviceId: _context2.t4
414
+ _context3.t4 = _context3.sent;
415
+ _context3.t5 = {
416
+ deviceId: _context3.t4
306
417
  };
307
- _context2.t6 = this.hostSign;
308
- _context2.t7 = {
309
- env: _context2.t2,
310
- timeout: _context2.t3,
311
- envInfo: _context2.t5,
312
- hostSign: _context2.t6,
418
+ _context3.t6 = this.hostSign;
419
+ _context3.t7 = {
420
+ env: _context3.t2,
421
+ timeout: _context3.t3,
422
+ envInfo: _context3.t5,
423
+ hostSign: _context3.t6,
313
424
  needEnvInfo: true,
314
425
  'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
315
426
  };
316
- _context2.next = 26;
317
- return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t7);
427
+ _context3.next = 26;
428
+ return _context3.t0.request.call(_context3.t0, _context3.t1, _context3.t7);
318
429
  case 26:
319
- res = _context2.sent;
430
+ res = _context3.sent;
320
431
  this.logger.logInfo({
321
432
  title: 'sdk_event_submitPayEnd'
322
433
  }, {
@@ -324,24 +435,24 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
324
435
  requestId: requestBizId,
325
436
  rpcTraceId: res.traceId
326
437
  });
327
- return _context2.abrupt("return", res);
438
+ return _context3.abrupt("return", res);
328
439
  case 31:
329
- _context2.prev = 31;
330
- _context2.t8 = _context2["catch"](13);
440
+ _context3.prev = 31;
441
+ _context3.t8 = _context3["catch"](13);
331
442
  this.logger.logError({
332
443
  title: 'sdk_event_submitPay_failed'
333
444
  }, {
334
445
  config: JSON.stringify(submitParams.paymentSessionConfig),
335
- errorMessage: JSON.stringify(_context2.t8),
446
+ errorMessage: JSON.stringify(_context3.t8),
336
447
  requestId: requestBizId,
337
- rpcTraceId: _context2.t8 === null || _context2.t8 === void 0 ? void 0 : _context2.t8.traceId
448
+ rpcTraceId: _context3.t8 === null || _context3.t8 === void 0 ? void 0 : _context3.t8.traceId
338
449
  });
339
- return _context2.abrupt("return", null);
450
+ return _context3.abrupt("return", null);
340
451
  case 35:
341
452
  case "end":
342
- return _context2.stop();
453
+ return _context3.stop();
343
454
  }
344
- }, _callee2, this, [[13, 31]]);
455
+ }, _callee3, this, [[13, 31]]);
345
456
  }));
346
457
  function processSubmitPay() {
347
458
  return _processSubmitPay.apply(this, arguments);
@@ -351,23 +462,23 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
351
462
  }, {
352
463
  key: "acquireApdidToken",
353
464
  value: function () {
354
- var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
355
- var _this$paymentContext$8;
465
+ var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
466
+ var _this$paymentContext$10;
356
467
  var securityService, productScene, deviceId;
357
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
358
- while (1) switch (_context3.prev = _context3.next) {
468
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
469
+ while (1) switch (_context4.prev = _context4.next) {
359
470
  case 0:
360
471
  securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
361
- productScene = (_this$paymentContext$8 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$8 === void 0 || (_this$paymentContext$8 = _this$paymentContext$8.paymentSessionConfig) === null || _this$paymentContext$8 === void 0 ? void 0 : _this$paymentContext$8.productScene;
472
+ productScene = (_this$paymentContext$10 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$10 === void 0 || (_this$paymentContext$10 = _this$paymentContext$10.paymentSessionConfig) === null || _this$paymentContext$10 === void 0 ? void 0 : _this$paymentContext$10.productScene;
362
473
  deviceId = securityService.getDeviceId({
363
474
  productScene: productScene
364
475
  });
365
- return _context3.abrupt("return", deviceId);
476
+ return _context4.abrupt("return", deviceId);
366
477
  case 4:
367
478
  case "end":
368
- return _context3.stop();
479
+ return _context4.stop();
369
480
  }
370
- }, _callee3, this);
481
+ }, _callee4, this);
371
482
  }));
372
483
  function acquireApdidToken() {
373
484
  return _acquireApdidToken.apply(this, arguments);
@@ -377,15 +488,16 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
377
488
  }, {
378
489
  key: "initSecuritySDK",
379
490
  value: function () {
380
- var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
381
- var _this$paymentContext$9, _this$paymentContext$10, productSceneVersion, nonCompliant, nonInitSecuritySDK, isFirstTimeToPay, shouldInitSecuritySDK;
382
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
383
- while (1) switch (_context4.prev = _context4.next) {
491
+ var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
492
+ var _this$paymentContext$11, _this$paymentContext$12, _this$paymentContext$13, _this$paymentContext$14, _this$paymentContext$15, _this$paymentContext$16, productSceneVersion, nonInitSecuritySDK, signButtonDisplay, userSignAgreement, isFirstTimeToPay, shouldInitSecuritySDK;
493
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
494
+ while (1) switch (_context5.prev = _context5.next) {
384
495
  case 0:
385
- _context4.prev = 0;
496
+ _context5.prev = 0;
386
497
  productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
387
- nonCompliant = (_this$paymentContext$9 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$9 === void 0 ? void 0 : _this$paymentContext$9.nonCompliant;
388
- nonInitSecuritySDK = (_this$paymentContext$10 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$10 === void 0 ? void 0 : _this$paymentContext$10.nonInitSecuritySDK;
498
+ nonInitSecuritySDK = (_this$paymentContext$11 = (_this$paymentContext$12 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$12 === void 0 ? void 0 : _this$paymentContext$12.nonInitSecuritySDK) !== null && _this$paymentContext$11 !== void 0 ? _this$paymentContext$11 : false;
499
+ signButtonDisplay = (_this$paymentContext$13 = (_this$paymentContext$14 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$14 === void 0 ? void 0 : _this$paymentContext$14.signButtonDisplay) !== null && _this$paymentContext$13 !== void 0 ? _this$paymentContext$13 : false;
500
+ userSignAgreement = (_this$paymentContext$15 = (_this$paymentContext$16 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$16 === void 0 ? void 0 : _this$paymentContext$16.userSignAgreement) !== null && _this$paymentContext$15 !== void 0 ? _this$paymentContext$15 : false;
389
501
  isFirstTimeToPay = !this.paymentContext.paymentSessionObj.action.autoDebitWithToken;
390
502
  shouldInitSecuritySDK = false;
391
503
  if (nonInitSecuritySDK) {
@@ -398,44 +510,38 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
398
510
  // console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 1.0');
399
511
  shouldInitSecuritySDK = false;
400
512
  } else if (productSceneVersion === '2.0') {
401
- if (nonCompliant === true) {
402
- // 未切流「隐私合规」
403
- // console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and nonCompliant is true');
404
- shouldInitSecuritySDK = true;
513
+ if (isFirstTimeToPay) {
514
+ // console.log((signButtonDisplay && userSignAgreement) ? '[web-sdk][security-sdk] DO init security sdk for easypay 2.0, first time to pay and user agreeement signing from merchant' : '[web-sdk][security-sdk] DO NOT init security sdk for easypay 2.0, first time to pay and user agreeement has not been signed from merchant');
515
+ shouldInitSecuritySDK = signButtonDisplay && userSignAgreement;
405
516
  } else {
406
- if (isFirstTimeToPay) {
407
- // console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 2.0 and when first time to pay');
408
- shouldInitSecuritySDK = false;
409
- } else {
410
- // 切流「隐私合规」且非首次支付
411
- // console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and when not first time to pay');
412
- shouldInitSecuritySDK = true;
413
- }
517
+ // 切流「隐私合规」且非首次支付
518
+ // console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and when not first time to pay');
519
+ shouldInitSecuritySDK = true;
414
520
  }
415
521
  }
416
522
  }
417
523
  if (!shouldInitSecuritySDK) {
418
- _context4.next = 10;
524
+ _context5.next = 11;
419
525
  break;
420
526
  }
421
- _context4.next = 10;
527
+ _context5.next = 11;
422
528
  return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
423
- case 10:
529
+ case 11:
424
530
  this.logger.logInfo({
425
531
  title: 'a3753.b101271.c388193.d514078'
426
532
  }, {
427
533
  riskSdkInfo: shouldInitSecuritySDK ? RiskSdkInfoEnum.NEED : RiskSdkInfoEnum.NO_NEED
428
534
  });
429
- _context4.next = 15;
535
+ _context5.next = 16;
430
536
  break;
431
- case 13:
432
- _context4.prev = 13;
433
- _context4.t0 = _context4["catch"](0);
434
- case 15:
537
+ case 14:
538
+ _context5.prev = 14;
539
+ _context5.t0 = _context5["catch"](0);
540
+ case 16:
435
541
  case "end":
436
- return _context4.stop();
542
+ return _context5.stop();
437
543
  }
438
- }, _callee4, this, [[0, 13]]);
544
+ }, _callee5, this, [[0, 14]]);
439
545
  }));
440
546
  function initSecuritySDK() {
441
547
  return _initSecuritySDK.apply(this, arguments);