@alipay/ams-checkout 2.0.2 → 2.0.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.
@@ -82,6 +82,21 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
82
82
  },
83
83
  eventCode = _ref.event,
84
84
  data = _ref.data;
85
+ if (eventCode && eventCode !== null && eventCode !== void 0 && eventCode.startsWith('getDomain')) {
86
+ var _window, _window2;
87
+ var hostname = (_window = window) === null || _window === void 0 || (_window = _window.location) === null || _window === void 0 ? void 0 : _window.hostname;
88
+ _this.logger.logInfo({
89
+ code: 'a3753.b146681',
90
+ msg: hostname
91
+ }).send();
92
+ var content = _objectSpread(_objectSpread({}, dataObj === null || dataObj === void 0 ? void 0 : dataObj.context), {}, {
93
+ data: {
94
+ doMain: (_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.location) === null || _window2 === void 0 ? void 0 : _window2.hostname
95
+ },
96
+ event: 'appEventCallback'
97
+ });
98
+ _this.dispatchToApp(content);
99
+ }
85
100
  if (code && code.startsWith('SDK_PAYMENT')) {
86
101
  var _this$eventListener;
87
102
  console.log('[antom-web-sdk] <antom-checkout-page> eventListenerWrapper', event, message, result);
@@ -0,0 +1,10 @@
1
+ export declare enum ProductScene {
2
+ EXPRESS_CHECKOUT = "EXPRESS_CHECKOUT",
3
+ ELEMENT_PAYMENT = "ELEMENT_PAYMENT"
4
+ }
5
+ interface EventScenario {
6
+ eventName: ProductScene;
7
+ supportedEvents: string[];
8
+ }
9
+ export declare const productEventScenarios: EventScenario[];
10
+ export {};
@@ -0,0 +1,17 @@
1
+ // 定义产品场景的枚举
2
+ export var ProductScene = /*#__PURE__*/function (ProductScene) {
3
+ ProductScene["EXPRESS_CHECKOUT"] = "EXPRESS_CHECKOUT";
4
+ ProductScene["ELEMENT_PAYMENT"] = "ELEMENT_PAYMENT";
5
+ return ProductScene;
6
+ }({});
7
+
8
+ // 定义一个事件场景的接口
9
+
10
+ // 存储产品场景及支持的事件名
11
+ export var productEventScenarios = [{
12
+ eventName: ProductScene.EXPRESS_CHECKOUT,
13
+ supportedEvents: [] // 没有支持的事件
14
+ }, {
15
+ eventName: ProductScene.ELEMENT_PAYMENT,
16
+ supportedEvents: ['paymentMethodChanged', 'valuesChanged'] // 支持的事件
17
+ }];
@@ -1,4 +1,4 @@
1
- import { AddressMountOptions, ICommonApiResponse, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions } from '../type';
1
+ import { AddressMountOptions, EventDataMap, EVENTNAME, ICommonApiResponse, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions, SubmitFuncParams } from '../type';
2
2
  declare class ElementController {
3
3
  private options;
4
4
  private elementContainer;
@@ -33,7 +33,7 @@ declare class ElementController {
33
33
  validateFields(): Promise<{
34
34
  isValid: boolean;
35
35
  }>;
36
- submitPayment(): Promise<IPaymentApiResponse>;
36
+ submitPayment(submitParams: SubmitFuncParams): Promise<IPaymentApiResponse>;
37
37
  private changeLoading;
38
38
  private addEventListener;
39
39
  private sendRequestAndWaitWebLaunch;
@@ -44,5 +44,7 @@ declare class ElementController {
44
44
  private destroyHandle;
45
45
  destroy(): void;
46
46
  private setControllerStatusOrView;
47
+ on<T extends EVENTNAME>(event: T, callback: (data: EventDataMap[T]) => void): void;
48
+ private isEventAllowed;
47
49
  }
48
50
  export default ElementController;
@@ -23,8 +23,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
23
23
  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; }
24
24
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
25
25
  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); }
26
- import { ServiceProvider } from "../../../../foundation/service";
27
- import { ELEMENT_SPM_MAP } from "../../../../util/spm-map";
26
+ import { productEventScenarios, ProductScene } from "../config";
28
27
  import { cleanMockup, removeRetentionPopup } from "../../../../component/component.popup.style";
