@alipay/ams-checkout 1.10.1 → 1.11.1

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 (41) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/request.js +3 -3
  3. package/esm/core/bus/ability/callback.d.ts +9 -0
  4. package/esm/core/bus/ability/callback.js +55 -0
  5. package/esm/core/bus/ability/security.d.ts +10 -0
  6. package/esm/core/bus/ability/security.js +104 -0
  7. package/esm/core/bus/ability/tracker.d.ts +9 -0
  8. package/esm/core/bus/ability/tracker.js +77 -0
  9. package/esm/core/bus/index.d.ts +125 -0
  10. package/esm/core/bus/index.js +366 -0
  11. package/esm/core/bus/interface.d.ts +32 -0
  12. package/esm/core/bus/interface.js +35 -0
  13. package/esm/core/component/index.d.ts +16 -1
  14. package/esm/core/component/index.js +189 -30
  15. package/esm/core/instance/index.d.ts +5 -1
  16. package/esm/core/instance/index.js +45 -7
  17. package/esm/index.d.ts +0 -3
  18. package/esm/index.js +8 -18
  19. package/esm/{core/applepay/index.d.ts → plugin/applepay/component.d.ts} +27 -8
  20. package/esm/{core/applepay/index.js → plugin/applepay/component.js} +150 -180
  21. package/esm/plugin/applepay/index.d.ts +17 -0
  22. package/esm/plugin/applepay/index.js +117 -0
  23. package/esm/{common → plugin}/applepay/interface.d.ts +62 -3
  24. package/esm/plugin/applepay/interface.js +69 -0
  25. package/esm/{common/applepay/index.d.ts → plugin/applepay/service.d.ts} +13 -7
  26. package/esm/{common/applepay/index.js → plugin/applepay/service.js} +159 -41
  27. package/esm/plugin/component/component.popup.style.js +1 -1
  28. package/esm/plugin/component/index.d.ts +3 -4
  29. package/esm/plugin/component/index.js +81 -49
  30. package/esm/plugin/const.d.ts +2 -0
  31. package/esm/plugin/const.js +19 -0
  32. package/esm/plugin/type.d.ts +33 -0
  33. package/esm/request/index.d.ts +1 -1
  34. package/esm/request/index.js +8 -14
  35. package/esm/service/index.d.ts +1 -1
  36. package/esm/types/index.d.ts +65 -6
  37. package/esm/types/index.js +8 -1
  38. package/esm/util/versionCompare.d.ts +2 -0
  39. package/esm/util/versionCompare.js +75 -0
  40. package/package.json +1 -1
  41. /package/esm/{common/applepay/interface.js → plugin/type.js} +0 -0
@@ -22,6 +22,7 @@ import { queryPaymentInfo, submitPayInfo } from "../../service";
22
22
  import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
23
23
  import { getType, isJsonString, isPC } from "../../util";
24
24
  import { isLocalMock } from "../../util/mock";
25
+ import { matchVersion } from "../../util/versionCompare";
25
26
  import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
