@alipay/ams-checkout 0.0.1758783821-dev.1 → 0.0.1758783821-dev.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/popupWindow.style.d.ts +1 -0
- package/esm/component/popupWindow.style.js +5 -2
- package/esm/config/index.d.ts +1 -0
- package/esm/config/index.js +2 -1
- package/esm/config/request.js +14 -2
- package/esm/constant/index.d.ts +33 -12
- package/esm/constant/index.js +43 -18
- package/esm/core/component/element/EventCenter/index.d.ts +3 -1
- package/esm/core/component/element/EventCenter/index.js +48 -11
- package/esm/core/component/element/elementContainerService/containerService.d.ts +1 -0
- package/esm/core/component/element/elementContainerService/containerService.js +5 -0
- package/esm/core/component/element/elementController/index.d.ts +3 -8
- package/esm/core/component/element/elementController/index.js +152 -66
- package/esm/core/component/element/elementProcessor/addressProcessor.js +2 -3
- 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 +36 -6
- package/esm/core/component/element/index.d.ts +3 -10
- package/esm/core/component/element/index.js +4 -1
- package/esm/core/component/element/mock.js +1 -0
- package/esm/core/component/element/type.d.ts +26 -6
- package/esm/core/component/element/type.js +18 -0
- package/esm/core/component/element/util.d.ts +6 -3
- package/esm/core/component/element/util.js +15 -2
- package/esm/foundation/core/index.js +28 -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/log/keys.js +2 -0
- 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 -5
- 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 +18 -2
- package/esm/types/index.js +2 -1
- package/esm/util/index.js +4 -1
- package/esm/util/spm-map.d.ts +22 -2
- package/esm/util/spm-map.js +13 -1
- package/package.json +12 -7
- 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
|
@@ -25,20 +25,23 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
25
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
26
|
import { cleanMockup, removeRetentionPopup } from "../../../../component/component.popup.style";
|
|
27
27
|
import { destroyModal } from "../../../../component/popupWindow.style";
|
|
28
|
-
import { ERRORMESSAGE, EVENT } from "../../../../constant";
|
|
28
|
+
import { ERRORMESSAGE, EVENT, PROMISE_CALLBACK_CODE } from "../../../../constant";
|
|
29
29
|
import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
|
|
30
30
|
import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
|
|
31
31
|
import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
|
|
32
32
|
import { IElementStatus } from "../../../../foundation";
|
|
33
33
|
import { AntomSDKCore } from "../../../../foundation/core";
|
|
34
34
|
import { ElementProcessor } from "../../../../foundation/product-processor/element";
|
|
35
|
+
import { ServiceProvider } from "../../../../foundation/service";
|
|
36
|
+
import { convertPaymentSession } from "../../../../foundation/utils/payment_context_utils";
|
|
35
37
|
import { ProductSceneEnum } from "../../../../types";
|
|
38
|
+
import { ELEMENT_SPM_MAP } from "../../../../util/spm-map";
|
|
36
39
|
import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
|
|
37
40
|
import { IContainerStatus } from "../elementContainerService/containerService";
|
|
38
41
|
import { EventCenter as ElementEventCenter } from "../EventCenter/index";
|
|
39
42
|
import { oneAccountUpdate, sdkActionUpdate } from "../mock";
|
|
40
|
-
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType } from "../type";
|
|
41
|
-
import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, showToast } from "../util";
|
|
43
|
+
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType, PaymentStatus } from "../type";
|
|
44
|
+
import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, safeStringify, showToast } from "../util";
|
|
42
45
|
var TIMEOUT_DURATION = 10000;
|
|
43
46
|
var ElementController = /*#__PURE__*/function () {
|
|
44
47
|
function ElementController(options) {
|
|
@@ -127,6 +130,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
127
130
|
message = _ref$message === void 0 ? '' : _ref$message,
|
|
128
131
|
_ref$result = _ref.result,
|
|
129
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
|
+
});
|
|
130
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, {
|
|
131
140
|
code: code,
|
|
132
141
|
message: message,
|
|
@@ -139,9 +148,10 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
139
148
|
}, {
|
|
140
149
|
key: "handleInitializationError",
|
|
141
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;
|
|
142
152
|
this.changeLoading(false);
|
|
143
153
|
this.setControllerStatusOrView(IElementStatus.READY);
|
|
144
|
-
this.onEventCallback(
|
|
154
|
+
this.onEventCallback(errorCode);
|
|
145
155
|
this.elementContainerService.getContainerServices().forEach(function (value) {
|
|
146
156
|
value.getContainerElement().remove();
|
|
147
157
|
});
|
|
@@ -180,7 +190,10 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
180
190
|
return setTimeout(function () {
|
|
181
191
|
clearTimeout(_this.initTimeout);
|
|
182
192
|
_this.initTimeout = null;
|
|
183
|
-
_this.handleInitializationError();
|
|
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
|
+
});
|
|
184
197
|
resolve({
|
|
185
198
|
error: ERRORMESSAGE.INITALIZE_TIMEOUT.WEB
|
|
186
199
|
});
|
|
@@ -199,6 +212,13 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
199
212
|
options: options
|
|
200
213
|
});
|
|
201
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].registerEventCenter(this.elementContainerService.getEventService(type));
|
|
202
222
|
this.elementProcessors[type].beforeMount();
|
|
203
223
|
}
|
|
204
224
|
// 处理业务流程启动失败
|
|
@@ -222,7 +242,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
222
242
|
key: "mount",
|
|
223
243
|
value: function mount(renderOptions, sdkSelector) {
|
|
224
244
|
var _this2 = this;
|
|
225
|
-
var
|
|
245
|
+
var _convertPaymentSessio = convertPaymentSession(this.options.sessionData),
|
|
246
|
+
sessionData = _convertPaymentSessio.id;
|
|
247
|
+
var startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.MOUNT, sessionData);
|
|
226
248
|
return new Promise(function (resolve) {
|
|
227
249
|
var checkMountResult = checkCanMount({
|
|
228
250
|
sdkSelector: sdkSelector,
|
|
@@ -230,8 +252,10 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
230
252
|
containerService: _this2.elementContainerService.getContainerService(renderOptions.type)
|
|
231
253
|
});
|
|
232
254
|
var readyCallback = function readyCallback(payload) {
|
|
233
|
-
_this2.elementEventCenter.endEvent(startEventId,
|
|
234
|
-
|
|
255
|
+
_this2.elementEventCenter.endEvent(startEventId, {
|
|
256
|
+
msg: safeStringify(payload)
|
|
257
|
+
});
|
|
258
|
+
resolve(_objectSpread({}, payload || {}));
|
|
235
259
|
};
|
|
236
260
|
if (!checkMountResult.success) {
|
|
237
261
|
_this2.handleMountError({
|
|
@@ -316,33 +340,57 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
316
340
|
value: function () {
|
|
317
341
|
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
318
342
|
var _this3 = this;
|
|
319
|
-
var startEventId, res, recordResult;
|
|
343
|
+
var startEventId, res, logParams, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
|
320
344
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
321
345
|
while (1) switch (_context4.prev = _context4.next) {
|
|
322
346
|
case 0:
|
|
347
|
+
this.serviceMap.Log.logInfo({
|
|
348
|
+
title: 'sdk_event_submitPay'
|
|
349
|
+
});
|
|
323
350
|
startEventId = this.elementEventCenter.registerEvent(EXPOSURE_API_EVENT.SUBMITPAYMENT);
|
|
324
351
|
if (!(this.elementContainer.getStatus() !== IElementStatus.IN_BIZ_FLOW)) {
|
|
325
|
-
_context4.next =
|
|
352
|
+
_context4.next = 7;
|
|
326
353
|
break;
|
|
327
354
|
}
|
|
328
355
|
res = {
|
|
329
|
-
error: ERRORMESSAGE.
|
|
356
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.UI_STATE_ERROR), {}, {
|
|
357
|
+
needChangeSessionForRetry: false
|
|
358
|
+
}),
|
|
359
|
+
status: PaymentStatus.FAIL
|
|
360
|
+
};
|
|
361
|
+
logParams = {
|
|
362
|
+
eventCode: PaymentStatus.FAIL,
|
|
363
|
+
errorName: ERRORMESSAGE.UI_STATE_ERROR.code,
|
|
364
|
+
needChangeSessionForRetry: false,
|
|
365
|
+
msg: safeStringify(res)
|
|
330
366
|
};
|
|
331
|
-
this.elementEventCenter.endEvent(startEventId,
|
|
367
|
+
this.elementEventCenter.endEvent(startEventId, logParams);
|
|
332
368
|
return _context4.abrupt("return", Promise.resolve(res));
|
|
333
|
-
case
|
|
369
|
+
case 7:
|
|
334
370
|
this.changeLoading(true);
|
|
335
371
|
recordResult = null;
|
|
336
|
-
_context4.prev =
|
|
337
|
-
_context4.next =
|
|
372
|
+
_context4.prev = 9;
|
|
373
|
+
_context4.next = 12;
|
|
338
374
|
return new Promise( /*#__PURE__*/function () {
|
|
339
375
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
340
|
-
var params, processStep, _yield$_this3$onValid2, data, errorResult;
|
|
376
|
+
var that, recordResultCallback, params, processStep, _yield$_this3$onValid2, data, errorResult;
|
|
341
377
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
342
378
|
while (1) switch (_context3.prev = _context3.next) {
|
|
343
379
|
case 0:
|
|
344
|
-
|
|
345
|
-
|
|
380
|
+
recordResultCallback = function _recordResultCallback(result) {
|
|
381
|
+
if (result instanceof Object) {
|
|
382
|
+
var _result$error, _that$elementProcesso, _result$error2;
|
|
383
|
+
var needChangeSessionForRetry = typeof (result === null || result === void 0 || (_result$error = result.error) === null || _result$error === void 0 ? void 0 : _result$error.needChangeSessionForRetry) === 'undefined' ? (_that$elementProcesso = that.elementProcessors[ElementType.payment]) === null || _that$elementProcesso === void 0 || (_that$elementProcesso = _that$elementProcesso.obtainDataRes) === null || _that$elementProcesso === void 0 || (_that$elementProcesso = _that$elementProcesso.originActionQueryResult) === null || _that$elementProcesso === void 0 ? void 0 : _that$elementProcesso.notSupportRetryPayForSameSession : result === null || result === void 0 || (_result$error2 = result.error) === null || _result$error2 === void 0 ? void 0 : _result$error2.needChangeSessionForRetry;
|
|
384
|
+
if (result !== null && result !== void 0 && result.error) {
|
|
385
|
+
result.error.needChangeSessionForRetry = needChangeSessionForRetry;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
recordResult = result;
|
|
389
|
+
resolve(recordResult);
|
|
390
|
+
};
|
|
391
|
+
that = _this3;
|
|
392
|
+
_context3.prev = 2;
|
|
393
|
+
_this3.submitPayPromise = recordResultCallback;
|
|
346
394
|
params = {}; // 统一处理逻辑
|
|
347
395
|
processStep = /*#__PURE__*/function () {
|
|
348
396
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(elementType, method) {
|
|
@@ -366,8 +414,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
366
414
|
_context2.next = 11;
|
|
367
415
|
break;
|
|
368
416
|
}
|
|
417
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
369
418
|
recordResult = data;
|
|
370
|
-
|
|
419
|
+
recordResultCallback(recordResult);
|
|
371
420
|
return _context2.abrupt("return", false);
|
|
372
421
|
case 11:
|
|
373
422
|
return _context2.abrupt("return", true);
|
|
@@ -381,70 +430,86 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
381
430
|
return _ref4.apply(this, arguments);
|
|
382
431
|
};
|
|
383
432
|
}(); // 按顺序处理步骤
|
|
384
|
-
_context3.next =
|
|
433
|
+
_context3.next = 8;
|
|
385
434
|
return processStep(ElementType.auth, ElementPaymentMethod.AUTH_ELEMENT);
|
|
386
|
-
case
|
|
435
|
+
case 8:
|
|
387
436
|
if (_context3.sent) {
|
|
388
|
-
_context3.next =
|
|
437
|
+
_context3.next = 10;
|
|
389
438
|
break;
|
|
390
439
|
}
|
|
391
440
|
return _context3.abrupt("return");
|
|
392
|
-
case 8:
|
|
393
|
-
_context3.next = 10;
|
|
394
|
-
return processStep(ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT);
|
|
395
441
|
case 10:
|
|
442
|
+
_context3.next = 12;
|
|
443
|
+
return processStep(ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT);
|
|
444
|
+
case 12:
|
|
396
445
|
if (_context3.sent) {
|
|
397
|
-
_context3.next =
|
|
446
|
+
_context3.next = 14;
|
|
398
447
|
break;
|
|
399
448
|
}
|
|
400
449
|
return _context3.abrupt("return");
|
|
401
|
-
case
|
|
450
|
+
case 14:
|
|
402
451
|
if (!_this3.elementProcessors[ElementType.payment]) {
|
|
403
|
-
_context3.next =
|
|
452
|
+
_context3.next = 21;
|
|
404
453
|
break;
|
|
405
454
|
}
|
|
406
|
-
_context3.next =
|
|
455
|
+
_context3.next = 17;
|
|
407
456
|
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
|
408
|
-
case
|
|
457
|
+
case 17:
|
|
409
458
|
_yield$_this3$onValid2 = _context3.sent;
|
|
410
459
|
data = _yield$_this3$onValid2.data;
|
|
460
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
461
|
+
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
|
411
462
|
recordResult = data;
|
|
412
|
-
|
|
413
|
-
case 19:
|
|
414
|
-
_context3.next = 26;
|
|
415
|
-
break;
|
|
463
|
+
recordResultCallback(recordResult);
|
|
416
464
|
case 21:
|
|
417
|
-
_context3.
|
|
418
|
-
|
|
465
|
+
_context3.next = 29;
|
|
466
|
+
break;
|
|
467
|
+
case 23:
|
|
468
|
+
_context3.prev = 23;
|
|
469
|
+
_context3.t0 = _context3["catch"](2);
|
|
419
470
|
errorResult = {
|
|
420
471
|
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
|
|
421
472
|
context: JSON.stringify(_context3.t0)
|
|
422
|
-
})
|
|
473
|
+
}),
|
|
474
|
+
status: PaymentStatus.FAIL
|
|
423
475
|
};
|
|
476
|
+
_this3.serviceMap.Log.logError({
|
|
477
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
478
|
+
}, {
|
|
479
|
+
msg: JSON.stringify(errorResult)
|
|
480
|
+
});
|
|
424
481
|
recordResult = errorResult;
|
|
425
|
-
|
|
426
|
-
case
|
|
482
|
+
recordResultCallback(errorResult);
|
|
483
|
+
case 29:
|
|
427
484
|
case "end":
|
|
428
485
|
return _context3.stop();
|
|
429
486
|
}
|
|
430
|
-
}, _callee3, null, [[
|
|
487
|
+
}, _callee3, null, [[2, 23]]);
|
|
431
488
|
}));
|
|
432
489
|
return function (_x) {
|
|
433
490
|
return _ref3.apply(this, arguments);
|
|
434
491
|
};
|
|
435
492
|
}());
|
|
436
|
-
case
|
|
493
|
+
case 12:
|
|
437
494
|
return _context4.abrupt("return", _context4.sent);
|
|
438
|
-
case
|
|
439
|
-
_context4.prev =
|
|
440
|
-
|
|
495
|
+
case 13:
|
|
496
|
+
_context4.prev = 13;
|
|
497
|
+
_logParams = {
|
|
498
|
+
eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
|
|
499
|
+
errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
|
|
500
|
+
errormessage: (_recordResult3 = recordResult) === null || _recordResult3 === void 0 || (_recordResult3 = _recordResult3.error) === null || _recordResult3 === void 0 ? void 0 : _recordResult3.message,
|
|
501
|
+
needChangeSessionForRetry: (_recordResult4 = recordResult) === null || _recordResult4 === void 0 || (_recordResult4 = _recordResult4.error) === null || _recordResult4 === void 0 ? void 0 : _recordResult4.needChangeSessionForRetry,
|
|
502
|
+
rpcTraceId: (_recordResult5 = recordResult) === null || _recordResult5 === void 0 || (_recordResult5 = _recordResult5.error) === null || _recordResult5 === void 0 ? void 0 : _recordResult5.traceId,
|
|
503
|
+
msg: safeStringify(recordResult)
|
|
504
|
+
};
|
|
505
|
+
this.elementEventCenter.endEvent(startEventId, _logParams);
|
|
441
506
|
this.changeLoading(false);
|
|
442
|
-
return _context4.finish(
|
|
443
|
-
case
|
|
507
|
+
return _context4.finish(13);
|
|
508
|
+
case 18:
|
|
444
509
|
case "end":
|
|
445
510
|
return _context4.stop();
|
|
446
511
|
}
|
|
447
|
-
}, _callee4, this, [[
|
|
512
|
+
}, _callee4, this, [[9,, 13, 18]]);
|
|
448
513
|
}));
|
|
449
514
|
function submitPayment() {
|
|
450
515
|
return _submitPayment.apply(this, arguments);
|
|
@@ -499,6 +564,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
499
564
|
handleRedirect(data, false, onEventCallback);
|
|
500
565
|
});
|
|
501
566
|
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
|
567
|
+
_this4.changeLoading(false);
|
|
502
568
|
_this4.setControllerStatusOrView(IElementStatus.READY);
|
|
503
569
|
_this4.destroyHandle();
|
|
504
570
|
});
|
|
@@ -534,7 +600,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
534
600
|
value: function () {
|
|
535
601
|
var _sendRequestAndWaitWebLaunch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(renderOptions, readyCallback) {
|
|
536
602
|
var _this5 = this;
|
|
537
|
-
var type, options, containerService, _yield$Promise$all, _yield$Promise$all2, _, obtainDataResult,
|
|
603
|
+
var type, options, containerService, _yield$Promise$all, _yield$Promise$all2, _, obtainDataResult, errorResult;
|
|
538
604
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
539
605
|
while (1) switch (_context5.prev = _context5.next) {
|
|
540
606
|
case 0:
|
|
@@ -545,7 +611,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
545
611
|
_context5.next = 7;
|
|
546
612
|
break;
|
|
547
613
|
}
|
|
548
|
-
this.handleInitializationError();
|
|
614
|
+
this.handleInitializationError(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CONTAINER_NOT_EXIST);
|
|
549
615
|
// 容器服务不存在,直接返回
|
|
550
616
|
readyCallback({
|
|
551
617
|
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
@@ -559,23 +625,24 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
559
625
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
560
626
|
_ = _yield$Promise$all2[0];
|
|
561
627
|
obtainDataResult = _yield$Promise$all2[1];
|
|
628
|
+
this.serviceMap.Log.logInfo({
|
|
629
|
+
title: 'sdk_event_webAppOnLaunch'
|
|
630
|
+
});
|
|
562
631
|
containerService === null || containerService === void 0 || containerService.switchContainerStatus(IContainerStatus.READY);
|
|
563
|
-
|
|
564
|
-
if (
|
|
632
|
+
errorResult = this.getErrorFromResponse(obtainDataResult);
|
|
633
|
+
if (errorResult) {
|
|
565
634
|
// 仅结束resove,传出回调码
|
|
566
|
-
readyCallback(
|
|
567
|
-
error: error
|
|
568
|
-
});
|
|
635
|
+
readyCallback(errorResult);
|
|
569
636
|
}
|
|
570
637
|
if (this.areAllContainersReady()) {
|
|
571
638
|
this.elementContainerService.getContainerServices().forEach(function (_, key) {
|
|
572
639
|
_this5.sendReady(key, options);
|
|
573
640
|
});
|
|
574
641
|
}
|
|
575
|
-
_context5.next =
|
|
642
|
+
_context5.next = 24;
|
|
576
643
|
break;
|
|
577
|
-
case
|
|
578
|
-
_context5.prev =
|
|
644
|
+
case 20:
|
|
645
|
+
_context5.prev = 20;
|
|
579
646
|
_context5.t0 = _context5["catch"](1);
|
|
580
647
|
this.handleInitializationError();
|
|
581
648
|
readyCallback({
|
|
@@ -583,11 +650,11 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
583
650
|
traceId: _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.traceId
|
|
584
651
|
})
|
|
585
652
|
});
|
|
586
|
-
case
|
|
653
|
+
case 24:
|
|
587
654
|
case "end":
|
|
588
655
|
return _context5.stop();
|
|
589
656
|
}
|
|
590
|
-
}, _callee5, this, [[1,
|
|
657
|
+
}, _callee5, this, [[1, 20]]);
|
|
591
658
|
}));
|
|
592
659
|
function sendRequestAndWaitWebLaunch(_x4, _x5) {
|
|
593
660
|
return _sendRequestAndWaitWebLaunch.apply(this, arguments);
|
|
@@ -600,14 +667,33 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
600
667
|
if (isLoadErrorPage(response === null || response === void 0 ? void 0 : response.originActionQueryResult)) {
|
|
601
668
|
var _response$originActio = response.originActionQueryResult,
|
|
602
669
|
traceId = _response$originActio.traceId,
|
|
603
|
-
errorCode = _response$originActio.errorCode
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
670
|
+
errorCode = _response$originActio.errorCode,
|
|
671
|
+
errorMessage = _response$originActio.errorMessage;
|
|
672
|
+
var error = {
|
|
673
|
+
code: errorCode,
|
|
674
|
+
message: errorMessage || ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED.message
|
|
675
|
+
};
|
|
676
|
+
if (!errorCode) {
|
|
677
|
+
error = _objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED);
|
|
607
678
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
679
|
+
if (PROMISE_CALLBACK_CODE[errorCode]) {
|
|
680
|
+
var _PROMISE_CALLBACK_COD;
|
|
681
|
+
error = {
|
|
682
|
+
code: PROMISE_CALLBACK_CODE[errorCode].code,
|
|
683
|
+
message: ((_PROMISE_CALLBACK_COD = PROMISE_CALLBACK_CODE[errorCode]) === null || _PROMISE_CALLBACK_COD === void 0 ? void 0 : _PROMISE_CALLBACK_COD.message) || errorMessage
|
|
684
|
+
};
|
|
685
|
+
} else {
|
|
686
|
+
this.serviceMap.Log.logError({
|
|
687
|
+
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
688
|
+
}, {
|
|
689
|
+
rpcTraceId: traceId
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
return {
|
|
693
|
+
error: _objectSpread(_objectSpread({}, error), {}, {
|
|
694
|
+
traceId: traceId !== null && traceId !== void 0 ? traceId : ''
|
|
695
|
+
})
|
|
696
|
+
};
|
|
611
697
|
}
|
|
612
698
|
return null;
|
|
613
699
|
}
|
|
@@ -21,7 +21,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
21
21
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
22
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
23
|
import { parseSessionData } from "../..";
|
|
24
|
-
import
|
|
24
|
+
import { ADDRESSElementAppVersion } from "../../../../config";
|
|
25
25
|
import { ProductSceneEnum } from "../../../../types";
|
|
26
26
|
import { generateIframeSrc as _generateIframeSrc } from "../util";
|
|
27
27
|
import BaseElementProcessor from "./baseElementProcessor";
|
|
@@ -95,8 +95,7 @@ var AddressProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
95
95
|
environment = _this$options.env.environment,
|
|
96
96
|
analytics = _this$options.analytics,
|
|
97
97
|
locale = _this$options.locale;
|
|
98
|
-
var
|
|
99
|
-
var pageUrl = "/element-address/".concat(version, "/pages/address/index.html");
|
|
98
|
+
var pageUrl = "/element-address/".concat(ADDRESSElementAppVersion, "/pages/address/index.html");
|
|
100
99
|
return _generateIframeSrc({
|
|
101
100
|
paymentSession: paymentSession,
|
|
102
101
|
paymentSessionObj: paymentSessionObj,
|
|
@@ -17,8 +17,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
17
17
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
18
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
19
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
20
|
+
import { AUTHElementAppVersion } from "../../../../config";
|
|
20
21
|
import { parseSessionData } from "../../index";
|
|
21
|
-
import PackageJson from "../../../../../package.json";
|
|
22
22
|
import { generateIframeSrc as _generateIframeSrc } from "../util";
|
|
23
23
|
import BaseElementProcessor from "./baseElementProcessor";
|
|
24
24
|
var AuthProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
@@ -69,8 +69,7 @@ var AuthProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
69
69
|
environment = _this$options.env.environment,
|
|
70
70
|
analytics = _this$options.analytics,
|
|
71
71
|
locale = _this$options.locale;
|
|
72
|
-
var
|
|
73
|
-
var pageUrl = "/auth-element/".concat(version, "/pages/element_auth/index.html");
|
|
72
|
+
var pageUrl = "/auth-element/".concat(AUTHElementAppVersion, "/pages/element_auth/index.html");
|
|
74
73
|
return _generateIframeSrc({
|
|
75
74
|
paymentSession: paymentSession,
|
|
76
75
|
paymentSessionObj: paymentSessionObj,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { LogService } from '../../../../foundation/service/log';
|
|
1
2
|
import BaseElementProcessor from './baseElementProcessor';
|
|
2
3
|
declare class PaymentProcessor extends BaseElementProcessor {
|
|
3
4
|
private ApplePayService;
|
|
4
5
|
onReady(extraParam: any): void;
|
|
6
|
+
getLogger(): LogService;
|
|
5
7
|
private addEventListener;
|
|
6
8
|
private initApplePaySdk;
|
|
7
9
|
beforeMount(): void;
|
|
@@ -23,7 +23,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
23
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; }
|
|
24
24
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
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
|
|
26
|
+
import { AMSPaymentElementAppVersion } from "../../../../config";
|
|
27
27
|
import { EVENT } from "../../../../constant";
|
|
28
28
|
import { ServiceProvider } from "../../../../foundation/service";
|
|
29
29
|
import { ApplePaySdk, handleGooglePay, isSkipRenderPaymentMethod } from "../../../../plugin/component/channel";
|
|
@@ -31,7 +31,7 @@ import { queryParse } from "../../../../util";
|
|
|
31
31
|
import { LogConfig, Logger } from "../../../../util/logger";
|
|
32
32
|
import { parseSessionData } from "../../index";
|
|
33
33
|
import { oneAccount, sdkAction } from "../mock";
|
|
34
|
-
import { generateIframeSrc as _generateIframeSrc, isElementPad, isElementPC } from "../util";
|
|
34
|
+
import { generateIframeSrc as _generateIframeSrc, isElementPad, isElementPC, safeStringify } from "../util";
|
|
35
35
|
import BaseElementProcessor from "./baseElementProcessor";
|
|
36
36
|
var logger = new Logger(LogConfig, true);
|
|
37
37
|
var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
@@ -54,6 +54,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
54
54
|
value: function onReady(extraParam) {
|
|
55
55
|
var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
|
|
56
56
|
var paymentContext = this.elementContainer.getPaymentContext();
|
|
57
|
+
this.getLogger().logInfo({
|
|
58
|
+
title: 'sdk_event_renderComponent'
|
|
59
|
+
});
|
|
57
60
|
this.eventCenter.dispatchToApp({
|
|
58
61
|
event: 'renderComponent',
|
|
59
62
|
data: {
|
|
@@ -80,6 +83,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
80
83
|
}
|
|
81
84
|
});
|
|
82
85
|
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "getLogger",
|
|
88
|
+
value: function getLogger() {
|
|
89
|
+
return ServiceProvider.getInstance(this.instanceId).getService('Log');
|
|
90
|
+
}
|
|
83
91
|
}, {
|
|
84
92
|
key: "addEventListener",
|
|
85
93
|
value: function addEventListener() {
|
|
@@ -215,13 +223,12 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
215
223
|
locale = _this$options.locale;
|
|
216
224
|
var _ref3 = paymentSessionObj || {},
|
|
217
225
|
extendInfo = _ref3.extendInfo;
|
|
218
|
-
var
|
|
219
|
-
var pageUrl = "/elements/".concat(version, "/pages/element_payment/index.html");
|
|
226
|
+
var pageUrl = "/elements/".concat(AMSPaymentElementAppVersion, "/pages/element_payment/index.html");
|
|
220
227
|
try {
|
|
221
228
|
var _JSON$parse;
|
|
222
229
|
var expressCheckout = JSON.parse((_JSON$parse = JSON.parse(extendInfo)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.expressCheckout);
|
|
223
230
|
if (expressCheckout) {
|
|
224
|
-
pageUrl = "/elements/".concat(
|
|
231
|
+
pageUrl = "/elements/".concat(AMSPaymentElementAppVersion, "/pages/express_checkout/index.html");
|
|
225
232
|
}
|
|
226
233
|
} catch (error) {}
|
|
227
234
|
var url = _generateIframeSrc({
|
|
@@ -242,7 +249,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
242
249
|
key: "obtainData",
|
|
243
250
|
value: function () {
|
|
244
251
|
var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
245
|
-
var _paymentSessionObj$co
|
|
252
|
+
var _paymentSessionObj$co,
|
|
253
|
+
_this3 = this;
|
|
246
254
|
var requestService, _this$elementContaine8, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options2, environment, locale, _ref4, paymentSessionConfig, hostSign, isConnect, LOCAL_MOCK, _queryParse, appType, terminalType, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
|
|
247
255
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
248
256
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -292,9 +300,31 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
292
300
|
// TODO dev环境接口超时
|
|
293
301
|
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
|
294
302
|
}).then(function (result) {
|
|
303
|
+
if (!result.success) {
|
|
304
|
+
_this3.getLogger().logError({
|
|
305
|
+
title: 'sdk_event_sdkQuery_failed'
|
|
306
|
+
}, {
|
|
307
|
+
config: safeStringify(paymentSessionConfig),
|
|
308
|
+
errorMessage: safeStringify((result === null || result === void 0 ? void 0 : result.errorMessage) || ''),
|
|
309
|
+
rpcTraceId: result === null || result === void 0 ? void 0 : result.traceId
|
|
310
|
+
});
|
|
311
|
+
} else {
|
|
312
|
+
_this3.getLogger().logInfo({
|
|
313
|
+
title: 'sdk_event_sdkQueryEnd'
|
|
314
|
+
}, {
|
|
315
|
+
config: safeStringify(paymentSessionConfig),
|
|
316
|
+
rpcTraceId: result === null || result === void 0 ? void 0 : result.traceId
|
|
317
|
+
});
|
|
318
|
+
}
|
|
295
319
|
resolve(result);
|
|
296
320
|
}, function (e) {
|
|
297
321
|
reject(e);
|
|
322
|
+
_this3.getLogger().logError({
|
|
323
|
+
title: 'sdk_event_sdkQuery_failed'
|
|
324
|
+
}, {
|
|
325
|
+
config: safeStringify(paymentSessionConfig),
|
|
326
|
+
errorMessage: safeStringify(e)
|
|
327
|
+
});
|
|
298
328
|
});
|
|
299
329
|
});
|
|
300
330
|
};
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IElementOptions, PaymentMountOptions } from './type';
|
|
2
2
|
export declare class ElementComponent {
|
|
3
3
|
private options;
|
|
4
4
|
private controller;
|
|
5
5
|
constructor(options: IElementOptions);
|
|
6
6
|
updatePayment(paymentSessionData: any): Promise<unknown>;
|
|
7
|
-
mount(renderOptions:
|
|
8
|
-
mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
|
9
|
-
mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
|
|
7
|
+
mount(renderOptions: PaymentMountOptions, sdkSelector: string): Promise<import("./type").ICommonApiResponse>;
|
|
10
8
|
validateFields(): Promise<{
|
|
11
9
|
isValid: boolean;
|
|
12
10
|
}>;
|
|
13
|
-
submitPayment(): Promise<import("./type").
|
|
14
|
-
error: {
|
|
15
|
-
code: string;
|
|
16
|
-
message: string;
|
|
17
|
-
};
|
|
18
|
-
}>;
|
|
11
|
+
submitPayment(): Promise<import("./type").IPaymentApiResponse>;
|
|
19
12
|
destroy(): void;
|
|
20
13
|
}
|
|
@@ -43,7 +43,10 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
43
43
|
return _updatePayment.apply(this, arguments);
|
|
44
44
|
}
|
|
45
45
|
return updatePayment;
|
|
46
|
-
}()
|
|
46
|
+
}() // 暂不透出 link 和 address element
|
|
47
|
+
// mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
|
|
48
|
+
// mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
|
49
|
+
// mount(renderOptions: PaymentMountOptions, sdkSelector: string);
|
|
47
50
|
}, {
|
|
48
51
|
key: "mount",
|
|
49
52
|
value: function mount(renderOptions, sdkSelector) {
|