@alipay/ams-checkout 0.0.1745808793-dev.0 → 0.0.1745808793-dev.2

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 (39) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +1 -0
  3. package/esm/component/channel.js +25 -42
  4. package/esm/config/index.d.ts +8 -8
  5. package/esm/config/index.js +8 -8
  6. package/esm/constant/easysafepay.d.ts +16 -0
  7. package/esm/constant/easysafepay.js +19 -0
  8. package/esm/constant/index.d.ts +4 -0
  9. package/esm/constant/index.js +4 -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 +81 -29
  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 +169 -71
  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/preload_helper.d.ts +2 -2
  28. package/esm/foundation/utils/preload_helper.js +8 -4
  29. package/esm/foundation/utils/web_app_url_utils.d.ts +55 -1
  30. package/esm/foundation/utils/web_app_url_utils.js +164 -8
  31. package/esm/index.js +1 -1
  32. package/esm/plugin/component/cashierApp.js +4 -4
  33. package/esm/plugin/component/channel.d.ts +2 -1
  34. package/esm/plugin/component/channel.js +9 -12
  35. package/esm/plugin/component/index.js +44 -42
  36. package/esm/plugin/type.d.ts +1 -1
  37. package/esm/types/index.d.ts +15 -0
  38. package/esm/types/index.js +6 -0
  39. package/package.json +1 -1
@@ -18,6 +18,9 @@ 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 { getDefaultEasySafePayPageUrl } from "../../utils/web_app_url_utils";
23
+ import { ESP_PAGE_NAME } from "../../../constant/easysafepay";
21
24
  export var EasySafePayProcessor = /*#__PURE__*/function () {
22
25
  function EasySafePayProcessor() {
23
26
  _classCallCheck(this, EasySafePayProcessor);
@@ -29,6 +32,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
29
32
  _defineProperty(this, "instanceId", void 0);
30
33
  // 服务端接口区域信息,请求时决定API域名
31
34
  _defineProperty(this, "hostSign", void 0);
35
+ _defineProperty(this, "allowQueryCall", void 0);
32
36
  // 是否允许submitPay提前调用,在ESP非首次的性能优化场景使用
33
37
  _defineProperty(this, "allowSubmitPayCallAhead", void 0);
34
38
  _defineProperty(this, "channelBehavior", void 0);
@@ -46,7 +50,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
46
50
  this.eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
47
51
 
48
52
  // preload web app
49
- PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, this.initConfig.environment);
53
+ PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, this.initConfig.environment, true);
50
54
  }