29
28
  import { destroyModal } from "../../../../component/popupWindow.style";
30
29
  import { ERRORMESSAGE, EVENT, PROMISE_CALLBACK_CODE } from "../../../../constant";
@@ -34,14 +33,16 @@ import PaymentProcessor from "../../../../core/component/element/elementProcesso
34
33
  import { IElementStatus } from "../../../../foundation";
35
34
  import { AntomSDKCore } from "../../../../foundation/core";
36
35
  import { ElementProcessor } from "../../../../foundation/product-processor/element";
36
+ import { ServiceProvider } from "../../../../foundation/service";
37
+ import { convertPaymentSession } from "../../../../foundation/utils/payment_context_utils";
37
38
  import { ProductSceneEnum } from "../../../../types";
39
+ import { ELEMENT_SPM_MAP } from "../../../../util/spm-map";
38
40
  import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
39
41
  import { IContainerStatus } from "../elementContainerService/containerService";
40
42
  import { EventCenter as ElementEventCenter } from "../EventCenter/index";
41
43
  import { oneAccountUpdate, sdkActionUpdate } from "../mock";
42
44
  import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType, PaymentStatus } from "../type";
43
- import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, safeStringify, showToast } from "../util";
44
- import { convertPaymentSession } from "../../../../foundation/utils/payment_context_utils";
45
+ import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, safeParse, safeStringify, showToast } from "../util";
45
46
  var TIMEOUT_DURATION = 10000;