26
27
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
27
28
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
@@ -52,9 +53,8 @@ var ComponentApp = /*#__PURE__*/function () {
52
53
  _defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
53
54
  _defineProperty(this, "_multipleCallbackEvents", void 0);
54
55
  _defineProperty(this, "_merchantAppointParam", void 0);
55
- _defineProperty(this, "_webAppHeartBeatTimeoutId", void 0);
56
56
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
57
- this._appVersion = '1.10.1';
57
+ this._appVersion = '1.11.1';
58
58
  this._isInitComponent = false;
59
59
  this._selector = "#".concat(COMPONENT_SECTION_ID);
60
60
  this.createIframeNode = function () {
@@ -364,7 +364,7 @@ var ComponentApp = /*#__PURE__*/function () {
364
364
  this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
365
365
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
366
366
  var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5;
367
- var envInfo, params, _this5$_renderParams$, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, extendInfoData, _this5$_renderParams6, _this5$_renderParams7, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
367
+ var envInfo, params, _ref3, _ref3$extendInfo, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, _ref4, skipSdkQuery, skipSdkQueryForm, extendInfoData, ifSkip, _this5$_renderParams6, _this5$_renderParams7, _ref5, _ref5$productSceneVer, productSceneVersion, _ref5$productScene, productScene, _ref6, _ref6$action, _ref6$action2, _ref6$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
368
368
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
369
369
  while (1) switch (_context2.prev = _context2.next) {
370
370
  case 0:
@@ -380,9 +380,10 @@ var ComponentApp = /*#__PURE__*/function () {
380
380
  /**
381
381
  * @description Simulated or unnecessary scenarios
382
382
  */
383
- _this5$_renderParams$ = (_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData, extendInfo = _this5$_renderParams$.extendInfo;
383
+ _ref3 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, _ref3$extendInfo = _ref3.extendInfo, extendInfo = _ref3$extendInfo === void 0 ? '' : _ref3$extendInfo;
384
384
  enableVaultingApiOptimize = false;
385
385
  enableEasypayApiOptimize = false;
386
+ _ref4 = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.action) || {}, skipSdkQuery = _ref4.skipSdkQuery, skipSdkQueryForm = _ref4.skipSdkQueryForm;
386
387
  try {
387
388
  extendInfoData = JSON.parse(extendInfo);
388
389
  enableVaultingApiOptimize = extendInfoData.enableVaultingApiOptimize || false;
@@ -391,95 +392,123 @@ var ComponentApp = /*#__PURE__*/function () {
391
392
  console.log(error);
392
393
  }
393
394
  if (!isLocalMock()) {
394
- _context2.next = 8;
395
+ _context2.next = 9;
395
396
  break;
396
397
  }
397
398
  return _context2.abrupt("return", resolve({
398
399
  message: 'sdk no need to make query request',
399
400
  success: true
400
401
  }));
401
- case 8:
402
- if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign && (_this5$_renderParams5 = _this5._renderParams) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.action) !== null && _this5$_renderParams5 !== void 0 && _this5$_renderParams5.skipSdkQuery && enableVaultingApiOptimize)) {
403
- _context2.next = 10;
402
+ case 9:
403
+ if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
404
+ _context2.next = 21;
404
405
  break;
405
406
  }
406
- return _context2.abrupt("return", resolve({
407
+ if (!enableVaultingApiOptimize) {
408
+ _context2.next = 21;
409
+ break;
410
+ }
411
+ if (!skipSdkQueryForm) {
412
+ _context2.next = 18;
413
+ break;
414
+ }
415
+ // 优先判断 skipSdkQueryForm
416
+ ifSkip = matchVersion(skipSdkQueryForm, _this5._appVersion);
417
+ if (!ifSkip) {
418
+ _context2.next = 16;
419
+ break;
420
+ }
421
+ resolve({
407
422
  message: 'sdk no need to make query request',
408
423
  success: true
409
- }));
410
- case 10:
424
+ });
425
+ return _context2.abrupt("return");
426
+ case 16:
427
+ _context2.next = 21;
428
+ break;
429
+ case 18:
430
+ if (!skipSdkQuery) {
431
+ _context2.next = 21;
432
+ break;
433
+ }
434
+ resolve({
435
+ message: 'sdk no need to make query request',
436
+ success: true
437
+ });
438
+ return _context2.abrupt("return");
439
+ case 21:
411
440
  if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
412
- _context2.next = 16;
441
+ _context2.next = 27;
413
442
  break;
414
443
  }
415
444
  params.paymentMethodType = 'CARD';
416
- _context2.next = 14;
445
+ _context2.next = 25;
417
446
  return _this5.getDeviceIdAndLog();
418
- case 14:
447
+ case 25:
419
448
  envInfo.deviceId = _context2.sent;
420
449
  if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
421
450
  envInfo.extendInfo = {
422
451
  WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
423
452
  };
424
453
  }
425
- case 16:
454
+ case 27:
426
455
  if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
427
- _context2.next = 26;
456
+ _context2.next = 37;
428
457
  break;
429
458
  }
