@alipay/ams-checkout 0.0.1758783821-dev.4 → 0.0.1758783821-dev.6

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 (28) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/constant/index.d.ts +102 -88
  3. package/esm/constant/index.js +23 -6
  4. package/esm/core/component/element/elementController/index.d.ts +3 -8
  5. package/esm/core/component/element/elementController/index.js +17 -13
  6. package/esm/core/component/element/index.d.ts +3 -10
  7. package/esm/core/component/element/index.js +4 -1
  8. package/esm/core/component/element/type.d.ts +22 -4
  9. package/esm/core/component/element/type.js +16 -0
  10. package/esm/core/component/element/util.d.ts +1 -1
  11. package/esm/plugin/component/index.js +2 -2
  12. package/esm/types/index.d.ts +2 -2
  13. package/esm/types/index.js +1 -1
  14. package/package.json +1 -1
  15. package/esm/core/component/oldElement/components/address.d.ts +0 -19
  16. package/esm/core/component/oldElement/components/address.js +0 -68
  17. package/esm/core/component/oldElement/components/auth.d.ts +0 -17
  18. package/esm/core/component/oldElement/components/auth.js +0 -60
  19. package/esm/core/component/oldElement/components/payment.d.ts +0 -19
  20. package/esm/core/component/oldElement/components/payment.js +0 -74
  21. package/esm/core/component/oldElement/index.d.ts +0 -59
  22. package/esm/core/component/oldElement/index.js +0 -956
  23. package/esm/core/component/oldElement/mock.d.ts +0 -6
  24. package/esm/core/component/oldElement/mock.js +0 -567
  25. package/esm/core/component/oldElement/type.d.ts +0 -354
  26. package/esm/core/component/oldElement/type.js +0 -81
  27. package/esm/core/component/oldElement/utils.d.ts +0 -13
  28. package/esm/core/component/oldElement/utils.js +0 -6
@@ -6,117 +6,117 @@
6
6
  */
7
7
  import { eventCodeEnum } from '../types';
