@alipay/ams-checkout 0.0.1730107332-dev.3 → 0.0.1730107332-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ 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 { uuid, ProductSceneEnum, ChannelCustomize, DisplayTypeEnum, isLocalMock, isPC, ServiceProvider, ProductInfoCacheUtil, WebAppUrlUtil } from "./deps";
19
+ import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, ProductInfoCacheUtil, ProductSceneEnum, ServiceProvider, uuid, WebAppUrlUtil } from "./deps";
20
20
  export var EasySafePayProcessor = /*#__PURE__*/function () {
21
21
  function EasySafePayProcessor() {
22
22
  _classCallCheck(this, EasySafePayProcessor);
@@ -88,7 +88,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
88
88
  hostSign: this.hostSign,
89
89
  productSceneVersion: productSceneVersion
90
90
  });
91
- // 返回结果之前,发送actionquery,并且等待Web应用启动的事件,内部是异步处理,不阻塞。
91
+ // 返回结果之前,发送 sessionData,并且等待Web应用启动的事件,内部是异步处理,不阻塞。
92
92
  this.sendRequestAndWaitWebLaunch();
93
93
  // 返回结果,RENDER,让外层去处理iframe加载等逻辑
94
94
  return _context.abrupt("return", {
@@ -209,15 +209,6 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
209
209
  value: function sendRequestAndWaitWebLaunch() {
210
210
  var _this2 = this;
211
211
  var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
212
- var requestPromise = Promise.all([this.processPaymentQuery(), this.processSubmitPay()]).then(function (_ref) {
213
- var _ref2 = _slicedToArray(_ref, 2),
214
- queryRes = _ref2[0],
215
- submitRes = _ref2[1];
216
- return {
217
- queryRes: queryRes,
218
- submitRes: submitRes
219
- };
220
- });
221
212
  var webLaunchPromise = new Promise(function (resolve) {
222
213
  eventCenter.listen('onLaunch', function (res) {
223
214
  resolve(res);
@@ -225,24 +216,27 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
225
216
  });
226
217
 
227
218
  // 等请求和 Web启动都Ready之后,发送renderComponent
228
- Promise.all([requestPromise, webLaunchPromise]).then(function (_ref3) {
229
- var _this2$paymentContext, _this2$paymentContext2, _this2$paymentContext3, _this2$paymentContext4, _this2$paymentContext5, _this2$paymentContext6;
230
- var _ref4 = _slicedToArray(_ref3, 2),
231
- requestResult = _ref4[0],
232
- launchRes = _ref4[1];
219
+ Promise.all([this.processSubmitPay, webLaunchPromise]).then(function (_ref) {
220
+ var _this2$paymentContext, _this2$paymentContext2, _this2$paymentContext3, _this2$paymentContext4, _this2$paymentContext5, _this2$paymentContext6, _this2$paymentContext7, _this2$paymentContext8;
221
+ var _ref2 = _slicedToArray(_ref, 2),
222
+ submitRes = _ref2[0],
223
+ launchRes = _ref2[1];
233
224
  var logMetaData = _this2.logger.getLogConfig().mdata;
234
225
  eventCenter.dispatchToApp({
235
226
  event: 'renderComponent',
236
227
  data: {
237
- queryResult: requestResult.queryRes,
238
- submitResult: requestResult.submitRes,
239
- sessionResult: (_this2$paymentContext = _this2.paymentContext) === null || _this2$paymentContext === void 0 ? void 0 : _this2$paymentContext.paymentSessionObj,
240
- paymentSessionData: (_this2$paymentContext2 = _this2.paymentContext) === null || _this2$paymentContext2 === void 0 ? void 0 : _this2$paymentContext2.paymentSession,
228
+ queryResult: _objectSpread(_objectSpread({}, (_this2$paymentContext = _this2.paymentContext) === null || _this2$paymentContext === void 0 ? void 0 : _this2$paymentContext.paymentSessionObj), {}, {
229
+ orderAmount: (_this2$paymentContext2 = _this2.paymentContext) === null || _this2$paymentContext2 === void 0 || (_this2$paymentContext2 = _this2$paymentContext2.paymentSessionObj) === null || _this2$paymentContext2 === void 0 ? void 0 : _this2$paymentContext2.paymentView // For ESP 1.0
230
+ }),
231
+ sessionResult: (_this2$paymentContext3 = _this2.paymentContext) === null || _this2$paymentContext3 === void 0 ? void 0 : _this2$paymentContext3.paymentSessionObj,
232
+ submitResult: submitRes,
233
+ paymentSessionData: (_this2$paymentContext4 = _this2.paymentContext) === null || _this2$paymentContext4 === void 0 ? void 0 : _this2$paymentContext4.paymentSession,
241
234
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
242
235
  renderDisplayType: _this2.paymentContext.displayInfo.type,
243
- appearance: (_this2$paymentContext3 = _this2.paymentContext.displayInfo) === null || _this2$paymentContext3 === void 0 ? void 0 : _this2$paymentContext3.appearance,
244
- notRedirectAfterComplete: ((_this2$paymentContext4 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext4 === void 0 ? void 0 : _this2$paymentContext4.notRedirectAfterComplete) === true,
245
- merchantAppointParam: (_this2$paymentContext5 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext5 === void 0 ? void 0 : _this2$paymentContext5.merchantAppointParam,
236
+ appearance: (_this2$paymentContext5 = _this2.paymentContext.displayInfo) === null || _this2$paymentContext5 === void 0 ? void 0 : _this2$paymentContext5.appearance,
237
+ notRedirectAfterComplete: ((_this2$paymentContext6 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext6 === void 0 ? void 0 : _this2$paymentContext6.notRedirectAfterComplete) === true,
238
+ isAppWebview: _this2.paymentContext.startBizFlowOptions.isAppWebview,
239
+ merchantAppointParam: (_this2$paymentContext7 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext7 === void 0 ? void 0 : _this2$paymentContext7.merchantAppointParam,
246
240
  allowSubmitPayCallAhead: _this2.allowSubmitPayCallAhead,
247
241
  envInfo: {
248
242
  screenHeight: screen.height,
@@ -252,7 +246,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
252
246
  trackId: logMetaData.requestSeq,
253
247
  platform: logMetaData.platform,
254
248
  firstLogTime: logMetaData.firstLogTime
255
- }, ((_this2$paymentContext6 = _this2.paymentContext.paymentSessionObj) === null || _this2$paymentContext6 === void 0 ? void 0 : _this2$paymentContext6.paymentSessionConfig) || {}), {}, {
249
+ }, ((_this2$paymentContext8 = _this2.paymentContext.paymentSessionObj) === null || _this2$paymentContext8 === void 0 ? void 0 : _this2$paymentContext8.paymentSessionConfig) || {}), {}, {
256
250
  renderDisplayType: logMetaData.renderDisplayType,
257
251
  sdkVersion: logMetaData.sdkVersion,
258
252
  merchantId: logMetaData.merchantId,
@@ -264,164 +258,42 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
264
258
  });
265
259
  }
266
260
  }, {
267
- key: "processPaymentQuery",
261
+ key: "processSubmitPay",
268
262
  value: function () {
269
- var _processPaymentQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
270
- var _this$paymentContext, _this$paymentContext2, _this$paymentContext3, _this$paymentContext4, _this$paymentContext5, _this$channelBehavior2;
271
- var envInfo, requestData, extendInfo, actionData, enableEasypayApiOptimize, extendInfoData, productSceneVersion, requestBizId, requester, res;
263
+ var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
264
+ var _this$paymentContext, _this$paymentContext2, _this$paymentContext3, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$2;
265
+ 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;
272
266
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
273
267
  while (1) switch (_context2.prev = _context2.next) {
274
- case 0:
275
- envInfo = {
276
- locale: this.initConfig.locale
277
- }; //
278
- requestData = {
279
- paymentSessionData: ((_this$paymentContext = this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSession) || '',
280
- 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,
281
- notRedirectAfterComplete: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.startBizFlowOptions.submitPayRequestExtra.notRedirectAfterComplete) === true
282
- // merchantAppointParam: this._merchantAppointParam,
283
- };
284
- extendInfo = ((_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 || (_this$paymentContext4 = _this$paymentContext4.paymentSessionObj) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.extendInfo) || '';
285
- actionData = (_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 || (_this$paymentContext5 = _this$paymentContext5.paymentSessionObj) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.action;
286
- enableEasypayApiOptimize = false;
287
- try {
288
- extendInfoData = JSON.parse(extendInfo);
289
- enableEasypayApiOptimize = extendInfoData.enableEasypayApiOptimize || false;
290
- } catch (error) {
291
- console.log(error);
292
- }
293
- if (!isLocalMock()) {
294
- _context2.next = 8;
295
- break;
296
- }
297
- return _context2.abrupt("return", {
298
- message: 'sdk no need to make query request',
299
- success: true
300
- });
301
- case 8:
302
- if (!((_this$channelBehavior2 = this.channelBehavior) !== null && _this$channelBehavior2 !== void 0 && _this$channelBehavior2.usePaymentSessionAsQueryResult)) {
303
- _context2.next = 10;
304
- break;
305
- }
306
- return _context2.abrupt("return", {
307
- autoDebitWithToken: actionData === null || actionData === void 0 ? void 0 : actionData.autoDebitWithToken,
308
- amountConfirmRequired: actionData === null || actionData === void 0 ? void 0 : actionData.amountConfirmRequired,
309
- success: true
310
- });
311
- case 10:
312
- if (!(actionData.skipSdkQuery && enableEasypayApiOptimize)) {
313
- _context2.next = 12;
314
- break;
315
- }
316
- return _context2.abrupt("return", {
317
- message: 'sdk no need to make query request',
318
- success: true
319
- });
320
- case 12:
321
- productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion; // ESP 2.0 无需Query
322
- if (!(productSceneVersion === '2.0')) {
323
- _context2.next = 15;
324
- break;
325
- }
326
- return _context2.abrupt("return", {
327
- message: 'sdk no need to make query request',
328
- success: true
329
- });
330
- case 15:
331
- _context2.next = 17;
332
- return this.acquireApdidToken();
333
- case 17:
334
- envInfo.deviceId = _context2.sent;
335
- requestBizId = uuid(); // 打日志
336
- this.logger.logInfo({
337
- title: 'sdk_event_sdkQuery'
338
- }, {
339
- paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
340
- requestBizId: requestBizId
341
- });
342
-
343
- // 真正发请求
344
- requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
345
- _context2.prev = 21;
346
- _context2.next = 24;
347
- return requester.request(requestData, {
348
- env: this.initConfig.environment,
349
- envInfo: envInfo,
350
- hostSign: this.hostSign,
351
- 'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
352
- });
353
- case 24:
354
- res = _context2.sent;
355
- this.logger.logInfo({
356
- title: 'sdk_event_sdkQueryEnd'
357
- }, {
358
- paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
359
- requestBizId: requestBizId,
360
- traceId: res.traceId
361
- });
362
- return _context2.abrupt("return", res);
363
- case 29:
364
- _context2.prev = 29;
365
- _context2.t0 = _context2["catch"](21);
366
- this.logger.logError({
367
- title: 'sdk_event_sdkQuery_failed'
368
- }, {
369
- paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
370
- errorReason: _context2.t0,
371
- requestBizId: requestBizId,
372
- traceId: _context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.traceId
373
- });
374
- throw _context2.t0;
375
- case 33:
376
- case "end":
377
- return _context2.stop();
378
- }
379
- }, _callee2, this, [[21, 29]]);
380
- }));
381
- function processPaymentQuery() {
382
- return _processPaymentQuery.apply(this, arguments);
383
- }
384
- return processPaymentQuery;
385
- }()
386
- }, {
387
- key: "processSubmitPay",
388
- value: function () {
389
- var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
390
- var _this$paymentContext6, _this$paymentContext7, _this$paymentContext9, _this$channelBehavior3, _this$channelBehavior4, _this$paymentContext$;
391
- var submitParams, shouldSkipSubmitPayInSDK, _this$paymentContext8, _ref5, _ref5$productSceneVer, productSceneVersion, _ref6, _ref6$action, _ref6$action2, _ref6$action2$enableS, enableSignAgreement, _ref6$action2$autoDeb, autoDebitWithToken, requestBizId, extParams, requester, res;
392
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
393
- while (1) switch (_context3.prev = _context3.next) {
394
268
  case 0:
395
269
  submitParams = {
396
- paymentSessionData: ((_this$paymentContext6 = this.paymentContext) === null || _this$paymentContext6 === void 0 ? void 0 : _this$paymentContext6.paymentSession) || '',
397
- paymentSessionConfig: (_this$paymentContext7 = this.paymentContext) === null || _this$paymentContext7 === void 0 || (_this$paymentContext7 = _this$paymentContext7.paymentSessionObj) === null || _this$paymentContext7 === void 0 ? void 0 : _this$paymentContext7.paymentSessionConfig
270
+ paymentSessionData: ((_this$paymentContext = this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSession) || '',
271
+ 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
398
272
  };
399
- shouldSkipSubmitPayInSDK = false;
400
- if (this.channelBehavior) {
401
- // 新逻辑走 channelBehavior判断
402
- shouldSkipSubmitPayInSDK = !this.channelBehavior.submitPayInSdk;
403
- } else {
404
- // TODO: 拉会找栎昂、甘颜一起对下
405
- // 老逻辑,只要服务端标记不跳过sdkquery,就需要跳过submitpay
406
- shouldSkipSubmitPayInSDK = !((_this$paymentContext8 = this.paymentContext) !== null && _this$paymentContext8 !== void 0 && (_this$paymentContext8 = _this$paymentContext8.paymentSessionObj) !== null && _this$paymentContext8 !== void 0 && (_this$paymentContext8 = _this$paymentContext8.action) !== null && _this$paymentContext8 !== void 0 && _this$paymentContext8.skipSdkQuery);
407
- }
408
- _ref5 = submitParams.paymentSessionConfig || {}, _ref5$productSceneVer = _ref5.productSceneVersion, productSceneVersion = _ref5$productSceneVer === void 0 ? '' : _ref5$productSceneVer;
409
- _ref6 = ((_this$paymentContext9 = this.paymentContext) === null || _this$paymentContext9 === void 0 ? void 0 : _this$paymentContext9.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;
273
+ _ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
274
+ _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;
410
275
  if (productSceneVersion === '2.0' && !autoDebitWithToken) {
411
276
  ///EasyPay 2.0 首次传signAgreement字段
412
277
  submitParams['signAgreement'] = enableSignAgreement;
278
+ 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;
279
+ isAppWebview = this.paymentContext.startBizFlowOptions.isAppWebview;
280
+ if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
281
+ backScheme = getBackScheme(undefined, this.logger);
282
+ if (backScheme && backScheme !== 'https') {
283
+ submitParams['h5FromApp'] = encodeURIComponent(backScheme);
284
+ }
285
+ }
413
286
  }
414
- // 带上标记告知WebCheckOut SDK已发送submitpay请求
415
- this.allowSubmitPayCallAhead = !shouldSkipSubmitPayInSDK;
416
- if (!shouldSkipSubmitPayInSDK) {
417
- _context3.next = 9;
287
+ this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
288
+ if (this.allowSubmitPayCallAhead) {
289
+ _context2.next = 7;
418
290
  break;
419
291
  }
420
- return _context3.abrupt("return", {
292
+ return _context2.abrupt("return", {
421
293
  message: 'sdk no need to make submitPay request',
422
294
  success: true
423
295
  });
424
- case 9:
296
+ case 7:
425
297
  requestBizId = uuid(); // 下面真实发请求
426
298
  this.logger.logInfo({
427
299
  title: 'sdk_event_submitPay'
@@ -430,40 +302,41 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
430
302
  requestBizId: requestBizId
431
303
  });
432
304
  // 由渠道定制点来构建额外参数
433
- extParams = ((_this$channelBehavior3 = this.channelBehavior) === null || _this$channelBehavior3 === void 0 || (_this$channelBehavior4 = _this$channelBehavior3.buildSubmitPayExtParams) === null || _this$channelBehavior4 === void 0 ? void 0 : _this$channelBehavior4.call(_this$channelBehavior3, {
305
+ 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, {
434
306
  instanceId: this.instanceId,
435
307
  locale: this.initConfig.locale,
436
- 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,
308
+ 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,
437
309
  paymentSessionData: this.paymentContext.paymentSession,
438
310
  env: this.initConfig.environment,
439
311
  sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
440
312
  })) || {};
313
+ extParams.complianceSDK = true;
441
314
  submitParams.extParams = extParams;
442
315
  requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
443
- _context3.prev = 14;
444
- _context3.t0 = requester;
445
- _context3.t1 = submitParams;
446
- _context3.t2 = this.initConfig.environment;
447
- _context3.next = 20;
316
+ _context2.prev = 13;
317
+ _context2.t0 = requester;
318
+ _context2.t1 = submitParams;
319
+ _context2.t2 = this.initConfig.environment;
320
+ _context2.next = 19;
448
321
  return this.acquireApdidToken();
449
- case 20:
450
- _context3.t3 = _context3.sent;
451
- _context3.t4 = {
452
- deviceId: _context3.t3
322
+ case 19:
323
+ _context2.t3 = _context2.sent;
324
+ _context2.t4 = {
325
+ deviceId: _context2.t3
453
326
  };
454
- _context3.t5 = this.hostSign;
455
- _context3.t6 = {
456
- env: _context3.t2,
327
+ _context2.t5 = this.hostSign;
328
+ _context2.t6 = {
329
+ env: _context2.t2,
457
330
  timeout: 15000,
458
- envInfo: _context3.t4,
459
- hostSign: _context3.t5,
331
+ envInfo: _context2.t4,
332
+ hostSign: _context2.t5,
460
333
  needEnvInfo: true,
461
334
  'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
462
335
  };
463
- _context3.next = 26;
464
- return _context3.t0.request.call(_context3.t0, _context3.t1, _context3.t6);
465
- case 26:
466
- res = _context3.sent;
336
+ _context2.next = 25;
337
+ return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t6);
338
+ case 25:
339
+ res = _context2.sent;
467
340
  this.logger.logInfo({
468
341
  title: 'sdk_event_submitPayEnd'
469
342
  }, {
@@ -471,50 +344,50 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
471
344
  requestBizId: requestBizId,
472
345
  traceId: res.traceId
473
346
  });
474
- return _context3.abrupt("return", res);
475
- case 31:
476
- _context3.prev = 31;
477
- _context3.t7 = _context3["catch"](14);
347
+ return _context2.abrupt("return", res);
348
+ case 30:
349
+ _context2.prev = 30;
350
+ _context2.t7 = _context2["catch"](13);
478
351
  this.logger.logError({
479
352
  title: 'sdk_event_submitPay_failed'
480
353
  }, {
481
354
  paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
482
- errorReason: _context3.t7,
355
+ errorReason: _context2.t7,
483
356
  requestBizId: requestBizId,
484
- traceId: _context3.t7 === null || _context3.t7 === void 0 ? void 0 : _context3.t7.traceId
357
+ traceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
485
358
  });
486
- throw _context3.t7;
487
- case 35:
359
+ throw _context2.t7;
360
+ case 34:
488
361
  case "end":
489
- return _context3.stop();
362
+ return _context2.stop();
490
363
  }
491
- }, _callee3, this, [[14, 31]]);
364
+ }, _callee2, this, [[13, 30]]);
492
365
  }));
493
366
  function processSubmitPay() {
494
367
  return _processSubmitPay.apply(this, arguments);
495
368
  }
496
369
  return processSubmitPay;
497
- }() // TOOD: 讨论下是否放到 requester里面
370
+ }()
498
371
  }, {
499
372
  key: "acquireApdidToken",
500
373
  value: function () {
501
- var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
502
- var _this$paymentContext$2;
374
+ var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
375
+ var _this$paymentContext$3;
503
376
  var securityService, productScene, deviceId;
504
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
505
- while (1) switch (_context4.prev = _context4.next) {
377
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
378
+ while (1) switch (_context3.prev = _context3.next) {
506
379
  case 0:
507
380
  securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
508
- productScene = (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentSessionConfig) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.productScene;
381
+ 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;
509
382
  deviceId = securityService.getDeviceId({
510
383
  productScene: productScene
511
384
  });
512
- return _context4.abrupt("return", deviceId);
385
+ return _context3.abrupt("return", deviceId);
513
386
  case 4:
514
387
  case "end":
515
- return _context4.stop();
388
+ return _context3.stop();
516
389
  }
517
- }, _callee4, this);
390
+ }, _callee3, this);
518
391
  }));
519
392
  function acquireApdidToken() {
520
393
  return _acquireApdidToken.apply(this, arguments);
@@ -524,58 +397,67 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
524
397
  }, {
525
398
  key: "initSecuritySDK",
526
399
  value: function () {
527
- var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
528
- var _this$paymentContext$3, productSceneVersion, nonCompliant, isFirstTimeToPay;
529
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
530
- while (1) switch (_context5.prev = _context5.next) {
400
+ var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
401
+ var _this$paymentContext$4, _this$paymentContext$5, productSceneVersion, nonCompliant, nonInitSecuritySDK, isFirstTimeToPay;
402
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
403
+ while (1) switch (_context4.prev = _context4.next) {
531
404
  case 0:
532
- _context5.prev = 0;
405
+ _context4.prev = 0;
533
406
  productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
534
- nonCompliant = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.nonCompliant;
407
+ nonCompliant = (_this$paymentContext$4 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$4 === void 0 ? void 0 : _this$paymentContext$4.nonCompliant;
408
+ nonInitSecuritySDK = (_this$paymentContext$5 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$5 === void 0 ? void 0 : _this$paymentContext$5.nonCompliant;
535
409
  isFirstTimeToPay = !this.paymentContext.paymentSessionObj.action.autoDebitWithToken;
410
+ if (!nonInitSecuritySDK) {
411
+ _context4.next = 8;
412
+ break;
413
+ }
414
+ // 钱包不依赖风控
415
+ console.log('[web-sdk][security-sdk] DO NOT init security sdk when nonInitSecuritySDK is true');
416
+ return _context4.abrupt("return");
417
+ case 8:
536
418
  if (!(productSceneVersion === '1.0')) {
537
- _context5.next = 9;
419
+ _context4.next = 13;
538
420
  break;
539
421
  }
540
- console.log('[web-sdk][security-sdk] skip init security sdk for easypay 1.0');
541
422
  // 1.0 不初始化 SecuritySDK
542
- return _context5.abrupt("return");
543
- case 9:
423
+ console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 1.0');
424
+ return _context4.abrupt("return");
425
+ case 13:
544
426
  if (!(productSceneVersion === '2.0')) {
545
- _context5.next = 20;
427
+ _context4.next = 24;
546
428
  break;
547
429
  }
548
430
  if (!(nonCompliant === true)) {
549
- _context5.next = 16;
431
+ _context4.next = 20;
550
432
  break;
551
433
  }
552
434
  // 未切流「隐私合规」
553
- console.log('[web-sdk][security-sdk] init security sdk for easypay 2.0 and nonCompliant is true');
554
- _context5.next = 14;
435
+ console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and nonCompliant is true');
436
+ _context4.next = 18;
555
437
  return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
556
- case 14:
557
- _context5.next = 20;
438
+ case 18:
439
+ _context4.next = 24;
558
440
  break;
559
- case 16:
441
+ case 20:
560
442
  if (isFirstTimeToPay) {
561
- _context5.next = 20;
443
+ _context4.next = 24;
562
444
  break;
563
445
  }
564
446
  // 切流「隐私合规」且非首次支付
565
- console.log('[web-sdk][security-sdk] init security sdk for easypay 2.0 and when not first time to pay');
566
- _context5.next = 20;
447
+ console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and when not first time to pay');
448
+ _context4.next = 24;
567
449
  return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
568
- case 20:
569
- _context5.next = 24;
570
- break;
571
- case 22:
572
- _context5.prev = 22;
573
- _context5.t0 = _context5["catch"](0);
574
450
  case 24:
451
+ _context4.next = 28;
452
+ break;
453
+ case 26:
454
+ _context4.prev = 26;
455
+ _context4.t0 = _context4["catch"](0);
456
+ case 28:
575
457
  case "end":
576
- return _context5.stop();
458
+ return _context4.stop();
577
459
  }
578
- }, _callee5, this, [[0, 22]]);
460
+ }, _callee4, this, [[0, 26]]);
579
461
  }));
