@alipay/ams-checkout 0.0.1759909830-dev.1 → 0.0.1760520369-dev.1
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/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 +533 -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 +56 -4
- package/esm/core/component/element/type.js +61 -2
- package/esm/core/component/element/util.d.ts +21 -5
- package/esm/core/component/element/util.js +59 -7
- package/esm/foundation/core/index.js +27 -8
- package/esm/foundation/index.d.ts +1 -0
- package/esm/foundation/product-processor/easysafepay/index.js +4 -2
- 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,387 @@ 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.INITALIZE_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
|
-
|
148
|
-
|
149
|
-
var startBizFlowData = {
|
150
|
-
paymentSession: _this.options.sessionData,
|
151
|
-
displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
|
152
|
-
appendAliasContainerId: true
|
153
|
-
})
|
257
|
+
resolve(_objectSpread(_objectSpread({}, payload || {}), {}, {
|
258
|
+
needChangeSessionForRetry: false
|
259
|
+
}));
|
154
260
|
};
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
261
|
+
if (!checkMountResult.success) {
|
262
|
+
_this2.handleMountError({
|
263
|
+
result: checkMountResult,
|
264
|
+
resolve: readyCallback
|
160
265
|
});
|
161
|
-
clearTimeout(_this.initTimeout);
|
162
|
-
_this.initTimeout = null;
|
163
|
-
_this.changeLoading(false);
|
164
266
|
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
267
|
}
|
186
|
-
|
187
|
-
|
268
|
+
_this2.clearAndSetInitTimeout(readyCallback);
|
269
|
+
_this2.changeLoading(true);
|
270
|
+
try {
|
271
|
+
var startBizFlowData = {
|
272
|
+
paymentSession: _this2.options.sessionData,
|
273
|
+
displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
|
274
|
+
appendAliasContainerId: true
|
275
|
+
})
|
276
|
+
};
|
277
|
+
_this2.setControllerStatusOrView(IElementStatus.IN_BIZ_FLOW);
|
278
|
+
_this2.elementContainer.startBizFlow(startBizFlowData);
|
279
|
+
_this2.initializeAndMountProcessor(renderOptions.type, sdkSelector, renderOptions);
|
280
|
+
_this2.sendRequestAndWaitWebLaunch(renderOptions, readyCallback);
|
281
|
+
_this2.addEventListener(readyCallback);
|
282
|
+
_this2.serviceMap.EventCenter.addIFrame(_this2.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
|
283
|
+
} catch (error) {
|
284
|
+
_this2.handleStartBizFlowError(error, readyCallback);
|
285
|
+
}
|
188
286
|
});
|
189
287
|
}
|
288
|
+
}, {
|
289
|
+
key: "validateFields",
|
290
|
+
value: (
|
291
|
+
/**
|
292
|
+
* 25/09/08 新增商户主动校验api
|
293
|
+
* @returns {Promise<{isValid: boolean}>}
|
294
|
+
*/
|
295
|
+
function () {
|
296
|
+
var _validateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
297
|
+
var startEventId, result, _this$elementProcesso, _validateResult$data, validateResult;
|
298
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
299
|
+
while (1) switch (_context.prev = _context.next) {
|
300
|
+
case 0:
|
301
|
+
startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.VALIDATAFIELDS);
|
302
|
+
result = {
|
303
|
+
isValid: false
|
304
|
+
};
|
305
|
+
_context.prev = 2;
|
306
|
+
if (!(this.initTimeout || !((_this$elementProcesso = this.elementProcessors) !== null && _this$elementProcesso !== void 0 && _this$elementProcesso[ElementType.payment]))) {
|
307
|
+
_context.next = 5;
|
308
|
+
break;
|
309
|
+
}
|
310
|
+
return _context.abrupt("return", result);
|
311
|
+
case 5:
|
312
|
+
_context.next = 7;
|
313
|
+
return this.onValidateFunc(this.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT);
|
314
|
+
case 7:
|
315
|
+
validateResult = _context.sent;
|
316
|
+
result = (_validateResult$data = validateResult.data) !== null && _validateResult$data !== void 0 ? _validateResult$data : {
|
317
|
+
isValid: false
|
318
|
+
};
|
319
|
+
return _context.abrupt("return", result);
|
320
|
+
case 12:
|
321
|
+
_context.prev = 12;
|
322
|
+
_context.t0 = _context["catch"](2);
|
323
|
+
return _context.abrupt("return", result);
|
324
|
+
case 15:
|
325
|
+
_context.prev = 15;
|
326
|
+
this.elementEventCenter.endEvent(startEventId, result);
|
327
|
+
return _context.finish(15);
|
328
|
+
case 18:
|
329
|
+
case "end":
|
330
|
+
return _context.stop();
|
331
|
+
}
|
332
|
+
}, _callee, this, [[2, 12, 15, 18]]);
|
333
|
+
}));
|
334
|
+
function validateFields() {
|
335
|
+
return _validateFields.apply(this, arguments);
|
336
|
+
}
|
337
|
+
return validateFields;
|
338
|
+
}())
|
190
339
|
}, {
|
191
340
|
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
|
-
|
341
|
+
value: function () {
|
342
|
+
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
343
|
+
var _this3 = this;
|
344
|
+
var startEventId, res, logParams, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
345
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
346
|
+
while (1) switch (_context4.prev = _context4.next) {
|
347
|
+
case 0:
|
348
|
+
startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.SUBMITPAYMENT);
|
349
|
+
if (!(this.elementContainer.getStatus() !== IElementStatus.IN_BIZ_FLOW)) {
|
350
|
+
_context4.next = 6;
|
351
|
+
break;
|
352
|
+
}
|
353
|
+
res = {
|
354
|
+
error: ERRORMESSAGE.UI_STATE_ERROR,
|
355
|
+
status: PaymentStatus.FAIL,
|
356
|
+
needChangeSessionForRetry: false
|
357
|
+
};
|
358
|
+
logParams = {
|
359
|
+
eventCode: PaymentStatus.FAIL,
|
360
|
+
errorName: ERRORMESSAGE.UI_STATE_ERROR.code,
|
361
|
+
needChangeSessionForRetry: false,
|
362
|
+
msg: safeStringify(res)
|
363
|
+
};
|
364
|
+
this.elementEventCenter.endEvent(startEventId, logParams);
|
365
|
+
return _context4.abrupt("return", Promise.resolve(res));
|
366
|
+
case 6:
|
367
|
+
this.changeLoading(true);
|
368
|
+
recordResult = null;
|
369
|
+
_context4.prev = 8;
|
370
|
+
_context4.next = 11;
|
371
|
+
return new Promise( /*#__PURE__*/function () {
|
372
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
373
|
+
var that, recordResultCallback, params, processStep, _yield$_this3$onValid2, data, errorResult;
|
374
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
375
|
+
while (1) switch (_context3.prev = _context3.next) {
|
376
|
+
case 0:
|
377
|
+
recordResultCallback = function _recordResultCallback(result) {
|
378
|
+
if (result instanceof Object) {
|
379
|
+
var _that$elementProcesso;
|
380
|
+
var needChangeSessionForRetry = typeof (result === null || result === void 0 ? void 0 : result.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 ? void 0 : result.needChangeSessionForRetry;
|
381
|
+
result.needChangeSessionForRetry = needChangeSessionForRetry || false;
|
382
|
+
}
|
383
|
+
recordResult = result;
|
384
|
+
resolve(recordResult);
|
385
|
+
};
|
386
|
+
that = _this3;
|
387
|
+
_context3.prev = 2;
|
388
|
+
_this3.submitPayPromise = recordResultCallback;
|
389
|
+
params = {}; // 统一处理逻辑
|
390
|
+
processStep = /*#__PURE__*/function () {
|
391
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(elementType, method) {
|
392
|
+
var _yield$_this3$onValid, data;
|
393
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
394
|
+
while (1) switch (_context2.prev = _context2.next) {
|
395
|
+
case 0:
|
396
|
+
if (_this3.elementProcessors[elementType]) {
|
397
|
+
_context2.next = 2;
|
398
|
+
break;
|
399
|
+
}
|
400
|
+
return _context2.abrupt("return", true);
|
401
|
+
case 2:
|
402
|
+
_context2.next = 4;
|
403
|
+
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[elementType].eventCenter, method);
|
404
|
+
case 4:
|
405
|
+
_yield$_this3$onValid = _context2.sent;
|
406
|
+
data = _yield$_this3$onValid.data;
|
407
|
+
params.shipping = data === null || data === void 0 ? void 0 : data.data;
|
408
|
+
if (data !== null && data !== void 0 && data.success) {
|
409
|
+
_context2.next = 11;
|
410
|
+
break;
|
411
|
+
}
|
412
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
413
|
+
recordResult = data;
|
414
|
+
recordResultCallback(recordResult);
|
415
|
+
return _context2.abrupt("return", false);
|
416
|
+
case 11:
|
417
|
+
return _context2.abrupt("return", true);
|
418
|
+
case 12:
|
419
|
+
case "end":
|
420
|
+
return _context2.stop();
|
421
|
+
}
|
422
|
+
}, _callee2);
|
423
|
+
}));
|
424
|
+
return function processStep(_x2, _x3) {
|
425
|
+
return _ref4.apply(this, arguments);
|
426
|
+
};
|
427
|
+
}(); // 按顺序处理步骤
|
428
|
+
_context3.next = 8;
|
429
|
+
return processStep(ElementType.auth, ElementPaymentMethod.AUTH_ELEMENT);
|
430
|
+
case 8:
|
431
|
+
if (_context3.sent) {
|
432
|
+
_context3.next = 10;
|
433
|
+
break;
|
434
|
+
}
|
435
|
+
return _context3.abrupt("return");
|
436
|
+
case 10:
|
437
|
+
_context3.next = 12;
|
438
|
+
return processStep(ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT);
|
439
|
+
case 12:
|
440
|
+
if (_context3.sent) {
|
441
|
+
_context3.next = 14;
|
442
|
+
break;
|
443
|
+
}
|
444
|
+
return _context3.abrupt("return");
|
445
|
+
case 14:
|
446
|
+
if (!_this3.elementProcessors[ElementType.payment]) {
|
447
|
+
_context3.next = 21;
|
448
|
+
break;
|
449
|
+
}
|
450
|
+
_context3.next = 17;
|
451
|
+
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
452
|
+
case 17:
|
453
|
+
_yield$_this3$onValid2 = _context3.sent;
|
454
|
+
data = _yield$_this3$onValid2.data;
|
455
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
456
|
+
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
457
|
+
recordResult = data;
|
458
|
+
recordResultCallback(recordResult);
|
459
|
+
case 21:
|
460
|
+
_context3.next = 29;
|
461
|
+
break;
|
462
|
+
case 23:
|
463
|
+
_context3.prev = 23;
|
464
|
+
_context3.t0 = _context3["catch"](2);
|
465
|
+
errorResult = {
|
466
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
|
467
|
+
context: JSON.stringify(_context3.t0)
|
468
|
+
}),
|
469
|
+
status: PaymentStatus.FAIL
|
470
|
+
};
|
471
|
+
_this3.serviceMap.Log.logError({
|
472
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
473
|
+
}, {
|
474
|
+
msg: JSON.stringify(errorResult)
|
475
|
+
});
|
476
|
+
recordResult = errorResult;
|
477
|
+
recordResultCallback(errorResult);
|
478
|
+
case 29:
|
479
|
+
case "end":
|
480
|
+
return _context3.stop();
|
481
|
+
}
|
482
|
+
}, _callee3, null, [[2, 23]]);
|
483
|
+
}));
|
484
|
+
return function (_x) {
|
485
|
+
return _ref3.apply(this, arguments);
|
486
|
+
};
|
487
|
+
}());
|
488
|
+
case 11:
|
489
|
+
return _context4.abrupt("return", _context4.sent);
|
490
|
+
case 12:
|
491
|
+
_context4.prev = 12;
|
492
|
+
_logParams = {
|
493
|
+
eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
|
494
|
+
errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
|
495
|
+
errormessage: (_recordResult3 = recordResult) === null || _recordResult3 === void 0 || (_recordResult3 = _recordResult3.error) === null || _recordResult3 === void 0 ? void 0 : _recordResult3.message,
|
496
|
+
needChangeSessionForRetry: (_recordResult4 = recordResult) === null || _recordResult4 === void 0 ? void 0 : _recordResult4.needChangeSessionForRetry,
|
497
|
+
rpcTraceId: (_recordResult5 = recordResult) === null || _recordResult5 === void 0 || (_recordResult5 = _recordResult5.error) === null || _recordResult5 === void 0 ? void 0 : _recordResult5.traceId,
|
498
|
+
msg: safeStringify(recordResult)
|
499
|
+
};
|
500
|
+
this.elementEventCenter.endEvent(startEventId, _logParams);
|
501
|
+
this.changeLoading(false);
|
502
|
+
return _context4.finish(12);
|
503
|
+
case 17:
|
504
|
+
case "end":
|
505
|
+
return _context4.stop();
|
506
|
+
}
|
507
|
+
}, _callee4, this, [[8,, 12, 17]]);
|
508
|
+
}));
|
509
|
+
function submitPayment() {
|
510
|
+
return _submitPayment.apply(this, arguments);
|
511
|
+
}
|
512
|
+
return submitPayment;
|
513
|
+
}()
|
262
514
|
}, {
|
263
515
|
key: "changeLoading",
|
264
516
|
value: function changeLoading(loading) {
|
@@ -290,9 +542,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
290
542
|
clearTimeout(_this4.initTimeout);
|
291
543
|
_this4.initTimeout = null;
|
292
544
|
if (_this4.elementContainerService.getContainerService(data.source)) {
|
293
|
-
renderCallback(
|
294
|
-
success: true
|
295
|
-
});
|
545
|
+
renderCallback();
|
296
546
|
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
297
547
|
}
|
298
548
|
_this4.changeLoading(false);
|
@@ -309,15 +559,15 @@ var ElementController = /*#__PURE__*/function () {
|
|
309
559
|
handleRedirect(data, false, onEventCallback);
|
310
560
|
});
|
311
561
|
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
562
|
+
_this4.changeLoading(false);
|
312
563
|
_this4.setControllerStatusOrView(IElementStatus.READY);
|
313
564
|
_this4.destroyHandle();
|
314
565
|
});
|
315
566
|
this.serviceMap.EventCenter.listen(EVENT.webAppReady.name, function (data) {
|
316
567
|
clearTimeout(_this4.initTimeout);
|
568
|
+
_this4.initTimeout = null;
|
317
569
|
if (_this4.elementContainerService.getContainerService(data.source)) {
|
318
|
-
renderCallback(
|
319
|
-
success: true
|
320
|
-
});
|
570
|
+
renderCallback();
|
321
571
|
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
322
572
|
}
|
323
573
|
_this4.changeLoading(false);
|
@@ -335,40 +585,129 @@ var ElementController = /*#__PURE__*/function () {
|
|
335
585
|
});
|
336
586
|
}
|
337
587
|
});
|
588
|
+
this.serviceMap.EventCenter.listen(EVENT.submitPromiseCallback.name, function (data) {
|
589
|
+
var _this4$submitPayPromi;
|
590
|
+
(_this4$submitPayPromi = _this4.submitPayPromise) === null || _this4$submitPayPromi === void 0 || _this4$submitPayPromi.call(_this4, data);
|
591
|
+
});
|
338
592
|
}
|
339
593
|
}, {
|
340
594
|
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
|
-
|
595
|
+
value: function () {
|
596
|
+
var _sendRequestAndWaitWebLaunch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(renderOptions, readyCallback) {
|
597
|
+
var _this5 = this;
|
598
|
+
var type, options, containerService, _yield$Promise$all, _yield$Promise$all2, _, obtainDataResult, errorResult;
|
599
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
600
|
+
while (1) switch (_context5.prev = _context5.next) {
|
601
|
+
case 0:
|
602
|
+
type = renderOptions.type, options = _objectWithoutProperties(renderOptions, _excluded);
|
603
|
+
_context5.prev = 1;
|
604
|
+
containerService = this.elementContainerService.getContainerService(type);
|
605
|
+
if (containerService) {
|
606
|
+
_context5.next = 7;
|
607
|
+
break;
|
608
|
+
}
|
609
|
+
this.handleInitializationError(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CONTAINER_NOT_EXIST);
|
610
|
+
// 容器服务不存在,直接返回
|
611
|
+
readyCallback({
|
612
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
613
|
+
});
|
614
|
+
return _context5.abrupt("return");
|
615
|
+
case 7:
|
616
|
+
_context5.next = 9;
|
617
|
+
return Promise.all([containerService.createWebLaunchPromise(), this.elementProcessors[type].obtainData()]);
|
618
|
+
case 9:
|
619
|
+
_yield$Promise$all = _context5.sent;
|
620
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
621
|
+
_ = _yield$Promise$all2[0];
|
622
|
+
obtainDataResult = _yield$Promise$all2[1];
|
623
|
+
this.serviceMap.Log.logInfo({
|
624
|
+
title: 'sdk_event_webAppOnLaunch'
|
625
|
+
});
|
626
|
+
containerService === null || containerService === void 0 || containerService.switchContainerStatus(IContainerStatus.READY);
|
627
|
+
errorResult = this.getErrorFromResponse(obtainDataResult);
|
628
|
+
if (errorResult) {
|
629
|
+
// 仅结束resove,传出回调码
|
630
|
+
readyCallback(errorResult);
|
631
|
+
}
|
632
|
+
if (this.areAllContainersReady()) {
|
633
|
+
this.elementContainerService.getContainerServices().forEach(function (_, key) {
|
634
|
+
_this5.sendReady(key, options);
|
635
|
+
});
|
636
|
+
}
|
637
|
+
_context5.next = 24;
|
638
|
+
break;
|
639
|
+
case 20:
|
640
|
+
_context5.prev = 20;
|
641
|
+
_context5.t0 = _context5["catch"](1);
|
642
|
+
this.handleInitializationError();
|
643
|
+
readyCallback({
|
644
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.INITALIZE_TIMEOUT.API), {}, {
|
645
|
+
traceId: _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.traceId
|
646
|
+
})
|
647
|
+
});
|
648
|
+
case 24:
|
649
|
+
case "end":
|
650
|
+
return _context5.stop();
|
651
|
+
}
|
652
|
+
}, _callee5, this, [[1, 20]]);
|
653
|
+
}));
|
654
|
+
function sendRequestAndWaitWebLaunch(_x4, _x5) {
|
655
|
+
return _sendRequestAndWaitWebLaunch.apply(this, arguments);
|
656
|
+
}
|
657
|
+
return sendRequestAndWaitWebLaunch;
|
658
|
+
}()
|
659
|
+
}, {
|
660
|
+
key: "getErrorFromResponse",
|
661
|
+
value: function getErrorFromResponse(response) {
|
662
|
+
if (isLoadErrorPage(response === null || response === void 0 ? void 0 : response.originActionQueryResult)) {
|
663
|
+
var _response$originActio = response.originActionQueryResult,
|
664
|
+
traceId = _response$originActio.traceId,
|
665
|
+
errorCode = _response$originActio.errorCode,
|
666
|
+
errorMessage = _response$originActio.errorMessage;
|
667
|
+
var error = {
|
668
|
+
code: errorCode,
|
669
|
+
message: errorMessage || ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED.message
|
670
|
+
};
|
671
|
+
if (!errorCode) {
|
672
|
+
error = _objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED);
|
673
|
+
}
|
674
|
+
if (PROMISE_CALLBACK_CODE[errorCode]) {
|
675
|
+
var _PROMISE_CALLBACK_COD;
|
676
|
+
error = {
|
677
|
+
code: PROMISE_CALLBACK_CODE[errorCode].code,
|
678
|
+
message: ((_PROMISE_CALLBACK_COD = PROMISE_CALLBACK_CODE[errorCode]) === null || _PROMISE_CALLBACK_COD === void 0 ? void 0 : _PROMISE_CALLBACK_COD.message) || errorMessage
|
679
|
+
};
|
680
|
+
} else {
|
681
|
+
this.serviceMap.Log.logError({
|
682
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
683
|
+
}, {
|
684
|
+
rpcTraceId: traceId
|
360
685
|
});
|
361
686
|
}
|
687
|
+
return {
|
688
|
+
error: _objectSpread(_objectSpread({}, error), {}, {
|
689
|
+
traceId: traceId !== null && traceId !== void 0 ? traceId : ''
|
690
|
+
})
|
691
|
+
};
|
692
|
+
}
|
693
|
+
return null;
|
694
|
+
}
|
695
|
+
}, {
|
696
|
+
key: "areAllContainersReady",
|
697
|
+
value: function areAllContainersReady() {
|
698
|
+
var container = this.elementContainerService.getContainerServices();
|
699
|
+
return _toConsumableArray(container.values()).every(function (service) {
|
700
|
+
return service.getContainerStatus() === IContainerStatus.READY;
|
362
701
|
});
|
363
702
|
}
|
364
703
|
}, {
|
365
704
|
key: "sendReady",
|
366
705
|
value: function sendReady(type, options) {
|
367
|
-
var _this$
|
368
|
-
var paymentResult = (_this$
|
706
|
+
var _this$elementProcesso2, _paymentSessionObj$co, _paymentSessionObj$pa, _paymentResult$origin;
|
707
|
+
var paymentResult = (_this$elementProcesso2 = this.elementProcessors[ElementType.payment]) === null || _this$elementProcesso2 === void 0 ? void 0 : _this$elementProcesso2.getObtainDataRes();
|
369
708
|
var paymentContext = this.elementContainer.getPaymentContext();
|
370
709
|
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;
|
710
|
+
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
711
|
if (!(paymentResult !== null && paymentResult !== void 0 && (_paymentResult$origin = paymentResult.originActionQueryResult) !== null && _paymentResult$origin !== void 0 && _paymentResult$origin.success) && isConnect) {
|
373
712
|
var _this$onEventCallback;
|
374
713
|
clearTimeout(this.initTimeout);
|
@@ -392,16 +731,16 @@ var ElementController = /*#__PURE__*/function () {
|
|
392
731
|
}, {
|
393
732
|
key: "updatePayment",
|
394
733
|
value: function () {
|
395
|
-
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
734
|
+
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(paymentSessionData) {
|
396
735
|
var _this6 = this;
|
397
|
-
return _regeneratorRuntime().wrap(function
|
398
|
-
while (1) switch (
|
736
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
737
|
+
while (1) switch (_context7.prev = _context7.next) {
|
399
738
|
case 0:
|
400
|
-
return
|
401
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
739
|
+
return _context7.abrupt("return", new Promise( /*#__PURE__*/function () {
|
740
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(resolve) {
|
402
741
|
var prePaymentSessionData, data, LOCAL_MOCK;
|
403
|
-
return _regeneratorRuntime().wrap(function
|
404
|
-
while (1) switch (
|
742
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
743
|
+
while (1) switch (_context6.prev = _context6.next) {
|
405
744
|
case 0:
|
406
745
|
if (checkCanUpdate({
|
407
746
|
status: _this6.elementContainer.getStatus(),
|
@@ -409,18 +748,18 @@ var ElementController = /*#__PURE__*/function () {
|
|
409
748
|
newPaymentSessionData: paymentSessionData,
|
410
749
|
oldPaymentSessionData: _this6.options.sessionData
|
411
750
|
})) {
|
412
|
-
|
751
|
+
_context6.next = 2;
|
413
752
|
break;
|
414
753
|
}
|
415
|
-
return
|
754
|
+
return _context6.abrupt("return", resolve(false));
|
416
755
|
case 2:
|
417
756
|
prePaymentSessionData = _this6.elementContainer.getPaymentContext().paymentSession;
|
418
757
|
_this6.elementContainer.updatePaymentSessionData(paymentSessionData);
|
419
758
|
// 1、数据获取
|
420
|
-
|
759
|
+
_context6.next = 6;
|
421
760
|
return _this6.elementProcessors[ElementType.payment].obtainData();
|
422
761
|
case 6:
|
423
|
-
data =
|
762
|
+
data = _context6.sent;
|
424
763
|
LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1; // 2、发送update消息
|
425
764
|
Object.values(_this6.elementProcessors).forEach(function (processor) {
|
426
765
|
processor.update({
|
@@ -441,21 +780,21 @@ var ElementController = /*#__PURE__*/function () {
|
|
441
780
|
});
|
442
781
|
case 10:
|
443
782
|
case "end":
|
444
|
-
return
|
783
|
+
return _context6.stop();
|
445
784
|
}
|
446
|
-
},
|
785
|
+
}, _callee6);
|
447
786
|
}));
|
448
|
-
return function (
|
787
|
+
return function (_x7) {
|
449
788
|
return _ref5.apply(this, arguments);
|
450
789
|
};
|
451
790
|
}()));
|
452
791
|
case 1:
|
453
792
|
case "end":
|
454
|
-
return
|
793
|
+
return _context7.stop();
|
455
794
|
}
|
456
|
-
},
|
795
|
+
}, _callee7);
|
457
796
|
}));
|
458
|
-
function updatePayment(
|
797
|
+
function updatePayment(_x6) {
|
459
798
|
return _updatePayment.apply(this, arguments);
|
460
799
|
}
|
461
800
|
return updatePayment;
|
@@ -475,8 +814,13 @@ var ElementController = /*#__PURE__*/function () {
|
|
475
814
|
}, {
|
476
815
|
key: "destroy",
|
477
816
|
value: function destroy() {
|
478
|
-
this.
|
479
|
-
|
817
|
+
var startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.DESTORY);
|
818
|
+
try {
|
819
|
+
this.destroyHandle();
|
820
|
+
this.setControllerStatusOrView(IElementStatus.DESTROYED);
|
821
|
+
} finally {
|
822
|
+
this.elementEventCenter.endEvent(startEventId);
|
823
|
+
}
|
480
824
|
}
|
481
825
|
}, {
|
482
826
|
key: "setControllerStatusOrView",
|