@alipay/ams-checkout 0.0.1757298389-dev.2 → 0.0.1757298389-dev.20
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/README.md +17 -1
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/component.popup.style.d.ts +1 -0
- package/esm/component/component.popup.style.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +60 -0
- package/esm/constant/index.js +68 -1
- package/esm/core/component/element/EventCenter/index.d.ts +29 -0
- package/esm/core/component/element/EventCenter/index.js +155 -0
- package/esm/core/component/element/elementContainerService/containerService.js +3 -2
- package/esm/core/component/element/elementController/index.d.ts +16 -4
- package/esm/core/component/element/elementController/index.js +495 -280
- package/esm/core/component/element/elementProcessor/addressProcessor.js +3 -3
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +20 -14
- package/esm/core/component/element/index.d.ts +3 -5
- package/esm/core/component/element/index.js +9 -3
- package/esm/core/component/element/mock.js +1 -0
- package/esm/core/component/element/type.d.ts +55 -5
- package/esm/core/component/element/type.js +59 -2
- package/esm/core/component/element/util.d.ts +20 -5
- package/esm/core/component/element/util.js +49 -7
- package/esm/core/component/index.d.ts +4 -1
- package/esm/core/component/index.js +105 -2
- package/esm/foundation/service/log/keys.js +2 -0
- package/esm/foundation/service/requester/requester.js +2 -3
- package/esm/index.d.ts +10 -1
- package/esm/index.js +15 -1
- package/esm/plugin/component/channel.js +5 -3
- package/esm/plugin/component/index.d.ts +2 -0
- package/esm/plugin/component/index.js +24 -8
- package/esm/plugin/paypal/index.js +5 -2
- package/esm/types/index.d.ts +13 -1
- package/esm/types/index.js +1 -1
- package/esm/util/spm-map.d.ts +8 -0
- package/esm/util/spm-map.js +5 -1
- package/package.json +13 -8
- 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,10 @@ 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 { ELEMENT_SPM_MAP } from "../../../../util/spm-map";
|
|
22
27
|
import { cleanMockup, removeRetentionPopup } from "../../../../component/component.popup.style";
|
|
23
28
|
import { destroyModal } from "../../../../component/popupWindow.style";
|
|
24
|
-
import { ERRORMESSAGE, EVENT } from "../../../../constant";
|
|
29
|
+
import { ERRORMESSAGE, EVENT, PROMISE_CALLBACK_CODE } from "../../../../constant";
|
|
25
30
|
import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
|
|
26
31
|
import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
|
|
27
32
|
import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
|
|
@@ -31,13 +36,12 @@ import { ElementProcessor } from "../../../../foundation/product-processor/eleme
|
|
|
31
36
|
import { ProductSceneEnum } from "../../../../types";
|
|
32
37
|
import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
|
|
33
38
|
import { IContainerStatus } from "../elementContainerService/containerService";
|
|
39
|
+
import { EventCenter as ElementEventCenter } from "../EventCenter/index";
|
|
34
40
|
import { oneAccountUpdate, sdkActionUpdate } from "../mock";
|
|
35
|
-
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, MountElementType } from "../type";
|
|
36
|
-
import { checkCanMount, checkCanUpdate, handleRedirect, showToast } from "../util";
|
|
41
|
+
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType, PaymentStatus } from "../type";
|
|
42
|
+
import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, showToast } from "../util";
|
|
37
43
|
var TIMEOUT_DURATION = 10000;
|
|
38
44
|
var ElementController = /*#__PURE__*/function () {
|
|
39
|
-
// 新增变量
|
|
40
|
-
|
|
41
45
|
function ElementController(options) {
|
|
42
46
|
_classCallCheck(this, ElementController);
|
|
43
47
|
_defineProperty(this, "options", void 0);
|
|
@@ -46,11 +50,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
46
50
|
_defineProperty(this, "loading", void 0);
|
|
47
51
|
_defineProperty(this, "elementProcessors", void 0);
|
|
48
52
|
_defineProperty(this, "initTimeout", void 0);
|
|
49
|
-
_defineProperty(this, "processingSubmitPay", void 0);
|
|
50
|
-
// 支付中
|
|
51
53
|
_defineProperty(this, "elementContainerService", void 0);
|
|
52
54
|
// 新增变量
|
|
53
55
|
_defineProperty(this, "onStatusChangeCallback", void 0);
|
|
56
|
+
// 新增变量
|
|
57
|
+
_defineProperty(this, "submitPayPromise", void 0);
|
|
58
|
+
_defineProperty(this, "elementEventCenter", void 0);
|
|
54
59
|
_defineProperty(this, "onValidateFunc", function (event, target) {
|
|
55
60
|
return new Promise(function (resolve) {
|
|
56
61
|
event.emitAndListen({
|
|
@@ -81,7 +86,6 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
81
86
|
});
|
|
82
87
|
this.options = options;
|
|
83
88
|
var _options = options;
|
|
84
|
-
this.processingSubmitPay = false;
|
|
85
89
|
this.onStatusChangeCallback = _options === null || _options === void 0 ? void 0 : _options.onStatusChangeCallback;
|
|
86
90
|
this.elementContainer = new AntomSDKCore();
|
|
87
91
|
this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor());
|
|
@@ -91,6 +95,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
91
95
|
instanceId: this.elementContainer.getInstanceId()
|
|
92
96
|
});
|
|
93
97
|
this.setControllerStatusOrView(IElementStatus.READY);
|
|
98
|
+
this.elementEventCenter = new ElementEventCenter({
|
|
99
|
+
logger: this.elementContainer.getServiceProvider().getService('Log')
|
|
100
|
+
});
|
|
94
101
|
}
|
|
95
102
|
_createClass(ElementController, [{
|
|
96
103
|
key: "initService",
|
|
@@ -127,219 +134,348 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
127
134
|
result: result
|
|
128
135
|
});
|
|
129
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* 处理初始化错误的方法
|
|
139
|
+
*/
|
|
130
140
|
}, {
|
|
131
|
-
key: "
|
|
132
|
-
value: function
|
|
141
|
+
key: "handleInitializationError",
|
|
142
|
+
value: function handleInitializationError() {
|
|
143
|
+
this.changeLoading(false);
|
|
144
|
+
this.setControllerStatusOrView(IElementStatus.READY);
|
|
145
|
+
this.onEventCallback(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CALL_APP_URL_ERROR);
|
|
146
|
+
this.elementContainerService.getContainerServices().forEach(function (value) {
|
|
147
|
+
value.getContainerElement().remove();
|
|
148
|
+
});
|
|
149
|
+
this.elementContainerService.destroy();
|
|
150
|
+
} // 处理挂载检查失败
|
|
151
|
+
}, {
|
|
152
|
+
key: "handleMountError",
|
|
153
|
+
value: function handleMountError(_ref2) {
|
|
154
|
+
var result = _ref2.result,
|
|
155
|
+
resolve = _ref2.resolve;
|
|
156
|
+
var errorMsg = result.errorMsg,
|
|
157
|
+
error = result.error;
|
|
158
|
+
this.onEventCallback({
|
|
159
|
+
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
|
160
|
+
message: errorMsg
|
|
161
|
+
});
|
|
162
|
+
resolve({
|
|
163
|
+
error: error
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// 清除并设置初始化定时器
|
|
168
|
+
}, {
|
|
169
|
+
key: "clearAndSetInitTimeout",
|
|
170
|
+
value: function clearAndSetInitTimeout(resolve) {
|
|
171
|
+
clearTimeout(this.initTimeout);
|
|
172
|
+
this.initTimeout = null;
|
|
173
|
+
this.initTimeout = this.setInitTimeout(resolve);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// 设置初始化超时定时器
|
|
177
|
+
}, {
|
|
178
|
+
key: "setInitTimeout",
|
|
179
|
+
value: function setInitTimeout(resolve) {
|
|
133
180
|
var _this = this;
|
|
134
|
-
return
|
|
135
|
-
var _checkCanMount = checkCanMount({
|
|
136
|
-
sdkSelector: sdkSelector,
|
|
137
|
-
status: _this.elementContainer.getStatus(),
|
|
138
|
-
containerService: _this.elementContainerService.getContainerService(renderOptions.type)
|
|
139
|
-
}),
|
|
140
|
-
success = _checkCanMount.success,
|
|
141
|
-
errorMsg = _checkCanMount.errorMsg;
|
|
142
|
-
if (!success) {
|
|
143
|
-
_this.onEventCallback({
|
|
144
|
-
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
|
145
|
-
message: errorMsg
|
|
146
|
-
});
|
|
147
|
-
resolve({
|
|
148
|
-
success: false
|
|
149
|
-
});
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
181
|
+
return setTimeout(function () {
|
|
152
182
|
clearTimeout(_this.initTimeout);
|
|
153
183
|
_this.initTimeout = null;
|
|
154
|
-
_this.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
184
|
+
_this.handleInitializationError();
|
|
185
|
+
resolve({
|
|
186
|
+
error: ERRORMESSAGE.INITALIZE_TIMEOUT.WEB
|
|
187
|
+
});
|
|
188
|
+
}, TIMEOUT_DURATION);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 初始化并挂载元素处理器
|
|
192
|
+
}, {
|
|
193
|
+
key: "initializeAndMountProcessor",
|
|
194
|
+
value: function initializeAndMountProcessor(type, selector, options) {
|
|
195
|
+
this.initElementProcessors(type);
|
|
196
|
+
this.elementContainerService.mount({
|
|
197
|
+
type: type,
|
|
198
|
+
selector: selector,
|
|
199
|
+
processor: this.elementProcessors[type],
|
|
200
|
+
options: options
|
|
201
|
+
});
|
|
202
|
+
this.elementProcessors[type].registerEventCenter(this.elementContainerService.getEventService(type));
|
|
203
|
+
this.elementProcessors[type].beforeMount();
|
|
204
|
+
}
|
|
205
|
+
// 处理业务流程启动失败
|
|
206
|
+
}, {
|
|
207
|
+
key: "handleStartBizFlowError",
|
|
208
|
+
value: function handleStartBizFlowError(error, readyCallback) {
|
|
209
|
+
readyCallback({
|
|
210
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.PARAM_INVALID), {}, {
|
|
211
|
+
context: JSON.stringify(error)
|
|
212
|
+
})
|
|
213
|
+
});
|
|
214
|
+
this.onEventCallback({
|
|
215
|
+
code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
|
|
216
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
|
217
|
+
});
|
|
218
|
+
clearTimeout(this.initTimeout);
|
|
219
|
+
this.initTimeout = null;
|
|
220
|
+
this.changeLoading(false);
|
|
221
|
+
}
|
|
222
|
+
}, {
|
|
223
|
+
key: "mount",
|
|
224
|
+
value: function mount(renderOptions, sdkSelector) {
|
|
225
|
+
var _this2 = this;
|
|
226
|
+
var startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.MOUNT);
|
|
227
|
+
return new Promise(function (resolve) {
|
|
228
|
+
var checkMountResult = checkCanMount({
|
|
229
|
+
sdkSelector: sdkSelector,
|
|
230
|
+
status: _this2.elementContainer.getStatus(),
|
|
231
|
+
containerService: _this2.elementContainerService.getContainerService(renderOptions.type)
|
|
232
|
+
});
|
|
233
|
+
var readyCallback = function readyCallback(payload) {
|
|
234
|
+
_this2.elementEventCenter.endEvent(startEventId, payload);
|
|
235
|
+
resolve(_objectSpread(_objectSpread({}, payload || {}), {}, {
|
|
236
|
+
needChangeSessionForRetry: false
|
|
237
|
+
}));
|
|
171
238
|
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
|
239
|
+
if (!checkMountResult.success) {
|
|
240
|
+
_this2.handleMountError({
|
|
241
|
+
result: checkMountResult,
|
|
242
|
+
resolve: readyCallback
|
|
177
243
|
});
|
|
178
|
-
clearTimeout(_this.initTimeout);
|
|
179
|
-
_this.initTimeout = null;
|
|
180
|
-
_this.changeLoading(false);
|
|
181
244
|
return;
|
|
182
|
-
});
|
|
183
|
-
_this.initElementProcessors(renderOptions.type);
|
|
184
|
-
_this.elementContainerService.mount({
|
|
185
|
-
type: renderOptions.type,
|
|
186
|
-
selector: sdkSelector,
|
|
187
|
-
processor: _this.elementProcessors[renderOptions.type],
|
|
188
|
-
options: renderOptions
|
|
189
|
-
});
|
|
190
|
-
_this.elementProcessors[renderOptions.type].registerEventCenter(_this.elementContainerService.getEventService(renderOptions.type));
|
|
191
|
-
_this.elementProcessors[renderOptions.type].beforeMount();
|
|
192
|
-
_this.sendRequestAndWaitWebLaunch(renderOptions);
|
|
193
|
-
function readyCallback(payload) {
|
|
194
|
-
var _this2 = this;
|
|
195
|
-
var resultData = _objectSpread({
|
|
196
|
-
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]),
|
|
197
|
-
on: function on(event, callback) {
|
|
198
|
-
_this2 === null || _this2 === void 0 || _this2.elementProcessors[renderOptions.type].registerEventListener(event, callback);
|
|
199
|
-
}
|
|
200
|
-
}, payload);
|
|
201
|
-
resolve(resultData);
|
|
202
245
|
}
|
|
203
|
-
|
|
204
|
-
|
|
246
|
+
_this2.clearAndSetInitTimeout(readyCallback);
|
|
247
|
+
_this2.changeLoading(true);
|
|
248
|
+
try {
|
|
249
|
+
var startBizFlowData = {
|
|
250
|
+
paymentSession: _this2.options.sessionData,
|
|
251
|
+
displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
|
|
252
|
+
appendAliasContainerId: true
|
|
253
|
+
})
|
|
254
|
+
};
|
|
255
|
+
_this2.setControllerStatusOrView(IElementStatus.IN_BIZ_FLOW);
|
|
256
|
+
_this2.elementContainer.startBizFlow(startBizFlowData);
|
|
257
|
+
_this2.initializeAndMountProcessor(renderOptions.type, sdkSelector, renderOptions);
|
|
258
|
+
_this2.sendRequestAndWaitWebLaunch(renderOptions, readyCallback);
|
|
259
|
+
_this2.addEventListener(readyCallback);
|
|
260
|
+
_this2.serviceMap.EventCenter.addIFrame(_this2.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
|
|
261
|
+
} catch (error) {
|
|
262
|
+
_this2.handleStartBizFlowError(error, readyCallback);
|
|
263
|
+
}
|
|
205
264
|
});
|
|
206
265
|
}
|
|
207
266
|
}, {
|
|
208
267
|
key: "validateFields",
|
|
209
|
-
value:
|
|
268
|
+
value: (
|
|
210
269
|
/**
|
|
211
270
|
* 25/09/08 新增商户主动校验api
|
|
212
271
|
* @returns {Promise<{isValid: boolean}>}
|
|
213
272
|
*/
|
|
214
|
-
function
|
|
215
|
-
var
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return _context.abrupt("return", resolve({
|
|
228
|
-
isValid: false
|
|
229
|
-
}));
|
|
230
|
-
case 4:
|
|
231
|
-
if (!((_this3$elementProcess = _this3.elementProcessors) !== null && _this3$elementProcess !== void 0 && _this3$elementProcess[ElementType.payment])) {
|
|
232
|
-
_context.next = 17;
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
_context.prev = 5;
|
|
236
|
-
_context.next = 8;
|
|
237
|
-
return _this3.onValidateFunc((_this3$elementProcess2 = _this3.elementProcessors[ElementType.payment]) === null || _this3$elementProcess2 === void 0 ? void 0 : _this3$elementProcess2.eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT);
|
|
238
|
-
case 8:
|
|
239
|
-
validateResult = _context.sent;
|
|
240
|
-
return _context.abrupt("return", resolve({
|
|
241
|
-
isValid: validateResult.data.success
|
|
242
|
-
}));
|
|
243
|
-
case 12:
|
|
244
|
-
_context.prev = 12;
|
|
245
|
-
_context.t0 = _context["catch"](5);
|
|
246
|
-
return _context.abrupt("return", resolve({
|
|
247
|
-
isValid: false
|
|
248
|
-
}));
|
|
249
|
-
case 15:
|
|
250
|
-
_context.next = 18;
|
|
273
|
+
function () {
|
|
274
|
+
var _validateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
275
|
+
var startEventId, result, _this$elementProcesso, _validateResult$data, validateResult;
|
|
276
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
277
|
+
while (1) switch (_context.prev = _context.next) {
|
|
278
|
+
case 0:
|
|
279
|
+
startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.VALIDATAFIELDS);
|
|
280
|
+
result = {
|
|
281
|
+
isValid: false
|
|
282
|
+
};
|
|
283
|
+
_context.prev = 2;
|
|
284
|
+
if (!(this.initTimeout || !((_this$elementProcesso = this.elementProcessors) !== null && _this$elementProcesso !== void 0 && _this$elementProcesso[ElementType.payment]))) {
|
|
285
|
+
_context.next = 5;
|
|
251
286
|
break;
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
287
|
+
}
|
|
288
|
+
return _context.abrupt("return", result);
|
|
289
|
+
case 5:
|
|
290
|
+
_context.next = 7;
|
|
291
|
+
return this.onValidateFunc(this.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT);
|
|
292
|
+
case 7:
|
|
293
|
+
validateResult = _context.sent;
|
|
294
|
+
result = (_validateResult$data = validateResult.data) !== null && _validateResult$data !== void 0 ? _validateResult$data : {
|
|
295
|
+
isValid: false
|
|
296
|
+
};
|
|
297
|
+
return _context.abrupt("return", result);
|
|
298
|
+
case 12:
|
|
299
|
+
_context.prev = 12;
|
|
300
|
+
_context.t0 = _context["catch"](2);
|
|
301
|
+
return _context.abrupt("return", result);
|
|
302
|
+
case 15:
|
|
303
|
+
_context.prev = 15;
|
|
304
|
+
this.elementEventCenter.endEvent(startEventId, result);
|
|
305
|
+
return _context.finish(15);
|
|
306
|
+
case 18:
|
|
307
|
+
case "end":
|
|
308
|
+
return _context.stop();
|
|
309
|
+
}
|
|
310
|
+
}, _callee, this, [[2, 12, 15, 18]]);
|
|
311
|
+
}));
|
|
312
|
+
function validateFields() {
|
|
313
|
+
return _validateFields.apply(this, arguments);
|
|
314
|
+
}
|
|
315
|
+
return validateFields;
|
|
316
|
+
}())
|
|
267
317
|
}, {
|
|
268
318
|
key: "submitPayment",
|
|
269
|
-
value: function
|
|
270
|
-
var
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
319
|
+
value: function () {
|
|
320
|
+
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
321
|
+
var _this3 = this;
|
|
322
|
+
var startEventId, res, recordResult;
|
|
323
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
324
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
325
|
+
case 0:
|
|
326
|
+
startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.SUBMITPAYMENT);
|
|
327
|
+
if (!(this.elementContainer.getStatus() !== IElementStatus.IN_BIZ_FLOW)) {
|
|
328
|
+
_context4.next = 5;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
res = {
|
|
332
|
+
error: ERRORMESSAGE.UI_STATE_ERROR,
|
|
333
|
+
status: PaymentStatus.FAIL,
|
|
334
|
+
needChangeSessionForRetry: false
|
|
335
|
+
};
|
|
336
|
+
this.elementEventCenter.endEvent(startEventId, res);
|
|
337
|
+
return _context4.abrupt("return", Promise.resolve(res));
|
|
338
|
+
case 5:
|
|
339
|
+
this.changeLoading(true);
|
|
340
|
+
recordResult = null;
|
|
341
|
+
_context4.prev = 7;
|
|
342
|
+
_context4.next = 10;
|
|
343
|
+
return new Promise( /*#__PURE__*/function () {
|
|
344
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
345
|
+
var that, recordResultCallback, params, processStep, _yield$_this3$onValid2, data, errorResult;
|
|
346
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
347
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
348
|
+
case 0:
|
|
349
|
+
recordResultCallback = function _recordResultCallback(result) {
|
|
350
|
+
if (result instanceof Object) {
|
|
351
|
+
var _that$elementProcesso;
|
|
352
|
+
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;
|
|
353
|
+
result.needChangeSessionForRetry = needChangeSessionForRetry || false;
|
|
354
|
+
}
|
|
355
|
+
recordResult = result;
|
|
356
|
+
resolve(recordResult);
|
|
357
|
+
};
|
|
358
|
+
that = _this3;
|
|
359
|
+
_context3.prev = 2;
|
|
360
|
+
_this3.submitPayPromise = recordResultCallback;
|
|
361
|
+
params = {}; // 统一处理逻辑
|
|
362
|
+
processStep = /*#__PURE__*/function () {
|
|
363
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(elementType, method) {
|
|
364
|
+
var _yield$_this3$onValid, data;
|
|
365
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
366
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
367
|
+
case 0:
|
|
368
|
+
if (_this3.elementProcessors[elementType]) {
|
|
369
|
+
_context2.next = 2;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
return _context2.abrupt("return", true);
|
|
373
|
+
case 2:
|
|
374
|
+
_context2.next = 4;
|
|
375
|
+
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[elementType].eventCenter, method);
|
|
376
|
+
case 4:
|
|
377
|
+
_yield$_this3$onValid = _context2.sent;
|
|
378
|
+
data = _yield$_this3$onValid.data;
|
|
379
|
+
params.shipping = data === null || data === void 0 ? void 0 : data.data;
|
|
380
|
+
if (data !== null && data !== void 0 && data.success) {
|
|
381
|
+
_context2.next = 11;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
385
|
+
recordResult = data;
|
|
386
|
+
recordResultCallback(recordResult);
|
|
387
|
+
return _context2.abrupt("return", false);
|
|
388
|
+
case 11:
|
|
389
|
+
return _context2.abrupt("return", true);
|
|
390
|
+
case 12:
|
|
391
|
+
case "end":
|
|
392
|
+
return _context2.stop();
|
|
393
|
+
}
|
|
394
|
+
}, _callee2);
|
|
395
|
+
}));
|
|
396
|
+
return function processStep(_x2, _x3) {
|
|
397
|
+
return _ref4.apply(this, arguments);
|
|
398
|
+
};
|
|
399
|
+
}(); // 按顺序处理步骤
|
|
400
|
+
_context3.next = 8;
|
|
401
|
+
return processStep(ElementType.auth, ElementPaymentMethod.AUTH_ELEMENT);
|
|
402
|
+
case 8:
|
|
403
|
+
if (_context3.sent) {
|
|
404
|
+
_context3.next = 10;
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
return _context3.abrupt("return");
|
|
408
|
+
case 10:
|
|
409
|
+
_context3.next = 12;
|
|
410
|
+
return processStep(ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT);
|
|
411
|
+
case 12:
|
|
412
|
+
if (_context3.sent) {
|
|
413
|
+
_context3.next = 14;
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
return _context3.abrupt("return");
|
|
417
|
+
case 14:
|
|
418
|
+
if (!_this3.elementProcessors[ElementType.payment]) {
|
|
419
|
+
_context3.next = 22;
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
_context3.next = 17;
|
|
423
|
+
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
|
424
|
+
case 17:
|
|
425
|
+
_yield$_this3$onValid2 = _context3.sent;
|
|
426
|
+
data = _yield$_this3$onValid2.data;
|
|
427
|
+
console.log('[test] data-----', data);
|
|
428
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
429
|
+
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
|
430
|
+
recordResult = data;
|
|
431
|
+
recordResultCallback(recordResult);
|
|
432
|
+
case 22:
|
|
433
|
+
_context3.next = 30;
|
|
434
|
+
break;
|
|
435
|
+
case 24:
|
|
436
|
+
_context3.prev = 24;
|
|
437
|
+
_context3.t0 = _context3["catch"](2);
|
|
438
|
+
errorResult = {
|
|
439
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
|
|
440
|
+
context: JSON.stringify(_context3.t0)
|
|
441
|
+
}),
|
|
442
|
+
status: PaymentStatus.FAIL
|
|
443
|
+
};
|
|
444
|
+
_this3.serviceMap.Log.logError({
|
|
445
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
446
|
+
}, {
|
|
447
|
+
msg: JSON.stringify(errorResult)
|
|
448
|
+
});
|
|
449
|
+
recordResult = errorResult;
|
|
450
|
+
recordResultCallback(errorResult);
|
|
451
|
+
case 30:
|
|
452
|
+
case "end":
|
|
453
|
+
return _context3.stop();
|
|
454
|
+
}
|
|
455
|
+
}, _callee3, null, [[2, 24]]);
|
|
456
|
+
}));
|
|
457
|
+
return function (_x) {
|
|
458
|
+
return _ref3.apply(this, arguments);
|
|
459
|
+
};
|
|
460
|
+
}());
|
|
461
|
+
case 10:
|
|
462
|
+
return _context4.abrupt("return", _context4.sent);
|
|
463
|
+
case 11:
|
|
464
|
+
_context4.prev = 11;
|
|
465
|
+
this.elementEventCenter.endEvent(startEventId, recordResult);
|
|
466
|
+
this.changeLoading(false);
|
|
467
|
+
return _context4.finish(11);
|
|
468
|
+
case 15:
|
|
469
|
+
case "end":
|
|
470
|
+
return _context4.stop();
|
|
471
|
+
}
|
|
472
|
+
}, _callee4, this, [[7,, 11, 15]]);
|
|
473
|
+
}));
|
|
474
|
+
function submitPayment() {
|
|
475
|
+
return _submitPayment.apply(this, arguments);
|
|
476
|
+
}
|
|
477
|
+
return submitPayment;
|
|
478
|
+
}()
|
|
343
479
|
}, {
|
|
344
480
|
key: "changeLoading",
|
|
345
481
|
value: function changeLoading(loading) {
|
|
@@ -362,24 +498,19 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
362
498
|
}, {
|
|
363
499
|
key: "addEventListener",
|
|
364
500
|
value: function addEventListener(renderCallback) {
|
|
365
|
-
var
|
|
501
|
+
var _this4 = this;
|
|
366
502
|
this.serviceMap.EventCenter.listen(ElementPaymentEvent.ON_EVENT_CALLBACK, function (data) {
|
|
367
|
-
var
|
|
368
|
-
(
|
|
369
|
-
});
|
|
370
|
-
this.serviceMap.EventCenter.listen(ElementPaymentEvent.ON_PAY_STATUS_CHANGE, function (data) {
|
|
371
|
-
_this5.processingSubmitPay = data.isProcessingPay;
|
|
503
|
+
var _this4$onEventCallbac;
|
|
504
|
+
(_this4$onEventCallbac = _this4.onEventCallback) === null || _this4$onEventCallbac === void 0 || _this4$onEventCallbac.call(_this4, data);
|
|
372
505
|
});
|
|
373
506
|
this.serviceMap.EventCenter.listen(EVENT.sizeChanged.name, function (data) {
|
|
374
|
-
clearTimeout(
|
|
375
|
-
|
|
376
|
-
if (
|
|
377
|
-
renderCallback(
|
|
378
|
-
|
|
379
|
-
});
|
|
380
|
-
_this5.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
|
507
|
+
clearTimeout(_this4.initTimeout);
|
|
508
|
+
_this4.initTimeout = null;
|
|
509
|
+
if (_this4.elementContainerService.getContainerService(data.source)) {
|
|
510
|
+
renderCallback();
|
|
511
|
+
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
|
381
512
|
}
|
|
382
|
-
|
|
513
|
+
_this4.changeLoading(false);
|
|
383
514
|
// 遍历containerService中的所有container查看是否所有状态都是IN_BIZ_FLOW
|
|
384
515
|
// const allContainersInBizFlow = Object.values(this.elementContainerService.getContainerServices()).every(
|
|
385
516
|
// (containerService) => containerService.getContainerStatus() === IContainerStatus.IN_BIZ_FLOW,
|
|
@@ -389,22 +520,21 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
389
520
|
// }
|
|
390
521
|
});
|
|
391
522
|
this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
|
|
392
|
-
var onEventCallback =
|
|
523
|
+
var onEventCallback = _this4.onEventCallback.bind(_this4);
|
|
393
524
|
handleRedirect(data, false, onEventCallback);
|
|
394
525
|
});
|
|
395
526
|
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
|
396
|
-
|
|
397
|
-
|
|
527
|
+
_this4.setControllerStatusOrView(IElementStatus.READY);
|
|
528
|
+
_this4.destroyHandle();
|
|
398
529
|
});
|
|
399
530
|
this.serviceMap.EventCenter.listen(EVENT.webAppReady.name, function (data) {
|
|
400
|
-
clearTimeout(
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
_this5.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
|
531
|
+
clearTimeout(_this4.initTimeout);
|
|
532
|
+
_this4.initTimeout = null;
|
|
533
|
+
if (_this4.elementContainerService.getContainerService(data.source)) {
|
|
534
|
+
renderCallback();
|
|
535
|
+
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
|
406
536
|
}
|
|
407
|
-
|
|
537
|
+
_this4.changeLoading(false);
|
|
408
538
|
});
|
|
409
539
|
this.serviceMap.EventCenter.listen(EVENT.showToast.name, function (data) {
|
|
410
540
|
showToast(data);
|
|
@@ -412,47 +542,127 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
412
542
|
this.serviceMap.EventCenter.listen(EVENT.messageForward.name, function (data) {
|
|
413
543
|
var source = MountElementType[data.source];
|
|
414
544
|
var target = MountElementType[data.target];
|
|
415
|
-
if (
|
|
416
|
-
|
|
545
|
+
if (_this4.elementProcessors[source] && _this4.elementProcessors[target]) {
|
|
546
|
+
_this4.elementProcessors[target].eventCenter.dispatchToApp({
|
|
417
547
|
event: data.event,
|
|
418
548
|
data: data
|
|
419
549
|
});
|
|
420
550
|
}
|
|
421
551
|
});
|
|
552
|
+
this.serviceMap.EventCenter.listen(EVENT.submitPromiseCallback.name, function (data) {
|
|
553
|
+
var _this4$submitPayPromi;
|
|
554
|
+
(_this4$submitPayPromi = _this4.submitPayPromise) === null || _this4$submitPayPromi === void 0 || _this4$submitPayPromi.call(_this4, data);
|
|
555
|
+
});
|
|
422
556
|
}
|
|
423
557
|
}, {
|
|
424
558
|
key: "sendRequestAndWaitWebLaunch",
|
|
425
|
-
value: function
|
|
426
|
-
var
|
|
427
|
-
|
|
428
|
-
options
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
559
|
+
value: function () {
|
|
560
|
+
var _sendRequestAndWaitWebLaunch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(renderOptions, readyCallback) {
|
|
561
|
+
var _this5 = this;
|
|
562
|
+
var type, options, containerService, _yield$Promise$all, _yield$Promise$all2, _, obtainDataResult, errorResult;
|
|
563
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
564
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
565
|
+
case 0:
|
|
566
|
+
type = renderOptions.type, options = _objectWithoutProperties(renderOptions, _excluded);
|
|
567
|
+
_context5.prev = 1;
|
|
568
|
+
containerService = this.elementContainerService.getContainerService(type);
|
|
569
|
+
if (containerService) {
|
|
570
|
+
_context5.next = 7;
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
this.handleInitializationError();
|
|
574
|
+
// 容器服务不存在,直接返回
|
|
575
|
+
readyCallback({
|
|
576
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
577
|
+
});
|
|
578
|
+
return _context5.abrupt("return");
|
|
579
|
+
case 7:
|
|
580
|
+
_context5.next = 9;
|
|
581
|
+
return Promise.all([containerService.createWebLaunchPromise(), this.elementProcessors[type].obtainData()]);
|
|
582
|
+
case 9:
|
|
583
|
+
_yield$Promise$all = _context5.sent;
|
|
584
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
585
|
+
_ = _yield$Promise$all2[0];
|
|
586
|
+
obtainDataResult = _yield$Promise$all2[1];
|
|
587
|
+
containerService === null || containerService === void 0 || containerService.switchContainerStatus(IContainerStatus.READY);
|
|
588
|
+
errorResult = this.getErrorFromResponse(obtainDataResult);
|
|
589
|
+
if (errorResult) {
|
|
590
|
+
// 仅结束resove,传出回调码
|
|
591
|
+
readyCallback(errorResult);
|
|
592
|
+
}
|
|
593
|
+
if (this.areAllContainersReady()) {
|
|
594
|
+
this.elementContainerService.getContainerServices().forEach(function (_, key) {
|
|
595
|
+
_this5.sendReady(key, options);
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
_context5.next = 23;
|
|
599
|
+
break;
|
|
600
|
+
case 19:
|
|
601
|
+
_context5.prev = 19;
|
|
602
|
+
_context5.t0 = _context5["catch"](1);
|
|
603
|
+
this.handleInitializationError();
|
|
604
|
+
readyCallback({
|
|
605
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.INITALIZE_TIMEOUT.API), {}, {
|
|
606
|
+
traceId: _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.traceId
|
|
607
|
+
})
|
|
608
|
+
});
|
|
609
|
+
case 23:
|
|
610
|
+
case "end":
|
|
611
|
+
return _context5.stop();
|
|
612
|
+
}
|
|
613
|
+
}, _callee5, this, [[1, 19]]);
|
|
614
|
+
}));
|
|
615
|
+
function sendRequestAndWaitWebLaunch(_x4, _x5) {
|
|
616
|
+
return _sendRequestAndWaitWebLaunch.apply(this, arguments);
|
|
617
|
+
}
|
|
618
|
+
return sendRequestAndWaitWebLaunch;
|
|
619
|
+
}()
|
|
620
|
+
}, {
|
|
621
|
+
key: "getErrorFromResponse",
|
|
622
|
+
value: function getErrorFromResponse(response) {
|
|
623
|
+
if (isLoadErrorPage(response === null || response === void 0 ? void 0 : response.originActionQueryResult)) {
|
|
624
|
+
var _response$originActio = response.originActionQueryResult,
|
|
625
|
+
traceId = _response$originActio.traceId,
|
|
626
|
+
errorCode = _response$originActio.errorCode,
|
|
627
|
+
errorMessage = _response$originActio.errorMessage;
|
|
628
|
+
var error = _objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED);
|
|
629
|
+
if (PROMISE_CALLBACK_CODE[errorCode]) {
|
|
630
|
+
var _PROMISE_CALLBACK_COD;
|
|
631
|
+
error = {
|
|
632
|
+
code: PROMISE_CALLBACK_CODE[errorCode].code,
|
|
633
|
+
message: ((_PROMISE_CALLBACK_COD = PROMISE_CALLBACK_CODE[errorCode]) === null || _PROMISE_CALLBACK_COD === void 0 ? void 0 : _PROMISE_CALLBACK_COD.message) || errorMessage
|
|
634
|
+
};
|
|
635
|
+
} else {
|
|
636
|
+
this.serviceMap.Log.logError({
|
|
637
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
638
|
+
}, {
|
|
639
|
+
rpcTraceId: traceId
|
|
444
640
|
});
|
|
445
641
|
}
|
|
642
|
+
return {
|
|
643
|
+
error: _objectSpread(_objectSpread({}, error), {}, {
|
|
644
|
+
traceId: traceId !== null && traceId !== void 0 ? traceId : ''
|
|
645
|
+
})
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
}, {
|
|
651
|
+
key: "areAllContainersReady",
|
|
652
|
+
value: function areAllContainersReady() {
|
|
653
|
+
var container = this.elementContainerService.getContainerServices();
|
|
654
|
+
return _toConsumableArray(container.values()).every(function (service) {
|
|
655
|
+
return service.getContainerStatus() === IContainerStatus.READY;
|
|
446
656
|
});
|
|
447
657
|
}
|
|
448
658
|
}, {
|
|
449
659
|
key: "sendReady",
|
|
450
660
|
value: function sendReady(type, options) {
|
|
451
|
-
var _this$
|
|
452
|
-
var paymentResult = (_this$
|
|
661
|
+
var _this$elementProcesso2, _paymentSessionObj$co, _paymentSessionObj$pa, _paymentResult$origin;
|
|
662
|
+
var paymentResult = (_this$elementProcesso2 = this.elementProcessors[ElementType.payment]) === null || _this$elementProcesso2 === void 0 ? void 0 : _this$elementProcesso2.getObtainDataRes();
|
|
453
663
|
var paymentContext = this.elementContainer.getPaymentContext();
|
|
454
664
|
var paymentSessionObj = paymentContext.paymentSessionObj;
|
|
455
|
-
var isConnect = paymentSessionObj.connectFactor.enableConnect && ((_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
|
|
665
|
+
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;
|
|
456
666
|
if (!(paymentResult !== null && paymentResult !== void 0 && (_paymentResult$origin = paymentResult.originActionQueryResult) !== null && _paymentResult$origin !== void 0 && _paymentResult$origin.success) && isConnect) {
|
|
457
667
|
var _this$onEventCallback;
|
|
458
668
|
clearTimeout(this.initTimeout);
|
|
@@ -476,37 +686,37 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
476
686
|
}, {
|
|
477
687
|
key: "updatePayment",
|
|
478
688
|
value: function () {
|
|
479
|
-
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
480
|
-
var
|
|
481
|
-
return _regeneratorRuntime().wrap(function
|
|
482
|
-
while (1) switch (
|
|
689
|
+
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(paymentSessionData) {
|
|
690
|
+
var _this6 = this;
|
|
691
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
692
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
483
693
|
case 0:
|
|
484
|
-
return
|
|
485
|
-
var
|
|
694
|
+
return _context7.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
695
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(resolve) {
|
|
486
696
|
var prePaymentSessionData, data, LOCAL_MOCK;
|
|
487
|
-
return _regeneratorRuntime().wrap(function
|
|
488
|
-
while (1) switch (
|
|
697
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
698
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
489
699
|
case 0:
|
|
490
700
|
if (checkCanUpdate({
|
|
491
|
-
status:
|
|
492
|
-
paymentContainerService:
|
|
701
|
+
status: _this6.elementContainer.getStatus(),
|
|
702
|
+
paymentContainerService: _this6.elementContainerService.getContainerService(ElementType.payment),
|
|
493
703
|
newPaymentSessionData: paymentSessionData,
|
|
494
|
-
oldPaymentSessionData:
|
|
704
|
+
oldPaymentSessionData: _this6.options.sessionData
|
|
495
705
|
})) {
|
|
496
|
-
|
|
706
|
+
_context6.next = 2;
|
|
497
707
|
break;
|
|
498
708
|
}
|
|
499
|
-
return
|
|
709
|
+
return _context6.abrupt("return", resolve(false));
|
|
500
710
|
case 2:
|
|
501
|
-
prePaymentSessionData =
|
|
502
|
-
|
|
711
|
+
prePaymentSessionData = _this6.elementContainer.getPaymentContext().paymentSession;
|
|
712
|
+
_this6.elementContainer.updatePaymentSessionData(paymentSessionData);
|
|
503
713
|
// 1、数据获取
|
|
504
|
-
|
|
505
|
-
return
|
|
714
|
+
_context6.next = 6;
|
|
715
|
+
return _this6.elementProcessors[ElementType.payment].obtainData();
|
|
506
716
|
case 6:
|
|
507
|
-
data =
|
|
717
|
+
data = _context6.sent;
|
|
508
718
|
LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1; // 2、发送update消息
|
|
509
|
-
Object.values(
|
|
719
|
+
Object.values(_this6.elementProcessors).forEach(function (processor) {
|
|
510
720
|
processor.update({
|
|
511
721
|
data: {
|
|
512
722
|
originActionQueryResult: LOCAL_MOCK ? sdkActionUpdate : data.originActionQueryResult,
|
|
@@ -516,30 +726,30 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
516
726
|
});
|
|
517
727
|
});
|
|
518
728
|
// 3、返回更新结果
|
|
519
|
-
|
|
729
|
+
_this6.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
|
|
520
730
|
// 若更新不成功,还原core.paymentContext信息
|
|
521
731
|
if (!data.success) {
|
|
522
|
-
|
|
732
|
+
_this6.elementContainer.updatePaymentSessionData(prePaymentSessionData);
|
|
523
733
|
}
|
|
524
734
|
return resolve(data.success || false);
|
|
525
735
|
});
|
|
526
736
|
case 10:
|
|
527
737
|
case "end":
|
|
528
|
-
return
|
|
738
|
+
return _context6.stop();
|
|
529
739
|
}
|
|
530
|
-
},
|
|
740
|
+
}, _callee6);
|
|
531
741
|
}));
|
|
532
|
-
return function (
|
|
533
|
-
return
|
|
742
|
+
return function (_x7) {
|
|
743
|
+
return _ref5.apply(this, arguments);
|
|
534
744
|
};
|
|
535
745
|
}()));
|
|
536
746
|
case 1:
|
|
537
747
|
case "end":
|
|
538
|
-
return
|
|
748
|
+
return _context7.stop();
|
|
539
749
|
}
|
|
540
|
-
},
|
|
750
|
+
}, _callee7);
|
|
541
751
|
}));
|
|
542
|
-
function updatePayment(
|
|
752
|
+
function updatePayment(_x6) {
|
|
543
753
|
return _updatePayment.apply(this, arguments);
|
|
544
754
|
}
|
|
545
755
|
return updatePayment;
|
|
@@ -559,8 +769,13 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
559
769
|
}, {
|
|
560
770
|
key: "destroy",
|
|
561
771
|
value: function destroy() {
|
|
562
|
-
this.
|
|
563
|
-
|
|
772
|
+
var startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.DESTORY);
|
|
773
|
+
try {
|
|
774
|
+
this.destroyHandle();
|
|
775
|
+
this.setControllerStatusOrView(IElementStatus.DESTROYED);
|
|
776
|
+
} finally {
|
|
777
|
+
this.elementEventCenter.endEvent(startEventId);
|
|
778
|
+
}
|
|
564
779
|
}
|
|
565
780
|
}, {
|
|
566
781
|
key: "setControllerStatusOrView",
|