430
- _ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
431
- _ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
459
+ _ref5 = params.paymentSessionConfig || {}, _ref5$productSceneVer = _ref5.productSceneVersion, productSceneVersion = _ref5$productSceneVer === void 0 ? '' : _ref5$productSceneVer, _ref5$productScene = _ref5.productScene, productScene = _ref5$productScene === void 0 ? '' : _ref5$productScene;
460
+ _ref6 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref6$action = _ref6.action, _ref6$action2 = _ref6$action === void 0 ? {} : _ref6$action, _ref6$action2$autoDeb = _ref6$action2.autoDebitWithToken, autoDebitWithToken = _ref6$action2$autoDeb === void 0 ? false : _ref6$action2$autoDeb;
432
461
  if (!((_this5$_renderParams7 = _this5._renderParams) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.action) !== null && _this5$_renderParams7 !== void 0 && _this5$_renderParams7.skipSdkQuery && enableEasypayApiOptimize)) {
433
- _context2.next = 21;
462
+ _context2.next = 32;
434
463
  break;
435
464
  }
436
465
  return _context2.abrupt("return", resolve({
437
466
  message: 'sdk no need to make query request',
438
467
  success: true
439
468
  }));
440
- case 21:
469
+ case 32:
441
470
  if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
442
- _context2.next = 23;
471
+ _context2.next = 34;
443
472
  break;
444
473
  }
445
474
  return _context2.abrupt("return", resolve({
446
475
  message: 'sdk no need to make query request',
447
476
  success: true
448
477
  }));
449
- case 23:
450
- _context2.next = 25;
478
+ case 34:
479
+ _context2.next = 36;
451
480
  return _this5.getDeviceIdAndLog();
452
- case 25:
481
+ case 36:
453
482
  envInfo.deviceId = _context2.sent;
454
- case 26:
483
+ case 37:
455
484
  if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
456
- _context2.next = 36;
485
+ _context2.next = 47;
457
486
  break;
458
487
  }
459
488
  action = ((_this5$_renderParams8 = _this5._renderParams) === null || _this5$_renderParams8 === void 0 || (_this5$_renderParams8 = _this5$_renderParams8.paymentSessionMetaData) === null || _this5$_renderParams8 === void 0 ? void 0 : _this5$_renderParams8.action) || {};
460
489
  signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
461
490
  if (!(signType === 'SMS')) {
462
- _context2.next = 31;
491
+ _context2.next = 42;
463
492
  break;
464
493
  }
465
494
  return _context2.abrupt("return", resolve({
466
495
  message: 'sdk no need to make query request',
467
496
  success: true
468
497
  }));
469
- case 31:
498
+ case 42:
470
499
  if (!(!signType || signType !== 'REDIRECT')) {
471
- _context2.next = 33;
500
+ _context2.next = 44;
472
501
  break;
473
502
  }
474
503
  return _context2.abrupt("return", resolve({
475
504
  success: false
476
505
  }));
477
- case 33:
478
- _context2.next = 35;
506
+ case 44:
507
+ _context2.next = 46;
479
508
  return _this5.getDeviceIdAndLog();
480
- case 35:
509
+ case 46:
481
510
  envInfo.deviceId = _context2.sent;
482
- case 36:
511
+ case 47:
483
512
  _this5.AMSSDK.logger.logInfo({
484
513
  title: 'sdk_event_sdkQuery'
485
514
  }, {
@@ -511,7 +540,7 @@ var ComponentApp = /*#__PURE__*/function () {
511
540
  paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
512
541
  }).send();
513
542
  });
514
- case 38:
543
+ case 49:
515
544
  case "end":
516
545
  return _context2.stop();
