@alipay/ams-checkout 0.0.1748326942-dev.0 → 0.0.1749206034-dev.0

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 (34) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +3 -1
  3. package/esm/component/channel.js +26 -62
  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 +7 -0
  9. package/esm/constant/index.js +7 -0
  10. package/esm/core/component/ckp/index.d.ts +2 -0
  11. package/esm/core/component/ckp/index.js +39 -5
  12. package/esm/core/component/element/util.js +1 -1
  13. package/esm/foundation/core/index.d.ts +3 -0
  14. package/esm/foundation/core/index.js +103 -37
  15. package/esm/foundation/index.d.ts +6 -0
  16. package/esm/foundation/product-processor/easysafepay/deps.d.ts +1 -1
  17. package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -0
  18. package/esm/foundation/product-processor/easysafepay/index.js +244 -121
  19. package/esm/foundation/service/container/index.d.ts +5 -0
  20. package/esm/foundation/service/container/index.js +96 -2
  21. package/esm/foundation/utils/preload_helper.d.ts +2 -2
  22. package/esm/foundation/utils/preload_helper.js +8 -4
  23. package/esm/foundation/utils/web_app_url_utils.d.ts +71 -1
  24. package/esm/foundation/utils/web_app_url_utils.js +215 -8
  25. package/esm/index.js +1 -1
  26. package/esm/plugin/component/cashierApp.js +4 -4
  27. package/esm/plugin/component/channel.d.ts +3 -1
  28. package/esm/plugin/component/channel.js +10 -12
  29. package/esm/plugin/component/index.js +45 -42
  30. package/esm/types/index.d.ts +17 -0
  31. package/esm/types/index.js +6 -0
  32. package/esm/util/redirect.d.ts +6 -0
  33. package/esm/util/redirect.js +54 -0
  34. package/package.json +3 -2
@@ -15,14 +15,13 @@ import { cleanMockup, createMockup, createRetentionPopup, handleDeclareInfo, hid
15
15
  import { insertStyleSheet } from "../../component/popupWindow.style";
16
16
  import { sdkVersion } from "../../config";
17
17
  import { COMPONENT_CLOSE_MASK_BLOCK_ID, EVENT, LOADING_ID } from "../../constant";
18
- import { DisplayTypeEnum, eventCodeEnum } from "../../types";
18
+ import { DisplayTypeEnum, eventCodeEnum, EventLoggingEventId } from "../../types";
19
19
  import { DisplayInfo, IElementStatus } from "../index";
20
20
  import { ServiceProvider } from "../service";
21
21
  import { getGrayscaleId } from "../utils/gray_scale_utils";
22
22
  import { convertPaymentSession, getWebAppVersion, saveWebAppVersion } from "../utils/payment_context_utils";
23
23
  import { redirect } from "../utils/redirect_utils";
24
24
  import { parseWebAppMatchConfig } from "../utils/web_app_url_utils";
25
-
26
25
  /**
27
26
  * @author 谦彧 <zhangmian.zm@alipay.com>
28
27
  * @date 2024/9/17
@@ -37,7 +36,9 @@ export var AntomSDKCore = /*#__PURE__*/function () {
37
36
  _defineProperty(this, "sdkMetaData", void 0);
38
37
  _defineProperty(this, "productProcessors", {});
39
38
  _defineProperty(this, "enablePopWindowEventCallback", false);
39
+ _defineProperty(this, "eventLogging", void 0);
40
40
  _defineProperty(this, "status", IElementStatus.UNINIT);
41
+ _defineProperty(this, "logger", void 0);
41
42
  this.status = IElementStatus.INITING;
42
43
  }
43
44
  _createClass(AntomSDKCore, [{
@@ -84,6 +85,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
84
85
  };
85
86
  this.sdkMetaData.webAppVersion = getWebAppVersion(this.sdkMetaData);
86
87
  ServiceProvider.getInstance(this.instanceId).init(options, this.sdkMetaData);
88
+ this.logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
87
89
  this.prepare(options, this.sdkMetaData);
88
90
  }
89
91
  }, {
@@ -178,6 +180,29 @@ export var AntomSDKCore = /*#__PURE__*/function () {
178
180
  return _ref2.apply(this, arguments);
179
181
  };
180
182
  }());