8
8
  export declare const ERRORMESSAGE: {
9
- readonly DOMAIN_NOT_IN_WHITE_LIST: {
10
- readonly code: eventCodeEnum.SDK_INTERNAL_ERROR;
11
- readonly message: "Origin of the message is not in the white list";
12
- };
13
- readonly NOT_JSON_FORMAT: {
14
- readonly code: eventCodeEnum.SDK_INTERNAL_ERROR;
15
- readonly message: "The message string should conform to the json format";
16
- };
17
- readonly SDK_COMPATIBILITY_ISSUES: {
18
- readonly code: eventCodeEnum.SDK_INTERNAL_ERROR;
19
- readonly BROWSER_NOT_SUPPORT_POSTMESSAGE: {
20
- readonly code: eventCodeEnum.SDK_INTERNAL_ERROR;
21
- readonly message: "The browser does not support the postmessage communication mode";
9
+ DOMAIN_NOT_IN_WHITE_LIST: {
10
+ code: eventCodeEnum;
11
+ message: string;
12
+ };
13
+ NOT_JSON_FORMAT: {
14
+ code: eventCodeEnum;
15
+ message: string;
16
+ };
17
+ SDK_COMPATIBILITY_ISSUES: {
18
+ code: eventCodeEnum;
19
+ BROWSER_NOT_SUPPORT_POSTMESSAGE: {
20
+ code: eventCodeEnum;
21
+ message: string;
22
22
  };
23
- readonly FAILED_TO_CREATE_IFRAME: {
24
- readonly code: eventCodeEnum.SDK_INTERNAL_ERROR;
25
- readonly message: "Failed to create iframe";
23
+ FAILED_TO_CREATE_IFRAME: {
24
+ code: eventCodeEnum;
25
+ message: string;
26
26
  };
27
27
  };
28
- readonly INIT_PARAMETER_ERROR: {
29
- readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
30
- readonly UI_MODE_NOT_SUPPORTED: {
31
- readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
32
- readonly message: "This UI mode is not supported";
28
+ INIT_PARAMETER_ERROR: {
29
+ code: eventCodeEnum;
30
+ UI_MODE_NOT_SUPPORTED: {
31
+ code: eventCodeEnum;
32
+ message: string;
33
33
  };
34
- readonly ENVIRONMENT_ERROR: {
35
- readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
36
- readonly message: "The current input environment does not support or is not in the standard enumeration";
34
+ ENVIRONMENT_ERROR: {
35
+ code: eventCodeEnum;
36
+ message: string;
37
37
  };
38
- readonly MODE_ERROR: {
39
- readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
40
- readonly message: "mode value not in enum";
38
+ MODE_ERROR: {
39
+ code: eventCodeEnum;
40
+ message: string;
41
41
  };
42
- readonly LOCALE_ERROR: {
43
- readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
44
- readonly message: "The current input language does not support or is not in the standard enumeration";
42
+ LOCALE_ERROR: {
43
+ code: eventCodeEnum;
44
+ message: string;
45
45
  };
46
- readonly NET_MODE_NOT_SUPPORT: {
47
- readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
48
- readonly message: "The network mode is not supported";
46
+ NET_MODE_NOT_SUPPORT: {
47
+ code: eventCodeEnum;
48
+ message: string;
49
49
  };
50
- readonly EVENT_ERROR: {
51
- readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
52
- readonly message: "Parameter type should be function";
50
+ EVENT_ERROR: {
51
+ code: eventCodeEnum;
52
+ message: string;
53
53
  };
54
54
  };
55
- readonly CREATEPAYMENT_PARAMETER_ERROR: {
56
- readonly code: eventCodeEnum.SDK_CREATEPAYMENT_PARAMETER_ERROR;
55
+ CREATEPAYMENT_PARAMETER_ERROR: {
56
+ code: eventCodeEnum;
57
57
  };
58
- readonly CREATECOMPONENT_ERROR: {
59
- readonly code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR;
60
- readonly message: "Failed to create component";
61
- readonly SINGLETON_COMPONENT_ERROR: {
62
- readonly code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR;
63
- readonly message: "Only one component can be rendered simultaneously";
58
+ CREATECOMPONENT_ERROR: {
59
+ code: eventCodeEnum;
60
+ message: string;
61
+ SINGLETON_COMPONENT_ERROR: {
62
+ code: eventCodeEnum;
63
+ message: string;
64
64
  };
65
- readonly LOAD_APP_TIMEOUT: {
66
- readonly code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR;
67
- readonly message: "Load resource timeout";
65
+ LOAD_APP_TIMEOUT: {
66
+ code: eventCodeEnum;
67
+ message: string;
68
68
  };
69
- readonly NETWORK_REQUEST_ERROR: {
70
- readonly code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR;
71
- readonly message: "Network request error";
69
+ NETWORK_REQUEST_ERROR: {
70
+ code: eventCodeEnum;
71
+ message: string;
72
72
  };
73
73
  };
74
- readonly SDK_LAUNCH_PAYMENT_APP_ERROR: {
75
- readonly code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR;
76
- readonly CALL_APP_URL_ERROR: {
77
- readonly code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR;
78
- readonly message: "Failed to launch app";
74
+ SDK_LAUNCH_PAYMENT_APP_ERROR: {
75
+ code: eventCodeEnum;
76
+ CALL_APP_URL_ERROR: {
77
+ code: eventCodeEnum;
78
+ message: string;
79
79
  };
80
80
  };
81
- readonly SDK_SUBMIT_ERROR: {
82
- readonly code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR;
83
- readonly message: "Component not created or current browser compatibility issue, not supported";
81
+ SDK_SUBMIT_ERROR: {
82
+ code: eventCodeEnum;
83
+ message: string;
84
84
  };
85
- readonly PARAM_INVALID: {
86
- readonly code: "PARAM_INVALID";
87
- readonly message: "The request is abnormal and the transaction cannot be initiated.";
85
+ PARAM_INVALID: {
86
+ code: string;
87
+ message: string;
88
88
  };
89
- readonly UI_STATE_ERROR: {
90
- readonly code: "UI_STATE_ERROR";
91
- readonly message: "The request is abnormal and the transaction cannot be initiated.";
89
+ UI_STATE_ERROR: {
90
+ code: string;
91
+ message: string;
92
92
  };
93
- readonly CONTAINER_NOT_LOADED: {
94
- readonly code: "CONTAINER_NOT_LOADED";
95
- readonly message: "The request is abnormal and the transaction cannot be initiated.";
93
+ CONTAINER_NOT_LOADED: {
94
+ code: string;
95
+ message: string;
96
96
  };
97
- readonly INITALIZE_TIMEOUT: {
98
- readonly code: "INITALIZE_TIMEOUT";
99
- readonly API: {
100
- readonly code: "INITALIZE_API_TIMEOUT";
101
- readonly message: "The request is abnormal and the transaction cannot be initiated.";
97
+ INITALIZE_TIMEOUT: {
98
+ code: string;
99
+ API: {
100
+ code: string;
101
+ message: string;
102
102
  };
103
- readonly WEB: {
104
- readonly code: "INITALIZE_WEB_TIMEOUT";
105
- readonly message: "The request is abnormal and the transaction cannot be initiated.";
103
+ WEB: {
104
+ code: string;
105
+ message: string;
106
106
  };
107
107
  };
108
- readonly ERR_DATA_STRUCT_UNRECOGNIZED: {
109
- readonly code: "ERR_DATA_STRUCT_UNRECOGNIZED";
110
- readonly status: "FAIL";
108
+ ERR_DATA_STRUCT_UNRECOGNIZED: {
109
+ code: string;
110
+ message: string;
111
111
  };
112
112
  /**
113
113
  @deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
114
114
  */
115
- readonly SDK_CALL_URL_ERROR: {
116
- readonly code: eventCodeEnum.SDK_CALL_URL_ERROR;
117
- readonly REDIRECT_ERROR: {
118
- readonly code: eventCodeEnum.SDK_CALL_URL_ERROR;
119
- readonly message: "Redirect data exception";
115
+ SDK_CALL_URL_ERROR: {
116
+ code: eventCodeEnum;
117
+ REDIRECT_ERROR: {
118
+ code: eventCodeEnum;
119
+ message: string;
120
120
  };
121
121
  };
122
122
  };
@@ -315,9 +315,23 @@ export declare const LOADINGIMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA
315
315
  * @description Promise回调code映射
316
316
  */
317
317
  export declare const PROMISE_CALLBACK_CODE: {
318
- SUCCESS: string;
319
- UNKNOWN_EXCEPTION: string;
320
- REPEAT_REQ_REJECT: string;
321
- PROCESS_FAIL: string;
322
- INQUIRY_PAYMENT_SESSION_FAILED: string;
318
+ SUCCESS: {
319
+ code: string;
320
+ };
321
+ UNKNOWN_EXCEPTION: {
322
+ code: string;
323
+ message: string;
324
+ };
325
+ REPEAT_REQ_REJECT: {
326
+ code: string;
327
+ message: string;
328
+ };
329
+ PROCESS_FAIL: {
330
+ code: string;
331
+ message: string;
332
+ };
333
+ INQUIRY_PAYMENT_SESSION_FAILED: {
334
+ code: string;
335
+ message: string;
336
+ };
323
337
  };
@@ -107,7 +107,7 @@ export var ERRORMESSAGE = {
107
107
  },
108
108
  ERR_DATA_STRUCT_UNRECOGNIZED: {
109
109
  code: 'ERR_DATA_STRUCT_UNRECOGNIZED',
110
- status: 'FAIL'
110
+ message: 'The request is abnormal and the transaction cannot be initiated.'
111
111
  },
112
112
  /**
113
113
  @deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
@@ -120,6 +120,9 @@ export var ERRORMESSAGE = {
120
120
  }
121
121
  }
122
122
  };
123
+
124
+ // as const satisfies Record<string, ErrorMessage>;
125
+
123
126
  export var BASEPLUGINID = 'CHECKOUT';
124
127
  export var COMPONENTPLUGINID = 'COMPONENT';
125
128
  export var EVENT = {
@@ -321,9 +324,23 @@ export var LOADINGIMG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACEB
321
324
  * @description Promise回调code映射
322
325
  */
323
326
  export var PROMISE_CALLBACK_CODE = {
324
- SUCCESS: 'SUCCESS',
325
- UNKNOWN_EXCEPTION: 'UNKNOWN_EXCEPTION',
326
- REPEAT_REQ_REJECT: 'REPEAT_REQ_REJECT',
327
- PROCESS_FAIL: 'PROCESS_FAIL',
328
- INQUIRY_PAYMENT_SESSION_FAILED: 'INQUIRY_PAYMENT_SESSION_FAILED'
327
+ SUCCESS: {
328
+ code: 'SUCCESS'
329
+ },
330
+ UNKNOWN_EXCEPTION: {
331
+ code: 'UNKNOWN_EXCEPTION',
332
+ message: 'Unknown anomaly. Please check the payment status and contact the merchant.'
333
+ },
334
+ REPEAT_REQ_REJECT: {
335
+ code: 'REPEAT_REQ_REJECT',
336
+ message: 'The order status is abnormal. Please check the payment status and contact the merchant.'
337
+ },
338
+ PROCESS_FAIL: {
339
+ code: 'PROCESS_FAIL',
340
+ message: 'The order status is abnormal. Please check the payment status and contact the merchant.'
341
+ },
342
+ INQUIRY_PAYMENT_SESSION_FAILED: {
343
+ code: 'INQUIRY_PAYMENT_SESSION_FAILED',
344
+ message: 'Unknown anomaly. Please check the payment status and contact the merchant.'
345
+ }
329
346
  };
@@ -1,4 +1,4 @@
1
- import { AddressMountOptions, IElementOptions, IMerchantResponse, LinkAuthMountOptions, PaymentMountOptions } from '../type';
1
+ import { AddressMountOptions, ICommonApiResponse, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions } from '../type';
2
2
  declare class ElementController {
3
3
  private options;
4
4
  private elementContainer;
@@ -23,7 +23,7 @@ declare class ElementController {
23
23
  private setInitTimeout;
24
24
  private initializeAndMountProcessor;
25
25
  private handleStartBizFlowError;
26
- mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string): any;
26
+ mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string): Promise<ICommonApiResponse>;
27
27
  private onValidateFunc;
28
28
  private onValidateAndSubmitPay;
29
29
  /**
@@ -33,12 +33,7 @@ declare class ElementController {
33
33
  validateFields(): Promise<{
34
34
  isValid: boolean;
35
35
  }>;
36
- submitPayment(): Promise<IMerchantResponse | {
37
- error: {
38
- readonly code: "CONTAINER_NOT_LOADED";
39
- readonly message: "The request is abnormal and the transaction cannot be initiated.";
40
- };
41
- }>;
36
+ submitPayment(): Promise<IPaymentApiResponse>;
42
37
  private changeLoading;
43
38
  private addEventListener;
44
39
  private sendRequestAndWaitWebLaunch;
@@ -38,7 +38,7 @@ import { ElementContainerService } from "../elementContainerService"; // 引入
38
38
  import { IContainerStatus } from "../elementContainerService/containerService";
39
39
  import { EventCenter as ElementEventCenter } from "../EventCenter/index";
40
40
  import { oneAccountUpdate, sdkActionUpdate } from "../mock";
41
- import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType } from "../type";
41
+ import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType, PaymentStatus } from "../type";
42
42
  import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, showToast } from "../util";
43
43
  var TIMEOUT_DURATION = 10000;
44
44
  var ElementController = /*#__PURE__*/function () {
@@ -327,7 +327,8 @@ var ElementController = /*#__PURE__*/function () {
327
327
  break;
328
328
  }
329
329
  res = {
330
- error: ERRORMESSAGE.CONTAINER_NOT_LOADED
330
+ error: ERRORMESSAGE.UI_STATE_ERROR,
331
+ status: PaymentStatus.FAIL
331
332
  };
332
333
  this.elementEventCenter.endEvent(startEventId, res);
333
334
  return _context4.abrupt("return", Promise.resolve(res));
@@ -367,8 +368,9 @@ var ElementController = /*#__PURE__*/function () {
367
368
  _context2.next = 11;
368
369
  break;
369
370
  }
371
+ // TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
370
372
  recordResult = data;
371
- resolve(data);
373
+ resolve(recordResult);
372
374
  return _context2.abrupt("return", false);
373
375
  case 11:
374
376
  return _context2.abrupt("return", true);
@@ -409,8 +411,10 @@ var ElementController = /*#__PURE__*/function () {
409
411
  case 15:
410
412
  _yield$_this3$onValid2 = _context3.sent;
411
413
  data = _yield$_this3$onValid2.data;
414
+ // TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
415
+ // TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
412
416
  recordResult = data;
413
- resolve(data);
417
+ resolve(recordResult);
414
418
  case 19:
415
419
  _context3.next = 27;
416
420
  break;
@@ -418,11 +422,10 @@ var ElementController = /*#__PURE__*/function () {
418
422
  _context3.prev = 21;
419
423
  _context3.t0 = _context3["catch"](0);
420
424
  errorResult = {
421
- error: {
422
- code: ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED.code,
425
+ error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
423
426
  context: JSON.stringify(_context3.t0)
424
- },
425
- status: ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED.status
427
+ }),
428
+ status: PaymentStatus.FAIL
426
429
  };
427
430
  _this3.serviceMap.Log.logError({
428
431
  title: ELEMENT_SPM_MAP.sdk_element_missKeyData
@@ -608,12 +611,13 @@ var ElementController = /*#__PURE__*/function () {
608
611
  traceId = _response$originActio.traceId,
609
612
  errorCode = _response$originActio.errorCode,
610
613
  errorMessage = _response$originActio.errorMessage;
611
- var error = {
612
- code: ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED.code
613
- };
614
+ var error = _objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED);
614
615
  if (PROMISE_CALLBACK_CODE[errorCode]) {
615
- error.code = PROMISE_CALLBACK_CODE[errorCode];
616
- error.message = errorMessage;
616
+ var _PROMISE_CALLBACK_COD;
617
+ error = {
618
+ code: PROMISE_CALLBACK_CODE[errorCode].code,
619
+ message: ((_PROMISE_CALLBACK_COD = PROMISE_CALLBACK_CODE[errorCode]) === null || _PROMISE_CALLBACK_COD === void 0 ? void 0 : _PROMISE_CALLBACK_COD.message) || errorMessage
620
+ };
617
621
  } else {
618
622
  this.serviceMap.Log.logError({
619
623
  title: ELEMENT_SPM_MAP.sdk_element_missKeyData
@@ -1,20 +1,13 @@
1
- import { AddressMountOptions, AddressMountResult, IElementOptions, LinkAuthMountOptions, LinkAuthMountResult, PaymentMountOptions, PaymentMountResult } from './type';
1
+ import { IElementOptions, PaymentMountOptions } from './type';
2
2
  export declare class ElementComponent {
3
3
  private options;
4
4
  private controller;
5
5
  constructor(options: IElementOptions);
6
6
  updatePayment(paymentSessionData: any): Promise<unknown>;
7
- mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
8
- mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
9
- mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
7
+ mount(renderOptions: PaymentMountOptions, sdkSelector: string): Promise<import("./type").ICommonApiResponse>;
10
8
  validateFields(): Promise<{
11
9
  isValid: boolean;
12
10
  }>;
13
- submitPayment(): Promise<import("./type").IMerchantResponse | {
14
- error: {
15
- readonly code: "CONTAINER_NOT_LOADED";
16
- readonly message: "The request is abnormal and the transaction cannot be initiated.";
17
- };
18
- }>;
11
+ submitPayment(): Promise<import("./type").IPaymentApiResponse>;
19
12
  destroy(): void;
20
13
  }
@@ -43,7 +43,10 @@ export var ElementComponent = /*#__PURE__*/function () {
43
43
  return _updatePayment.apply(this, arguments);
44
44
  }
45
45
  return updatePayment;
46
- }()
46
+ }() // 暂不透出 link 和 address element
47
+ // mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
48
+ // mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
49
+ // mount(renderOptions: PaymentMountOptions, sdkSelector: string);
47
50
  }, {
48
51
  key: "mount",
49
52
  value: function mount(renderOptions, sdkSelector) {
@@ -36,6 +36,20 @@ export declare enum ElementType {
36
36
  address = "address",
37
37
  payment = "payment"
38
38
  }
39
+ /**
40
+ * TODO 替换外外网链接
41
+ * 支付状态参考: https://yuque.antfin.com/antom_ka_team/yg9y7x/fe8xxqgbivnx5fd2#rGgE
42
+ */
43
+ export declare enum PaymentStatus {
44
+ SUCCESS = "SUCCESS",
45
+ PROCESSING = "PROCESSING",
46
+ CANCELLED = "CANCELLED",
47
+ PENDING = "PENDING",
48
+ S = "SUCCESS",
49
+ F = "FAIL",
50
+ U = "PROCESSING",
51
+ FAIL = "FAIL"
52
+ }
39
53
  export declare const MountElementType: {
40
54
  auth: ElementPaymentMethod;
41
55
  address: ElementPaymentMethod;
@@ -194,6 +208,8 @@ export interface ValidateResult<T = {}> {
194
208
  success: boolean;
195
209
  data: {
196
210
  success: boolean;
211
+ status: PaymentStatus;
212
+ message?: string;
197
213
  data: T;
198
214
  };
199
215
  }
@@ -393,15 +409,17 @@ export interface IToastOptions {
393
409
  icon?: 'SUCCESS' | 'FAIL';
394
410
  spin?: boolean;
395
411
  }
396
- export interface IMerchantResponse {
397
- success?: boolean;
412
+ export interface ICommonApiResponse {
398
413
  error?: {
399
414
  code: string;
400
- message?: string;
415
+ message: string;
401
416
  traceId?: string;
402
417
  context?: any;
403
418
  };
404
- status?: string;
419
+ }
420
+ export interface IPaymentApiResponse extends ICommonApiResponse {
421
+ status: keyof typeof PaymentStatus;
422
+ userCanceled3D?: boolean;
405
423
  }
406
424
  export declare class InvalidElementConfigError extends Error {
407
425
  errors: Array<{
@@ -49,6 +49,22 @@ export var ElementType = /*#__PURE__*/function (ElementType) {
49
49
  ElementType["payment"] = "payment";
50
50
  return ElementType;
51
51
  }({});
52
+
53
+ /**
54
+ * TODO 替换外外网链接
55
+ * 支付状态参考: https://yuque.antfin.com/antom_ka_team/yg9y7x/fe8xxqgbivnx5fd2#rGgE
56
+ */
57
+ export var PaymentStatus = /*#__PURE__*/function (PaymentStatus) {
58
+ PaymentStatus["SUCCESS"] = "SUCCESS";
59
+ PaymentStatus["PROCESSING"] = "PROCESSING";
60
+ PaymentStatus["CANCELLED"] = "CANCELLED";
61
+ PaymentStatus["PENDING"] = "PENDING";
62
+ PaymentStatus["S"] = "SUCCESS";
63
+ PaymentStatus["F"] = "FAIL";
64
+ PaymentStatus["U"] = "PROCESSING";
65
+ PaymentStatus["FAIL"] = "FAIL";
66
+ return PaymentStatus;
67
+ }({});
52
68
  export var MountElementType = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ElementType.auth, ElementPaymentMethod.AUTH_ELEMENT), ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT), ElementType.payment, ElementPaymentMethod.PAYMENT_ELEMENT), ElementPaymentMethod.AUTH_ELEMENT, ElementType.auth), ElementPaymentMethod.ADDRESS_ELEMENT, ElementType.address), ElementPaymentMethod.PAYMENT_ELEMENT, ElementType.payment);
53
69
  export var ThemeType = /*#__PURE__*/function (ThemeType) {
54
70
  ThemeType["NostalgicGray"] = "nostalgicGray";
@@ -39,7 +39,7 @@ export declare function checkCanMount({ sdkSelector, containerService, status, }
39
39
  errorMsg?: string;
40
40
  error?: {
41
41
  code: string;
42
- message?: string;
42
+ message: string;
43
43
  };
44
44
  };
45
45
  export declare function checkCanUpdate({ status, paymentContainerService, newPaymentSessionData, oldPaymentSessionData, }: {
@@ -17,13 +17,13 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
17
  * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
18
18
  */
19
19
  /* eslint-disable @typescript-eslint/no-explicit-any */
20
+ import { ElementPaymentMethod } from "../../core/component/element/type";
20
21
  import { v4 as uuid } from 'uuid';
21
22
  import { sdkVersion } from "../../config";
22
23
  import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID, POPUP_LOADTIME_LOG_LIMIT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../constant";
23
- import { ElementPaymentMethod } from "../../core/component/oldElement/type";
24
24
  import { queryPaymentInfo, submitPayInfo } from "../../service";
25
25
  import { ComponentSignEnum, DisplayTypeEnum, eventCodeEnum, MessageName, PlatformEnum, ProductSceneEnum, RedirectType, TargetEnum } from "../../types";
26
- import { getType, isJsonString, isPC, device } from "../../util";
26
+ import { device, getType, isJsonString, isPC } from "../../util";
27
27
  import { getBackScheme } from "../../util/getBackScheme";
28
28
  import { isLocalMock } from "../../util/mock";
29
29
  import { matchVersion } from "../../util/versionCompare";
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { IApplePayContactField } from '../plugin/applepay/interface';
9
9
  export type onChange = () => onCnageResult;
10
- export { ElementType, PaymentElementLayout, ThemeType, type IElementOptions, } from '../core/component/oldElement/type';
10
+ export { type IElementOptions, ElementType, PaymentElementLayout, ThemeType } from '../core/component/element/type';
11
11
  interface onCnageResult {
12
12
  complete: boolean;
13
13
  addressValue: AddressItem[];
@@ -838,6 +838,6 @@ export declare enum EventLoggingEventId {
838
838
  }
839
839
  export interface ErrorMessage {
840
840
  code: string;
841
- message?: string;
841
+ message: string;
842
842
  [key: string]: ErrorMessage | string;
843
843
  }
@@ -8,7 +8,7 @@
8
8
 
9
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
10
10
 
11
- export { ElementType, PaymentElementLayout, ThemeType } from "../core/component/oldElement/type";
11
+ export { ElementType, PaymentElementLayout, ThemeType } from "../core/component/element/type";
12
12
 
13
13
  /**
14
14
  * SDK options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1758783821-dev.4",
3
+ "version": "0.0.1758783821-dev.6",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",
@@ -1,19 +0,0 @@
1
- import { AddressMountComponentsParams } from '../type';
2
- interface ElementAddressMountOptions extends Omit<AddressMountComponentsParams, 'type'> {
3
- selector: string;
4
- }
5
- export declare class ElementAddressComponent {
6
- private sdk;
7
- private elementContainer;
8
- private isConnect;
9
- constructor();
10
- create(options: {
11
- environment: string;
12
- locale: string;
13
- appVersion: string;
14
- }, isConnect: boolean): void;
15
- mount(options: ElementAddressMountOptions): Promise<HTMLIFrameElement | undefined>;
16
- update(): void;
17
- unmount(): void;
18
- }
19
- export {};
@@ -1,68 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
- 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; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
- 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); }
8
- import { AddressComponent } from "../../address";
9
- export var ElementAddressComponent = /*#__PURE__*/function () {
10
- function ElementAddressComponent() {
11
- _classCallCheck(this, ElementAddressComponent);
12
- _defineProperty(this, "sdk", void 0);
13
- _defineProperty(this, "elementContainer", void 0);
14
- _defineProperty(this, "isConnect", void 0);
15
- }
16
- _createClass(ElementAddressComponent, [{
17
- key: "create",
18
- value: function create(options, isConnect) {
19
- this.isConnect = isConnect;
20
- this.sdk = new AddressComponent(options);
21
- }
22
- }, {
23
- key: "mount",
24
- value: function mount(options) {
25
- var _this = this;
26
- var elementContainer = document.querySelector(options.selector);
27
- if (this.isConnect) {
28
- elementContainer.style.display = 'none';
29
- }
30
- return new Promise(function (resolve) {
31
- _this.sdk.mountComponent({
32
- sessionData: options.sessionData,
33
- elementProps: options.elementProps,
34
- configParams: options.configParams,
35
- appearance: options.appearance,
36
- prefillValue: options.prefillValue,
37
- appendAliasContainerId: true
38
- }, options.selector).then(function () {
39
- var _elementContainer$get;
40
- _this.elementContainer = elementContainer;
41
- var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
42
- resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
43
- }, function () {
44
- resolve(undefined);
45
- });
46
- });
47
- }
48
- }, {
49
- key: "update",
50
- value: function update() {
51
- if (this.elementContainer && this.isConnect) {
52
- this.elementContainer.style.display = '';
53
- }
54
- // 下发数据
55
- }
56
- }, {
57
- key: "unmount",
58
- value: function unmount() {
59
- var _this$elementContaine, _this$elementContaine2;
60
- var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
61
- if (containers !== null && containers !== void 0 && containers[0]) {
62
- var _containers$, _containers$$remove;
63
- (_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
64
- }
65
- }
66
- }]);
67
- return ElementAddressComponent;
68
- }();