51
55
  }, {
52
56
  key: "startBizFlow",
@@ -73,6 +77,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
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
79
  this.channelBehavior = ChannelCustomize.getChannelBehavior(paymentContext.paymentSessionObj);
80
+
76
81
  // 首次支付
77
82
  isFirstTimeToPay = !autoDebitWithToken; // 处理ESP1.0极速外跳支付场景
78
83
  if (!(productSceneVersion === '1.0' && isFirstTimeToPay && requireFastSdk)) {
@@ -113,15 +118,19 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
113
118
  }, {
114
119
  key: "buildWebAppUrl",
115
120
  value: function buildWebAppUrl() {
116
- var _paymentContext$payme3, _paymentContext$payme4, _this$initConfig$anal;
121
+ var _paymentContext$payme3, _paymentContext$payme4, _paymentContext$payme5, _this$initConfig$anal;
117
122
  var paymentContext = this.paymentContext;
118
123
  var paymentMethodCategoryType = (_paymentContext$payme3 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme3 === void 0 ? void 0 : _paymentContext$payme3.paymentMethodCategoryType;
119
- var productSceneVersion = (_paymentContext$payme4 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme4 === void 0 ? void 0 : _paymentContext$payme4.productSceneVersion;
124
+ var productScene = (_paymentContext$payme4 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme4 === void 0 ? void 0 : _paymentContext$payme4.productScene;
125
+ var productSceneVersion = (_paymentContext$payme5 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme5 === void 0 ? void 0 : _paymentContext$payme5.productSceneVersion;
120
126
  var hostSign = this.hostSign;
121
- var webAppUrl = WebAppUrlUtil.getWebAppUrl({
127
+ var mid = paymentContext.paymentSessionObj.clientId;
128
+ var extendInfo = paymentContext.paymentSessionObj.extendInfo;
129
+ var webAppUrl = WebAppUrlUtil.getWebAppV2Url({
122
130
  environment: this.initConfig.environment,
123
131
  paymentMethodCategoryType: paymentMethodCategoryType,
124
132
  sdkMetaData: paymentContext.sdkMetaData,
133
+ productScene: productScene,
125
134
  productSceneVersion: productSceneVersion,
126
135
  isPreload: false,
127
136
  query: {
@@ -130,7 +139,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
130
139
  instanceId: this.instanceId,
131
140
  locale: this.initConfig.locale,
132
141
  hostSign: hostSign
133
- }
142
+ },
143
+ mid: mid,
144
+ extendInfo: extendInfo
134
145
  });
135
146
  return webAppUrl;
136
147
  }
@@ -177,17 +188,19 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
177
188
  });
178
189
 
179
190
  // 等请求和 Web启动都Ready之后,发送renderComponent
180
- Promise.all([this.initSecuritySDK(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
191
+ Promise.all([this.initSecuritySDK(), this.processQuery(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
181
192
  var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext$4;
182
- var _ref2 = _slicedToArray(_ref, 3),
193
+ var _ref2 = _slicedToArray(_ref, 4),
183
194
  _initSecurityRes = _ref2[0],
184
- submitRes = _ref2[1],
185
- _webLaunchRes = _ref2[2];
195
+ queryRes = _ref2[1],
196
+ submitRes = _ref2[2],
197
+ _webLaunchRes = _ref2[3];
186
198
  var logMetaData = _this.logger.getLogConfig().mdata;
187
199
  _this.eventCenter.dispatchToApp({
188
200
  event: 'renderComponent',
189
201
  data: {
190
202
  sessionResult: (_this$paymentContext = _this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSessionObj,
203
+ queryResult: queryRes,
191
204
  submitResult: submitRes,
192
205
  paymentSessionData: (_this$paymentContext2 = _this.paymentContext) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSessionId,
193
206
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
@@ -197,6 +210,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
197
210
  isAppWebview: _this.paymentContext.startBizFlowOptions.isAppWebview,
198
211
  merchantAppointParam: (_this$paymentContext$3 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.merchantAppointParam,
199
212
  allowSubmitPayCallAhead: _this.allowSubmitPayCallAhead,
213
+ doubleFaUrl: getDefaultEasySafePayPageUrl(ESP_PAGE_NAME.DOUBLE_FA, _this.initConfig.environment),
200
214
  envInfo: {
201
215
  screenHeight: screen.height,
202
216
  screenWidth: screen.width
@@ -225,24 +239,105 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
225
239
  });
226
240
  }
227
241
  }, {
228
- key: "processSubmitPay",
242
+ key: "processQuery",
229
243
  value: function () {
230
- var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
231
- var _this$paymentContext3, _this$paymentContext4, _this$paymentContext5, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$6;
232
- 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;
244
+ var _processQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
245
+ var _this$paymentContext3, _this$paymentContext4;
246
+ var queryParams, extendInfo, extendInfoData, needQueryRender, requestBizId, requester, _this$paymentContext$5, res;
233
247
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
234
248
  while (1) switch (_context2.prev = _context2.next) {
235
249
  case 0:
236
- submitParams = {
250
+ queryParams = {
237
251
  paymentSessionData: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionId) || '',
238
252
  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
239
253
  };
254
+ extendInfo = this.paymentContext.paymentSessionObj.extendInfo;
255
+ try {
256
+ extendInfoData = JSON.parse(extendInfo);
257
+ needQueryRender = isEmpty(extendInfoData.needQueryRender) || extendInfoData.needQueryRender === true;
258
+ this.allowQueryCall = needQueryRender;
259
+ } catch (error) {
260
+ console.log(error);
261
+ }
262
+ if (this.allowQueryCall) {
263
+ _context2.next = 5;
264
+ break;
265
+ }
266
+ return _context2.abrupt("return", null);
267
+ case 5:
268
+ requestBizId = uuid();
269
+ this.logger.logInfo({
270
+ title: 'sdk_event_sdkQuery'
271
+ }, {
272
+ config: JSON.stringify(queryParams.paymentSessionConfig),
273
+ requestId: requestBizId
274
+ });
275
+ requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
276
+ _context2.prev = 8;
277
+ _context2.next = 11;
278
+ return requester.request(_objectSpread(_objectSpread({}, queryParams), {}, {
279
+ actionType: 'init',
280
+ integrationType: 'SDK',
281
+ sdkVersion: (_this$paymentContext$5 = this.paymentContext.sdkMetaData.sdkVersion) !== null && _this$paymentContext$5 !== void 0 ? _this$paymentContext$5 : '1.0.0'
282
+ }), {
283
+ env: this.initConfig.environment,
284
+ timeout: this.SDK_REQUEST_TIMEOUT,
285
+ hostSign: this.hostSign,
286
+ needEnvInfo: true,
287
+ 'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
288
+ });
289
+ case 11:
290
+ res = _context2.sent;
291
+ this.logger.logInfo({
292
+ title: 'sdk_event_sdkQueryEnd'
293
+ }, {
294
+ config: JSON.stringify(queryParams.paymentSessionConfig),
295
+ requestId: requestBizId,
296
+ rpcTraceId: res.traceId
297
+ });
298
+ return _context2.abrupt("return", res);
299
+ case 16:
300
+ _context2.prev = 16;
301
+ _context2.t0 = _context2["catch"](8);
302
+ this.logger.logError({
303
+ title: 'sdk_event_sdkQuery_failed'
304
+ }, {
305
+ config: JSON.stringify(queryParams.paymentSessionConfig),
306
+ errorMessage: JSON.stringify(_context2.t0),
307
+ requestId: requestBizId,
308
+ rpcTraceId: _context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.traceId
309
+ });
310
+ return _context2.abrupt("return", null);
311
+ case 20:
312
+ case "end":
313
+ return _context2.stop();
314
+ }
315
+ }, _callee2, this, [[8, 16]]);
316
+ }));
317
+ function processQuery() {
318
+ return _processQuery.apply(this, arguments);
319
+ }
320
+ return processQuery;
321
+ }()
322
+ }, {
323
+ key: "processSubmitPay",
324
+ value: function () {
325
+ var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
326
+ var _this$paymentContext5, _this$paymentContext6, _this$paymentContext7, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$7, _this$paymentContext8;
327
+ var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$6, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, _this$paymentContext$8, res;
328
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
329
+ while (1) switch (_context3.prev = _context3.next) {
330
+ case 0:
331
+ submitParams = {
332
+ paymentSessionData: ((_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.paymentSessionId) || '',
333
+ paymentSessionConfig: (_this$paymentContext6 = this.paymentContext) === null || _this$paymentContext6 === void 0 || (_this$paymentContext6 = _this$paymentContext6.paymentSessionObj) === null || _this$paymentContext6 === void 0 ? void 0 : _this$paymentContext6.paymentSessionConfig
334
+ };
240
335
  _ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
241
- _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;
336
+ _ref4 = ((_this$paymentContext7 = this.paymentContext) === null || _this$paymentContext7 === void 0 ? void 0 : _this$paymentContext7.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;
242
337
  if (productSceneVersion === '2.0' && !autoDebitWithToken) {
243
338
  ///EasyPay 2.0 首次传signAgreement字段
244
339
  submitParams['signAgreement'] = enableSignAgreement;
245
- 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;
340
+ 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;
246
341
  isAppWebview = this.paymentContext.startBizFlowOptions.isAppWebview;
247
342
  if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
248
343
  backScheme = getBackScheme(undefined, this.logger);
@@ -254,10 +349,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
254
349
  this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
255
350
  //console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
256
351
  if (this.allowSubmitPayCallAhead) {
257
- _context2.next = 7;
352
+ _context3.next = 7;
258
353
  break;
259
354
  }
260
- return _context2.abrupt("return", {
355
+ return _context3.abrupt("return", {
261
356
  message: 'sdk no need to make submitPay request',
262
357
  success: true
263
358
  });
@@ -273,42 +368,45 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
273
368
  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, {
274
369
  instanceId: this.instanceId,
275
370
  locale: this.initConfig.locale,
276
- 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,
371
+ 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,
277
372
  paymentSessionData: this.paymentContext.paymentSessionId,
278
373
  env: this.initConfig.environment,
279
- sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
280
- })) || {};
281
- extParams.complianceSDK = true;
374
+ sdkVersion: this.paymentContext.sdkMetaData.sdkVersion,
375
+ notRedirectAfterComplete: ((_this$paymentContext8 = this.paymentContext) === null || _this$paymentContext8 === void 0 || (_this$paymentContext8 = _this$paymentContext8.startBizFlowOptions) === null || _this$paymentContext8 === void 0 || (_this$paymentContext8 = _this$paymentContext8.submitPayRequestExtra) === null || _this$paymentContext8 === void 0 ? void 0 : _this$paymentContext8.notRedirectAfterComplete) === true
376
+ })) || {}; // 二次支付不再需要该参数
377
+ if (!autoDebitWithToken) {
378
+ extParams.complianceSDK = true;
379
+ }
282
380
  submitParams.extParams = extParams;
283
381
  requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
284
- _context2.prev = 13;
285
- _context2.t0 = requester;
286
- _context2.t1 = _objectSpread(_objectSpread({}, submitParams), {}, {
382
+ _context3.prev = 13;
383
+ _context3.t0 = requester;
384
+ _context3.t1 = _objectSpread(_objectSpread({}, submitParams), {}, {
287
385
  integrationType: 'SDK',
288
- sdkVersion: (_this$paymentContext$7 = this.paymentContext.sdkMetaData.sdkVersion) !== null && _this$paymentContext$7 !== void 0 ? _this$paymentContext$7 : '1.0.0'
386
+ sdkVersion: (_this$paymentContext$8 = this.paymentContext.sdkMetaData.sdkVersion) !== null && _this$paymentContext$8 !== void 0 ? _this$paymentContext$8 : '1.0.0'
289
387
  });
290
- _context2.t2 = this.initConfig.environment;
291
- _context2.t3 = this.SDK_REQUEST_TIMEOUT;
292
- _context2.next = 20;
388
+ _context3.t2 = this.initConfig.environment;
389
+ _context3.t3 = this.SDK_REQUEST_TIMEOUT;
390
+ _context3.next = 20;
293
391
  return this.acquireApdidToken();
294
392
  case 20:
295
- _context2.t4 = _context2.sent;
296
- _context2.t5 = {
297
- deviceId: _context2.t4
393
+ _context3.t4 = _context3.sent;
394
+ _context3.t5 = {
395
+ deviceId: _context3.t4
298
396
  };
299
- _context2.t6 = this.hostSign;
300
- _context2.t7 = {
301
- env: _context2.t2,
302
- timeout: _context2.t3,
303
- envInfo: _context2.t5,
304
- hostSign: _context2.t6,
397
+ _context3.t6 = this.hostSign;
398
+ _context3.t7 = {
399
+ env: _context3.t2,
400
+ timeout: _context3.t3,
401
+ envInfo: _context3.t5,
402
+ hostSign: _context3.t6,
305
403
  needEnvInfo: true,
306
404
  'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
307
405
  };
308
- _context2.next = 26;
309
- return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t7);
406
+ _context3.next = 26;
407
+ return _context3.t0.request.call(_context3.t0, _context3.t1, _context3.t7);
310
408
  case 26:
311
- res = _context2.sent;
409
+ res = _context3.sent;
312
410
  this.logger.logInfo({
313
411
  title: 'sdk_event_submitPayEnd'
314
412
  }, {
@@ -316,24 +414,24 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
316
414
  requestId: requestBizId,
317
415
  rpcTraceId: res.traceId
318
416
  });
319
- return _context2.abrupt("return", res);
417
+ return _context3.abrupt("return", res);
320
418
  case 31:
321
- _context2.prev = 31;
322
- _context2.t8 = _context2["catch"](13);
419
+ _context3.prev = 31;
420
+ _context3.t8 = _context3["catch"](13);
323
421
  this.logger.logError({
324
422
  title: 'sdk_event_submitPay_failed'
325
423
  }, {
326
424
  config: JSON.stringify(submitParams.paymentSessionConfig),
327
- errorMessage: JSON.stringify(_context2.t8),
425
+ errorMessage: JSON.stringify(_context3.t8),
328
426
  requestId: requestBizId,
329
- rpcTraceId: _context2.t8 === null || _context2.t8 === void 0 ? void 0 : _context2.t8.traceId
427
+ rpcTraceId: _context3.t8 === null || _context3.t8 === void 0 ? void 0 : _context3.t8.traceId
330
428
  });
331
- return _context2.abrupt("return", null);
429
+ return _context3.abrupt("return", null);
332
430
  case 35:
333
431
  case "end":
334
- return _context2.stop();
432
+ return _context3.stop();
335
433
  }
336
- }, _callee2, this, [[13, 31]]);
434
+ }, _callee3, this, [[13, 31]]);
337
435
  }));
338
436
  function processSubmitPay() {
339
437
  return _processSubmitPay.apply(this, arguments);
@@ -343,23 +441,23 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
343
441
  }, {
344
442
  key: "acquireApdidToken",
345
443
  value: function () {
346
- var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
347
- var _this$paymentContext$8;
444
+ var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
445
+ var _this$paymentContext$9;
348
446
  var securityService, productScene, deviceId;
349
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
350
- while (1) switch (_context3.prev = _context3.next) {
447
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
448
+ while (1) switch (_context4.prev = _context4.next) {
351
449
  case 0:
352
450
  securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
353
- 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;
451
+ productScene = (_this$paymentContext$9 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$9 === void 0 || (_this$paymentContext$9 = _this$paymentContext$9.paymentSessionConfig) === null || _this$paymentContext$9 === void 0 ? void 0 : _this$paymentContext$9.productScene;
354
452
  deviceId = securityService.getDeviceId({
355
453
  productScene: productScene
356
454
  });
357
- return _context3.abrupt("return", deviceId);
455
+ return _context4.abrupt("return", deviceId);
358
456
  case 4:
359
457
  case "end":
360
- return _context3.stop();
458
+ return _context4.stop();
361
459
  }
362
- }, _callee3, this);
460
+ }, _callee4, this);
363
461
  }));
364
462
  function acquireApdidToken() {
365
463
  return _acquireApdidToken.apply(this, arguments);
@@ -369,15 +467,15 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
369
467
  }, {
370
468
  key: "initSecuritySDK",
371
469
  value: function () {
372
- var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
373
- var _this$paymentContext$9, _this$paymentContext$10, productSceneVersion, nonCompliant, nonInitSecuritySDK, isFirstTimeToPay, shouldInitSecuritySDK;
374
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
375
- while (1) switch (_context4.prev = _context4.next) {
470
+ var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
471
+ var _this$paymentContext$10, _this$paymentContext$11, productSceneVersion, nonCompliant, nonInitSecuritySDK, isFirstTimeToPay, shouldInitSecuritySDK;
472
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
473
+ while (1) switch (_context5.prev = _context5.next) {
376
474
  case 0:
377
- _context4.prev = 0;
475
+ _context5.prev = 0;
378
476
  productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
379
- nonCompliant = (_this$paymentContext$9 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$9 === void 0 ? void 0 : _this$paymentContext$9.nonCompliant;
380
- nonInitSecuritySDK = (_this$paymentContext$10 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$10 === void 0 ? void 0 : _this$paymentContext$10.nonInitSecuritySDK;
477
+ nonCompliant = (_this$paymentContext$10 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$10 === void 0 ? void 0 : _this$paymentContext$10.nonCompliant;
478
+ nonInitSecuritySDK = (_this$paymentContext$11 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$11 === void 0 ? void 0 : _this$paymentContext$11.nonInitSecuritySDK;
381
479
  isFirstTimeToPay = !this.paymentContext.paymentSessionObj.action.autoDebitWithToken;
382
480
  shouldInitSecuritySDK = false;
383
481
  if (nonInitSecuritySDK) {
@@ -407,10 +505,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
407
505
  }
408
506
  }
409
507
  if (!shouldInitSecuritySDK) {
410
- _context4.next = 10;
508
+ _context5.next = 10;
411
509
  break;
412
510
  }
413
- _context4.next = 10;
511
+ _context5.next = 10;
414
512
  return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
415
513
  case 10:
416
514
  this.logger.logInfo({
@@ -418,16 +516,16 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
418
516
  }, {
419
517
  riskSdkInfo: shouldInitSecuritySDK ? RiskSdkInfoEnum.NEED : RiskSdkInfoEnum.NO_NEED
420
518
  });
421
- _context4.next = 15;
519
+ _context5.next = 15;
422
520
  break;
423
521
  case 13:
424
- _context4.prev = 13;
425
- _context4.t0 = _context4["catch"](0);
522
+ _context5.prev = 13;
523
+ _context5.t0 = _context5["catch"](0);
426
524
  case 15:
427
525
  case "end":
428
- return _context4.stop();
526
+ return _context5.stop();
429
527
  }
430
- }, _callee4, this, [[0, 13]]);
528
+ }, _callee5, this, [[0, 13]]);
431
529
  }));
432
530
  function initSecuritySDK() {
433
531
  return _initSecuritySDK.apply(this, arguments);
@@ -29,5 +29,6 @@ export declare class ContainerService implements Service {
29
29
  private handleAppHeartBeat;
30
30
  private changeCloseBtnVisibility;
31
31
  private handleMaskCloseBtnShow;
32
+ private handleCloseButtonTheme;
32
33
  getWebApp(): HTMLIFrameElement;
33
34
  }
@@ -11,7 +11,7 @@ import { isEmpty } from "../../../util";
11
11
  import { addInlineLoading, createInlineBaseElement } from "../../../component/component.inline.style";
12
12
  import { addPopupLoading, createBaseElement } from "../../../component/component.popup.style";
13
13
  import { insertStyleSheet } from "../../../component/popupWindow.style";
14
- import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, EVENT, LOADING_ID, MOCKUP_ID, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../../constant";
14
+ import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, EVENT, LOADING_ID, MOCKUP_ID, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT, closeImg, closeImgLight } from "../../../constant";
15
15
  import { DisplayTypeEnum, ProductSceneEnum } from "../../../types";
16
16
  import { ServiceProvider } from "../index";
17
17
  import { PopupManager } from "./popup";
@@ -194,7 +194,8 @@ export var ContainerService = /*#__PURE__*/function () {
194
194
  this.eventCenter.listen(EVENT.sizeChanged.name, function (data) {
195
195
  _this.handleSizeChanged(_objectSpread({}, data));
196
196
  });
197
- this.eventCenter.listen(EVENT.showCloseButton.name, function () {
197
+ this.eventCenter.listen(EVENT.showCloseButton.name, function (data) {
198
+ _this.handleCloseButtonTheme(data.theme);
198
199
  _this.changeCloseBtnVisibility(true);
199
200
  });
200
201
  this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
@@ -323,6 +324,23 @@ export var ContainerService = /*#__PURE__*/function () {
323
324
  closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-hidden"));
324
325
  }
325
326
  }
327
+ }, {
328
+ key: "handleCloseButtonTheme",
329
+ value: function handleCloseButtonTheme(theme) {
330
+ if (!theme) return;
331
+ var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
332
+ var closeButtonImg = closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.querySelector('img');
333
+ var maskCloseBlock = document.getElementById(COMPONENT_CLOSE_MASK_BLOCK_ID);
334
+ if (theme === 'light') {
335
+ closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImgLight);
336
+ closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
337
+ maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
338
+ } else {
339
+ closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImg);
340
+ closeBlock === null || closeBlock === void 0 || closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
341
+ maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.remove("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
342
+ }
343
+ }
326
344
  }, {
327
345
  key: "getWebApp",
328
346
  value: function getWebApp() {
@@ -4,10 +4,10 @@ export default class PreloadHelper {
4
4
  static isWebAppPreloaded: boolean;
5
5
  static isSecuritySDKPreloaded: boolean;
6
6
  private static securitySdkMap;
7
- static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string): void;
7
+ static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string, useV2?: boolean): void;
8
8
  static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
9
9
  static getSecuritySdk(scene: any): Security;
10
- static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string): {
10
+ static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string, useV2?: boolean): {
11
11
  preloadUrl: string;
12
12
  containerId: string;
13
13
  };
@@ -8,7 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
8
8
  import { sdkVersion } from "../../config";
9
9
  import { createPreloadIframe } from "../service/container/utils";
10
10
  import { ProductSceneEnum } from "../../types";
11
- import { getWebAppUrl } from "../utils/web_app_url_utils";
11
+ import { getWebAppUrl, getWebAppV2Url } from "../utils/web_app_url_utils";
12
12
  import { ProductInfoCacheUtil } from "../utils/payment_product_utils";
13
13
  import { getWebAppVersion } from "./payment_context_utils";
14
14
  import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security } from "../../util/security";
@@ -22,12 +22,13 @@ var PreloadHelper = /*#__PURE__*/function () {
22
22
  key: "preloadWebApp",
23
23
  value: function preloadWebApp(productScene, paymentMethodCategoryType) {
24
24
  var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'prod';
25
+ var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
25
26
  try {
26
27
  if (this.isWebAppPreloaded) {
27
28
  console.log('[web-sdk] web app already preloaded');
28
29
  return;
29
30
  }
30
- var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
31
+ var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment, useV2),
31
32
  preloadUrl = _this$buildWebAppPrel.preloadUrl,
32
33
  containerId = _this$buildWebAppPrel.containerId;
33
34
  var preloadIframe = createPreloadIframe(containerId);
@@ -89,6 +90,7 @@ var PreloadHelper = /*#__PURE__*/function () {
89
90
  }, {
90
91
  key: "buildWebAppPreloadUrl",
91
92
  value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
93
+ var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
92
94
  var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
93
95
  var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
94
96
  if (previousProductInfo) {
@@ -101,14 +103,16 @@ var PreloadHelper = /*#__PURE__*/function () {
101
103
  webAppVersion: ''
102
104
  };
103
105
  sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
104
- var preloadUrl = getWebAppUrl({
106
+ var preloadUrlParams = {
105
107
  environment: environment,
106
108
  sdkMetaData: sdkMetaData,
107
109
  paymentMethodCategoryType: paymentMethodCategoryType,
108
110
  isPreload: true,
111
+ productScene: productScene,
109
112
  productSceneVersion: productSceneVersion,
110
113
  query: undefined
111
- });
114
+ };
115
+ var preloadUrl = useV2 ? getWebAppV2Url(preloadUrlParams) : getWebAppUrl(preloadUrlParams);
112
116
  return {
113
117
  preloadUrl: preloadUrl,
114
118
  containerId: containerId
@@ -1,5 +1,6 @@
1
- import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum } from '../../types';
1
+ import { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from '../../types';
2
2
  import { SDKMetaData } from '../index';
3
+ import { ESP_PAGE_NAME } from "../../constant/easysafepay";
3
4
  /**
4
5
  * Tell the SDK which version of the Web App to load.
5
6
  * Sent by server inside paymentSession.
@@ -16,6 +17,16 @@ export interface WebAppMatchConfig {
16
17
  mid?: string;
17
18
  greyscale?: string;
18
19
  }
20
+ /**
21
+ * Tell the SDK which Web App URL to load.
22
+ * Sent by server inside paymentSession.
23
+ */
24
+ export interface WebAppUrlMatchConfig {
25
+ minSDKVersion: string;
26
+ url: string;
27
+ doubleFa: string;
28
+ mids?: string[];
29
+ }
19
30
  export interface QueryParams {
20
31
  displayType: DisplayTypeEnum;
21
32
  locale: string;
@@ -27,20 +38,63 @@ export interface QueryParams {
27
38
  export declare const getWebAppUrlInfo: (params: {
28
39
  environment: string;
29
40
  sdkMetaData: SDKMetaData;
41
+ productScene: ProductSceneEnum;
30
42
  productSceneVersion: string;
31
43
  paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
32
44
  isPreload?: boolean;
33
45
  query: QueryParams;
46
+ v2Url?: string;
34
47
  }) => {
35
48
  path: string;
36
49
  locationSearch: string;
37
50
  };
51
+ export declare const getWebAppV2Url: (params: {
52
+ environment: string;
53
+ sdkMetaData: SDKMetaData;
54
+ productScene: ProductSceneEnum;
55
+ productSceneVersion: string;
56
+ paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
57
+ isPreload?: boolean;
58
+ query: QueryParams;
59
+ mid?: string;
60
+ extendInfo?: string;
61
+ }) => string;
38
62
  export declare const getWebAppUrl: (params: {
39
63
  environment: string;
40
64
  sdkMetaData: SDKMetaData;
65
+ productScene: ProductSceneEnum;
41
66
  productSceneVersion: string;
42
67
  paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
43
68
  isPreload?: boolean;
44
69
  query: QueryParams;
70
+ v2Url?: string;
45
71
  }) => string;
46
72
  export declare const parseWebAppMatchConfig: (extendInfo: string) => WebAppMatchConfig[];
73
+ export declare const parseWebAppUrlMatchConfig: (extendInfo: string) => WebAppUrlMatchConfig[];
74
+ /**
75
+ * Save the current checkout URL to localStorage for the specified product scene.
76
+ *
77
+ * @param productScene - The product scene for which the checkout URL should be saved.
78
+ */
79
+ export declare const saveLocalCheckoutUrl: (productScene: ProductSceneEnum, url: string) => void;
80
+ /**
81
+ * Retrieve the saved checkout URL from localStorage for the specified product scene.
82
+ * If no url is found, a default checkout url string is returned.
83
+ *
84
+ * @param productScene - The product scene for which the checkout URL should be retrieved.
85
+ */
86
+ export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, environment: string) => string;
87
+ /**
88
+ * Provide default checkout URL for the specified product scene.
89
+ * Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
90
+ *
91
+ * @param productScene - The product scene for which the default checkout URL should be provided.
92
+ */
93
+ export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
94
+ export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, config: WebAppUrlMatchConfig[], environment: string) => string;
95
+ /**
96
+ * V2应用EasySafePay 热更新兜底URL构建规则
97
+ * 1. 兜底URL版本与sdk版本保持一致
98
+ * 2. DEV环境下html新增版本前缀
99
+ **/
100
+ export declare const getDefaultEasySafePayPageUrl: (pageName: ESP_PAGE_NAME, env: string) => string;