@alipay/ams-checkout 0.0.1699863258-dev.2 → 0.0.1699863258-dev.3

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.
@@ -152,6 +152,9 @@ export declare const EVENT: {
152
152
  getDeviceId: {
153
153
  name: string;
154
154
  };
155
+ declareEventCallbackInfo: {
156
+ name: string;
157
+ };
155
158
  };
156
159
  export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
157
160
  export declare const COMPONENT_SECTION_ID = "ams-component-section";
@@ -151,6 +151,9 @@ export var EVENT = {
151
151
  },
152
152
  getDeviceId: {
153
153
  name: 'getDeviceId'
154
+ },
155
+ declareEventCallbackInfo: {
156
+ name: 'declareEventCallbackInfo'
154
157
  }
155
158
  };
156
159
  export var COMPONENT_CONTAINER_ID = 'ams-component-container';
@@ -22,6 +22,7 @@ export default class ComponentApp {
22
22
  private _componentSign;
23
23
  private _appLocationSearch;
24
24
  private _renderDisplayType;
25
+ private _multipleCallbackEvents;
25
26
  constructor();
26
27
  /**
27
28
  * @description Cancel listening and destroy the dom
@@ -72,6 +73,7 @@ export default class ComponentApp {
72
73
  private handleSizeChanged;
73
74
  private handleRedirect;
74
75
  private handleDeclareInfo;
76
+ private handleDeclarePopWindowCallback;
75
77
  private handleCloseBtnShow;
76
78
  /**
77
79
  * @description Send message to SDK
@@ -48,6 +48,7 @@ var ComponentApp = /*#__PURE__*/function () {
48
48
  _defineProperty(this, "_componentSign", componentSignEnum.NONE);
49
49
  _defineProperty(this, "_appLocationSearch", void 0);
50
50
  _defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
51
+ _defineProperty(this, "_multipleCallbackEvents", void 0);
51
52
  this._appVersion = '1.6.1';
52
53
  this._isInitComponent = false;
53
54
  this._selector = "#".concat(COMPONENT_SECTION_ID);
@@ -259,11 +260,11 @@ var ComponentApp = /*#__PURE__*/function () {
259
260
  }
260
261
  this.createApp(renderParams);
261
262
  return Promise.all([this.createActionQueryPromise(), this.createSubmitPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
262
- _this3.AMSSDK.logger.logInfo({
263
- title: 'sdk_event_successfully_created_app_process'
264
- }).send();
265
263
  return Promise.resolve();
266
264
  }).catch(function (error) {
265
+ _this3.AMSSDK.logger.logError({
266
+ title: 'sdk_error_created_app_process_failed'
267
+ }).send();
267
268
  _this3._isInitComponent = false;
268
269
  _this3.cleanContainer();
269
270
  return Promise.reject(error);
@@ -340,7 +341,7 @@ var ComponentApp = /*#__PURE__*/function () {
340
341
  /**
341
342
  * @description Simulated or unnecessary scenarios
342
343
  */
343
- if (!(isLocalMock() || (_this5$_renderParams4 = _this5._renderParams) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) !== null && _this5$_renderParams4 !== void 0 && _this5$_renderParams4.action.skipSdkQuery)) {
344
+ if (!(isLocalMock() || (_this5$_renderParams4 = _this5._renderParams) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.action) !== null && _this5$_renderParams4 !== void 0 && _this5$_renderParams4.skipSdkQuery)) {
344
345
  _context2.next = 4;
345
346
  break;
346
347
  }
@@ -407,6 +408,11 @@ var ComponentApp = /*#__PURE__*/function () {
407
408
  case 26:
408
409
  envInfo.deviceId = _context2.sent;
409
410
  case 27:
411
+ _this5.AMSSDK.logger.logInfo({
412
+ title: 'sdk_event_sdkQuery'
413
+ }, {
414
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
415
+ }).send();
410
416
  queryPaymentInfo(params, {
411
417
  env: _this5.AMSSDK.options.env.environment,
412
418
  envInfo: envInfo
@@ -430,8 +436,14 @@ var ComponentApp = /*#__PURE__*/function () {
430
436
  code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
431
437
  });
432
438
  reject(err);
439
+ }).finally(function () {
440
+ _this5.AMSSDK.logger.logInfo({
441
+ title: 'sdk_event_sdkQueryEnd'
442
+ }, {
443
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
444
+ }).send();
433
445
  });
434
- case 28:
446
+ case 29:
435
447
  case "end":
436
448
  return _context2.stop();
437
449
  }
@@ -465,7 +477,7 @@ var ComponentApp = /*#__PURE__*/function () {
465
477
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
466
478
  while (1) switch (_context3.prev = _context3.next) {
467
479
  case 0:
468
- if (!(!((_this6$_renderParams = _this6._renderParams) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.paymentSessionMetaData) !== null && _this6$_renderParams !== void 0 && _this6$_renderParams.action.skipSdkQuery) || componentSignEnum.EASY_PAY_WALLET !== _this6._componentSign)) {
480
+ if (!(!((_this6$_renderParams = _this6._renderParams) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.paymentSessionMetaData) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.action) !== null && _this6$_renderParams !== void 0 && _this6$_renderParams.skipSdkQuery) || componentSignEnum.EASY_PAY_WALLET !== _this6._componentSign)) {
469
481
  _context3.next = 2;
470
482
  break;
471
483
  }
@@ -474,10 +486,28 @@ var ComponentApp = /*#__PURE__*/function () {
474
486
  success: true
475
487
  }));
476
488
  case 2:
477
- submitPayInfo(params, {
478
- env: _this6.AMSSDK.options.env.environment,
479
- timeout: 15000
480
- }, _this6.AMSSDK.logger).then(function (res) {
489
+ _this6.AMSSDK.logger.logInfo({
490
+ title: 'sdk_event_submitPay'
491
+ }, {
492
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
493
+ }).send();
494
+ _context3.t0 = submitPayInfo;
495
+ _context3.t1 = params;
496
+ _context3.t2 = _this6.AMSSDK.options.env.environment;
497
+ _context3.next = 8;
498
+ return _this6.getDeviceIdAndLog();
499
+ case 8:
500
+ _context3.t3 = _context3.sent;
501
+ _context3.t4 = {
502
+ deviceId: _context3.t3
503
+ };
504
+ _context3.t5 = {
505
+ env: _context3.t2,
506
+ timeout: 15000,
507
+ envInfo: _context3.t4
508
+ };
509
+ _context3.t6 = _this6.AMSSDK.logger;
510
+ (0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6).then(function (res) {
481
511
  _this6._performanceData.push({
482
512
  key: 'sdk_submit_end',
483
513
  value: Date.now()
@@ -488,11 +518,17 @@ var ComponentApp = /*#__PURE__*/function () {
488
518
  resolve(res);
489
519
  }
490
520
  }).catch(function () {
491
- return resolve({
521
+ resolve({
492
522
  success: false
493
523
  });
524
+ }).finally(function () {
525
+ _this6.AMSSDK.logger.logInfo({
526
+ title: 'sdk_event_submitPayEnd'
527
+ }, {
528
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
529
+ }).send();
494
530
  });
495
- case 3:
531
+ case 13:
496
532
  case "end":
497
533
  return _context3.stop();
498
534
  }
@@ -689,7 +725,7 @@ var ComponentApp = /*#__PURE__*/function () {
689
725
  }, {
690
726
  key: "_handleAppMessage",
691
727
  value: function _handleAppMessage(data) {
692
- var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name, EVENT.popupWindow.name, EVENT.threedReady.name, EVENT.closePopup.name, EVENT.getDeviceId.name];
728
+ var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name, EVENT.popupWindow.name, EVENT.threedReady.name, EVENT.closePopup.name, EVENT.getDeviceId.name, EVENT.declareEventCallbackInfo.name];
693
729
  if (!eventKeyMap.includes(data.context.event)) {
694
730
  return;
695
731
  }
@@ -762,6 +798,10 @@ var ComponentApp = /*#__PURE__*/function () {
762
798
  this.handleDeclareInfo(data.context.data);
763
799
  return;
764
800
  }
801
+ if (data.context.event === EVENT.declareEventCallbackInfo.name) {
802
+ this._multipleCallbackEvents = data.context.data;
803
+ return;
804
+ }
765
805
  if (data.context.event === EVENT.eventCallback.name) {
766
806
  this.AMSSDK.logger.logInfo({
767
807
  title: 'sdk_event_event_callback'
@@ -904,6 +944,24 @@ var ComponentApp = /*#__PURE__*/function () {
904
944
  closeDialogData: closeDialogData
905
945
  });
906
946
  }
947
+ }, {
948
+ key: "handleDeclarePopWindowCallback",
949
+ value: function handleDeclarePopWindowCallback() {
950
+ var eventInfoName = 'popWindowEventInfo';
951
+ if (this._multipleCallbackEvents && eventInfoName in this._multipleCallbackEvents) {
952
+ var eventInfo = this._multipleCallbackEvents[eventInfoName];
953
+ if (eventInfo.enableCallback) {
954
+ this.dispatchToSDK(EVENT.eventCallback.name, {
955
+ code: eventInfo.eventName,
956
+ result: {
957
+ result: eventInfo.eventResult
958
+ }
959
+ });
960
+ }
961
+ } else {
962
+ console.log("not valid ".concat(eventInfoName, " in "), this._multipleCallbackEvents);
963
+ }
964
+ }
907
965
  }, {
908
966
  key: "handleCloseBtnShow",
909
967
  value: function handleCloseBtnShow(showClose) {
@@ -1083,6 +1141,7 @@ var ComponentApp = /*#__PURE__*/function () {
1083
1141
  if (this._isRetention) this.showRetentionPopup();else {
1084
1142
  this.cleanContainer();
1085
1143
  this.dispatchToSDK(EVENT.close.name, {});
1144
+ this.handleDeclarePopWindowCallback();
1086
1145
  }
1087
1146
  }
1088
1147
  }, {
@@ -1091,6 +1150,7 @@ var ComponentApp = /*#__PURE__*/function () {
1091
1150
  this.dispatchToSDK(EVENT.close.name, {});
1092
1151
  this.hideRetentionPopupFunc();
1093
1152
  this.cleanContainer();
1153
+ this.handleDeclarePopWindowCallback();
1094
1154
  }
1095
1155
  }, {
1096
1156
  key: "removeRetentionPopup",
@@ -375,4 +375,12 @@ declare global {
375
375
  [key: string]: any;
376
376
  }
377
377
  }
378
+ export interface CallbackEventInfo {
379
+ enableCallback: boolean;
380
+ eventName: string;
381
+ eventResult?: any;
382
+ }
383
+ export interface MultipleCallbackEvents {
384
+ [key: string]: CallbackEventInfo;
385
+ }
378
386
  export {};
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@alipay/ams-checkout","version":"0.0.1699863258-dev.2","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
1
+ {"name":"@alipay/ams-checkout","version":"0.0.1699863258-dev.3","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}