580
462
  function initSecuritySDK() {
581
463
  return _initSecuritySDK.apply(this, arguments);
@@ -54,7 +54,6 @@ export var ContainerService = /*#__PURE__*/function () {
54
54
  }, {
55
55
  key: "load",
56
56
  value: function load(displayInfo, url, closeBtnFunc) {
57
- console.log('load');
58
57
  var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(displayInfo.selector) : ''));
59
58
  this.webApp = webApp;
60
59
  this.displayInfo = displayInfo;
@@ -20,15 +20,31 @@ export var redirect = function redirect(payload, instanceId) {
20
20
  logService.logInfo({
21
21
  title: 'sdk_event_call_url_start'
22
22
  }, _objectSpread({}, payload)).send();
23
+ if (payload.isCallApp && payload.schemeUrl) {
24
+ var detectSuccessDelay = payload.callAppDetectSuccessDelay;
25
+ var _callAppLib = new CallApp({
26
+ successCb: function successCb() {
27
+ successCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
28
+ },
29
+ resultJudgmentTime: detectSuccessDelay
30
+ });
31
+ _callAppLib.open({
32
+ scheme: payload.schemeUrl,
33
+ fallback: function fallback() {
34
+ failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
35
+ }
36
+ });
37
+ return;
38
+ }
23
39
  // 支持 target: _blank,新开tab页打开
24
40
  if (payload.browserLinkTarget === TargetEnum.BLANK) {
25
- if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', payload, serviceProvider);
41
+ if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
26
42
  successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
27
43
  window.open(payload.url);
28
44
  return;
29
45
  }
30
46
  if (payload.browserLinkTarget === TargetEnum.REPLACE && !(payload !== null && payload !== void 0 && payload.applinkUrl) && !(payload !== null && payload !== void 0 && payload.schemeUrl)) {
31
- if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', payload, serviceProvider);
47
+ if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
32
48
  successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
33
49
  window.location.replace(payload.url);
34
50
  return;
@@ -55,14 +71,14 @@ export var redirect = function redirect(payload, instanceId) {
55
71
  fallback: function fallback() {
56
72
  // Applink evoke failed, try to use scheme url
57
73
  if (payload.applinkUrl) {
58
- failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, payload, serviceProvider);
74
+ failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
59
75
  }
60
76
  callAppLib.open({
61
77
  scheme: payload.schemeUrl,
62
78
  fallback: function fallback() {
63
79
  // SchemeUrl evoke failed
64
80
  if (payload.schemeUrl) {
65
- failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, payload, serviceProvider);
81
+ failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
66
82
  }
67
83
  window.location.href = payload.url;
68
84
  successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
@@ -84,10 +100,10 @@ var successCallback = function successCallback(payload, type, url, serviceProvid
84
100
  url: url
85
101
  }).send();
86
102
  };
87
- var failCallback = function failCallback(payload, type, url, behaviorData, serviceProvider) {
103
+ var failCallback = function failCallback(payload, type, url, serviceProvider) {
88
104
  serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
89
105
  code: eventCodeEnum.SDK_CALL_URL_ERROR,
90
- message: "Failed to open app,applinkUrl: ".concat(behaviorData === null || behaviorData === void 0 ? void 0 : behaviorData.applinkUrl, " schemeUrl: ").concat(behaviorData === null || behaviorData === void 0 ? void 0 : behaviorData.schemeUrl, " normalUrl: ").concat(behaviorData === null || behaviorData === void 0 ? void 0 : behaviorData.url)
106
+ message: "Failed to open app,applinkUrl: ".concat(payload === null || payload === void 0 ? void 0 : payload.applinkUrl, " schemeUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.schemeUrl, " normalUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.url)
91
107
  });
92
108
  serviceProvider.getService('Log').logInfo({
93
109
  title: 'sdk_error_call_url_failed'
package/esm/index.js CHANGED
@@ -37,7 +37,8 @@ export var AMSEasyPay = /*#__PURE__*/function () {
37
37
  paymentSession: params.sessionData || params.paymentSessionData,
38
38
  displayInfo: {
39
39
  type: DisplayTypeEnum.popup
40
- }
40
+ },
41
+ isAppWebview: params.isAppWebview
41
42
  });
42
43
  }
43
44
  }]);