46
47
  var ElementController = /*#__PURE__*/function () {
47
48
  function ElementController(options) {
@@ -77,7 +78,10 @@ var ElementController = /*#__PURE__*/function () {
77
78
  event.emitAndListen({
78
79
  event: ElementPaymentEvent.SUBMIT_PAY,
79
80
  data: {
80
- params: _objectSpread({}, params),
81
+ params: _objectSpread(_objectSpread({}, params), {}, {
82
+ doMain: window.location.hostname
83
+ // sessionResult: this.parseData, 该参数在应用层好像没有使用 TODO
84
+ }),
81
85
  target: target,
82
86
  source: ElementPaymentMethod.CONTAINER_ELEMENT
83
87
  }
@@ -89,13 +93,16 @@ var ElementController = /*#__PURE__*/function () {
89
93
  this.options = options;
90
94
  var _options = options;
91
95
  this.onStatusChangeCallback = _options === null || _options === void 0 ? void 0 : _options.onStatusChangeCallback;
96
+ // 初始化 this.elementContainer 的 status 为 INITING
92
97
  this.elementContainer = new AntomSDKCore();
93
98
  this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor());
99
+ // 初始化实例 id,监听 onRedirect 事件
94
100
  this.elementContainer.init(this.options, ProductSceneEnum.ELEMENT_PAYMENT);
95
101
  this.initService();
96
102
  this.elementContainerService = new ElementContainerService({
97
103
  instanceId: this.elementContainer.getInstanceId()
98
104
  });
105
+ // status 设置为 READY
99
106
  this.setControllerStatusOrView(IElementStatus.READY);
100
107
  this.elementEventCenter = new ElementEventCenter({
101
108
  logger: this.elementContainer.getServiceProvider().getService('Log')
@@ -205,6 +212,7 @@ var ElementController = /*#__PURE__*/function () {
205
212
  key: "initializeAndMountProcessor",
206
213
  value: function initializeAndMountProcessor(type, selector, options) {
207
214
  this.initElementProcessors(type);
215
+ // 创建 iframe,拉起应用页面,同时监听全局的数据更新和获取事件
208
216
  this.elementContainerService.mount({
209
217
  type: type,
210
218
  selector: selector,
@@ -241,6 +249,7 @@ var ElementController = /*#__PURE__*/function () {
241
249
  key: "mount",
242
250
  value: function mount(renderOptions, sdkSelector) {
243
251
  var _this2 = this;
252
+ // 此处的 id 是 sessionData && 分割的前3位
244
253
  var _convertPaymentSessio = convertPaymentSession(this.options.sessionData),
245
254
  sessionData = _convertPaymentSessio.id;
246
255
  var startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.MOUNT, sessionData);
@@ -264,6 +273,7 @@ var ElementController = /*#__PURE__*/function () {
264
273
  return;
265
274
  }
266
275
  _this2.clearAndSetInitTimeout(readyCallback);
276
+ // 回调 loading 的 onStartLoading
267
277
  _this2.changeLoading(true);
268
278
  try {
269
279
  var startBizFlowData = {
@@ -272,10 +282,14 @@ var ElementController = /*#__PURE__*/function () {
272
282
  appendAliasContainerId: true
273
283
  })
274
284
  };
285
+ // status 设置为 IN_BIZ_FLOW
275
286
  _this2.setControllerStatusOrView(IElementStatus.IN_BIZ_FLOW);
276
287
  _this2.elementContainer.startBizFlow(startBizFlowData);
288
+ // 创建 iframe 加载应用页面
277
289
  _this2.initializeAndMountProcessor(renderOptions.type, sdkSelector, renderOptions);
290
+ // 监听应用页面 onLaunch 事件,请求 sdkAction.query 接口的数据,请求完成后处理数据异常情况或发送 renderComponent 事件及数据给应用层渲染页面内容
278
291
  _this2.sendRequestAndWaitWebLaunch(renderOptions, readyCallback);
292
+ // 监听事件
279
293
  _this2.addEventListener(readyCallback);
280
294
  _this2.serviceMap.EventCenter.addIFrame(_this2.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
281
295
  } catch (error) {
@@ -337,7 +351,7 @@ var ElementController = /*#__PURE__*/function () {
337
351
  }, {
338
352
  key: "submitPayment",
339
353
  value: function () {
340
- var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
354
+ var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(submitParams) {
341
355
  var _this3 = this;
342
356
  var startEventId, res, logParams, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
343
357
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -369,7 +383,7 @@ var ElementController = /*#__PURE__*/function () {
369
383
  _context4.next = 11;
370
384
  return new Promise( /*#__PURE__*/function () {
371
385
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
372
- var that, recordResultCallback, params, processStep, _yield$_this3$onValid2, data, errorResult;
386
+ var that, recordResultCallback, params, processStep, _submitParams$handleA, _yield$_this3$onValid2, _data, errorString, errorResult;
373
387
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
374
388
  while (1) switch (_context3.prev = _context3.next) {
375
389
  case 0:
@@ -422,7 +436,7 @@ var ElementController = /*#__PURE__*/function () {
422
436
  }
423
437
  }, _callee2);
424
438
  }));
425
- return function processStep(_x2, _x3) {
439
+ return function processStep(_x3, _x4) {
426
440
  return _ref4.apply(this, arguments);
427
441
  };
428
442
  }(); // 按顺序处理步骤
@@ -449,23 +463,28 @@ var ElementController = /*#__PURE__*/function () {
449
463
  break;
450
464
  }
451
465
  _context3.next = 17;
452
- return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
466
+ return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, _objectSpread(_objectSpread({}, params), {}, {
467
+ handleActions: (_submitParams$handleA = submitParams === null || submitParams === void 0 ? void 0 : submitParams.handleActions) !== null && _submitParams$handleA !== void 0 ? _submitParams$handleA : true,
468
+ shipping: submitParams === null || submitParams === void 0 ? void 0 : submitParams.shippingInfo
469
+ }));
453
470
  case 17:
454
471
  _yield$_this3$onValid2 = _context3.sent;
455
- data = _yield$_this3$onValid2.data;
472
+ _data = _yield$_this3$onValid2.data;
456
473
  // TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
457
474
  // TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
458
- recordResult = data;
475
+ recordResult = _data;
459
476
  recordResultCallback(recordResult);
460
477
  case 21:
461
- _context3.next = 29;
478
+ _context3.next = 30;
462
479
  break;
463
480
  case 23:
464
481
  _context3.prev = 23;
465
482
  _context3.t0 = _context3["catch"](2);
483
+ // 修复error为{}空对象的问题,上报stack&message
484
+ errorString = JSON.stringify(_context3.t0, Object.getOwnPropertyNames(_context3.t0));
466
485
  errorResult = {
467
486
  error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
468
- context: JSON.stringify(_context3.t0)
487
+ context: errorString
469
488
  }),
470
489
  status: PaymentStatus.FAIL
471
490
  };
@@ -476,13 +495,13 @@ var ElementController = /*#__PURE__*/function () {
476
495
  });
477
496
  recordResult = errorResult;
478
497
  recordResultCallback(errorResult);
479
- case 29:
498
+ case 30:
480
499
  case "end":
481
500
  return _context3.stop();
482
501
  }
483
502
  }, _callee3, null, [[2, 23]]);
484
503
  }));
485
- return function (_x) {
504
+ return function (_x2) {
486
505
  return _ref3.apply(this, arguments);
487
506
  };
488
507
  }());
@@ -507,7 +526,7 @@ var ElementController = /*#__PURE__*/function () {
507
526
  }
508
527
  }, _callee4, this, [[8,, 12, 17]]);
509
528
  }));