517
546
  }
@@ -542,7 +571,7 @@ var ComponentApp = /*#__PURE__*/function () {
542
571
 
543
572
  // eslint-disable-next-line no-async-promise-executor
544
573
  this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
545
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
574
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
546
575
  var _this6$_renderParams;
547
576
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
548
577
  while (1) switch (_context3.prev = _context3.next) {
@@ -605,7 +634,7 @@ var ComponentApp = /*#__PURE__*/function () {
605
634
  }, _callee3);
606
635
  }));
607
636
  return function (_x3) {
608
- return _ref5.apply(this, arguments);
637
+ return _ref7.apply(this, arguments);
609
638
  };
610
639
  }());
611
640
  }
@@ -1196,9 +1225,9 @@ var ComponentApp = /*#__PURE__*/function () {
1196
1225
  }
1197
1226
  }, {
1198
1227
  key: "handleDeclareInfo",
1199
- value: function handleDeclareInfo(_ref6) {
1200
- var _ref6$closeDialogData = _ref6.closeDialogData,
1201
- closeDialogData = _ref6$closeDialogData === void 0 ? {} : _ref6$closeDialogData;
1228
+ value: function handleDeclareInfo(_ref8) {
1229
+ var _ref8$closeDialogData = _ref8.closeDialogData,
1230
+ closeDialogData = _ref8$closeDialogData === void 0 ? {} : _ref8$closeDialogData;
1202
1231
  _handleDeclareInfo({
1203
1232
  closeDialogData: closeDialogData
1204
1233
  });
@@ -1235,12 +1264,12 @@ var ComponentApp = /*#__PURE__*/function () {
1235
1264
  }
1236
1265
  };
1237
1266
  }
1238
- if (this._webAppHeartBeatTimeoutId) {
1239
- clearTimeout(this._webAppHeartBeatTimeoutId);
1240
- this._webAppHeartBeatTimeoutId = null;
1267
+ if (window._webAppHeartBeatTimeoutId) {
1268
+ clearTimeout(window._webAppHeartBeatTimeoutId);
1269
+ window._webAppHeartBeatTimeoutId = null;
1241
1270
  }
1242
1271
  if (this._webAppHeartBeatTimeoutFn) {
1243
- this._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
1272
+ window._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
1244
1273
  }
1245
1274
  setTimeout(function () {
1246
1275
  if (_this8.isAppAttached()) {
@@ -1299,17 +1328,20 @@ var ComponentApp = /*#__PURE__*/function () {
1299
1328
  key: "dispatchToApp",
1300
1329
  value: function dispatchToApp(payload) {
1301
1330
  var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1331
+ var sendLog = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1302
1332
  var data = Object.assign({}, payload, {
1303
1333
  name: messageName.SDK_TO_APP,
1304
1334
  mode: this.AMSSDK.options.mode,
1305
1335
  appId: COMPONENTPLUGINID,
1306
1336
  instanceId: this.AMSSDK._instanceId
1307
1337
  });
1308
- this.AMSSDK.logger.logInfo({
1309
- title: 'sdk_event_send_message_to_web'
1310
- }, {
1311
- event: data === null || data === void 0 ? void 0 : data.context.event
1312
- }).send();
1338
+ if (sendLog) {
1339
+ this.AMSSDK.logger.logInfo({
1340
+ title: 'sdk_event_send_message_to_web'
1341
+ }, {
1342
+ event: data === null || data === void 0 ? void 0 : data.context.event
1343
+ }).send();
1344
+ }
1313
1345
  if (targetElement && targetElement.contentWindow) {
1314
1346
  return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
1315
1347
  }
@@ -1386,7 +1418,7 @@ var ComponentApp = /*#__PURE__*/function () {
1386
1418
  }
1387
1419
  }
1388
1420
  }
1389
- });
1421
+ }, null, true);
1390
1422
  this.AMSSDK.logger.logInfo({
1391
1423
  title: 'sdk_event_renderComponent'
1392
1424
  });
@@ -0,0 +1,2 @@
1
+ import { IExtendPlugin } from './type';
2
+ export declare const ExtendPlugin: IExtendPlugin;
@@ -0,0 +1,19 @@
1
+ import { ApplePayActionEnum, PaymentActionEnum } from "../core/bus/interface";
2
+ import { paymentMethodCategoryTypeEnum, productSceneEnum, ProductSceneVersion } from "../types/index";
3
+ export var ExtendPlugin = [{
4
+ sessionMatcher: {
5
+ productScene: productSceneEnum.CASHIER_PAYMENT,
6
+ productSceneVersion: ProductSceneVersion.V1,
7
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum.CARD,
8
+ paymentMethodTypes: ["CARD_APPLE_PAY"]
9
+ },
10
+ paymentChannelMatcher: {
11
+ paymentMethod: 'ApplePay'
12
+ },
13
+ busActionNames: {
14
+ canMakePayments: ApplePayActionEnum.canMakePayments,
15
+ optional_init: PaymentActionEnum.optional_init,
16
+ createComponent: ApplePayActionEnum.createComponent,
17
+ destoryComponent: ApplePayActionEnum.destoryComponent
18
+ }
19
+ }];
@@ -0,0 +1,33 @@
1
+ import { BusSubscriber } from '../core/bus';
2
+ import { paymentMethodCategoryTypeEnum, productSceneEnum, ProductSceneVersion } from '../types';
3
+ export type IExtendPlugin = IExtendPluginItem[];
4
+ export interface ComponentActionNamesType {
5
+ canMakePayments?: string;
6
+ optional_init?: string;
7
+ createComponent?: string;
8
+ mountComponent?: string;
9
+ submit?: string;
10
+ destoryComponent?: string;
11
+ }
12
+ export type IExtendPluginItem = {
13
+ /**
14
+ * 以下为sessionData匹配的场景
15
+ */
16
+ sessionMatcher?: {
17
+ productScene: productSceneEnum;
18
+ productSceneVersion: ProductSceneVersion;
19
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
20
+ paymentMethodTypes: string[];
21
+ };
22
+ /**
23
+ * 用于无sessionData场景,比如:canMakePayments
24
+ */
25
+ paymentChannelMatcher?: {
26
+ paymentMethod: string;
27
+ };
28
+ /**
29
+ * 以下plugin 实现的定义
30
+ */
31
+ busActionNames: ComponentActionNamesType;
32
+ busSubscriber?: BusSubscriber;
33
+ };
@@ -1,5 +1,5 @@
1
1
  import { RequestConfig } from '../types';
2
- import { Logger } from '../util/logger';
2
+ import type { Logger } from '../util/logger';
3
3
  /**
4
4
  *
5
5
  * @param requestData 请求参数
@@ -50,8 +50,6 @@ function requestInstance(options) {
50
50
  withCredentials: (_options$withCredenti = options.withCredentials) !== null && _options$withCredenti !== void 0 ? _options$withCredenti : true,
51
51
  method: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
52
52
  });
53
- console.log('baseURL', baseURL);
54
- console.log('_headers', _headers);
55
53
  return instance.request;
56
54
  }
57
55
 
@@ -99,25 +97,21 @@ function _request() {
99
97
  })];
100
98
  startTime = Date.now();
101
99
  _context.prev = 5;
102
- console.log('requestInstance options', options);
103
- console.log('requestInstance -data', _data);
104
100
  myRequest = requestInstance(options);
105
- _context.next = 11;
101
+ _context.next = 9;
106
102
  return myRequest({
107
103
  data: _data
108
104
  });
109
- case 11:
105
+ case 9:
110
106
  _yield$myRequest = _context.sent;
111
107
  data = _yield$myRequest.data;
112
108
  headers = _yield$myRequest.headers;
113
- console.log('requestInstance data', data);
114
- console.log('requestInstance headers', headers);
115
109
  resData = data || {};
116
110
  traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
117
111
  resData.traceId = traceId || '';
118
112
  handleGetWayError = fomatGetwayError(headers, traceId);
119
113
  if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
120
- _context.next = 25;
114
+ _context.next = 21;
121
115
  break;
122
116
  }
123
117
  errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
@@ -136,7 +130,7 @@ function _request() {
136
130
  errorCode: errorCode,
137
131
  success: false
138
132
  }));
139
- case 25:
133
+ case 21:
140
134
  logger.reportRPC({
141
135
  name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
142
136
  label: 'request',
@@ -147,8 +141,8 @@ function _request() {
147
141
  traceId: traceId
148
142
  }).send();
149
143
  return _context.abrupt("return", resData);
150
- case 29:
151
- _context.prev = 29;
144
+ case 25:
145
+ _context.prev = 25;
152
146
  _context.t0 = _context["catch"](5);
153
147
  _error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
154
148
  success: false,
@@ -170,11 +164,11 @@ function _request() {
170
164
  errorCode: _errorCode,
171
165
  errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
172
166
  }));
173
- case 36:
167
+ case 32:
174
168
  case "end":
175
169
  return _context.stop();
176
170
  }
177
- }, _callee, null, [[5, 29]]);
171
+ }, _callee, null, [[5, 25]]);
178
172
  }));
179
173
  return _request.apply(this, arguments);
180
174
  }
@@ -1,5 +1,5 @@
1
1
  import { ApplePayPaymentSessionRequest, ApplePayPaymentSessionResult, CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
2
- import { Logger } from '../util/logger';
2
+ import type { Logger } from '../util/logger';
3
3
  export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
4
4
  export declare function antomConfig(options: RequestConfig, logger: Logger): Promise<any>;
5
5
  export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
@@ -133,18 +133,24 @@ export interface IpaymentSessionMetaData {
133
133
  action?: {
134
134
  autoDebitWithToken: boolean;
135
135
  skipSdkQuery: boolean;
136
+ skipSdkQueryForm?: {
137
+ value: boolean;
138
+ version: string;
139
+ platform: string;
140
+ };
136
141
  };
137
142
  paymentSessionFactor?: {
138
- applePay?: {
143
+ extendInfo?: {
139
144
  merchantCapabilities?: string[];
140
145
  supportedNetworks?: string[];
141
146
  };
142
147
  merchantInfo?: {
143
148
  registeredCountry?: string;
144
149
  partnerId?: string;
150
+ merchantName?: string;
145
151
  };
146
152
  order?: {
147
- orderDescription?: string;
153
+ orderDescription: string;
148
154
  };
149
155
  paymentAmount?: {
150
156
  value?: string;
@@ -156,6 +162,43 @@ export interface IpaymentSessionMetaData {
156
162
  paymentMethodViewMetaData?: any;
157
163
  paymentRequestId?: string;
158
164
  supportedLanguages?: any;
165
+ /**
166
+ * 当前为苹果分期场景的信息
167
+ */
168
+ recurringInfo?: {
169
+ /**
170
+ * 代扣协议开始日期 不传为当前系统时间
171
+ */
172
+ startDate?: number;
173
+ /**
174
+ * 代扣协议结束日期 不传不限制结束时间
175
+ */
176
+ endDate?: number;
177
+ /**
178
+ * 付款时间间隔单位,支持:"year" "month" "day" "hour" "minute" 不传默认month
179
+ */
180
+ intervalUnit?: string;
181
+ /**
182
+ * 付款时间间隔。比如每过6个月付款一次,intervalCount就是6, 不传默认为1
183
+ */
184
+ intervalCount?: number;
185
+ /**
186
+ * 分期标题信息
187
+ */
188
+ title?: string;
189
+ /**
190
+ * 分期管理页面
191
+ */
192
+ managementURL?: string;
193
+ /**
194
+ * 苹果通知ipay MAPN信息变更的地址
195
+ */
196
+ tokenNotificationURL?: string;
197
+ /**
198
+ * 分期协议描述
199
+ */
200
+ agreementDescription?: string;
201
+ };
159
202
  };