@@ -106,25 +106,8 @@ export interface IcreateComponent {
106
106
  accentColor?: string;
107
107
  };
108
108
  merchantAppointParam?: IMerchantAppointParam;
109
+ isAppWebview?: boolean;
109
110
  }
110
- export interface IappendIframeNodesParams extends IcreateComponent {
111
- paymentSessionMetaData: IPaymentSessionMetaData;
112
- renderDisplayType: DisplayTypeEnum;
113
- selector?: Iselector;
114
- paypalConfiguration?: IPaypalConfiguration;
115
- connectFactor?: {
116
- enableConnect: boolean;
117
- };
118
- /** 将address-element参数定义合入原参数定义 */
119
- configParams?: {
120
- hideFields?: string[];
121
- addressAutoSuggestDisabled?: addressAutoSuggestDisabledType;
122
- };
123
- prefillValue?: AddressItem[];
124
- componentSession?: string;
125
- loca?: string;
126
- }
127
- /** 表单地址数据 */
128
111
  export interface AddressItem {
129
112
  shippingName: {
130
113
  firstName: string;
@@ -167,7 +150,6 @@ export interface AddressItem {
167
150
  prefer?: '1' | '0';
168
151
  shippingId?: string;
169
152
  }
170
- type addressAutoSuggestDisabledType = 0 | 1;
171
153
  export interface IPaypalConfiguration {
172
154
  style?: object;
173
155
  blockPayPalCreditButton?: boolean;
@@ -231,6 +213,7 @@ export interface PaymentSessionActionData {
231
213
  skipSdkQuery: boolean;
232
214
  requireFastSdk: boolean;
233
215
  nonCompliant?: boolean;
216
+ nonInitSecuritySdk?: boolean;
234
217
  skipSdkQueryForm?: {
235
218
  value: boolean;
236
219
  version: string;
@@ -245,6 +228,7 @@ export interface IPaymentSessionMetaData {
245
228
  moneyView?: any;
246
229
  extendInfo?: string;
247
230
  paymentMethodInfoView?: any;
231
+ paymentView?: any;
248
232
  action?: PaymentSessionActionData;
249
233
  authUrlInfo?: {
250
234
  appIdentifier?: string;
@@ -655,10 +639,6 @@ export declare enum ProductSceneVersion {
655
639
  V1 = "1.0",
656
640
  V2 = "2.0"
657
641
  }
658
- export type IAppendParams = {
659
- componentSign: ComponentSignEnum;
660
- iframeNodesParams: IappendIframeNodesParams;
661
- };
662
642
  export declare enum EventCallbackCode {
663
643
  Failed = "Failed",
664
644
  Completed = "Completed"