510
- function submitPayment() {
529
+ function submitPayment(_x) {
511
530
  return _submitPayment.apply(this, arguments);
512
531
  }
513
532
  return submitPayment;
@@ -615,7 +634,10 @@ var ElementController = /*#__PURE__*/function () {
615
634
  return _context5.abrupt("return");
616
635
  case 7:
617
636
  _context5.next = 9;
618
- return Promise.all([containerService.createWebLaunchPromise(), this.elementProcessors[type].obtainData()]);
637
+ return Promise.all([containerService.createWebLaunchPromise(),
638
+ // 监听 onLaunch 事件
639
+ this.elementProcessors[type].obtainData() // 请求 sdkAction.query 的数据,connect 还会请求 account.query
640
+ ]);
619
641
  case 9:
620
642
  _yield$Promise$all = _context5.sent;
621
643
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
@@ -624,12 +646,15 @@ var ElementController = /*#__PURE__*/function () {
624
646
  this.serviceMap.Log.logInfo({
625
647
  title: 'sdk_event_webAppOnLaunch'
626
648
  });
649
+ // 应用页面加载完成且接口请求完成,状态设置为 READY
627
650
  containerService === null || containerService === void 0 || containerService.switchContainerStatus(IContainerStatus.READY);
651
+ // 处理接口数据异常情况,直接回调,结束流程
628
652
  errorResult = this.getErrorFromResponse(obtainDataResult);
629
653
  if (errorResult) {
630
- // 仅结束resove,传出回调码
654
+ // 仅结束resolve,传出回调码
631
655
  readyCallback(errorResult);
632
656
  }
657
+ // 页面加载和数据状态 READY 后,SDK 向应用层发送 renderComponent 事件,传递应用层渲染必须的数据
633
658
  if (this.areAllContainersReady()) {
634
659
  this.elementContainerService.getContainerServices().forEach(function (_, key) {
635
660
  _this5.sendReady(key, options);
@@ -652,7 +677,7 @@ var ElementController = /*#__PURE__*/function () {
652
677
  }
653
678
  }, _callee5, this, [[1, 20]]);
654
679
  }));
655
- function sendRequestAndWaitWebLaunch(_x4, _x5) {
680
+ function sendRequestAndWaitWebLaunch(_x5, _x6) {
656
681
  return _sendRequestAndWaitWebLaunch.apply(this, arguments);
657
682
  }
658
683
  return sendRequestAndWaitWebLaunch;
@@ -785,7 +810,7 @@ var ElementController = /*#__PURE__*/function () {
785
810
  }
786
811
  }, _callee6);
787
812
  }));
788
- return function (_x7) {
813
+ return function (_x8) {
789
814
  return _ref5.apply(this, arguments);
790
815
  };
791
816
  }()));
@@ -795,7 +820,7 @@ var ElementController = /*#__PURE__*/function () {
795
820
  }
796
821
  }, _callee7);
797
822
  }));
