@alipay/ams-checkout 1.44.0 → 1.46.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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/popupWindow.style.d.ts +19 -9
- package/esm/component/popupWindow.style.js +26 -13
- package/esm/config/index.d.ts +8 -7
- package/esm/config/index.js +8 -7
- package/esm/config/request.js +14 -2
- package/esm/constant/index.d.ts +58 -0
- package/esm/constant/index.js +64 -1
- package/esm/core/component/element/EventCenter/index.d.ts +31 -0
- package/esm/core/component/element/EventCenter/index.js +178 -0
- package/esm/core/component/element/elementContainerService/containerService.d.ts +1 -0
- package/esm/core/component/element/elementContainerService/containerService.js +8 -2
- package/esm/core/component/element/elementController/index.d.ts +24 -3
- package/esm/core/component/element/elementController/index.js +534 -189
- package/esm/core/component/element/elementProcessor/addressProcessor.js +5 -6
- package/esm/core/component/element/elementProcessor/authProcessor.js +2 -3
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +2 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +55 -19
- package/esm/core/component/element/index.d.ts +6 -5
- package/esm/core/component/element/index.js +14 -3
- package/esm/core/component/element/mock.js +1 -0
- package/esm/core/component/element/type.d.ts +57 -4
- package/esm/core/component/element/type.js +63 -2
- package/esm/core/component/element/util.d.ts +20 -4
- package/esm/core/component/element/util.js +59 -7
- package/esm/foundation/core/index.js +37 -8
- package/esm/foundation/index.d.ts +2 -0
- package/esm/foundation/product-processor/easysafepay/index.js +8 -4
- package/esm/foundation/product-processor/element/index.js +1 -0
- package/esm/foundation/service/container/popup.d.ts +11 -0
- package/esm/foundation/service/container/popup.js +23 -2
- package/esm/foundation/service/log/keys.js +4 -0
- package/esm/foundation/service/requester/requester.js +2 -3
- package/esm/foundation/utils/payment_context_utils.js +1 -0
- package/esm/index.js +2 -1
- package/esm/plugin/component/cashierApp.d.ts +2 -0
- package/esm/plugin/component/cashierApp.js +2 -2
- package/esm/plugin/component/channel.js +20 -4
- package/esm/plugin/component/component.popup.style.d.ts +1 -0
- package/esm/plugin/component/component.popup.style.js +1 -1
- package/esm/plugin/component/index.d.ts +1 -0
- package/esm/plugin/component/index.js +9 -5
- package/esm/types/index.d.ts +22 -2
- package/esm/types/index.js +2 -1
- package/esm/util/index.js +4 -1
- package/esm/util/spm-map.d.ts +24 -2
- package/esm/util/spm-map.js +14 -1
- package/package.json +1 -1
- package/esm/core/component/oldElement/components/address.d.ts +0 -19
- package/esm/core/component/oldElement/components/address.js +0 -68
- package/esm/core/component/oldElement/components/auth.d.ts +0 -17
- package/esm/core/component/oldElement/components/auth.js +0 -60
- package/esm/core/component/oldElement/components/payment.d.ts +0 -19
- package/esm/core/component/oldElement/components/payment.js +0 -74
- package/esm/core/component/oldElement/index.d.ts +0 -59
- package/esm/core/component/oldElement/index.js +0 -956
- package/esm/core/component/oldElement/mock.d.ts +0 -6
- package/esm/core/component/oldElement/mock.js +0 -567
- package/esm/core/component/oldElement/type.d.ts +0 -354
- package/esm/core/component/oldElement/type.js +0 -81
- package/esm/core/component/oldElement/utils.d.ts +0 -13
- package/esm/core/component/oldElement/utils.js +0 -6
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
var _excluded = ["type"];
|
|
2
2
|
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); }
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
3
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -19,9 +23,11 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
19
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; }
|
|
20
24
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
21
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";
|
|
22
28
|
import { cleanMockup, removeRetentionPopup } from "../../../../component/component.popup.style";
|
|
23
29
|
import { destroyModal } from "../../../../component/popupWindow.style";
|
|
24
|
-
import { ERRORMESSAGE, EVENT } from "../../../../constant";
|
|
30
|
+
import { ERRORMESSAGE, EVENT, PROMISE_CALLBACK_CODE } from "../../../../constant";
|
|
25
31
|
import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
|
|
26
32
|
import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
|
|
27
33
|
import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
|
|
@@ -31,13 +37,13 @@ import { ElementProcessor } from "../../../../foundation/product-processor/eleme
|
|
|
31
37
|
import { ProductSceneEnum } from "../../../../types";
|
|
32
38
|
import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
|
|
33
39
|
import { IContainerStatus } from "../elementContainerService/containerService";
|
|
40
|
+
import { EventCenter as ElementEventCenter } from "../EventCenter/index";
|
|
34
41
|
import { oneAccountUpdate, sdkActionUpdate } from "../mock";
|
|
35
|
-
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, MountElementType } from "../type";
|
|
36
|
-
import { checkCanMount, checkCanUpdate, handleRedirect, showToast } from "../util";
|
|
42
|
+
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";
|
|
37
45
|
var TIMEOUT_DURATION = 10000;
|
|
38
46
|
var ElementController = /*#__PURE__*/function () {
|
|
39
|
-
// 新增变量
|
|
40
|
-
|
|
41
47
|
function ElementController(options) {
|
|
42
48
|
_classCallCheck(this, ElementController);
|
|
43
49
|
_defineProperty(this, "options", void 0);
|
|
@@ -49,10 +55,27 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
49
55
|
_defineProperty(this, "elementContainerService", void 0);
|
|
50
56
|
// 新增变量
|
|
51
57
|
_defineProperty(this, "onStatusChangeCallback", void 0);
|
|
52
|
-
|
|
58
|
+
// 新增变量
|
|
59
|
+
_defineProperty(this, "submitPayPromise", void 0);
|
|
60
|
+
_defineProperty(this, "elementEventCenter", void 0);
|
|
61
|
+
_defineProperty(this, "onValidateFunc", function (event, target) {
|
|
53
62
|
return new Promise(function (resolve) {
|
|
54
63
|
event.emitAndListen({
|
|
55
64
|
event: ElementPaymentEvent.VALIDATE,
|
|
65
|
+
data: {
|
|
66
|
+
params: {},
|
|
67
|
+
target: target,
|
|
68
|
+
source: ElementPaymentMethod.CONTAINER_ELEMENT
|
|
69
|
+
}
|
|
70
|
+
}, function (result) {
|
|
71
|
+
resolve(result);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
_defineProperty(this, "onValidateAndSubmitPay", function (event, target, params) {
|
|
76
|
+
return new Promise(function (resolve) {
|
|
77
|
+
event.emitAndListen({
|
|
78
|
+
event: ElementPaymentEvent.SUBMIT_PAY,
|
|
56
79
|
data: {
|
|
57
80
|
params: _objectSpread({}, params),
|
|
58
81
|
target: target,
|
|
@@ -74,6 +97,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
74
97
|
instanceId: this.elementContainer.getInstanceId()
|
|
75
98
|
});
|
|
76
99
|
this.setControllerStatusOrView(IElementStatus.READY);
|
|
100
|
+
this.elementEventCenter = new ElementEventCenter({
|
|
101
|
+
logger: this.elementContainer.getServiceProvider().getService('Log')
|
|
102
|
+
});
|
|
77
103
|
}
|
|
78
104
|
_createClass(ElementController, [{
|
|
79
105
|
key: "initService",
|
|
@@ -104,161 +130,388 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
104
130
|
message = _ref$message === void 0 ? '' : _ref$message,
|
|
105
131
|
_ref$result = _ref.result,
|
|
106
132
|
result = _ref$result === void 0 ? undefined : _ref$result;
|
|
133
|
+
this.serviceMap.Log.logInfo({
|
|
134
|
+
title: 'sdk_event_event_callback'
|
|
135
|
+
}, {
|
|
136
|
+
eventCode: safeStringify(code || ''),
|
|
137
|
+
eventMessage: safeStringify(message || '')
|
|
138
|
+
});
|
|
107
139
|
this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 || (_this$options$onEvent = _this$options.onEventCallback) === null || _this$options$onEvent === void 0 || _this$options$onEvent.call(_this$options, {
|
|
108
140
|
code: code,
|
|
109
141
|
message: message,
|
|
110
142
|
result: result
|
|
111
143
|
});
|
|
112
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* 处理初始化错误的方法
|
|
147
|
+
*/
|
|
113
148
|
}, {
|
|
114
|
-
key: "
|
|
115
|
-
value: function
|
|
149
|
+
key: "handleInitializationError",
|
|
150
|
+
value: function handleInitializationError() {
|
|
151
|
+
var errorCode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CALL_APP_URL_ERROR;
|
|
152
|
+
this.changeLoading(false);
|
|
153
|
+
this.setControllerStatusOrView(IElementStatus.READY);
|
|
154
|
+
this.onEventCallback(errorCode);
|
|
155
|
+
this.elementContainerService.getContainerServices().forEach(function (value) {
|
|
156
|
+
value.getContainerElement().remove();
|
|
157
|
+
});
|
|
158
|
+
this.elementContainerService.destroy();
|
|
159
|
+
} // 处理挂载检查失败
|
|
160
|
+
}, {
|
|
161
|
+
key: "handleMountError",
|
|
162
|
+
value: function handleMountError(_ref2) {
|
|
163
|
+
var result = _ref2.result,
|
|
164
|
+
resolve = _ref2.resolve;
|
|
165
|
+
var errorMsg = result.errorMsg,
|
|
166
|
+
error = result.error;
|
|
167
|
+
this.onEventCallback({
|
|
168
|
+
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
|
169
|
+
message: errorMsg
|
|
170
|
+
});
|
|
171
|
+
resolve({
|
|
172
|
+
error: error
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// 清除并设置初始化定时器
|
|
177
|
+
}, {
|
|
178
|
+
key: "clearAndSetInitTimeout",
|
|
179
|
+
value: function clearAndSetInitTimeout(resolve) {
|
|
180
|
+
clearTimeout(this.initTimeout);
|
|
181
|
+
this.initTimeout = null;
|
|
182
|
+
this.initTimeout = this.setInitTimeout(resolve);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 设置初始化超时定时器
|
|
186
|
+
}, {
|
|
187
|
+
key: "setInitTimeout",
|
|
188
|
+
value: function setInitTimeout(resolve) {
|
|
116
189
|
var _this = this;
|
|
117
|
-
return
|
|
118
|
-
var _checkCanMount = checkCanMount({
|
|
119
|
-
sdkSelector: sdkSelector,
|
|
120
|
-
status: _this.elementContainer.getStatus(),
|
|
121
|
-
containerService: _this.elementContainerService.getContainerService(renderOptions.type)
|
|
122
|
-
}),
|
|
123
|
-
success = _checkCanMount.success,
|
|
124
|
-
errorMsg = _checkCanMount.errorMsg;
|
|
125
|
-
if (!success) {
|
|
126
|
-
_this.onEventCallback({
|
|
127
|
-
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
|
128
|
-
message: errorMsg
|
|
129
|
-
});
|
|
130
|
-
resolve({
|
|
131
|
-
success: false
|
|
132
|
-
});
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
190
|
+
return setTimeout(function () {
|
|
135
191
|
clearTimeout(_this.initTimeout);
|
|
136
192
|
_this.initTimeout = null;
|
|
137
|
-
_this.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
193
|
+
_this.handleInitializationError(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.LOAD_APP_TIME_OUT);
|
|
194
|
+
_this.serviceMap.Log.logInfo({
|
|
195
|
+
title: 'sdk_event_web_app_timeout'
|
|
196
|
+
});
|
|
197
|
+
resolve({
|
|
198
|
+
error: ERRORMESSAGE.INITIALIZE_TIMEOUT.WEB
|
|
199
|
+
});
|
|
200
|
+
}, TIMEOUT_DURATION);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// 初始化并挂载元素处理器
|
|
204
|
+
}, {
|
|
205
|
+
key: "initializeAndMountProcessor",
|
|
206
|
+
value: function initializeAndMountProcessor(type, selector, options) {
|
|
207
|
+
this.initElementProcessors(type);
|
|
208
|
+
this.elementContainerService.mount({
|
|
209
|
+
type: type,
|
|
210
|
+
selector: selector,
|
|
211
|
+
processor: this.elementProcessors[type],
|
|
212
|
+
options: options
|
|
213
|
+
});
|
|
214
|
+
this.elementProcessors[type].registerEventCenter(this.elementContainerService.getEventService(type));
|
|
215
|
+
// 渲染后instance已变更,更新埋点源数据,修复埋点没有sessionData的问题
|
|
216
|
+
var newInstanceId = this.elementContainerService.getContainerService(type).getInstanceId();
|
|
217
|
+
var paymentContext = this.elementContainer.getPaymentContext();
|
|
218
|
+
ServiceProvider.getInstance(newInstanceId).update(paymentContext);
|
|
219
|
+
// 更新埋点service
|
|
220
|
+
this.serviceMap.Log = ServiceProvider.getInstance(newInstanceId).getService('Log');
|
|
221
|
+
this.elementProcessors[type].beforeMount();
|
|
222
|
+
}
|
|
223
|
+
// 处理业务流程启动失败
|
|
224
|
+
}, {
|
|
225
|
+
key: "handleStartBizFlowError",
|
|
226
|
+
value: function handleStartBizFlowError(error, readyCallback) {
|
|
227
|
+
readyCallback({
|
|
228
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.PARAM_INVALID), {}, {
|
|
229
|
+
context: JSON.stringify(error)
|
|
230
|
+
})
|
|
231
|
+
});
|
|
232
|
+
this.onEventCallback({
|
|
233
|
+
code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
|
|
234
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
|
235
|
+
});
|
|
236
|
+
clearTimeout(this.initTimeout);
|
|
237
|
+
this.initTimeout = null;
|
|
238
|
+
this.changeLoading(false);
|
|
239
|
+
}
|
|
240
|
+
}, {
|
|
241
|
+
key: "mount",
|
|
242
|
+
value: function mount(renderOptions, sdkSelector) {
|
|
243
|
+
var _this2 = this;
|
|
244
|
+
var _convertPaymentSessio = convertPaymentSession(this.options.sessionData),
|
|
245
|
+
sessionData = _convertPaymentSessio.id;
|
|
246
|
+
var startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.MOUNT, sessionData);
|
|
247
|
+
return new Promise(function (resolve) {
|
|
248
|
+
var checkMountResult = checkCanMount({
|
|
249
|
+
sdkSelector: sdkSelector,
|
|
250
|
+
status: _this2.elementContainer.getStatus(),
|
|
251
|
+
containerService: _this2.elementContainerService.getContainerService(renderOptions.type)
|
|
252
|
+
});
|
|
253
|
+
var readyCallback = function readyCallback(payload) {
|
|
254
|
+
_this2.elementEventCenter.endEvent(startEventId, {
|
|
255
|
+
msg: safeStringify(payload)
|
|
145
256
|
});
|
|
146
|
-
|
|
147
|
-
}, TIMEOUT_DURATION);
|
|
148
|
-
_this.changeLoading(true);
|
|
149
|
-
var startBizFlowData = {
|
|
150
|
-
paymentSession: _this.options.sessionData,
|
|
151
|
-
displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
|
|
152
|
-
appendAliasContainerId: true
|
|
153
|
-
})
|
|
257
|
+
resolve(_objectSpread({}, payload || {}));
|
|
154
258
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
|
259
|
+
if (!checkMountResult.success) {
|
|
260
|
+
_this2.handleMountError({
|
|
261
|
+
result: checkMountResult,
|
|
262
|
+
resolve: readyCallback
|
|
160
263
|
});
|
|
161
|
-
clearTimeout(_this.initTimeout);
|
|
162
|
-
_this.initTimeout = null;
|
|
163
|
-
_this.changeLoading(false);
|
|
164
264
|
return;
|
|
165
|
-
});
|
|
166
|
-
_this.initElementProcessors(renderOptions.type);
|
|
167
|
-
_this.elementContainerService.mount({
|
|
168
|
-
type: renderOptions.type,
|
|
169
|
-
selector: sdkSelector,
|
|
170
|
-
processor: _this.elementProcessors[renderOptions.type],
|
|
171
|
-
options: renderOptions
|
|
172
|
-
});
|
|
173
|
-
_this.elementProcessors[renderOptions.type].registerEventCenter(_this.elementContainerService.getEventService(renderOptions.type));
|
|
174
|
-
_this.elementProcessors[renderOptions.type].beforeMount();
|
|
175
|
-
_this.sendRequestAndWaitWebLaunch(renderOptions);
|
|
176
|
-
function readyCallback(payload) {
|
|
177
|
-
var _this2 = this;
|
|
178
|
-
var resultData = _objectSpread({
|
|
179
|
-
getValue: this === null || this === void 0 ? void 0 : this.elementProcessors[renderOptions.type].getValue.bind(this === null || this === void 0 ? void 0 : this.elementProcessors[renderOptions.type]),
|
|
180
|
-
on: function on(event, callback) {
|
|
181
|
-
_this2 === null || _this2 === void 0 || _this2.elementProcessors[renderOptions.type].registerEventListener(event, callback);
|
|
182
|
-
}
|
|
183
|
-
}, payload);
|
|
184
|
-
resolve(resultData);
|
|
185
265
|
}
|
|
186
|
-
|
|
187
|
-
|
|
266
|
+
_this2.clearAndSetInitTimeout(readyCallback);
|
|
267
|
+
_this2.changeLoading(true);
|
|
268
|
+
try {
|
|
269
|
+
var startBizFlowData = {
|
|
270
|
+
paymentSession: _this2.options.sessionData,
|
|
271
|
+
displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
|
|
272
|
+
appendAliasContainerId: true
|
|
273
|
+
})
|
|
274
|
+
};
|
|
275
|
+
_this2.setControllerStatusOrView(IElementStatus.IN_BIZ_FLOW);
|
|
276
|
+
_this2.elementContainer.startBizFlow(startBizFlowData);
|
|
277
|
+
_this2.initializeAndMountProcessor(renderOptions.type, sdkSelector, renderOptions);
|
|
278
|
+
_this2.sendRequestAndWaitWebLaunch(renderOptions, readyCallback);
|
|
279
|
+
_this2.addEventListener(readyCallback);
|
|
280
|
+
_this2.serviceMap.EventCenter.addIFrame(_this2.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
|
|
281
|
+
} catch (error) {
|
|
282
|
+
_this2.handleStartBizFlowError(error, readyCallback);
|
|
283
|
+
}
|
|
188
284
|
});
|
|
189
285
|
}
|
|
286
|
+
}, {
|
|
287
|
+
key: "validateFields",
|
|
288
|
+
value: (
|
|
289
|
+
/**
|
|
290
|
+
* 25/09/08 新增商户主动校验api
|
|
291
|
+
* @returns {Promise<{isValid: boolean}>}
|
|
292
|
+
*/
|
|
293
|
+
function () {
|
|
294
|
+
var _validateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
295
|
+
var startEventId, result, _this$elementProcesso, _validateResult$data, validateResult;
|
|
296
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
297
|
+
while (1) switch (_context.prev = _context.next) {
|
|
298
|
+
case 0:
|
|
299
|
+
startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.VALIDATAFIELDS);
|
|
300
|
+
result = {
|
|
301
|
+
isValid: false
|
|
302
|
+
};
|
|
303
|
+
_context.prev = 2;
|
|
304
|
+
if (!(this.initTimeout || !((_this$elementProcesso = this.elementProcessors) !== null && _this$elementProcesso !== void 0 && _this$elementProcesso[ElementType.payment]))) {
|
|
305
|
+
_context.next = 5;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
return _context.abrupt("return", result);
|
|
309
|
+
case 5:
|
|
310
|
+
_context.next = 7;
|
|
311
|
+
return this.onValidateFunc(this.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT);
|
|
312
|
+
case 7:
|
|
313
|
+
validateResult = _context.sent;
|
|
314
|
+
result = (_validateResult$data = validateResult.data) !== null && _validateResult$data !== void 0 ? _validateResult$data : {
|
|
315
|
+
isValid: false
|
|
316
|
+
};
|
|
317
|
+
return _context.abrupt("return", result);
|
|
318
|
+
case 12:
|
|
319
|
+
_context.prev = 12;
|
|
320
|
+
_context.t0 = _context["catch"](2);
|
|
321
|
+
return _context.abrupt("return", result);
|
|
322
|
+
case 15:
|
|
323
|
+
_context.prev = 15;
|
|
324
|
+
this.elementEventCenter.endEvent(startEventId, result);
|
|
325
|
+
return _context.finish(15);
|
|
326
|
+
case 18:
|
|
327
|
+
case "end":
|
|
328
|
+
return _context.stop();
|
|
329
|
+
}
|
|
330
|
+
}, _callee, this, [[2, 12, 15, 18]]);
|
|
331
|
+
}));
|
|
332
|
+
function validateFields() {
|
|
333
|
+
return _validateFields.apply(this, arguments);
|
|
334
|
+
}
|
|
335
|
+
return validateFields;
|
|
336
|
+
}())
|
|
190
337
|
}, {
|
|
191
338
|
key: "submitPayment",
|
|
192
|
-
value: function
|
|
193
|
-
var
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
339
|
+
value: function () {
|
|
340
|
+
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
341
|
+
var _this3 = this;
|
|
342
|
+
var startEventId, res, logParams, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
|
343
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
344
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
345
|
+
case 0:
|
|
346
|
+
startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.SUBMITPAYMENT);
|
|
347
|
+
if (!(this.elementContainer.getStatus() !== IElementStatus.IN_BIZ_FLOW)) {
|
|
348
|
+
_context4.next = 6;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
res = {
|
|
352
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.UI_STATE_ERROR), {}, {
|
|
353
|
+
needChangeSessionForRetry: false
|
|
354
|
+
}),
|
|
355
|
+
status: PaymentStatus.FAIL
|
|
356
|
+
};
|
|
357
|
+
logParams = {
|
|
358
|
+
eventCode: PaymentStatus.FAIL,
|
|
359
|
+
errorName: ERRORMESSAGE.UI_STATE_ERROR.code,
|
|
360
|
+
needChangeSessionForRetry: false,
|
|
361
|
+
msg: safeStringify(res)
|
|
362
|
+
};
|
|
363
|
+
this.elementEventCenter.endEvent(startEventId, logParams);
|
|
364
|
+
return _context4.abrupt("return", Promise.resolve(res));
|
|
365
|
+
case 6:
|
|
366
|
+
this.changeLoading(true);
|
|
367
|
+
recordResult = null;
|
|
368
|
+
_context4.prev = 8;
|
|
369
|
+
_context4.next = 11;
|
|
370
|
+
return new Promise( /*#__PURE__*/function () {
|
|
371
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
372
|
+
var that, recordResultCallback, params, processStep, _yield$_this3$onValid2, data, errorResult;
|
|
373
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
374
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
375
|
+
case 0:
|
|
376
|
+
recordResultCallback = function _recordResultCallback(result) {
|
|
377
|
+
if (result instanceof Object) {
|
|
378
|
+
var _result$error, _that$elementProcesso, _result$error2;
|
|
379
|
+
var needChangeSessionForRetry = typeof (result === null || result === void 0 || (_result$error = result.error) === null || _result$error === void 0 ? void 0 : _result$error.needChangeSessionForRetry) === 'undefined' ? (_that$elementProcesso = that.elementProcessors[ElementType.payment]) === null || _that$elementProcesso === void 0 || (_that$elementProcesso = _that$elementProcesso.obtainDataRes) === null || _that$elementProcesso === void 0 || (_that$elementProcesso = _that$elementProcesso.originActionQueryResult) === null || _that$elementProcesso === void 0 ? void 0 : _that$elementProcesso.notSupportRetryPayForSameSession : result === null || result === void 0 || (_result$error2 = result.error) === null || _result$error2 === void 0 ? void 0 : _result$error2.needChangeSessionForRetry;
|
|
380
|
+
if (result !== null && result !== void 0 && result.error) {
|
|
381
|
+
result.error.needChangeSessionForRetry = needChangeSessionForRetry;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
recordResult = result;
|
|
385
|
+
resolve(recordResult);
|
|
386
|
+
};
|
|
387
|
+
that = _this3;
|
|
388
|
+
_context3.prev = 2;
|
|
389
|
+
_this3.submitPayPromise = recordResultCallback;
|
|
390
|
+
params = {}; // 统一处理逻辑
|
|
391
|
+
processStep = /*#__PURE__*/function () {
|
|
392
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(elementType, method) {
|
|
393
|
+
var _yield$_this3$onValid, data;
|
|
394
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
395
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
396
|
+
case 0:
|
|
397
|
+
if (_this3.elementProcessors[elementType]) {
|
|
398
|
+
_context2.next = 2;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
return _context2.abrupt("return", true);
|
|
402
|
+
case 2:
|
|
403
|
+
_context2.next = 4;
|
|
404
|
+
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[elementType].eventCenter, method);
|
|
405
|
+
case 4:
|
|
406
|
+
_yield$_this3$onValid = _context2.sent;
|
|
407
|
+
data = _yield$_this3$onValid.data;
|
|
408
|
+
params.shipping = data === null || data === void 0 ? void 0 : data.data;
|
|
409
|
+
if (data !== null && data !== void 0 && data.success) {
|
|
410
|
+
_context2.next = 11;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
414
|
+
recordResult = data;
|
|
415
|
+
recordResultCallback(recordResult);
|
|
416
|
+
return _context2.abrupt("return", false);
|
|
417
|
+
case 11:
|
|
418
|
+
return _context2.abrupt("return", true);
|
|
419
|
+
case 12:
|
|
420
|
+
case "end":
|
|
421
|
+
return _context2.stop();
|
|
422
|
+
}
|
|
423
|
+
}, _callee2);
|
|
424
|
+
}));
|
|
425
|
+
return function processStep(_x2, _x3) {
|
|
426
|
+
return _ref4.apply(this, arguments);
|
|
427
|
+
};
|
|
428
|
+
}(); // 按顺序处理步骤
|
|
429
|
+
_context3.next = 8;
|
|
430
|
+
return processStep(ElementType.auth, ElementPaymentMethod.AUTH_ELEMENT);
|
|
431
|
+
case 8:
|
|
432
|
+
if (_context3.sent) {
|
|
433
|
+
_context3.next = 10;
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
return _context3.abrupt("return");
|
|
437
|
+
case 10:
|
|
438
|
+
_context3.next = 12;
|
|
439
|
+
return processStep(ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT);
|
|
440
|
+
case 12:
|
|
441
|
+
if (_context3.sent) {
|
|
442
|
+
_context3.next = 14;
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
return _context3.abrupt("return");
|
|
446
|
+
case 14:
|
|
447
|
+
if (!_this3.elementProcessors[ElementType.payment]) {
|
|
448
|
+
_context3.next = 21;
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
_context3.next = 17;
|
|
452
|
+
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
|
453
|
+
case 17:
|
|
454
|
+
_yield$_this3$onValid2 = _context3.sent;
|
|
455
|
+
data = _yield$_this3$onValid2.data;
|
|
456
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
457
|
+
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
|
458
|
+
recordResult = data;
|
|
459
|
+
recordResultCallback(recordResult);
|
|
460
|
+
case 21:
|
|
461
|
+
_context3.next = 29;
|
|
462
|
+
break;
|
|
463
|
+
case 23:
|
|
464
|
+
_context3.prev = 23;
|
|
465
|
+
_context3.t0 = _context3["catch"](2);
|
|
466
|
+
errorResult = {
|
|
467
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
|
|
468
|
+
context: JSON.stringify(_context3.t0)
|
|
469
|
+
}),
|
|
470
|
+
status: PaymentStatus.FAIL
|
|
471
|
+
};
|
|
472
|
+
_this3.serviceMap.Log.logError({
|
|
473
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
474
|
+
}, {
|
|
475
|
+
msg: JSON.stringify(errorResult)
|
|
476
|
+
});
|
|
477
|
+
recordResult = errorResult;
|
|
478
|
+
recordResultCallback(errorResult);
|
|
479
|
+
case 29:
|
|
480
|
+
case "end":
|
|
481
|
+
return _context3.stop();
|
|
482
|
+
}
|
|
483
|
+
}, _callee3, null, [[2, 23]]);
|
|
484
|
+
}));
|
|
485
|
+
return function (_x) {
|
|
486
|
+
return _ref3.apply(this, arguments);
|
|
487
|
+
};
|
|
488
|
+
}());
|
|
489
|
+
case 11:
|
|
490
|
+
return _context4.abrupt("return", _context4.sent);
|
|
491
|
+
case 12:
|
|
492
|
+
_context4.prev = 12;
|
|
493
|
+
_logParams = {
|
|
494
|
+
eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
|
|
495
|
+
errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
|
|
496
|
+
errormessage: (_recordResult3 = recordResult) === null || _recordResult3 === void 0 || (_recordResult3 = _recordResult3.error) === null || _recordResult3 === void 0 ? void 0 : _recordResult3.message,
|
|
497
|
+
needChangeSessionForRetry: (_recordResult4 = recordResult) === null || _recordResult4 === void 0 || (_recordResult4 = _recordResult4.error) === null || _recordResult4 === void 0 ? void 0 : _recordResult4.needChangeSessionForRetry,
|
|
498
|
+
rpcTraceId: (_recordResult5 = recordResult) === null || _recordResult5 === void 0 || (_recordResult5 = _recordResult5.error) === null || _recordResult5 === void 0 ? void 0 : _recordResult5.traceId,
|
|
499
|
+
msg: safeStringify(recordResult)
|
|
500
|
+
};
|
|
501
|
+
this.elementEventCenter.endEvent(startEventId, _logParams);
|
|
502
|
+
this.changeLoading(false);
|
|
503
|
+
return _context4.finish(12);
|
|
504
|
+
case 17:
|
|
505
|
+
case "end":
|
|
506
|
+
return _context4.stop();
|
|
507
|
+
}
|
|
508
|
+
}, _callee4, this, [[8,, 12, 17]]);
|
|
509
|
+
}));
|
|
510
|
+
function submitPayment() {
|
|
511
|
+
return _submitPayment.apply(this, arguments);
|
|
512
|
+
}
|
|
513
|
+
return submitPayment;
|
|
514
|
+
}()
|
|
262
515
|
}, {
|
|
263
516
|
key: "changeLoading",
|
|
264
517
|
value: function changeLoading(loading) {
|
|
@@ -290,9 +543,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
290
543
|
clearTimeout(_this4.initTimeout);
|
|
291
544
|
_this4.initTimeout = null;
|
|
292
545
|
if (_this4.elementContainerService.getContainerService(data.source)) {
|
|
293
|
-
renderCallback(
|
|
294
|
-
success: true
|
|
295
|
-
});
|
|
546
|
+
renderCallback();
|
|
296
547
|
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
|
297
548
|
}
|
|
298
549
|
_this4.changeLoading(false);
|
|
@@ -309,15 +560,15 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
309
560
|
handleRedirect(data, false, onEventCallback);
|
|
310
561
|
});
|
|
311
562
|
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
|
563
|
+
_this4.changeLoading(false);
|
|
312
564
|
_this4.setControllerStatusOrView(IElementStatus.READY);
|
|
313
565
|
_this4.destroyHandle();
|
|
314
566
|
});
|
|
315
567
|
this.serviceMap.EventCenter.listen(EVENT.webAppReady.name, function (data) {
|
|
316
568
|
clearTimeout(_this4.initTimeout);
|
|
569
|
+
_this4.initTimeout = null;
|
|
317
570
|
if (_this4.elementContainerService.getContainerService(data.source)) {
|
|
318
|
-
renderCallback(
|
|
319
|
-
success: true
|
|
320
|
-
});
|
|
571
|
+
renderCallback();
|
|
321
572
|
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
|
322
573
|
}
|
|
323
574
|
_this4.changeLoading(false);
|
|
@@ -335,40 +586,129 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
335
586
|
});
|
|
336
587
|
}
|
|
337
588
|
});
|
|
589
|
+
this.serviceMap.EventCenter.listen(EVENT.submitPromiseCallback.name, function (data) {
|
|
590
|
+
var _this4$submitPayPromi;
|
|
591
|
+
(_this4$submitPayPromi = _this4.submitPayPromise) === null || _this4$submitPayPromi === void 0 || _this4$submitPayPromi.call(_this4, data);
|
|
592
|
+
});
|
|
338
593
|
}
|
|
339
594
|
}, {
|
|
340
595
|
key: "sendRequestAndWaitWebLaunch",
|
|
341
|
-
value: function
|
|
342
|
-
var
|
|
343
|
-
|
|
344
|
-
options
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
596
|
+
value: function () {
|
|
597
|
+
var _sendRequestAndWaitWebLaunch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(renderOptions, readyCallback) {
|
|
598
|
+
var _this5 = this;
|
|
599
|
+
var type, options, containerService, _yield$Promise$all, _yield$Promise$all2, _, obtainDataResult, errorResult;
|
|
600
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
601
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
602
|
+
case 0:
|
|
603
|
+
type = renderOptions.type, options = _objectWithoutProperties(renderOptions, _excluded);
|
|
604
|
+
_context5.prev = 1;
|
|
605
|
+
containerService = this.elementContainerService.getContainerService(type);
|
|
606
|
+
if (containerService) {
|
|
607
|
+
_context5.next = 7;
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
this.handleInitializationError(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CONTAINER_NOT_EXIST);
|
|
611
|
+
// 容器服务不存在,直接返回
|
|
612
|
+
readyCallback({
|
|
613
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
614
|
+
});
|
|
615
|
+
return _context5.abrupt("return");
|
|
616
|
+
case 7:
|
|
617
|
+
_context5.next = 9;
|
|
618
|
+
return Promise.all([containerService.createWebLaunchPromise(), this.elementProcessors[type].obtainData()]);
|
|
619
|
+
case 9:
|
|
620
|
+
_yield$Promise$all = _context5.sent;
|
|
621
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
622
|
+
_ = _yield$Promise$all2[0];
|
|
623
|
+
obtainDataResult = _yield$Promise$all2[1];
|
|
624
|
+
this.serviceMap.Log.logInfo({
|
|
625
|
+
title: 'sdk_event_webAppOnLaunch'
|
|
626
|
+
});
|
|
627
|
+
containerService === null || containerService === void 0 || containerService.switchContainerStatus(IContainerStatus.READY);
|
|
628
|
+
errorResult = this.getErrorFromResponse(obtainDataResult);
|
|
629
|
+
if (errorResult) {
|
|
630
|
+
// 仅结束resove,传出回调码
|
|
631
|
+
readyCallback(errorResult);
|
|
632
|
+
}
|
|
633
|
+
if (this.areAllContainersReady()) {
|
|
634
|
+
this.elementContainerService.getContainerServices().forEach(function (_, key) {
|
|
635
|
+
_this5.sendReady(key, options);
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
_context5.next = 24;
|
|
639
|
+
break;
|
|
640
|
+
case 20:
|
|
641
|
+
_context5.prev = 20;
|
|
642
|
+
_context5.t0 = _context5["catch"](1);
|
|
643
|
+
this.handleInitializationError();
|
|
644
|
+
readyCallback({
|
|
645
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.INITIALIZE_TIMEOUT.API), {}, {
|
|
646
|
+
traceId: _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.traceId
|
|
647
|
+
})
|
|
648
|
+
});
|
|
649
|
+
case 24:
|
|
650
|
+
case "end":
|
|
651
|
+
return _context5.stop();
|
|
652
|
+
}
|
|
653
|
+
}, _callee5, this, [[1, 20]]);
|
|
654
|
+
}));
|
|
655
|
+
function sendRequestAndWaitWebLaunch(_x4, _x5) {
|
|
656
|
+
return _sendRequestAndWaitWebLaunch.apply(this, arguments);
|
|
657
|
+
}
|
|
658
|
+
return sendRequestAndWaitWebLaunch;
|
|
659
|
+
}()
|
|
660
|
+
}, {
|
|
661
|
+
key: "getErrorFromResponse",
|
|
662
|
+
value: function getErrorFromResponse(response) {
|
|
663
|
+
if (isLoadErrorPage(response === null || response === void 0 ? void 0 : response.originActionQueryResult)) {
|
|
664
|
+
var _response$originActio = response.originActionQueryResult,
|
|
665
|
+
traceId = _response$originActio.traceId,
|
|
666
|
+
errorCode = _response$originActio.errorCode,
|
|
667
|
+
errorMessage = _response$originActio.errorMessage;
|
|
668
|
+
var error = {
|
|
669
|
+
code: errorCode,
|
|
670
|
+
message: errorMessage || ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED.message
|
|
671
|
+
};
|
|
672
|
+
if (!errorCode) {
|
|
673
|
+
error = _objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED);
|
|
674
|
+
}
|
|
675
|
+
if (PROMISE_CALLBACK_CODE[errorCode]) {
|
|
676
|
+
var _PROMISE_CALLBACK_COD;
|
|
677
|
+
error = {
|
|
678
|
+
code: PROMISE_CALLBACK_CODE[errorCode].code,
|
|
679
|
+
message: ((_PROMISE_CALLBACK_COD = PROMISE_CALLBACK_CODE[errorCode]) === null || _PROMISE_CALLBACK_COD === void 0 ? void 0 : _PROMISE_CALLBACK_COD.message) || errorMessage
|
|
680
|
+
};
|
|
681
|
+
} else {
|
|
682
|
+
this.serviceMap.Log.logError({
|
|
683
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
684
|
+
}, {
|
|
685
|
+
rpcTraceId: traceId
|
|
360
686
|
});
|
|
361
687
|
}
|
|
688
|
+
return {
|
|
689
|
+
error: _objectSpread(_objectSpread({}, error), {}, {
|
|
690
|
+
traceId: traceId !== null && traceId !== void 0 ? traceId : ''
|
|
691
|
+
})
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
return null;
|
|
695
|
+
}
|
|
696
|
+
}, {
|
|
697
|
+
key: "areAllContainersReady",
|
|
698
|
+
value: function areAllContainersReady() {
|
|
699
|
+
var container = this.elementContainerService.getContainerServices();
|
|
700
|
+
return _toConsumableArray(container.values()).every(function (service) {
|
|
701
|
+
return service.getContainerStatus() === IContainerStatus.READY;
|
|
362
702
|
});
|
|
363
703
|
}
|
|
364
704
|
}, {
|
|
365
705
|
key: "sendReady",
|
|
366
706
|
value: function sendReady(type, options) {
|
|
367
|
-
var _this$
|
|
368
|
-
var paymentResult = (_this$
|
|
707
|
+
var _this$elementProcesso2, _paymentSessionObj$co, _paymentSessionObj$pa, _paymentResult$origin;
|
|
708
|
+
var paymentResult = (_this$elementProcesso2 = this.elementProcessors[ElementType.payment]) === null || _this$elementProcesso2 === void 0 ? void 0 : _this$elementProcesso2.getObtainDataRes();
|
|
369
709
|
var paymentContext = this.elementContainer.getPaymentContext();
|
|
370
710
|
var paymentSessionObj = paymentContext.paymentSessionObj;
|
|
371
|
-
var isConnect = paymentSessionObj.connectFactor.enableConnect && ((_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
|
|
711
|
+
var isConnect = ((_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect) && ((_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
|
|
372
712
|
if (!(paymentResult !== null && paymentResult !== void 0 && (_paymentResult$origin = paymentResult.originActionQueryResult) !== null && _paymentResult$origin !== void 0 && _paymentResult$origin.success) && isConnect) {
|
|
373
713
|
var _this$onEventCallback;
|
|
374
714
|
clearTimeout(this.initTimeout);
|
|
@@ -392,16 +732,16 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
392
732
|
}, {
|
|
393
733
|
key: "updatePayment",
|
|
394
734
|
value: function () {
|
|
395
|
-
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
735
|
+
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(paymentSessionData) {
|
|
396
736
|
var _this6 = this;
|
|
397
|
-
return _regeneratorRuntime().wrap(function
|
|
398
|
-
while (1) switch (
|
|
737
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
738
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
399
739
|
case 0:
|
|
400
|
-
return
|
|
401
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
740
|
+
return _context7.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
741
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(resolve) {
|
|
402
742
|
var prePaymentSessionData, data, LOCAL_MOCK;
|
|
403
|
-
return _regeneratorRuntime().wrap(function
|
|
404
|
-
while (1) switch (
|
|
743
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
744
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
405
745
|
case 0:
|
|
406
746
|
if (checkCanUpdate({
|
|
407
747
|
status: _this6.elementContainer.getStatus(),
|
|
@@ -409,18 +749,18 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
409
749
|
newPaymentSessionData: paymentSessionData,
|
|
410
750
|
oldPaymentSessionData: _this6.options.sessionData
|
|
411
751
|
})) {
|
|
412
|
-
|
|
752
|
+
_context6.next = 2;
|
|
413
753
|
break;
|
|
414
754
|
}
|
|
415
|
-
return
|
|
755
|
+
return _context6.abrupt("return", resolve(false));
|
|
416
756
|
case 2:
|
|
417
757
|
prePaymentSessionData = _this6.elementContainer.getPaymentContext().paymentSession;
|
|
418
758
|
_this6.elementContainer.updatePaymentSessionData(paymentSessionData);
|
|
419
759
|
// 1、数据获取
|
|
420
|
-
|
|
760
|
+
_context6.next = 6;
|
|
421
761
|
return _this6.elementProcessors[ElementType.payment].obtainData();
|
|
422
762
|
case 6:
|
|
423
|
-
data =
|
|
763
|
+
data = _context6.sent;
|
|
424
764
|
LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1; // 2、发送update消息
|
|
425
765
|
Object.values(_this6.elementProcessors).forEach(function (processor) {
|
|
426
766
|
processor.update({
|
|
@@ -441,21 +781,21 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
441
781
|
});
|
|
442
782
|
case 10:
|
|
443
783
|
case "end":
|
|
444
|
-
return
|
|
784
|
+
return _context6.stop();
|
|
445
785
|
}
|
|
446
|
-
},
|
|
786
|
+
}, _callee6);
|
|
447
787
|
}));
|
|
448
|
-
return function (
|
|
788
|
+
return function (_x7) {
|
|
449
789
|
return _ref5.apply(this, arguments);
|
|
450
790
|
};
|
|
451
791
|
}()));
|
|
452
792
|
case 1:
|
|
453
793
|
case "end":
|
|
454
|
-
return
|
|
794
|
+
return _context7.stop();
|
|
455
795
|
}
|
|
456
|
-
},
|
|
796
|
+
}, _callee7);
|
|
457
797
|
}));
|
|
458
|
-
function updatePayment(
|
|
798
|
+
function updatePayment(_x6) {
|
|
459
799
|
return _updatePayment.apply(this, arguments);
|
|
460
800
|
}
|
|
461
801
|
return updatePayment;
|
|
@@ -475,8 +815,13 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
475
815
|
}, {
|
|
476
816
|
key: "destroy",
|
|
477
817
|
value: function destroy() {
|
|
478
|
-
this.
|
|
479
|
-
|
|
818
|
+
var startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.DESTORY);
|
|
819
|
+
try {
|
|
820
|
+
this.destroyHandle();
|
|
821
|
+
this.setControllerStatusOrView(IElementStatus.DESTROYED);
|
|
822
|
+
} finally {
|
|
823
|
+
this.elementEventCenter.endEvent(startEventId);
|
|
824
|
+
}
|
|
480
825
|
}
|
|
481
826
|
}, {
|
|
482
827
|
key: "setControllerStatusOrView",
|