183
+ eventCenter.listen(EVENT.getSdkVersion.name, /*#__PURE__*/function () {
184
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data, payload) {
185
+ var _payload$context3;
186
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
187
+ while (1) switch (_context3.prev = _context3.next) {
188
+ case 0:
189
+ eventCenter.dispatchToApp({
190
+ event: 'appEventCallback',
191
+ eventCallbackId: (_payload$context3 = payload.context) === null || _payload$context3 === void 0 ? void 0 : _payload$context3.eventCallbackId,
192
+ data: {
193
+ version: sdkMetaData === null || sdkMetaData === void 0 ? void 0 : sdkMetaData.sdkVersion
194
+ }
195
+ });
196
+ case 1:
197
+ case "end":
198
+ return _context3.stop();
199
+ }
200
+ }, _callee3);
201
+ }));
202
+ return function (_x5, _x6) {
203
+ return _ref3.apply(this, arguments);
204
+ };
205
+ }());
181
206
  eventCenter.listen(EVENT.destroy.name, function (data) {
182
207
  _this.setStatus(IElementStatus.READY);
183
208
  _this.destroy();
@@ -188,6 +213,12 @@ export var AntomSDKCore = /*#__PURE__*/function () {
188
213
  });
189
214
  eventCenter.listen(EVENT.eventCallback.name, function (data) {
190
215
  var _options$onEventCallb;
216
+ _this.logger.logInfo({
217
+ title: 'sdk_event_event_callback'
218
+ }, {
219
+ eventCode: JSON.stringify((data === null || data === void 0 ? void 0 : data.code) || ''),
220
+ eventMessage: JSON.stringify((data === null || data === void 0 ? void 0 : data.message) || '')
221
+ });
191
222
  (_options$onEventCallb = options.onEventCallback) === null || _options$onEventCallb === void 0 || _options$onEventCallb.call(options, data);
192
223
  });
193
224
  eventCenter.listen(EVENT.error.name, function (data) {
@@ -197,6 +228,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
197
228
  eventCenter.listen(EVENT.declareEventCallbackInfo.name, function (data) {
198
229
  if (data !== null && data !== void 0 && data.popWindowEventInfo) {
199
230
  _this.enablePopWindowEventCallback = data.popWindowEventInfo.enableCallback;
231
+ _this.eventLogging = data.popWindowEventInfo.eventLogging;
200
232
  }
201
233
  });
202
234
 
@@ -208,18 +240,21 @@ export var AntomSDKCore = /*#__PURE__*/function () {
208
240
  }, {
209
241
  key: "startBizFlow",
210
242
  value: function () {
211
- var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options) {
243
+ var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
212
244
  var _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3;
213
245
  var paymentSession, displayInfo, _convertPaymentSessio2, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload;
214
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
215
- while (1) switch (_context3.prev = _context3.next) {
246
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
247
+ while (1) switch (_context4.prev = _context4.next) {
216
248
  case 0:
217
249
  if (!(!options || !options.paymentSession)) {
218
- _context3.next = 2;
250
+ _context4.next = 2;
219
251
  break;
220
252
  }
221
253
  throw new Error('paymentSession is empty');
222
254
  case 2:
255
+ this.logger.logInfo({
256
+ title: 'sdk_event_createComponent'
257
+ });
223
258
  this.setStatus(IElementStatus.IN_BIZ_FLOW);
224
259
  paymentSession = options.paymentSession, displayInfo = options.displayInfo;
225
260
  _convertPaymentSessio2 = convertPaymentSession(paymentSession), paymentSessionId = _convertPaymentSessio2.id, paymentSessionMetaData = _convertPaymentSessio2.data;
@@ -245,61 +280,61 @@ export var AntomSDKCore = /*#__PURE__*/function () {
245
280
  // Invoke processor
246
281
  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;
247
282
  paymentMethod = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$3 === void 0 || (_this$paymentContext$3 = _this$paymentContext$3.paymentMethodInfoView) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.paymentMethodType;
248
- _context3.prev = 14;
283
+ _context4.prev = 15;
249
284
  if (!this.productProcessors["".concat(productScene, "|").concat(paymentMethod)]) {
250
- _context3.next = 21;
285
+ _context4.next = 22;
251
286
  break;
252
287
  }
253
- _context3.next = 18;
288
+ _context4.next = 19;
254
289
  return this.productProcessors["".concat(productScene, "|").concat(paymentMethod)].startBizFlow(this.paymentContext);
255
- case 18:
256
- this.bizFlowStartBehavior = _context3.sent;
257
- _context3.next = 25;
290
+ case 19:
291
+ this.bizFlowStartBehavior = _context4.sent;
292
+ _context4.next = 26;
258
293
  break;
259
- case 21:
294
+ case 22:
260
295
  if (!this.productProcessors["".concat(productScene)]) {
261
- _context3.next = 25;
296
+ _context4.next = 26;
262
297
  break;
263
298
  }
264
- _context3.next = 24;
299
+ _context4.next = 25;
265
300
  return this.productProcessors["".concat(productScene)].startBizFlow(this.paymentContext);
266
- case 24:
267
- this.bizFlowStartBehavior = _context3.sent;
268
301
  case 25:
269
- _context3.next = 30;
302
+ this.bizFlowStartBehavior = _context4.sent;
303
+ case 26:
304
+ _context4.next = 31;
270
305
  break;
271
- case 27:
272
- _context3.prev = 27;
273
- _context3.t0 = _context3["catch"](14);
274
- console.error('Invoke processor failed', _context3.t0);
275
- case 30:
306
+ case 28:
307
+ _context4.prev = 28;
308
+ _context4.t0 = _context4["catch"](15);
309
+ console.error('Invoke processor failed', _context4.t0);
310
+ case 31:
276
311
  if (!(!this.bizFlowStartBehavior || this.bizFlowStartBehavior.behaviorType === 'NONE' || !this.bizFlowStartBehavior.payload)) {
277
- _context3.next = 32;
312
+ _context4.next = 33;
278
313
  break;
279
314
  }
280
- return _context3.abrupt("return");
281
- case 32:
315
+ return _context4.abrupt("return");
316
+ case 33:
282
317
  if (!(this.bizFlowStartBehavior.behaviorType === 'RENDER')) {
283
- _context3.next = 35;
318
+ _context4.next = 36;
284
319
  break;
285
320
  }
286
321
  this.handleBehaviorRender();
287
- return _context3.abrupt("return");
288
- case 35:
322
+ return _context4.abrupt("return");
323
+ case 36:
289
324
  if (!(this.bizFlowStartBehavior.behaviorType === 'REDIRECT')) {
290
- _context3.next = 39;
325
+ _context4.next = 40;
291
326
  break;
292
327
  }
293
328
  payload = (_this$bizFlowStartBeh = this.bizFlowStartBehavior) === null || _this$bizFlowStartBeh === void 0 ? void 0 : _this$bizFlowStartBeh.payload;
294
329
  redirect(payload, this.instanceId);
295
- return _context3.abrupt("return");
296
- case 39:
330
+ return _context4.abrupt("return");
331
+ case 40:
297
332
  case "end":
298
- return _context3.stop();
333
+ return _context4.stop();
299
334
  }
300
- }, _callee3, this, [[14, 27]]);
335
+ }, _callee4, this, [[15, 28]]);
301
336
  }));