798
- function updatePayment(_x6) {
823
+ function updatePayment(_x7) {
799
824
  return _updatePayment.apply(this, arguments);
800
825
  }
801
826
  return updatePayment;
@@ -832,6 +857,30 @@ var ElementController = /*#__PURE__*/function () {
832
857
  (_this$onStatusChangeC = this.onStatusChangeCallback) === null || _this$onStatusChangeC === void 0 || _this$onStatusChangeC.call(this, "\u72B6\u6001\u7531 ".concat(_status, " \u53D8\u66F4\u4E3A ").concat(status));
833
858
  this.elementContainer.setStatus(status);
834
859
  }
860
+ }, {
861
+ key: "on",
862
+ value: function on(event, callback) {
863
+ if (!this.isEventAllowed(event)) {
864
+ return console.error("Event \"".concat(event, "\" is not allowed."));
865
+ }
866
+ this.serviceMap.EventCenter.listen(event, function (data) {
867
+ callback === null || callback === void 0 || callback(data);
868
+ });
869
+ }
870
+ }, {
871
+ key: "isEventAllowed",
872
+ value: function isEventAllowed(event) {
873
+ var _safeParse, _this$elementContaine;
874
+ // 获取当前场景
875
+ var isExpressCheckout = (_safeParse = safeParse((_this$elementContaine = this.elementContainer.getPaymentContext()) === null || _this$elementContaine === void 0 || (_this$elementContaine = _this$elementContaine.paymentSessionObj) === null || _this$elementContaine === void 0 ? void 0 : _this$elementContaine.extendInfo)) === null || _safeParse === void 0 ? void 0 : _safeParse.expressCheckout;
876
+ var productScene = isExpressCheckout ? ProductScene.EXPRESS_CHECKOUT : ProductScene.ELEMENT_PAYMENT;
877
+ // 查找对应的产品场景
878
+ var scenario = productEventScenarios.find(function (s) {
879
+ return s.eventName === productScene;
880
+ });
881
+ // 检查场景存在且事件名称在支持的事件列表中
882
+ return scenario !== undefined && scenario.supportedEvents.includes(event);
883
+ }
835
884
  }]);
836
885
  return ElementController;
837
886
  }();
@@ -88,7 +88,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
88
88
  sessionResult: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionObj,
89
89
  notRedirectAfterComplete: (extraParam === null || extraParam === void 0 ? void 0 : extraParam.notRedirectAfterComplete) === true,
90
90
  merchantAppointParam: extraParam === null || extraParam === void 0 ? void 0 : extraParam.merchantAppointParam,
91
- originOneAccountQueryResult: extraParam === null || extraParam === void 0 ? void 0 : extraParam.originOneAccountQueryResult
91
+ originOneAccountQueryResult: extraParam === null || extraParam === void 0 ? void 0 : extraParam.originOneAccountQueryResult,
92
+ // TODO: 传递商户页面的domain
93
+ doMain: window.location.hostname
92
94
  }
93
95
  });
94
96
  }
@@ -1,4 +1,4 @@
1
- import { IElementOptions, PaymentMountOptions } from './type';
1
+ import { EventDataMap, EVENTNAME, IElementOptions, PaymentMountOptions, SubmitFuncParams } from './type';
2
2
  export declare class ElementComponent {
3
3
  private options;
4
4
  private controller;
@@ -8,6 +8,7 @@ export declare class ElementComponent {
8
8
  validateFields(): Promise<{
9
9
  isValid: boolean;
10
10
  }>;
11
- submitPayment(): Promise<import("./type").IPaymentApiResponse>;
11
+ submitPayment(params: SubmitFuncParams): Promise<import("./type").IPaymentApiResponse>;
12
12
  destroy(): void;
13
+ on<T extends EVENTNAME>(event: T, callback: (data: EventDataMap[T]) => void): void;
13
14
  }
@@ -62,14 +62,19 @@ export var ElementComponent = /*#__PURE__*/function () {
62
62
  }
63
63
  }, {
64
64
  key: "submitPayment",
65
- value: function submitPayment() {
66
- return this.controller.submitPayment();
65
+ value: function submitPayment(params) {
66
+ return this.controller.submitPayment(params);
67
67
  }
68
68
  }, {
69
69
  key: "destroy",
70
70
  value: function destroy() {
71
71
  this.controller.destroy();
72
72
  }
73
+ }, {
74
+ key: "on",
75
+ value: function on(event, callback) {
76
+ this.controller.on(event, callback);
77
+ }
73
78
  }]);
