@alipay/ams-checkout 0.0.1744283958-dev.9 → 0.0.1744698677-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/core/component/element/elementContainerService/containerService.js +2 -1
- package/esm/core/component/element/elementController/index.d.ts +2 -0
- package/esm/core/component/element/elementController/index.js +41 -13
- package/esm/core/component/element/elementProcessor/addressProcessor.js +20 -5
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +2 -1
- package/esm/core/component/element/mock.d.ts +2 -0
- package/esm/core/component/element/mock.js +5 -1
- package/esm/foundation/service/log/keys.js +3 -1
- package/package.json +1 -1
@@ -7,6 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
7
7
|
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); }
|
8
8
|
import { EVENT } from "../../../../constant";
|
9
9
|
import { ServiceProvider } from "./../../../../foundation/service";
|
10
|
+
import { device } from "../../../../util";
|
10
11
|
import { DisplayTypeEnum, PlatformEnum, ProductSceneEnum } from "./../../../../types";
|
11
12
|
export var IContainerStatus = /*#__PURE__*/function (IContainerStatus) {
|
12
13
|
IContainerStatus["UNINIT"] = "UNINIT";
|
@@ -42,7 +43,7 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
42
43
|
});
|
43
44
|
this.containerElement = this.containerService.load({
|
44
45
|
type: DisplayTypeEnum.inline,
|
45
|
-
platform: PlatformEnum.desktop,
|
46
|
+
platform: device.isMobile ? PlatformEnum.mobile : PlatformEnum.desktop,
|
46
47
|
isRetention: false,
|
47
48
|
selector: selector,
|
48
49
|
appendAliasContainerId: true,
|
@@ -7,6 +7,7 @@ declare class ElementController {
|
|
7
7
|
private elementProcessors;
|
8
8
|
private initTimeout;
|
9
9
|
private elementContainerService;
|
10
|
+
private onStatusChangeCallback;
|
10
11
|
constructor(options: IElementOptions);
|
11
12
|
private initService;
|
12
13
|
private initElementProcessors;
|
@@ -21,5 +22,6 @@ declare class ElementController {
|
|
21
22
|
updatePayment(paymentSessionData: any): Promise<unknown>;
|
22
23
|
private destroyHandle;
|
23
24
|
destroy(): void;
|
25
|
+
private setControllerStatusOrView;
|
24
26
|
}
|
25
27
|
export default ElementController;
|
@@ -23,9 +23,10 @@ import { EVENT } from "../../../../constant";
|
|
23
23
|
import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
|
24
24
|
import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
|
25
25
|
import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
|
26
|
+
import { IElementStatus } from "../../../../foundation";
|
26
27
|
import { AntomSDKCore } from "../../../../foundation/core";
|
27
28
|
import { ElementProcessor } from "../../../../foundation/product-processor/element";
|
28
|
-
import {
|
29
|
+
import { cleanMockup, removeRetentionPopup } from "../../../../component/component.popup.style";
|
29
30
|
import { ProductSceneEnum } from "../../../../types";
|
30
31
|
import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
|
31
32
|
import { IContainerStatus } from "../elementContainerService/containerService";
|
@@ -45,6 +46,8 @@ var ElementController = /*#__PURE__*/function () {
|
|
45
46
|
_defineProperty(this, "elementProcessors", void 0);
|
46
47
|
_defineProperty(this, "initTimeout", void 0);
|
47
48
|
_defineProperty(this, "elementContainerService", void 0);
|
49
|
+
// 新增变量
|
50
|
+
_defineProperty(this, "onStatusChangeCallback", void 0);
|
48
51
|
_defineProperty(this, "onValidateFunc", function (event, target, params) {
|
49
52
|
return new Promise(function (resolve) {
|
50
53
|
event.emitAndListen({
|
@@ -60,6 +63,8 @@ var ElementController = /*#__PURE__*/function () {
|
|
60
63
|
});
|
61
64
|
});
|
62
65
|
this.options = options;
|
66
|
+
var _options = options;
|
67
|
+
this.onStatusChangeCallback = _options === null || _options === void 0 ? void 0 : _options.onStatusChangeCallback;
|
63
68
|
this.elementContainer = new AntomSDKCore();
|
64
69
|
this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor());
|
65
70
|
this.elementContainer.init(this.options, ProductSceneEnum.ELEMENT_PAYMENT);
|
@@ -67,7 +72,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
67
72
|
this.elementContainerService = new ElementContainerService({
|
68
73
|
instanceId: this.elementContainer.getInstanceId()
|
69
74
|
});
|
70
|
-
this.
|
75
|
+
this.setControllerStatusOrView(IElementStatus.READY);
|
71
76
|
}
|
72
77
|
_createClass(ElementController, [{
|
73
78
|
key: "initService",
|
@@ -127,7 +132,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
127
132
|
clearTimeout(_this.initTimeout);
|
128
133
|
_this.initTimeout = null;
|
129
134
|
_this.changeLoading(false);
|
130
|
-
_this.
|
135
|
+
_this.setControllerStatusOrView(IElementStatus.READY);
|
131
136
|
_this.elementContainerService.getContainerServices().forEach(function (value) {
|
132
137
|
value.getContainerElement().remove();
|
133
138
|
});
|
@@ -143,6 +148,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
143
148
|
if (cashier && renderOptions.sessionData) {
|
144
149
|
startBizFlowData.paymentSession = renderOptions.sessionData;
|
145
150
|
}
|
151
|
+
_this.setControllerStatusOrView(IElementStatus.IN_BIZ_FLOW);
|
146
152
|
_this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
|
147
153
|
_this.onEventCallback({
|
148
154
|
code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
|
@@ -291,14 +297,14 @@ var ElementController = /*#__PURE__*/function () {
|
|
291
297
|
// (containerService) => containerService.getContainerStatus() === IContainerStatus.IN_BIZ_FLOW,
|
292
298
|
// );
|
293
299
|
// if (allContainersInBizFlow) {
|
294
|
-
// this.
|
300
|
+
// this.setControllerStatusOrView(IContainerStatus.IN_BIZ_FLOW);
|
295
301
|
// }
|
296
302
|
});
|
297
303
|
this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
|
298
304
|
handleRedirect(data);
|
299
305
|
});
|
300
306
|
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
301
|
-
_this4.
|
307
|
+
_this4.setControllerStatusOrView(IElementStatus.READY);
|
302
308
|
_this4.destroyHandle();
|
303
309
|
});
|
304
310
|
this.serviceMap.EventCenter.listen(EVENT.webAppReady.name, function (data) {
|
@@ -343,8 +349,20 @@ var ElementController = /*#__PURE__*/function () {
|
|
343
349
|
}, {
|
344
350
|
key: "sendReady",
|
345
351
|
value: function sendReady(type, options) {
|
346
|
-
var _this$elementProcesso;
|
352
|
+
var _this$elementProcesso, _paymentResult$origin;
|
347
353
|
var paymentResult = (_this$elementProcesso = this.elementProcessors[ElementType.payment]) === null || _this$elementProcesso === void 0 ? void 0 : _this$elementProcesso.getObtainDataRes();
|
354
|
+
if (!(paymentResult !== null && paymentResult !== void 0 && (_paymentResult$origin = paymentResult.originActionQueryResult) !== null && _paymentResult$origin !== void 0 && _paymentResult$origin.success)) {
|
355
|
+
var _this$options$onEvent, _this$options;
|
356
|
+
clearTimeout(this.initTimeout);
|
357
|
+
this.changeLoading(false);
|
358
|
+
this.initTimeout = null;
|
359
|
+
(_this$options$onEvent = (_this$options = this.options).onEventCallback) === null || _this$options$onEvent === void 0 || _this$options$onEvent.call(_this$options, {
|
360
|
+
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
361
|
+
message: 'Component initialization exception.'
|
362
|
+
});
|
363
|
+
this.destroy();
|
364
|
+
return;
|
365
|
+
}
|
348
366
|
var paymentContext = this.elementContainer.getPaymentContext();
|
349
367
|
var params = _objectSpread(_objectSpread({}, options), {}, {
|
350
368
|
originActionQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originActionQueryResult,
|
@@ -428,19 +446,29 @@ var ElementController = /*#__PURE__*/function () {
|
|
428
446
|
}, {
|
429
447
|
key: "destroyHandle",
|
430
448
|
value: function destroyHandle() {
|
449
|
+
var _this7 = this;
|
431
450
|
this.elementContainer.destroy();
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
}
|
451
|
+
cleanMockup();
|
452
|
+
removeRetentionPopup();
|
453
|
+
setTimeout(function () {
|
454
|
+
_this7.serviceMap.EventCenter.cleanIFrames();
|
455
|
+
_this7.elementContainerService.destroy();
|
456
|
+
}, 0);
|
438
457
|
}
|
439
458
|
}, {
|
440
459
|
key: "destroy",
|
441
460
|
value: function destroy() {
|
442
461
|
this.destroyHandle();
|
443
|
-
this.
|
462
|
+
this.setControllerStatusOrView(IElementStatus.DESTROYED);
|
463
|
+
}
|
464
|
+
}, {
|
465
|
+
key: "setControllerStatusOrView",
|
466
|
+
value: function setControllerStatusOrView(status) {
|
467
|
+
var _this$onStatusChangeC;
|
468
|
+
var _status = this.elementContainer.getStatus();
|
469
|
+
if (status === _status) return;
|
470
|
+
(_this$onStatusChangeC = this.onStatusChangeCallback) === null || _this$onStatusChangeC === void 0 || _this$onStatusChangeC.call(this, "\u72B6\u6001\u7531 ".concat(_status, " \u53D8\u66F4\u4E3A ").concat(status));
|
471
|
+
this.elementContainer.setStatus(status);
|
444
472
|
}
|
445
473
|
}]);
|
446
474
|
return ElementController;
|
@@ -5,6 +5,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
5
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
6
6
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
7
7
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
10
|
+
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; }
|
8
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9
12
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
10
13
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
@@ -17,6 +20,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
17
20
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
18
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; } }
|
19
22
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
23
|
+
import { ProductSceneEnum } from "../../../../types";
|
20
24
|
import { parseSessionData } from "../..";
|
21
25
|
import PackageJson from "../../../../../package.json";
|
22
26
|
import { generateIframeSrc as _generateIframeSrc } from "../util";
|
@@ -31,21 +35,32 @@ var AddressProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
31
35
|
_createClass(AddressProcessor, [{
|
32
36
|
key: "onReady",
|
33
37
|
value: function onReady(extraParam) {
|
34
|
-
var
|
38
|
+
var _paymentSessionObj$pa, _extraParam$originOne;
|
39
|
+
var paymentContext = this.elementContainer.getPaymentContext();
|
40
|
+
var paymentSessionObj = paymentContext.paymentSessionObj,
|
41
|
+
paymentSessionId = paymentContext.paymentSessionId,
|
42
|
+
displayInfo = paymentContext.displayInfo;
|
43
|
+
var isConnect = paymentSessionObj.connectFactor.enableConnect && ((_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
|
35
44
|
this.eventCenter.dispatchToApp({
|
36
45
|
event: 'renderComponent',
|
37
46
|
data: {
|
38
47
|
params: {
|
39
48
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
40
|
-
paymentSessionData:
|
49
|
+
paymentSessionData: paymentSessionId,
|
41
50
|
queryResult: extraParam.queryResult,
|
42
51
|
envInfo: {
|
43
52
|
screenHeight: screen.height,
|
44
53
|
screenWidth: screen.width
|
45
54
|
},
|
46
|
-
|
47
|
-
|
48
|
-
|
55
|
+
configParams: _objectSpread({
|
56
|
+
needEditBackBtn: isConnect,
|
57
|
+
autoSaveAsDefaultAddress: isConnect,
|
58
|
+
editingNeedShippingQuery: isConnect,
|
59
|
+
showTitle: isConnect
|
60
|
+
}, extraParam.configParams),
|
61
|
+
appearance: displayInfo.appearance,
|
62
|
+
sessionResult: paymentSessionObj,
|
63
|
+
prefillValue: extraParam !== null && extraParam !== void 0 && extraParam.originOneAccountQueryResult ? extraParam === null || extraParam === void 0 || (_extraParam$originOne = extraParam.originOneAccountQueryResult) === null || _extraParam$originOne === void 0 ? void 0 : _extraParam$originOne.shippings : extraParam.prefillValue
|
49
64
|
},
|
50
65
|
target: 'ADDRESS_ELEMENT'
|
51
66
|
}
|
@@ -73,7 +73,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
73
73
|
appearance: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.displayInfo.appearance,
|
74
74
|
sessionResult: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionObj,
|
75
75
|
notRedirectAfterComplete: (extraParam === null || extraParam === void 0 ? void 0 : extraParam.notRedirectAfterComplete) === true,
|
76
|
-
merchantAppointParam: extraParam === null || extraParam === void 0 ? void 0 : extraParam.merchantAppointParam
|
76
|
+
merchantAppointParam: extraParam === null || extraParam === void 0 ? void 0 : extraParam.merchantAppointParam,
|
77
|
+
originOneAccountQueryResult: extraParam === null || extraParam === void 0 ? void 0 : extraParam.originOneAccountQueryResult
|
77
78
|
}
|
78
79
|
});
|
79
80
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export var
|
1
|
+
export var sdkAction1 = {
|
2
2
|
accountInfo: {
|
3
3
|
accountStatus: 'EFFECTIVE',
|
4
4
|
email: 'test10@test.com'
|
@@ -361,6 +361,10 @@ export var sdkAction = {
|
|
361
361
|
},
|
362
362
|
success: true
|
363
363
|
};
|
364
|
+
export var sdkAction2 = {
|
365
|
+
success: false
|
366
|
+
};
|
367
|
+
export var sdkAction = sdkAction1;
|
364
368
|
export var oneAccount1 = {
|
365
369
|
accountInfo: {
|
366
370
|
accountStatus: 'EFFECTIVE',
|
@@ -89,7 +89,9 @@ _defineProperty(LogComplianceExtendKeys, "complianceExtParams", {
|
|
89
89
|
// M 数字类型
|
90
90
|
timeCost: 'M',
|
91
91
|
pageLoadProgress: 'M',
|
92
|
-
fsDuration: 'M'
|
92
|
+
fsDuration: 'M',
|
93
|
+
// 由于部分logerror参数是msg
|
94
|
+
msg: 'C'
|
93
95
|
});
|
94
96
|
export var KEYS = {
|
95
97
|
EVENT_SDK_ON_ABNORMAL_EVENT_NAME: {
|