@alipay/ams-checkout 0.0.1757298389-dev.2 → 0.0.1757298389-dev.21
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 +497 -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,347 @@ 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 = 21;
|
|
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
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
428
|
+
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
|
429
|
+
recordResult = data;
|
|
430
|
+
recordResultCallback(recordResult);
|
|
431
|
+
case 21:
|
|
432
|
+
_context3.next = 29;
|
|
433
|
+
break;
|
|
434
|
+
case 23:
|
|
435
|
+
_context3.prev = 23;
|
|
436
|
+
_context3.t0 = _context3["catch"](2);
|
|
437
|
+
errorResult = {
|
|
438
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
|
|
439
|
+
context: JSON.stringify(_context3.t0)
|
|
440
|
+
}),
|
|
441
|
+
status: PaymentStatus.FAIL
|
|
442
|
+
};
|
|
443
|
+
_this3.serviceMap.Log.logError({
|
|
444
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
445
|
+
}, {
|
|
446
|
+
msg: JSON.stringify(errorResult)
|
|
447
|
+
});
|
|
448
|
+
recordResult = errorResult;
|
|
449
|
+
recordResultCallback(errorResult);
|
|
450
|
+
case 29:
|
|
451
|
+
case "end":
|
|
452
|
+
return _context3.stop();
|
|
453
|
+
}
|
|
454
|
+
}, _callee3, null, [[2, 23]]);
|
|
455
|
+
}));
|
|
456
|
+
return function (_x) {
|
|
457
|
+
return _ref3.apply(this, arguments);
|
|
458
|
+
};
|
|
459
|
+
}());
|
|
460
|
+
case 10:
|
|
461
|
+
return _context4.abrupt("return", _context4.sent);
|
|
462
|
+
case 11:
|
|
463
|
+
_context4.prev = 11;
|
|
464
|
+
this.elementEventCenter.endEvent(startEventId, recordResult);
|
|
465
|
+
this.changeLoading(false);
|
|
466
|
+
return _context4.finish(11);
|
|
467
|
+
case 15:
|
|
468
|
+
case "end":
|
|
469
|
+
return _context4.stop();
|
|
470
|
+
}
|
|
471
|
+
}, _callee4, this, [[7,, 11, 15]]);
|
|
472
|
+
}));
|
|
473
|
+
function submitPayment() {
|
|
474
|
+
return _submitPayment.apply(this, arguments);
|
|
475
|
+
}
|
|
476
|
+
return submitPayment;
|
|
477
|
+
}()
|
|
343
478
|
}, {
|
|
344
479
|
key: "changeLoading",
|
|
345
480
|
value: function changeLoading(loading) {
|
|
@@ -362,24 +497,19 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
362
497
|
}, {
|
|
363
498
|
key: "addEventListener",
|
|
364
499
|
value: function addEventListener(renderCallback) {
|
|
365
|
-
var
|
|
500
|
+
var _this4 = this;
|
|
366
501
|
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;
|
|
502
|
+
var _this4$onEventCallbac;
|
|
503
|
+
(_this4$onEventCallbac = _this4.onEventCallback) === null || _this4$onEventCallbac === void 0 || _this4$onEventCallbac.call(_this4, data);
|
|
372
504
|
});
|
|
373
505
|
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);
|
|
506
|
+
clearTimeout(_this4.initTimeout);
|
|
507
|
+
_this4.initTimeout = null;
|
|
508
|
+
if (_this4.elementContainerService.getContainerService(data.source)) {
|
|
509
|
+
renderCallback();
|
|
510
|
+
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
|
381
511
|
}
|
|
382
|
-
|
|
512
|
+
_this4.changeLoading(false);
|
|
383
513
|
// 遍历containerService中的所有container查看是否所有状态都是IN_BIZ_FLOW
|
|
384
514
|
// const allContainersInBizFlow = Object.values(this.elementContainerService.getContainerServices()).every(
|
|
385
515
|
// (containerService) => containerService.getContainerStatus() === IContainerStatus.IN_BIZ_FLOW,
|
|
@@ -389,22 +519,21 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
389
519
|
// }
|
|
390
520
|
});
|
|
391
521
|
this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
|
|
392
|
-
var onEventCallback =
|
|
522
|
+
var onEventCallback = _this4.onEventCallback.bind(_this4);
|
|
393
523
|
handleRedirect(data, false, onEventCallback);
|
|
394
524
|
});
|
|
395
525
|
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
|
396
|
-
|
|
397
|
-
|
|
526
|
+
_this4.setControllerStatusOrView(IElementStatus.READY);
|
|
527
|
+
_this4.destroyHandle();
|
|
398
528
|
});
|
|
399
529
|
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);
|
|
530
|
+
clearTimeout(_this4.initTimeout);
|
|
531
|
+
_this4.initTimeout = null;
|
|
532
|
+
if (_this4.elementContainerService.getContainerService(data.source)) {
|
|
533
|
+
renderCallback();
|
|
534
|
+
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
|
406
535
|
}
|
|
407
|
-
|
|
536
|
+
_this4.changeLoading(false);
|
|
408
537
|
});
|
|
409
538
|
this.serviceMap.EventCenter.listen(EVENT.showToast.name, function (data) {
|
|
410
539
|
showToast(data);
|
|
@@ -412,47 +541,130 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
412
541
|
this.serviceMap.EventCenter.listen(EVENT.messageForward.name, function (data) {
|
|
413
542
|
var source = MountElementType[data.source];
|
|
414
543
|
var target = MountElementType[data.target];
|
|
415
|
-
if (
|
|
416
|
-
|
|
544
|
+
if (_this4.elementProcessors[source] && _this4.elementProcessors[target]) {
|
|
545
|
+
_this4.elementProcessors[target].eventCenter.dispatchToApp({
|
|
417
546
|
event: data.event,
|
|
418
547
|
data: data
|
|
419
548
|
});
|
|
420
549
|
}
|
|
421
550
|
});
|
|
551
|
+
this.serviceMap.EventCenter.listen(EVENT.submitPromiseCallback.name, function (data) {
|
|
552
|
+
var _this4$submitPayPromi;
|
|
553
|
+
(_this4$submitPayPromi = _this4.submitPayPromise) === null || _this4$submitPayPromi === void 0 || _this4$submitPayPromi.call(_this4, data);
|
|
554
|
+
});
|
|
422
555
|
}
|
|
423
556
|
}, {
|
|
424
557
|
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
|
-
|
|
558
|
+
value: function () {
|
|
559
|
+
var _sendRequestAndWaitWebLaunch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(renderOptions, readyCallback) {
|
|
560
|
+
var _this5 = this;
|
|
561
|
+
var type, options, containerService, _yield$Promise$all, _yield$Promise$all2, _, obtainDataResult, errorResult;
|
|
562
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
563
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
564
|
+
case 0:
|
|
565
|
+
type = renderOptions.type, options = _objectWithoutProperties(renderOptions, _excluded);
|
|
566
|
+
_context5.prev = 1;
|
|
567
|
+
containerService = this.elementContainerService.getContainerService(type);
|
|
568
|
+
if (containerService) {
|
|
569
|
+
_context5.next = 7;
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
this.handleInitializationError();
|
|
573
|
+
// 容器服务不存在,直接返回
|
|
574
|
+
readyCallback({
|
|
575
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
576
|
+
});
|
|
577
|
+
return _context5.abrupt("return");
|
|
578
|
+
case 7:
|
|
579
|
+
_context5.next = 9;
|
|
580
|
+
return Promise.all([containerService.createWebLaunchPromise(), this.elementProcessors[type].obtainData()]);
|
|
581
|
+
case 9:
|
|
582
|
+
_yield$Promise$all = _context5.sent;
|
|
583
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
584
|
+
_ = _yield$Promise$all2[0];
|
|
585
|
+
obtainDataResult = _yield$Promise$all2[1];
|
|
586
|
+
containerService === null || containerService === void 0 || containerService.switchContainerStatus(IContainerStatus.READY);
|
|
587
|
+
errorResult = this.getErrorFromResponse(obtainDataResult);
|
|
588
|
+
if (errorResult) {
|
|
589
|
+
// 仅结束resove,传出回调码
|
|
590
|
+
readyCallback(errorResult);
|
|
591
|
+
}
|
|
592
|
+
if (this.areAllContainersReady()) {
|
|
593
|
+
this.elementContainerService.getContainerServices().forEach(function (_, key) {
|
|
594
|
+
_this5.sendReady(key, options);
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
_context5.next = 23;
|
|
598
|
+
break;
|
|
599
|
+
case 19:
|
|
600
|
+
_context5.prev = 19;
|
|
601
|
+
_context5.t0 = _context5["catch"](1);
|
|
602
|
+
this.handleInitializationError();
|
|
603
|
+
readyCallback({
|
|
604
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.INITALIZE_TIMEOUT.API), {}, {
|
|
605
|
+
traceId: _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.traceId
|
|
606
|
+
})
|
|
607
|
+
});
|
|
608
|
+
case 23:
|
|
609
|
+
case "end":
|
|
610
|
+
return _context5.stop();
|
|
611
|
+
}
|
|
612
|
+
}, _callee5, this, [[1, 19]]);
|
|
613
|
+
}));
|
|
614
|
+
function sendRequestAndWaitWebLaunch(_x4, _x5) {
|
|
615
|
+
return _sendRequestAndWaitWebLaunch.apply(this, arguments);
|
|
616
|
+
}
|
|
617
|
+
return sendRequestAndWaitWebLaunch;
|
|
618
|
+
}()
|
|
619
|
+
}, {
|
|
620
|
+
key: "getErrorFromResponse",
|
|
621
|
+
value: function getErrorFromResponse(response) {
|
|
622
|
+
if (isLoadErrorPage(response === null || response === void 0 ? void 0 : response.originActionQueryResult)) {
|
|
623
|
+
var _response$originActio = response.originActionQueryResult,
|
|
624
|
+
traceId = _response$originActio.traceId,
|
|
625
|
+
errorCode = _response$originActio.errorCode,
|
|
626
|
+
errorMessage = _response$originActio.errorMessage;
|
|
627
|
+
var error = {
|
|
628
|
+
code: errorCode,
|
|
629
|
+
message: errorMessage
|
|
630
|
+
};
|
|
631
|
+
if (PROMISE_CALLBACK_CODE[errorCode]) {
|
|
632
|
+
var _PROMISE_CALLBACK_COD;
|
|
633
|
+
error = {
|
|
634
|
+
code: PROMISE_CALLBACK_CODE[errorCode].code,
|
|
635
|
+
message: ((_PROMISE_CALLBACK_COD = PROMISE_CALLBACK_CODE[errorCode]) === null || _PROMISE_CALLBACK_COD === void 0 ? void 0 : _PROMISE_CALLBACK_COD.message) || errorMessage
|
|
636
|
+
};
|
|
637
|
+
} else {
|
|
638
|
+
this.serviceMap.Log.logError({
|
|
639
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
640
|
+
}, {
|
|
641
|
+
rpcTraceId: traceId
|
|
444
642
|
});
|
|
445
643
|
}
|
|
644
|
+
return {
|
|
645
|
+
error: _objectSpread(_objectSpread({}, error), {}, {
|
|
646
|
+
traceId: traceId !== null && traceId !== void 0 ? traceId : ''
|
|
647
|
+
})
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
652
|
+
}, {
|
|
653
|
+
key: "areAllContainersReady",
|
|
654
|
+
value: function areAllContainersReady() {
|
|
655
|
+
var container = this.elementContainerService.getContainerServices();
|
|
656
|
+
return _toConsumableArray(container.values()).every(function (service) {
|
|
657
|
+
return service.getContainerStatus() === IContainerStatus.READY;
|
|
446
658
|
});
|
|
447
659
|
}
|
|
448
660
|
}, {
|
|
449
661
|
key: "sendReady",
|
|
450
662
|
value: function sendReady(type, options) {
|
|
451
|
-
var _this$
|
|
452
|
-
var paymentResult = (_this$
|
|
663
|
+
var _this$elementProcesso2, _paymentSessionObj$co, _paymentSessionObj$pa, _paymentResult$origin;
|
|
664
|
+
var paymentResult = (_this$elementProcesso2 = this.elementProcessors[ElementType.payment]) === null || _this$elementProcesso2 === void 0 ? void 0 : _this$elementProcesso2.getObtainDataRes();
|
|
453
665
|
var paymentContext = this.elementContainer.getPaymentContext();
|
|
454
666
|
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;
|
|
667
|
+
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
668
|
if (!(paymentResult !== null && paymentResult !== void 0 && (_paymentResult$origin = paymentResult.originActionQueryResult) !== null && _paymentResult$origin !== void 0 && _paymentResult$origin.success) && isConnect) {
|
|
457
669
|
var _this$onEventCallback;
|
|
458
670
|
clearTimeout(this.initTimeout);
|
|
@@ -476,37 +688,37 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
476
688
|
}, {
|
|
477
689
|
key: "updatePayment",
|
|
478
690
|
value: function () {
|
|
479
|
-
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
480
|
-
var
|
|
481
|
-
return _regeneratorRuntime().wrap(function
|
|
482
|
-
while (1) switch (
|
|
691
|
+
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(paymentSessionData) {
|
|
692
|
+
var _this6 = this;
|
|
693
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
694
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
483
695
|
case 0:
|
|
484
|
-
return
|
|
485
|
-
var
|
|
696
|
+
return _context7.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
697
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(resolve) {
|
|
486
698
|
var prePaymentSessionData, data, LOCAL_MOCK;
|
|
487
|
-
return _regeneratorRuntime().wrap(function
|
|
488
|
-
while (1) switch (
|
|
699
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
700
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
489
701
|
case 0:
|
|
490
702
|
if (checkCanUpdate({
|
|
491
|
-
status:
|
|
492
|
-
paymentContainerService:
|
|
703
|
+
status: _this6.elementContainer.getStatus(),
|
|
704
|
+
paymentContainerService: _this6.elementContainerService.getContainerService(ElementType.payment),
|
|
493
705
|
newPaymentSessionData: paymentSessionData,
|
|
494
|
-
oldPaymentSessionData:
|
|
706
|
+
oldPaymentSessionData: _this6.options.sessionData
|
|
495
707
|
})) {
|
|
496
|
-
|
|
708
|
+
_context6.next = 2;
|
|
497
709
|
break;
|
|
498
710
|
}
|
|
499
|
-
return
|
|
711
|
+
return _context6.abrupt("return", resolve(false));
|
|
500
712
|
case 2:
|
|
501
|
-
prePaymentSessionData =
|
|
502
|
-
|
|
713
|
+
prePaymentSessionData = _this6.elementContainer.getPaymentContext().paymentSession;
|
|
714
|
+
_this6.elementContainer.updatePaymentSessionData(paymentSessionData);
|
|
503
715
|
// 1、数据获取
|
|
504
|
-
|
|
505
|
-
return
|
|
716
|
+
_context6.next = 6;
|
|
717
|
+
return _this6.elementProcessors[ElementType.payment].obtainData();
|
|
506
718
|
case 6:
|
|
507
|
-
data =
|
|
719
|
+
data = _context6.sent;
|
|
508
720
|
LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1; // 2、发送update消息
|
|
509
|
-
Object.values(
|
|
721
|
+
Object.values(_this6.elementProcessors).forEach(function (processor) {
|
|
510
722
|
processor.update({
|
|
511
723
|
data: {
|
|
512
724
|
originActionQueryResult: LOCAL_MOCK ? sdkActionUpdate : data.originActionQueryResult,
|
|
@@ -516,30 +728,30 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
516
728
|
});
|
|
517
729
|
});
|
|
518
730
|
// 3、返回更新结果
|
|
519
|
-
|
|
731
|
+
_this6.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
|
|
520
732
|
// 若更新不成功,还原core.paymentContext信息
|
|
521
733
|
if (!data.success) {
|
|
522
|
-
|
|
734
|
+
_this6.elementContainer.updatePaymentSessionData(prePaymentSessionData);
|
|
523
735
|
}
|
|
524
736
|
return resolve(data.success || false);
|
|
525
737
|
});
|
|
526
738
|
case 10:
|
|
527
739
|
case "end":
|
|
528
|
-
return
|
|
740
|
+
return _context6.stop();
|
|
529
741
|
}
|
|
530
|
-
},
|
|
742
|
+
}, _callee6);
|
|
531
743
|
}));
|
|
532
|
-
return function (
|
|
533
|
-
return
|
|
744
|
+
return function (_x7) {
|
|
745
|
+
return _ref5.apply(this, arguments);
|
|
534
746
|
};
|
|
535
747
|
}()));
|
|
536
748
|
case 1:
|
|
537
749
|
case "end":
|
|
538
|
-
return
|
|
750
|
+
return _context7.stop();
|
|
539
751
|
}
|
|
540
|
-
},
|
|
752
|
+
}, _callee7);
|
|
541
753
|
}));
|
|
542
|
-
function updatePayment(
|
|
754
|
+
function updatePayment(_x6) {
|
|
543
755
|
return _updatePayment.apply(this, arguments);
|
|
544
756
|
}
|
|
545
757
|
return updatePayment;
|
|
@@ -559,8 +771,13 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
559
771
|
}, {
|
|
560
772
|
key: "destroy",
|
|
561
773
|
value: function destroy() {
|
|
562
|
-
this.
|
|
563
|
-
|
|
774
|
+
var startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.DESTORY);
|
|
775
|
+
try {
|
|
776
|
+
this.destroyHandle();
|
|
777
|
+
this.setControllerStatusOrView(IElementStatus.DESTROYED);
|
|
778
|
+
} finally {
|
|
779
|
+
this.elementEventCenter.endEvent(startEventId);
|
|
780
|
+
}
|
|
564
781
|
}
|
|
565
782
|
}, {
|
|
566
783
|
key: "setControllerStatusOrView",
|