74
79
  return ElementComponent;
75
80
  }();
@@ -179,10 +179,15 @@ export interface PaymentMountOptions extends BaseMountOptions {
179
179
  'radius-component': string;
180
180
  'radius-button': string;
181
181
  'wrapper-padding': string;
182
+ 'stroke-default': string;
183
+ 'stroke-active': string;
182
184
  }>>;
183
185
  card?: {
184
186
  showBrandIcon?: boolean;
185
187
  };
188
+ accordion?: {
189
+ showRadio?: boolean;
190
+ };
186
191
  };
187
192
  notRedirectAfterComplete?: boolean;
188
193
  merchantAppointParam?: IMerchantAppointParam;
@@ -238,6 +243,23 @@ export interface PaymentSubmitData {
238
243
  paymentMethodId?: string;
239
244
  };
240
245
  }
246
+ export interface ShippingInfo {
247
+ shippingName: {
248
+ firstName: string;
249
+ lastName: string;
250
+ middleName?: string;
251
+ fullName?: string;
252
+ };
253
+ shippingPhoneNo: string;
254
+ shippingAddress: {
255
+ region: string;
256
+ address1: string;
257
+ address2: string;
258
+ city?: string;
259
+ state?: string;
260
+ zipCode: string;
261
+ };
262
+ }
241
263
  export interface AddressSubmitData {
242
264
  shippingName: {
243
265
  firstName: string;
@@ -261,6 +283,10 @@ export interface AddressSubmitData {
261
283
  shippingId: string;
262
284
  actionFlag?: 'I' | 'U' | 'D';
263
285
  }
286
+ export interface SubmitFuncParams {
287
+ handleActions?: boolean;
288
+ shippingInfo?: ShippingInfo;
289
+ }
264
290
  export interface SubmitServiceParams extends PaymentSubmitData {
265
291
  accountInfo: AuthSubmitData['accountInfo'];
266
292
  shipping?: AddressSubmitData;
@@ -413,6 +439,14 @@ export interface IToastOptions {
413
439
  icon?: 'SUCCESS' | 'FAIL';
414
440
  spin?: boolean;
415
441
  }
442
+ interface IPaymentSession {
443
+ nextAction: INextAction;
444
+ }
445
+ interface INextAction {
446
+ normalUrl: string;
447
+ applinkUrl?: string;
448
+ schemeUrl?: string;
449
+ }
416
450
  export interface ICommonApiResponse {
417
451
  error?: {
418
452
  code: string;
@@ -423,8 +457,9 @@ export interface ICommonApiResponse {
423
457
  };
424
458
  }
425
459
  export interface IPaymentApiResponse extends ICommonApiResponse {
426
- status: keyof typeof PaymentStatus;
460
+ status: keyof typeof PaymentStatus | '';
427
461
  userCanceled3D?: boolean;
462
+ session?: IPaymentSession;
428
463
  }
429
464
  export declare class InvalidElementConfigError extends Error {
430
465
  errors: Array<{
@@ -443,4 +478,30 @@ export declare enum EXPOSURE_API_EVENT {
443
478
  VALIDATAFIELDS = "validateFields",
444
479
  UPDATEPAYMENT = "updatePayment"
445
480
  }
481
+ export declare enum EVENTNAME {
482
+ PAYMENTMETHODCHANGED = "paymentMethodChanged",
483
+ VALUESCHANGED = "valuesChanged"
484
+ }
485
+ interface PaymentMethodChangedData {
486
+ type: string;
487
+ name: string;
488
+ }
489
+ interface ValuesChangedData {
490
+ region: string;
491
+ state: string;
492
+ city: string;
493
+ address1: string;
494
+ address2: string;
495
+ zipCode: string;
496
+ phoneNo: string;
497
+ name: {
498
+ firstName: string;
499
+ lastName: string;
500
+ middleName: string;
501
+ };
502
+ }
503
+ export interface EventDataMap {
504
+ [EVENTNAME.PAYMENTMETHODCHANGED]: PaymentMethodChangedData;
505
+ [EVENTNAME.VALUESCHANGED]: ValuesChangedData;
506
+ }
446
507
  export {};
@@ -147,4 +147,11 @@ export var EXPOSURE_API_EVENT = /*#__PURE__*/function (EXPOSURE_API_EVENT) {
147
147
  EXPOSURE_API_EVENT["VALIDATAFIELDS"] = "validateFields";
148
148
  EXPOSURE_API_EVENT["UPDATEPAYMENT"] = "updatePayment";
149
149
  return EXPOSURE_API_EVENT;
150
- }({});
150
+ }({});
151
+ export var EVENTNAME = /*#__PURE__*/function (EVENTNAME) {
152
+ EVENTNAME["PAYMENTMETHODCHANGED"] = "paymentMethodChanged";
153
+ EVENTNAME["VALUESCHANGED"] = "valuesChanged";
154
+ return EVENTNAME;
155
+ }({});
156
+
157
+ // 支付方式改变的回调函数的数据结构
@@ -83,3 +83,4 @@ export declare const isElementPC: () => boolean;
83
83
  */
84
84
  export declare const isLoadErrorPage: (params: CashierSdkActionQueryResult) => boolean;
85
85
  export declare const safeStringify: (payload: any, defaultValue?: string) => string;
86
+ export declare const safeParse: (payload: any, defaultValue?: Record<string, any>) => Record<string, any>;
@@ -63,14 +63,20 @@ export function checkCanMount(_ref) {
63
63
  return {
64
64
  success: false,
65
65
  errorMsg: "Element with selector ".concat(sdkSelector, " not found."),
66
- error: ERRORMESSAGE.PARAM_INVALID
66
+ error: {
67
+ code: ERRORMESSAGE.PARAM_INVALID.code,
68
+ message: "Element with selector ".concat(sdkSelector, " not found.")
69
+ }
67
70
  };
68
71
  }
69
72
  if (status === IElementStatus.DESTROYED) {
70
73
  return {
71
74
  success: false,
72
75
  errorMsg: "Creating components in the destroyed state is forbidden.",
73
- error: ERRORMESSAGE.UI_STATE_ERROR
76
+ error: {
77
+ code: ERRORMESSAGE.UI_STATE_ERROR.code,
78
+ message: "Creating components in the destroyed state is forbidden."
79
+ }
74
80
  };
75
81
  }
76
82
  if (status === IElementStatus.READY) {
@@ -82,7 +88,10 @@ export function checkCanMount(_ref) {
82
88
  return {
83
89
  success: false,
84
90
  errorMsg: "SDK status error.",
85
- error: ERRORMESSAGE.UI_STATE_ERROR
91
+ error: {
92
+ code: ERRORMESSAGE.UI_STATE_ERROR.code,
93
+ message: "SDK status error."
94
+ }
86
95
  };
87
96
  }
88
97
  return {
@@ -526,4 +535,14 @@ export var safeStringify = function safeStringify(payload) {
526
535
  console.error('JSON.stringify failed:', e);
527
536
  return defaultValue;
528
537
  }
538
+ };
539
+ export var safeParse = function safeParse(payload) {
540
+ var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
541
+ if (!payload) return defaultValue;
542
+ try {
543
+ return JSON.parse(payload) || defaultValue;
544
+ } catch (e) {
545
+ console.error('JSON.parse failed:', e);
546
+ return defaultValue;
547
+ }
529
548
  };
@@ -1,5 +1,5 @@
1
- import { PaymentContext, SDKMetaData, Service } from '../../index';
2
1
  import { IoptionsParams } from '../../../types';
2
+ import { PaymentContext, SDKMetaData, Service } from '../../index';
3
3
  import { LogExtra, LogMetaData, LogPayload } from './types';
4
4
  /**
5
5
  * @author 谦彧 <zhangmian.zm@alipay.com>
@@ -35,6 +35,7 @@ export declare class LogService implements Service {
35
35
  log(type: string, payload: LogPayload, extra?: LogExtra, enableExtractCompliance?: boolean): LogService;
36
36
  private reportLogs;
37
37
  private loadScript;
38
+ private fallbackLoadScript;
38
39
  private initTracker;
39
40
  send(): void;
40
41
  setComponentStartTime(val: number): void;