160
203
  }
161
204
  export declare enum localeEnum {
@@ -201,8 +244,8 @@ export declare enum platformEnum {
201
244
  desktop = "desktop",
202
245
  mobile = "mobile"
203
246
  }
204
- type EventCallbackResult = {
205
- result: {
247
+ export type EventCallbackResult = {
248
+ result?: {
206
249
  resultCode: string;
207
250
  resultStatus: string;
208
251
  resultMessage: string;
@@ -410,9 +453,14 @@ export declare enum eventCodeEnum {
410
453
  SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
411
454
  SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
412
455
  SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS",
413
- SDK_PAYMENT_FINISH = "SDK_PAYMENT_FINISH",
456
+ SDK_PAYMENT_SUCCESSFUL = "SDK_PAYMENT_SUCCESSFUL",
414
457
  SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
415
- SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL"
458
+ SDK_PAYMENT_ERROR = "SDK_PAYMENT_ERROR",
459
+ SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL",
460
+ /**
461
+ * 当前为Apple Pay发起了Pay请求,但是用户关闭了页面
462
+ */
463
+ SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING"
416
464
  }
417
465
  export declare enum RedirectType {
418
466
  ApplinkUrl = "ApplinkUrl",
@@ -433,4 +481,15 @@ export interface CallbackEventInfo {
433
481
  export interface MultipleCallbackEvents {
434
482
  [key: string]: CallbackEventInfo;
435
483
  }
484
+ export type PaymentMethodTypeEnum = 'ApplePay';
485
+ export type ApplePaySubTypeEnum = 'ApplePayRecurringPayment';
486
+ export type SubPaymentMethodTypeEnum = ApplePaySubTypeEnum;
487
+ export declare enum ProductSceneVersion {
488
+ V1 = "1.0",
489
+ V2 = "2.0"
490
+ }
491
+ export type IAppendParams = {
492
+ componentSign: componentSignEnum;
493
+ iframeNodesParams: IappendIframeNodesParams;
494
+ };
436
495
  export {};
@@ -153,9 +153,11 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
153
153
  eventCodeEnum["SDK_CREATECOMPONENT_ERROR"] = "SDK_CREATECOMPONENT_ERROR";
154
154
  eventCodeEnum["SDK_CALL_URL_ERROR"] = "SDK_CALL_URL_ERROR";
155
155
  eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
156
- eventCodeEnum["SDK_PAYMENT_FINISH"] = "SDK_PAYMENT_FINISH";
156
+ eventCodeEnum["SDK_PAYMENT_SUCCESSFUL"] = "SDK_PAYMENT_SUCCESSFUL";
157
157
  eventCodeEnum["SDK_PAYMENT_FAIL"] = "SDK_PAYMENT_FAIL";
158
+ eventCodeEnum["SDK_PAYMENT_ERROR"] = "SDK_PAYMENT_ERROR";
158
159
  eventCodeEnum["SDK_PAYMENT_CANCEL"] = "SDK_PAYMENT_CANCEL";
160
+ eventCodeEnum["SDK_PAYMENT_PROCESSING"] = "SDK_PAYMENT_PROCESSING";
159
161
  return eventCodeEnum;
160
162
  }({});
161
163
  export var RedirectType = /*#__PURE__*/function (RedirectType) {
@@ -164,4 +166,9 @@ export var RedirectType = /*#__PURE__*/function (RedirectType) {
164
166
  RedirectType["NormalUrl"] = "NormalUrl";
165
167
  RedirectType["Unknown"] = "Unknown";
166
168
  return RedirectType;
169
+ }({});
170
+ export var ProductSceneVersion = /*#__PURE__*/function (ProductSceneVersion) {
171
+ ProductSceneVersion["V1"] = "1.0";
172
+ ProductSceneVersion["V2"] = "2.0";
173
+ return ProductSceneVersion;
167
174
  }({});
@@ -4,3 +4,5 @@
4
4
  * @param v2
5
5
  */
6
6
  export declare function compareVersion(v1: string, v2: string): 1 | 0 | -1;
7
+ export declare function isVersionInRange(currentVersion: any, minVersion: any, maxVersion: any): boolean;
8
+ export declare function matchVersion(config: any, currentVersion: any): boolean;
@@ -1,3 +1,9 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  /**
2
8
  * 返回值0标识一样大,1表示v1大,-1表示v2大
3
9
  * @param v1
@@ -42,4 +48,73 @@ export function compareVersion(v1, v2) {
42
48
  } else {
43
49
  return 1;
44
50
  }
51
+ }
52
+ export function isVersionInRange(currentVersion, minVersion, maxVersion) {
53
+ function splitVersion(version) {
54
+ return version.split('.').map(function (num) {
55
+ return parseInt(num, 10);
56
+ });
57
+ }
58
+ function compareVersions(v1, v2) {
59
+ for (var i = 0; i < Math.max(v1.length, v2.length); i++) {
60
+ var num1 = v1[i] === undefined ? 0 : v1[i];
61
+ var num2 = v2[i] === undefined ? 0 : v2[i];
62
+ if (num1 > num2) return 1;
63
+ if (num1 < num2) return -1;
64
+ }
65
+ return 0;
66
+ }
67
+ var current = splitVersion(currentVersion);
68
+ var min = minVersion ? splitVersion(minVersion) : null;
69
+ var max = maxVersion ? splitVersion(maxVersion) : null;
70
+ if (min && compareVersions(current, min) < 0) {
71
+ // 当前版本小于最小允许版本
72
+ return false;
73
+ }
74
+ if (max && compareVersions(current, max) > 0) {
75
+ // 当前版本大于最大允许版本
76
+ return false;
77
+ }
78
+ // 当前版本在允许的版本范围内
79
+ return true;
80
+ }
81
+ export function matchVersion(config, currentVersion) {
82
+ var value = config.value,
83
+ version = config.version,
84
+ platform = config.platform;
85
+ var CURRENT_PLATFORM = 'WEB';
86
+ var isMatchVersion = false;
87
+ var isMatchPlatform = false;
88
+
89
+ // 平台判断
90
+ if (platform) {
91
+ var platformList = platform.split('|').map(function (platform) {
92
+ return platform.toLocaleUpperCase();
93
+ });
94
+ isMatchPlatform = platformList.includes(CURRENT_PLATFORM);
95
+ } else {
96
+ // 没有表示平台全匹配
97
+ isMatchPlatform = true;
98
+ }
99
+ // 版本判断
100
+ if (!version) {
101
+ // 为空全匹配
102
+ isMatchVersion = true;
103
+ } else if (version.indexOf('|') !== -1) {
104
+ // | 范围匹配
105
+ var _version$split = version.split('|'),
106
+ _version$split2 = _slicedToArray(_version$split, 2),
107
+ _version$split2$ = _version$split2[0],
108
+ minVersion = _version$split2$ === void 0 ? '' : _version$split2$,
109
+ _version$split2$2 = _version$split2[1],
110
+ maxVersion = _version$split2$2 === void 0 ? '' : _version$split2$2;
111
+ isMatchVersion = isVersionInRange(currentVersion, minVersion, maxVersion);
112
+ } else if (version.indexOf(',') !== -1) {
113
+ // , 枚举匹配
114
+ var versionList = version.split(',');
115
+ isMatchVersion = versionList.includes(currentVersion);
116
+ } else {
117
+ isMatchVersion = version === currentVersion;
118
+ }
119
+ return value && isMatchPlatform && isMatchVersion;
45
120
  }