302
- function startBizFlow(_x5) {
337
+ function startBizFlow(_x7) {
303
338
  return _startBizFlow.apply(this, arguments);
304
339
  }
305
340
  return startBizFlow;
@@ -342,7 +377,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
342
377
  showRetentionPopup();
343
378
  return;
344
379
  } else {
345
- _this2.handleClose(isOnCloseEvent);
380
+ _this2.handleClose(isOnCloseEvent, 'behavior');
346
381
  }
347
382
  };
348
383
 
@@ -368,9 +403,10 @@ export var AntomSDKCore = /*#__PURE__*/function () {
368
403
  if (displayType == DisplayTypeEnum.popup) {
369
404
  createRetentionPopup(platform, function () {
370
405
  hideRetentionPopup();
406
+ _this2.handleRemain();
371
407
  }, function () {
372
408
  hideRetentionPopup();
373
- _this2.handleClose();
409
+ _this2.handleClose(false, 'retention');
374
410
  });
375
411
  createMockup({
376
412
  platform: platform,
@@ -381,13 +417,40 @@ export var AntomSDKCore = /*#__PURE__*/function () {
381
417
  return;
382
418
  }
383
419
  }
420
+ }, {
421
+ key: "handleRemain",
422
+ value: function handleRemain() {
423
+ if (this.eventLogging && this.eventLogging.enableLogging) {
424
+ var _this$eventLogging, _this$eventLogging2, _this$eventLogging3, _this$eventLogging4;
425
+ this.logger.logInfo({
426
+ code: ((_this$eventLogging = this.eventLogging) === null || _this$eventLogging === void 0 ? void 0 : _this$eventLogging.eventName) || ''
427
+ }, {
428
+ eventId: EventLoggingEventId.ContinuePaying,
429
+ eventName: ((_this$eventLogging2 = this.eventLogging) === null || _this$eventLogging2 === void 0 ? void 0 : _this$eventLogging2.eventName) || '',
430
+ eventAlias: ((_this$eventLogging3 = this.eventLogging) === null || _this$eventLogging3 === void 0 ? void 0 : _this$eventLogging3.eventAlias) || '',
431
+ userPath: ((_this$eventLogging4 = this.eventLogging) === null || _this$eventLogging4 === void 0 ? void 0 : _this$eventLogging4.userPath) || ''
432
+ });
433
+ }
434
+ }
384
435
  }, {
385
436
  key: "handleClose",
386
437
  value: function handleClose() {
387
438
  var isOnCloseEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
439
+ var source = arguments.length > 1 ? arguments[1] : undefined;
388
440
  var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
389
441
  eventCenter.emit(EVENT.closeCallback.name, {});
390
442
  if (this.enablePopWindowEventCallback && !isOnCloseEvent) {
443
+ if (this.eventLogging && this.eventLogging.enableLogging) {
444
+ var _this$eventLogging5, _this$eventLogging6, _this$eventLogging7, _this$eventLogging8;
445
+ this.logger.logInfo({
446
+ code: ((_this$eventLogging5 = this.eventLogging) === null || _this$eventLogging5 === void 0 ? void 0 : _this$eventLogging5.eventName) || ''
447
+ }, {
448
+ eventId: source === 'behavior' ? EventLoggingEventId.OnlyClose : EventLoggingEventId.LeaveAnyWay,
449
+ eventName: ((_this$eventLogging6 = this.eventLogging) === null || _this$eventLogging6 === void 0 ? void 0 : _this$eventLogging6.eventName) || '',
450
+ eventAlias: ((_this$eventLogging7 = this.eventLogging) === null || _this$eventLogging7 === void 0 ? void 0 : _this$eventLogging7.eventAlias) || '',
451
+ userPath: ((_this$eventLogging8 = this.eventLogging) === null || _this$eventLogging8 === void 0 ? void 0 : _this$eventLogging8.userPath) || ''
452
+ });
453
+ }
391
454
  eventCenter.emit(EVENT.eventCallback.name, {
392
455
  code: eventCodeEnum.SDK_PAYMENT_CANCEL,
393
456
  result: {
@@ -423,6 +486,9 @@ export var AntomSDKCore = /*#__PURE__*/function () {
423
486
  setTimeout(function () {
424
487
  cleanElement();
425
488
  }, 300);
489
+ this.logger.logInfo({
490
+ title: 'sdk_event_destroyComponent'
491
+ });
426
492
  }
427
493
  }, {
428
494
  key: "getInstanceId",
@@ -76,6 +76,12 @@ export interface SDKMetaData {
76
76
  webAppVersion: string;
77
77
  greyscaleId?: number;
78
78
  }
79
+ export interface EventLogging {
80
+ enableLogging?: boolean;
81
+ eventName?: string;
82
+ eventAlias?: string;
83
+ userPath?: string;
84
+ }
79
85
  export interface InitContext {
80
86
  initOptions: IoptionsParams;
81
87
  sdkMetaData: SDKMetaData;
@@ -4,7 +4,7 @@ export type { BizFlowStartBehavior, PaymentContext, ProductProcessor, RedirectBe
4
4
  export * as ChannelCustomize from '../../../component/channel';
5
5
  export type { IChannelBehavior } from '../../../component/channel';
6
6
  export { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum, RiskSdkInfoEnum } from '../../../types';
7
- export type { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, IoptionsParams, } from '../../../types';
7
+ export type { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSdkActionQuerySessionResult, CashierSubmitPayRequest, CashierSubmitPayResult, IoptionsParams, } from '../../../types';
8
8
  export { isPC } from '../../../util';
9
9
  export { getBackScheme } from '../../utils/redirect_utils';
10
10
  export { isLocalMock } from '../../../util/mock';
@@ -7,6 +7,7 @@ export declare class EasySafePayProcessor implements ProductProcessor {
7
7
  private eventCenter;
8
8
  private instanceId;
9
9
  private hostSign;
10
+ private allowQueryCall;
10
11
  private allowSubmitPayCallAhead;
11
12
  private channelBehavior?;
12
13
  private SECURITY_SDK_INIT_TIMEOUT;
@@ -21,6 +22,7 @@ export declare class EasySafePayProcessor implements ProductProcessor {
21
22
  * start waiting web launch, then send renderComponent event
22
23
  * */
23
24
  private sendRequestAndWaitWebLaunch;
25
+ private processQuery;
24
26
  private processSubmitPay;
25
27
  private acquireApdidToken;
26
28
  private initSecuritySDK;