@alipay/ams-checkout 0.0.1757298389-dev.11 → 0.0.1757298389-dev.13

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.
@@ -6,124 +6,125 @@
6
6
  */
7
7
  import { eventCodeEnum } from '../types';
8
8
  export declare const ERRORMESSAGE: {
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;
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";
22
22
  };
23
- FAILED_TO_CREATE_IFRAME: {
24
- code: eventCodeEnum;
25
- message: string;
23
+ readonly FAILED_TO_CREATE_IFRAME: {
24
+ readonly code: eventCodeEnum.SDK_INTERNAL_ERROR;
25
+ readonly message: "Failed to create iframe";
26
26
  };
27
27
  };
28
- INIT_PARAMETER_ERROR: {
29
- code: eventCodeEnum;
30
- UI_MODE_NOT_SUPPORTED: {
31
- code: eventCodeEnum;
32
- message: string;
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";
33
33
  };
34
- ENVIRONMENT_ERROR: {
35
- code: eventCodeEnum;
36
- message: string;
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";
37
37
  };
38
- MODE_ERROR: {
39
- code: eventCodeEnum;
40
- message: string;
38
+ readonly MODE_ERROR: {
39
+ readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
40
+ readonly message: "mode value not in enum";
41
41
  };
42
- LOCALE_ERROR: {
43
- code: eventCodeEnum;
44
- message: string;
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";
45
45
  };
46
- NET_MODE_NOT_SUPPORT: {
47
- code: eventCodeEnum;
48
- message: string;
46
+ readonly NET_MODE_NOT_SUPPORT: {
47
+ readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
48
+ readonly message: "The network mode is not supported";
49
49
  };
50
- EVENT_ERROR: {
51
- code: eventCodeEnum;
52
- message: string;
50
+ readonly EVENT_ERROR: {
51
+ readonly code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR;
52
+ readonly message: "Parameter type should be function";
53
53
  };
54
54
  };
55
- CREATEPAYMENT_PARAMETER_ERROR: {
56
- code: eventCodeEnum;
55
+ readonly CREATEPAYMENT_PARAMETER_ERROR: {
56
+ readonly code: eventCodeEnum.SDK_CREATEPAYMENT_PARAMETER_ERROR;
57
57
  };
58
- CREATECOMPONENT_ERROR: {
59
- code: eventCodeEnum;
60
- message: string;
61
- SINGLETON_COMPONENT_ERROR: {
62
- code: eventCodeEnum;
63
- message: string;
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";
64
64
  };
65
- LOAD_APP_TIMEOUT: {
66
- code: eventCodeEnum;
67
- message: string;
65
+ readonly LOAD_APP_TIMEOUT: {
66
+ readonly code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR;
67
+ readonly message: "Load resource timeout";
68
68
  };
69
- NETWORK_REQUEST_ERROR: {
70
- code: eventCodeEnum;
71
- message: string;
69
+ readonly NETWORK_REQUEST_ERROR: {
70
+ readonly code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR;
71
+ readonly message: "Network request error";
72
72
  };
73
73
  };
74
- SDK_LAUNCH_PAYMENT_APP_ERROR: {
75
- code: eventCodeEnum;
76
- CALL_APP_URL_ERROR: {
77
- code: eventCodeEnum;
78
- message: string;
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";
79
79
  };
80
80
  };
81
- SDK_SUBMIT_ERROR: {
82
- code: eventCodeEnum;
83
- message: string;
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";
84
84
  };
85
- PARAM_INVALID: {
86
- code: string;
87
- message: string;
85
+ readonly PARAM_INVALID: {
86
+ readonly code: "PARAM_INVALID";
87
+ readonly message: "The request is abnormal and the transaction cannot be initiated.";
88
88
  };
89
- UI_STATE_ERROR: {
90
- code: string;
91
- message: string;
89
+ readonly UI_STATE_ERROR: {
90
+ readonly code: "UI_STATE_ERROR";
91
+ readonly message: "The request is abnormal and the transaction cannot be initiated.";
92
92
  };
93
- CONTAINER_NOT_LOADED: {
94
- code: string;
95
- message: string;
93
+ readonly CONTAINER_NOT_LOADED: {
94
+ readonly code: "CONTAINER_NOT_LOADED";
95
+ readonly message: "The request is abnormal and the transaction cannot be initiated.";
96
96
  };
97
- INITALIZE_TIMEOUT: {
98
- API: {
99
- code: string;
100
- message: string;
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.";
101
102
  };
102
- WEB: {
103
- code: string;
104
- message: string;
103
+ readonly WEB: {
104
+ readonly code: "INITALIZE_WEB_TIMEOUT";
105
+ readonly message: "The request is abnormal and the transaction cannot be initiated.";
105
106
  };
106
107
  };
107
- ERR_DATA_STRUCT_UNRECOGNIZED: {
108
- code: string;
109
- status: string;
108
+ readonly ERR_DATA_STRUCT_UNRECOGNIZED: {
109
+ readonly code: "ERR_DATA_STRUCT_UNRECOGNIZED";
110
+ readonly status: "FAIL";
110
111
  };
111
- INQUIRY_PAYMENT_SESSION_FAILED: {
112
- code: string;
113
- message: string;
112
+ readonly INQUIRY_PAYMENT_SESSION_FAILED: {
113
+ readonly code: "INQUIRY_PAYMENT_SESSION_FAILED";
114
+ readonly message: "The order status is abnormal. Please check the payment status and contact the merchant.";
114
115
  };
115
- UNKNOWN_EXCEPTION: {
116
- code: string;
117
- message: string;
116
+ readonly UNKNOWN_EXCEPTION: {
117
+ readonly code: "UNKNOWN_EXCEPTION";
118
+ readonly message: "Unknown exception. Please check the payment status and contact the merchant";
118
119
  };
119
120
  /**
120
121
  @deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
121
122
  */
122
- SDK_CALL_URL_ERROR: {
123
- code: eventCodeEnum;
124
- REDIRECT_ERROR: {
125
- code: eventCodeEnum;
126
- message: string;
123
+ readonly SDK_CALL_URL_ERROR: {
124
+ readonly code: eventCodeEnum.SDK_CALL_URL_ERROR;
125
+ readonly REDIRECT_ERROR: {
126
+ readonly code: eventCodeEnum.SDK_CALL_URL_ERROR;
127
+ readonly message: "Redirect data exception";
127
128
  };
128
129
  };
129
130
  };
@@ -84,24 +84,25 @@ export var ERRORMESSAGE = {
84
84
  },
85
85
  PARAM_INVALID: {
86
86
  code: 'PARAM_INVALID',
87
- message: '请求异常,交易无法发起。'
87
+ message: 'The request is abnormal and the transaction cannot be initiated.'
88
88
  },
89
89
  UI_STATE_ERROR: {
90
90
  code: 'UI_STATE_ERROR',
91
- message: '请求异常,交易无法发起。'
91
+ message: 'The request is abnormal and the transaction cannot be initiated.'
92
92
  },
93
93
  CONTAINER_NOT_LOADED: {
94
94
  code: 'CONTAINER_NOT_LOADED',
95
- message: '请求异常,交易无法发起。'
95
+ message: 'The request is abnormal and the transaction cannot be initiated.'
96
96
  },
97
97
  INITALIZE_TIMEOUT: {
98
+ code: 'INITALIZE_TIMEOUT',
98
99
  API: {
99
100
  code: 'INITALIZE_API_TIMEOUT',
100
- message: '请求异常,交易无法发起。'
101
+ message: 'The request is abnormal and the transaction cannot be initiated.'
101
102
  },
102
103
  WEB: {
103
104
  code: 'INITALIZE_WEB_TIMEOUT',
104
- message: '请求异常,交易无法发起。'
105
+ message: 'The request is abnormal and the transaction cannot be initiated.'
105
106
  }
106
107
  },
107
108
  ERR_DATA_STRUCT_UNRECOGNIZED: {
@@ -110,11 +111,11 @@ export var ERRORMESSAGE = {
110
111
  },
111
112
  INQUIRY_PAYMENT_SESSION_FAILED: {
112
113
  code: 'INQUIRY_PAYMENT_SESSION_FAILED',
113
- message: '订单状态异常。请检查付款情况并联系商户'
114
+ message: 'The order status is abnormal. Please check the payment status and contact the merchant.'
114
115
  },
115
116
  UNKNOWN_EXCEPTION: {
116
117
  code: 'UNKNOWN_EXCEPTION',
117
- message: '未知异常。请检查付款情况并联系商户'
118
+ message: 'Unknown exception. Please check the payment status and contact the merchant'
118
119
  },
119
120
  /**
120
121
  @deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
@@ -35,8 +35,8 @@ declare class ElementController {
35
35
  }>;
36
36
  submitPayment(): Promise<IMerchantResponse | {
37
37
  error: {
38
- code: string;
39
- message: string;
38
+ readonly code: "CONTAINER_NOT_LOADED";
39
+ readonly message: "The request is abnormal and the transaction cannot be initiated.";
40
40
  };
41
41
  }>;
42
42
  private changeLoading;
@@ -561,25 +561,21 @@ var ElementController = /*#__PURE__*/function () {
561
561
  obtainDataResult = _yield$Promise$all2[1];
562
562
  containerService === null || containerService === void 0 || containerService.switchContainerStatus(IContainerStatus.READY);
563
563
  error = this.getErrorFromResponse(obtainDataResult);
564
- if (!error) {
565
- _context5.next = 19;
566
- break;
564
+ if (error) {
565
+ // 仅结束resove,传出回调码
566
+ readyCallback({
567
+ error: error
568
+ });
567
569
  }
568
- this.handleInitializationError();
569
- readyCallback({
570
- error: error
571
- });
572
- return _context5.abrupt("return");
573
- case 19:
574
570
  if (this.areAllContainersReady()) {
575
571
  this.elementContainerService.getContainerServices().forEach(function (_, key) {
576
572
  _this5.sendReady(key, options);
577
573
  });
578
574
  }
579
- _context5.next = 26;
575
+ _context5.next = 23;
580
576
  break;
581
- case 22:
582
- _context5.prev = 22;
577
+ case 19:
578
+ _context5.prev = 19;
583
579
  _context5.t0 = _context5["catch"](1);
584
580
  this.handleInitializationError();
585
581
  readyCallback({
@@ -587,11 +583,11 @@ var ElementController = /*#__PURE__*/function () {
587
583
  traceId: _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.traceId
588
584
  })
589
585
  });
590
- case 26:
586
+ case 23:
591
587
  case "end":
592
588
  return _context5.stop();
593
589
  }
594
- }, _callee5, this, [[1, 22]]);
590
+ }, _callee5, this, [[1, 19]]);
595
591
  }));
596
592
  function sendRequestAndWaitWebLaunch(_x4, _x5) {
597
593
  return _sendRequestAndWaitWebLaunch.apply(this, arguments);
@@ -602,14 +598,17 @@ var ElementController = /*#__PURE__*/function () {
602
598
  key: "getErrorFromResponse",
603
599
  value: function getErrorFromResponse(response) {
604
600
  if (isLoadErrorPage(response === null || response === void 0 ? void 0 : response.originActionQueryResult)) {
601
+ var _baseError;
605
602
  var _response$originActio = response.originActionQueryResult,
606
603
  traceId = _response$originActio.traceId,
607
- errorCode = _response$originActio.errorCode;
604
+ errorCode = _response$originActio.errorCode,
605
+ errorMessage = _response$originActio.errorMessage;
608
606
  var baseError = ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED;
609
607
  if ([ERRORMESSAGE.INQUIRY_PAYMENT_SESSION_FAILED.code, ERRORMESSAGE.UNKNOWN_EXCEPTION.code].includes(errorCode)) {
610
608
  baseError = ERRORMESSAGE[errorCode];
611
609
  }
612
610
  return _objectSpread(_objectSpread({}, baseError), {}, {
611
+ message: errorMessage || ((_baseError = baseError) === null || _baseError === void 0 ? void 0 : _baseError.message),
613
612
  traceId: traceId !== null && traceId !== void 0 ? traceId : ''
614
613
  });
615
614
  }
@@ -12,8 +12,8 @@ export declare class ElementComponent {
12
12
  }>;
13
13
  submitPayment(): Promise<import("./type").IMerchantResponse | {
14
14
  error: {
15
- code: string;
16
- message: string;
15
+ readonly code: "CONTAINER_NOT_LOADED";
16
+ readonly message: "The request is abnormal and the transaction cannot be initiated.";
17
17
  };
18
18
  }>;
19
19
  destroy(): void;
@@ -8,14 +8,14 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
8
8
  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; }
9
9
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
10
  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); }
11
+ import { MODE } from "../../constant/easysafepay";
11
12
  import { BusManager, BusMessage } from "../../core/bus";
12
13
  import { SecuritySDKActionEnum } from "../../core/bus/interface";
14
+ import { getDoubleFaUrlFromSession } from "../../foundation/utils/web_app_url_utils";
13
15
  import { getApplePayPaymentSession, submitPayInfo } from "../../service";
14
16
  import { EnvironmentEnum } from "../../types";
15
17
  import { device, isEmpty } from "../../util";
16
18
  import { APPLE_PAY_RECURRING_VERSION, APPLE_PAY_VERSION } from "../applepay/interface";
17
- import { getDoubleFaUrlFromSession } from "../../foundation/utils/web_app_url_utils";
18
- import { MODE } from "../../constant/easysafepay";
19
19
  var APPLEPAYERRORENUM = /*#__PURE__*/function (APPLEPAYERRORENUM) {
20
20
  APPLEPAYERRORENUM["APPLE_PAY_MISSING_DATA"] = "APPLE_PAY_MISSING_DATA";
21
21
  APPLEPAYERRORENUM["APPLE_PAY_NOT_SUPPORTED"] = "APPLE_PAY_NOT_SUPPORTED";
@@ -112,6 +112,9 @@ export var handleGooglePay = function handleGooglePay(data) {
112
112
  reject(err);
113
113
  });
114
114
  };
115
+ script.onerror = function (err) {
116
+ reject(err);
117
+ };
115
118
  });
116
119
  };
117
120
  export var ApplePaySdk = /*#__PURE__*/function () {
@@ -836,3 +836,8 @@ export declare enum EventLoggingEventId {
836
836
  LeaveAnyWay = "LeaveAnyWay",
837
837
  ContinuePaying = "ContinuePaying"
838
838
  }
839
+ export interface ErrorMessage {
840
+ code: string;
841
+ message?: string;
842
+ [key: string]: ErrorMessage | string;
843
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1757298389-dev.11",
3
+ "version": "0.0.1757298389-dev.13",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",