@alipay/ams-checkout 0.0.1726734012-dev.1 → 0.0.1726734012-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/channel.d.ts +19 -0
- package/esm/component/channel.js +87 -0
- package/esm/component/component.inline.style.d.ts +10 -0
- package/esm/component/component.inline.style.js +121 -0
- package/esm/component/component.popup.style.d.ts +25 -0
- package/esm/component/component.popup.style.js +203 -0
- package/esm/component/popupWindow.style.d.ts +11 -0
- package/esm/component/popupWindow.style.js +121 -0
- package/esm/config/index.d.ts +11 -0
- package/esm/config/index.js +20 -1
- package/esm/constant/index.d.ts +25 -0
- package/esm/constant/index.js +28 -0
- package/esm/core/bus/index.d.ts +3 -3
- package/esm/core/bus/index.js +14 -14
- package/esm/core/component/address.d.ts +8 -0
- package/esm/core/component/address.js +72 -0
- package/esm/core/component/appPreloadProcessing.js +2 -2
- package/esm/core/component/ckp/index.js +12 -8
- package/esm/core/component/element/components/address.d.ts +19 -0
- package/esm/core/component/element/components/address.js +68 -0
- package/esm/core/component/element/components/auth.d.ts +17 -0
- package/esm/core/component/element/components/auth.js +60 -0
- package/esm/core/component/element/components/payment.d.ts +19 -0
- package/esm/core/component/element/components/payment.js +74 -0
- package/esm/core/component/element/index.d.ts +47 -0
- package/esm/core/component/element/index.js +817 -0
- package/esm/core/component/element/mock.d.ts +4 -0
- package/esm/core/component/element/mock.js +491 -0
- package/esm/core/component/element/type.d.ts +191 -0
- package/esm/core/component/element/type.js +36 -0
- package/esm/core/component/element/utils.d.ts +13 -0
- package/esm/core/component/element/utils.js +6 -0
- package/esm/core/component/index.d.ts +12 -7
- package/esm/core/component/index.js +132 -78
- package/esm/core/drop-in/index.js +2 -2
- package/esm/core/instance/index.d.ts +1 -0
- package/esm/core/instance/index.js +24 -11
- package/esm/foundation/core/index.d.ts +28 -0
- package/esm/foundation/core/index.js +396 -0
- package/esm/foundation/index.d.ts +75 -0
- package/esm/foundation/index.js +42 -0
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +18 -0
- package/esm/foundation/product-processor/easysafepay/deps.js +12 -0
- package/esm/foundation/product-processor/easysafepay/index.d.ts +26 -0
- package/esm/foundation/product-processor/easysafepay/index.js +464 -0
- package/esm/foundation/service/api-bus/ability/callback.d.ts +9 -0
- package/esm/foundation/service/api-bus/ability/callback.js +55 -0
- package/esm/foundation/service/api-bus/ability/globalData.d.ts +10 -0
- package/esm/foundation/service/api-bus/ability/globalData.js +89 -0
- package/esm/foundation/service/api-bus/ability/request.d.ts +10 -0
- package/esm/foundation/service/api-bus/ability/request.js +151 -0
- package/esm/foundation/service/api-bus/ability/security.d.ts +12 -0
- package/esm/foundation/service/api-bus/ability/security.js +161 -0
- package/esm/foundation/service/api-bus/ability/tracker.d.ts +9 -0
- package/esm/foundation/service/api-bus/ability/tracker.js +80 -0
- package/esm/foundation/service/api-bus/busManager.d.ts +127 -0
- package/esm/foundation/service/api-bus/busManager.js +398 -0
- package/esm/foundation/service/api-bus/index.d.ts +20 -0
- package/esm/foundation/service/api-bus/index.js +88 -0
- package/esm/foundation/service/api-bus/interface.d.ts +48 -0
- package/esm/foundation/service/api-bus/interface.js +54 -0
- package/esm/foundation/service/container/index.d.ts +32 -0
- package/esm/foundation/service/container/index.js +330 -0
- package/esm/foundation/service/container/popup.d.ts +17 -0
- package/esm/foundation/service/container/popup.js +103 -0
- package/esm/foundation/service/container/utils.d.ts +7 -0
- package/esm/foundation/service/container/utils.js +48 -0
- package/esm/foundation/service/event-center.d.ts +82 -0
- package/esm/foundation/service/event-center.js +274 -0
- package/esm/foundation/service/global-data/index.d.ts +11 -0
- package/esm/foundation/service/global-data/index.js +68 -0
- package/esm/foundation/service/index.d.ts +19 -0
- package/esm/foundation/service/index.js +82 -0
- package/esm/foundation/service/log/index.d.ts +43 -0
- package/esm/foundation/service/log/index.js +250 -0
- package/esm/foundation/service/log/keys.d.ts +13 -0
- package/esm/foundation/service/log/keys.js +103 -0
- package/esm/foundation/service/log/processor.d.ts +9 -0
- package/esm/foundation/service/log/processor.js +148 -0
- package/esm/foundation/service/log/types.d.ts +32 -0
- package/esm/foundation/service/log/types.js +1 -0
- package/esm/foundation/service/requester/deps.d.ts +17 -0
- package/esm/foundation/service/requester/deps.js +11 -0
- package/esm/foundation/service/requester/requester.d.ts +22 -0
- package/esm/foundation/service/requester/requester.js +217 -0
- package/esm/foundation/service/security/index.d.ts +28 -0
- package/esm/foundation/service/security/index.js +284 -0
- package/esm/foundation/service/security/security.d.ts +33 -0
- package/esm/foundation/service/security/security.js +182 -0
- package/esm/foundation/utils/gray_scale_utils.d.ts +7 -0
- package/esm/foundation/utils/gray_scale_utils.js +40 -0
- package/esm/foundation/utils/payment_context_utils.d.ts +13 -0
- package/esm/foundation/utils/payment_context_utils.js +57 -0
- package/esm/foundation/utils/payment_product_utils.d.ts +13 -0
- package/esm/foundation/utils/payment_product_utils.js +38 -0
- package/esm/foundation/utils/redirect_utils.d.ts +11 -0
- package/esm/foundation/utils/redirect_utils.js +262 -0
- package/esm/foundation/utils/system_events.d.ts +4 -0
- package/esm/foundation/utils/system_events.js +66 -0
- package/esm/foundation/utils/web_app_url_utils.d.ts +46 -0
- package/esm/foundation/utils/web_app_url_utils.js +112 -0
- package/esm/index.d.ts +19 -12
- package/esm/index.js +110 -56
- package/esm/plugin/applepay/component.js +13 -11
- package/esm/plugin/applepay/index.js +10 -6
- package/esm/plugin/applepay/service.d.ts +2 -2
- package/esm/plugin/applepay/service.js +26 -18
- package/esm/plugin/component/cashierApp.d.ts +10 -8
- package/esm/plugin/component/cashierApp.js +48 -11
- package/esm/plugin/component/channel.d.ts +4 -3
- package/esm/plugin/component/channel.js +39 -2
- package/esm/plugin/component/component.inline.style.d.ts +9 -10
- package/esm/plugin/component/component.inline.style.js +93 -10
- package/esm/plugin/component/component.popup.style.d.ts +15 -6
- package/esm/plugin/component/component.popup.style.js +30 -7
- package/esm/plugin/component/index.d.ts +14 -8
- package/esm/plugin/component/index.js +383 -187
- package/esm/plugin/component/popupWindow.style.d.ts +5 -2
- package/esm/plugin/component/popupWindow.style.js +70 -14
- package/esm/plugin/const.js +5 -5
- package/esm/plugin/drop-in/index.d.ts +5 -5
- package/esm/plugin/drop-in/index.js +7 -7
- package/esm/plugin/payment-element/utils.d.ts +2 -0
- package/esm/plugin/payment-element/utils.js +6 -0
- package/esm/plugin/paypal/index.js +2 -1
- package/esm/plugin/type.d.ts +4 -3
- package/esm/service/element.d.ts +4 -0
- package/esm/service/element.js +51 -0
- package/esm/service/index.d.ts +1 -0
- package/esm/service/index.js +6 -2
- package/esm/types/index.d.ts +337 -40
- package/esm/types/index.js +119 -55
- package/esm/util/createIframeNode.d.ts +2 -2
- package/esm/util/createIframeNode.js +3 -3
- package/esm/util/getBackScheme.d.ts +5 -0
- package/esm/util/getBackScheme.js +133 -0
- package/esm/util/index.js +4 -8
- package/esm/util/logger.d.ts +3 -3
- package/esm/util/logger.js +49 -13
- package/esm/util/security.d.ts +3 -2
- package/esm/util/security.js +2 -2
- package/esm/util/spm-map.d.ts +172 -0
- package/esm/util/spm-map.js +172 -0
- package/package.json +3 -1
@@ -0,0 +1,36 @@
|
|
1
|
+
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); }
|
2
|
+
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; }
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
4
|
+
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); }
|
5
|
+
export var ThemeType = /*#__PURE__*/function (ThemeType) {
|
6
|
+
ThemeType["NostalgicGray"] = "nostalgicGray";
|
7
|
+
ThemeType["Default"] = "default";
|
8
|
+
ThemeType["Night"] = "night";
|
9
|
+
ThemeType["CherryBlossomPink"] = "cherryBlossomPink";
|
10
|
+
ThemeType["GamingPurple"] = "gamingPurple";
|
11
|
+
ThemeType["AgateGreen"] = "agateGreen";
|
12
|
+
return ThemeType;
|
13
|
+
}({});
|
14
|
+
export var addressTheme = _defineProperty(_defineProperty({}, ThemeType.Default, 'LIGHT'), ThemeType.Night, 'NIGHT');
|
15
|
+
export var EventCallbackCode = /*#__PURE__*/function (EventCallbackCode) {
|
16
|
+
EventCallbackCode["Failed"] = "Failed";
|
17
|
+
EventCallbackCode["Completed"] = "Completed";
|
18
|
+
return EventCallbackCode;
|
19
|
+
}({});
|
20
|
+
export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
|
21
|
+
ELEMENT_ENVIRONMENT["DEV"] = "DEV";
|
22
|
+
ELEMENT_ENVIRONMENT["TEST"] = "TEST";
|
23
|
+
ELEMENT_ENVIRONMENT["SIT"] = "SIT";
|
24
|
+
ELEMENT_ENVIRONMENT["PRE"] = "PRE";
|
25
|
+
ELEMENT_ENVIRONMENT["PROD"] = "PROD";
|
26
|
+
ELEMENT_ENVIRONMENT["SANDBOX"] = "SANDBOX";
|
27
|
+
return ELEMENT_ENVIRONMENT;
|
28
|
+
}({});
|
29
|
+
// export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
|
30
|
+
|
31
|
+
export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbackName) {
|
32
|
+
AddressEventCallbackName["SHIPPING_CHANGE"] = "SHIPPING_CHANGE";
|
33
|
+
return AddressEventCallbackName;
|
34
|
+
}({});
|
35
|
+
|
36
|
+
// export type IMountResult = AddressMountResult | LinkAuthMountResult | PaymentMountResult;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export interface ISessionDataExtendInfo {
|
2
|
+
displayLayout: 'LEFT_ORDER_AND_RIGHT_PAYMENT' | 'LEFT_PAYMENT_AND_RIGHT_ORDER';
|
3
|
+
displayAntomLogo: string;
|
4
|
+
themeType: 'LIGHT' | 'NIGHT' | 'CUSTOMIZE';
|
5
|
+
OPEN_MULTI_PAYMENT_ABILITY: boolean;
|
6
|
+
[key: string]: any;
|
7
|
+
}
|
8
|
+
export interface LinkData {
|
9
|
+
linkId: string;
|
10
|
+
region: string;
|
11
|
+
displaySetting?: ISessionDataExtendInfo;
|
12
|
+
}
|
13
|
+
export declare const displayIframe: (selector: string) => void;
|
@@ -1,14 +1,18 @@
|
|
1
1
|
import ComponentApp from '../../plugin/component';
|
2
|
-
import {
|
2
|
+
import { ComponentSignEnum, IcreateComponent, IoptionsParams, IPaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
|
3
3
|
import CoreInstance from '../instance/index';
|
4
|
-
export declare const getComponentSign: (params:
|
5
|
-
export declare const parseSessionData: (sessionData: string) => [
|
4
|
+
export declare const getComponentSign: (params: IPaymentSessionMetaData) => ComponentSignEnum;
|
5
|
+
export declare const parseSessionData: (sessionData: string) => [IPaymentSessionMetaData, string];
|
6
|
+
export type IAMSComponentOptions = IoptionsParams & {
|
7
|
+
appVersion: string;
|
8
|
+
};
|
6
9
|
export declare class AMSComponent extends CoreInstance {
|
7
10
|
_componentApp: ComponentApp;
|
8
|
-
channelType:
|
11
|
+
channelType: ComponentSignEnum[];
|
9
12
|
productSceneVersion: string;
|
10
13
|
timer: any;
|
11
|
-
|
14
|
+
isSuccessfullyPreloaded: boolean;
|
15
|
+
constructor(options: IAMSComponentOptions);
|
12
16
|
private parameterInitAndCheck;
|
13
17
|
private pluginAppendIframe;
|
14
18
|
private savePreviousChannel;
|
@@ -30,8 +34,8 @@ export declare class AMSComponent extends CoreInstance {
|
|
30
34
|
*/
|
31
35
|
createComponent(params: IcreateComponent): Promise<void>;
|
32
36
|
private createComponentProcess;
|
33
|
-
preloadComponent(
|
34
|
-
clearPreloadIframe
|
37
|
+
preloadComponent(): void;
|
38
|
+
private clearPreloadIframe;
|
35
39
|
/**
|
36
40
|
* @description Create and render components in the specified element area
|
37
41
|
* @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
@@ -45,4 +49,5 @@ export declare class AMSComponent extends CoreInstance {
|
|
45
49
|
* @param data - Transfer information in the submission interface according to your requirements (optional)
|
46
50
|
*/
|
47
51
|
submit(data?: Isubmit): Promise<unknown>;
|
52
|
+
preload(_options: any): void;
|
48
53
|
}
|
@@ -17,6 +17,10 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
17
17
|
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; }
|
18
18
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
19
19
|
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); }
|
20
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
21
|
+
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."); }
|
22
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
23
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
20
24
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
21
25
|
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."); }
|
22
26
|
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); }
|
@@ -36,7 +40,7 @@ import { ApplePayBusSubscriber } from "../../plugin/applepay";
|
|
36
40
|
import ComponentApp from "../../plugin/component";
|
37
41
|
import { ExtendPlugin } from "../../plugin/const";
|
38
42
|
import { PaypalBusSubscriber } from "../../plugin/paypal";
|
39
|
-
import {
|
43
|
+
import { ComponentSignEnum, ComponentSignEnumV2, EnvironmentEnum, modeEnum, networkModeEnum, ProductSceneEnum, DisplayTypeEnum } from "../../types";
|
40
44
|
import { getOrSetStorageId, isPC, parseBase64ToString } from "../../util";
|
41
45
|
import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
|
42
46
|
import { getSecurityConfigStorageKey } from "../../util/security";
|
@@ -53,7 +57,9 @@ export var getComponentSign = function getComponentSign(params) {
|
|
53
57
|
productScene = _params$paymentSessio3 === void 0 ? '' : _params$paymentSessio3,
|
54
58
|
_params$paymentSessio4 = _params$paymentSessio2.paymentMethodCategoryType,
|
55
59
|
paymentMethodCategoryType = _params$paymentSessio4 === void 0 ? '' : _params$paymentSessio4;
|
56
|
-
|
60
|
+
if (productScene && paymentMethodCategoryType) return "".concat(productScene, "_").concat(paymentMethodCategoryType);
|
61
|
+
if (productScene) return "".concat(productScene);
|
62
|
+
return ComponentSignEnum.NONE;
|
57
63
|
};
|
58
64
|
export var parseSessionData = function parseSessionData(sessionData) {
|
59
65
|
try {
|
@@ -68,7 +74,7 @@ export var parseSessionData = function parseSessionData(sessionData) {
|
|
68
74
|
var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
|
69
75
|
if (isPC() && parseData !== null && parseData !== void 0 && parseData.paymentSessionConfig) {
|
70
76
|
var productScene = parseData.paymentSessionConfig.productScene;
|
71
|
-
if (productScene ===
|
77
|
+
if (productScene === ProductSceneEnum.EASY_PAY) {
|
72
78
|
var _parseData$paymentMet;
|
73
79
|
// 非TOSS渠道,在PC场景需要改成1.0
|
74
80
|
if ('BANKTRANSFER_QUICKPAY' !== (parseData === null || parseData === void 0 || (_parseData$paymentMet = parseData.paymentMethodInfoView) === null || _parseData$paymentMet === void 0 ? void 0 : _parseData$paymentMet.paymentMethodType)) {
|
@@ -85,17 +91,26 @@ var handleSessionData = function handleSessionData(originSessionData) {
|
|
85
91
|
resetEasyPaySceneVersion(parseData);
|
86
92
|
return [parseData !== null && parseData !== void 0 ? parseData : {}, sessionData];
|
87
93
|
};
|
88
|
-
var handleParams = function handleParams(params) {
|
94
|
+
var handleParams = function handleParams(params, _this) {
|
89
95
|
var _params = Object.assign({
|
90
96
|
paymentSessionMetaData: {},
|
91
|
-
renderDisplayType:
|
97
|
+
renderDisplayType: DisplayTypeEnum.popup
|
92
98
|
}, params);
|
93
99
|
var _handleSessionData = handleSessionData(_params.sessionData || (_params === null || _params === void 0 ? void 0 : _params.paymentSessionData)),
|
94
100
|
_handleSessionData2 = _slicedToArray(_handleSessionData, 2),
|
95
101
|
parseData = _handleSessionData2[0],
|
96
102
|
sessionData = _handleSessionData2[1];
|
97
103
|
var componentSign = getComponentSign(parseData);
|
98
|
-
if (componentSign ===
|
104
|
+
if (_toConsumableArray(Object.values(ComponentSignEnumV2)).includes(componentSign) && _params.renderDisplayType === DisplayTypeEnum.popup) {
|
105
|
+
return Promise.reject({
|
106
|
+
code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
|
107
|
+
message: "unsupported payment method"
|
108
|
+
});
|
109
|
+
}
|
110
|
+
if (_this.options.product === ProductSceneEnum.ELEMENT_ADDRESS) {
|
111
|
+
componentSign = ComponentSignEnum.ELEMENT_ADDRESS;
|
112
|
+
}
|
113
|
+
if (componentSign === ComponentSignEnum.NONE) {
|
99
114
|
// eslint-disable-next-line prefer-promise-reject-errors
|
100
115
|
return Promise.reject({
|
101
116
|
code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
|
@@ -118,21 +133,24 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
118
133
|
_inherits(AMSComponent, _CoreInstance);
|
119
134
|
var _super = _createSuper(AMSComponent);
|
120
135
|
function AMSComponent(options) {
|
121
|
-
var
|
136
|
+
var _this2;
|
122
137
|
_classCallCheck(this, AMSComponent);
|
123
|
-
|
138
|
+
_this2 = _super.call(this, options);
|
124
139
|
// Instantiate the plug-in and set render
|
125
|
-
_defineProperty(_assertThisInitialized(
|
126
|
-
_defineProperty(_assertThisInitialized(
|
127
|
-
_defineProperty(_assertThisInitialized(
|
128
|
-
|
140
|
+
_defineProperty(_assertThisInitialized(_this2), "channelType", void 0);
|
141
|
+
_defineProperty(_assertThisInitialized(_this2), "productSceneVersion", void 0);
|
142
|
+
_defineProperty(_assertThisInitialized(_this2), "timer", void 0);
|
143
|
+
_defineProperty(_assertThisInitialized(_this2), "isSuccessfullyPreloaded", void 0);
|
144
|
+
var ComponentPlugin = new ComponentApp({
|
145
|
+
appVersion: options.appVersion
|
146
|
+
});
|
129
147
|
ComponentPlugin.setRender(createIframeNode);
|
130
148
|
ComponentPlugin.setPreloadRender(createPreloadIframeNode);
|
131
149
|
// Register Cashier Application Plug in
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
return
|
150
|
+
_this2._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
|
151
|
+
_this2._componentApp = _this2._getPlugin(COMPONENTPLUGINID);
|
152
|
+
_this2.registerBusAbility();
|
153
|
+
return _this2;
|
136
154
|
}
|
137
155
|
_createClass(AMSComponent, [{
|
138
156
|
key: "parameterInitAndCheck",
|
@@ -146,7 +164,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
146
164
|
selector: selector,
|
147
165
|
renderDisplayType: renderDisplayType
|
148
166
|
}, params);
|
149
|
-
if (_params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
|
167
|
+
if (this.options.product !== ProductSceneEnum.ELEMENT_ADDRESS && _params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
|
150
168
|
return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
|
151
169
|
}
|
152
170
|
if (this.options.networkMode === networkModeEnum.proxy) {
|
@@ -202,29 +220,24 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
202
220
|
this.logger.logInfo({
|
203
221
|
title: 'preload_match'
|
204
222
|
}, {
|
205
|
-
|
206
|
-
|
207
|
-
sessionDataChannel: channelType,
|
208
|
-
sessionDataVersion: productSceneVersion
|
223
|
+
eventMessage: channelType,
|
224
|
+
productSceneVersion: productSceneVersion
|
209
225
|
});
|
210
226
|
} else {
|
211
227
|
this.logger.logInfo({
|
212
228
|
title: 'preload_no_match'
|
213
229
|
}, {
|
214
|
-
|
215
|
-
|
216
|
-
sessionDataChannel: channelType,
|
217
|
-
sessionDataVersion: productSceneVersion
|
230
|
+
eventMessage: channelType,
|
231
|
+
productSceneVersion: productSceneVersion
|
218
232
|
});
|
219
233
|
}
|
220
234
|
var previousChannel = {
|
221
|
-
channelType: channelType ===
|
235
|
+
channelType: channelType === ComponentSignEnum.VAULTING_CARD ? ComponentSignEnum.CASHIER_PAYMENT_CARD : channelType,
|
222
236
|
productSceneVersion: productSceneVersion
|
223
237
|
};
|
224
238
|
localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
|
225
239
|
}
|
226
240
|
}
|
227
|
-
|
228
241
|
/**
|
229
242
|
* 初始化 Bus总线的能力
|
230
243
|
*/
|
@@ -232,12 +245,12 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
232
245
|
key: "registerBusAbility",
|
233
246
|
value: function registerBusAbility() {
|
234
247
|
var _this$originOptions,
|
235
|
-
|
236
|
-
BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !==
|
248
|
+
_this3 = this;
|
249
|
+
BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== EnvironmentEnum.prod, this.logger);
|
237
250
|
BusManager.clear();
|
238
251
|
BusManager.addInterceptor({
|
239
252
|
onPublishException: function onPublishException(message, e) {
|
240
|
-
|
253
|
+
_this3.logger.logError({
|
241
254
|
title: 'onBusPublishException'
|
242
255
|
}, _objectSpread(_objectSpread({}, message), {}, {
|
243
256
|
errorMessage: JSON.stringify(e)
|
@@ -246,12 +259,12 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
246
259
|
});
|
247
260
|
// subscribe basic ablility
|
248
261
|
BusManager.subscribe(new SDKCallbackBusSubscriber(function (state) {
|
249
|
-
var
|
250
|
-
(
|
262
|
+
var _this3$_componentApp;
|
263
|
+
(_this3$_componentApp = _this3._componentApp) === null || _this3$_componentApp === void 0 || (_this3$_componentApp = _this3$_componentApp.AMSSDK) === null || _this3$_componentApp === void 0 || _this3$_componentApp._eventCenter.emit(EVENT.eventCallback.name, state);
|
251
264
|
}));
|
252
265
|
BusManager.subscribe(new SecurityBusSubscriber(function (deviceIdParameter, isPolling) {
|
253
|
-
var
|
254
|
-
return (
|
266
|
+
var _this3$_componentApp2;
|
267
|
+
return (_this3$_componentApp2 = _this3._componentApp) === null || _this3$_componentApp2 === void 0 ? void 0 : _this3$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
|
255
268
|
}));
|
256
269
|
BusManager.subscribe(new TrackerBusSubscriber(this.logger));
|
257
270
|
// subscribe plugin
|
@@ -266,7 +279,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
266
279
|
}
|
267
280
|
var paymentChannelMatcher = item.paymentChannelMatcher;
|
268
281
|
if (paymentChannelMatcher) {
|
269
|
-
|
282
|
+
_this3._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
|
270
283
|
}
|
271
284
|
var sessionMatcher = item.sessionMatcher;
|
272
285
|
if (sessionMatcher) {
|
@@ -274,19 +287,18 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
274
287
|
if (sessionMatcher.paymentMethodTypes) {
|
275
288
|
sessionMatcher.paymentMethodTypes.forEach(function (paymentMethodType) {
|
276
289
|
var subPluginKey = pluginKey + paymentMethodType;
|
277
|
-
|
290
|
+
_this3._registerPlugin(subPluginKey, item.busActionNames);
|
278
291
|
});
|
279
292
|
} else {
|
280
|
-
|
293
|
+
_this3._registerPlugin(pluginKey, item.busActionNames);
|
281
294
|
}
|
282
295
|
}
|
283
296
|
var optInit = item === null || item === void 0 || (_item$busActionNames = item.busActionNames) === null || _item$busActionNames === void 0 ? void 0 : _item$busActionNames.optional_init;
|
284
297
|
if (optInit) {
|
285
|
-
BusManager.publish(new BusMessage(optInit, JSON.stringify(
|
298
|
+
BusManager.publish(new BusMessage(optInit, JSON.stringify(_this3.originOptions)));
|
286
299
|
}
|
287
300
|
});
|
288
301
|
}
|
289
|
-
|
290
302
|
/**
|
291
303
|
* To determine whether the corresponding payment method is available,
|
292
304
|
* only the channel described in the document will be called, and it will be returned as available by default
|
@@ -297,14 +309,14 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
297
309
|
}, {
|
298
310
|
key: "canMakePayments",
|
299
311
|
value: function canMakePayments(paymentMethod, subPaymentMethod) {
|
300
|
-
var
|
312
|
+
var _this4 = this;
|
301
313
|
// 判断支付方式是否可用
|
302
314
|
return new Promise(function (resolve) {
|
303
|
-
var
|
315
|
+
var _this4$_getPlugin;
|
304
316
|
if (!paymentMethod) {
|
305
317
|
return resolve(true);
|
306
318
|
}
|
307
|
-
var actionName = (
|
319
|
+
var actionName = (_this4$_getPlugin = _this4._getPlugin(paymentMethod)) === null || _this4$_getPlugin === void 0 ? void 0 : _this4$_getPlugin.canMakePayments;
|
308
320
|
if (actionName && BusManager.isSubscribed(actionName)) {
|
309
321
|
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
310
322
|
paymentMethod: paymentMethod,
|
@@ -314,10 +326,10 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
314
326
|
}).then(function (message) {
|
315
327
|
resolve(message.getJSONObject());
|
316
328
|
}).catch(function (e) {
|
317
|
-
|
329
|
+
_this4.logger.logInfo({
|
318
330
|
title: 'canMakePayments_error'
|
319
331
|
}, {
|
320
|
-
|
332
|
+
errorMessage: JSON.stringify(e)
|
321
333
|
});
|
322
334
|
resolve(false);
|
323
335
|
});
|
@@ -326,7 +338,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
326
338
|
}
|
327
339
|
});
|
328
340
|
}
|
329
|
-
|
330
341
|
/**
|
331
342
|
* @description Create component application
|
332
343
|
* @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
|
@@ -334,26 +345,31 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
334
345
|
}, {
|
335
346
|
key: "createComponent",
|
336
347
|
value: function createComponent(params) {
|
337
|
-
var
|
348
|
+
var _this5 = this;
|
349
|
+
if (!this.isSuccessfullyPreloaded) {
|
350
|
+
this.preloadComponent();
|
351
|
+
}
|
352
|
+
;
|
353
|
+
console.log('执行了createComponent', params);
|
338
354
|
this.clearPreloadIframe();
|
339
355
|
this.logger.setComponentStartTime(Date.now());
|
340
356
|
return this.parameterInitAndCheck({
|
341
357
|
params: params,
|
342
|
-
renderDisplayType:
|
358
|
+
renderDisplayType: DisplayTypeEnum.popup
|
343
359
|
}).then(function (_params) {
|
344
|
-
return handleParams(_params);
|
360
|
+
return handleParams(_params, _this5);
|
345
361
|
}).catch(function (error) {
|
346
|
-
|
362
|
+
_this5.logger.logError({
|
347
363
|
title: 'sdk_error_parameter'
|
348
364
|
}, {
|
349
365
|
params: JSON.stringify(params)
|
350
366
|
}).send();
|
351
|
-
|
367
|
+
_this5._eventCenter.emit(EVENT.error.name, error);
|
352
368
|
return Promise.reject(error);
|
353
369
|
}).then(function (appendParams) {
|
354
370
|
var iframeNodesParams = appendParams.iframeNodesParams;
|
355
|
-
|
356
|
-
return
|
371
|
+
_this5.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
372
|
+
return _this5.createComponentProcess(appendParams);
|
357
373
|
});
|
358
374
|
}
|
359
375
|
}, {
|
@@ -374,26 +390,46 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
374
390
|
this.savePreviousChannel(iframeNodesParams);
|
375
391
|
return this.pluginAppendIframe(appendParams);
|
376
392
|
}
|
393
|
+
|
394
|
+
// preloadComponent(channelType, productSceneVersion) {
|
395
|
+
// this.channelType = channelType;
|
396
|
+
// this.productSceneVersion = productSceneVersion;
|
397
|
+
// const MAX_CLEAR_TIME = 10000;
|
398
|
+
|
399
|
+
// if (Array.isArray(channelType)) {
|
400
|
+
// for (let i = 0; i < channelType.length; i++) {
|
401
|
+
// this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
|
402
|
+
// }
|
403
|
+
// } else {
|
404
|
+
// this.logger.logError(
|
405
|
+
// { title: 'performance_optimization_channelType_error' },
|
406
|
+
// { eventMessage: channelType }
|
407
|
+
// );
|
408
|
+
// }
|
409
|
+
// this.timer = setTimeout(() => {
|
410
|
+
// this.clearPreloadIframe(true);
|
411
|
+
// }, MAX_CLEAR_TIME);
|
412
|
+
// }
|
377
413
|
}, {
|
378
414
|
key: "preloadComponent",
|
379
|
-
value: function preloadComponent(
|
380
|
-
var
|
381
|
-
|
382
|
-
this.productSceneVersion = productSceneVersion;
|
415
|
+
value: function preloadComponent() {
|
416
|
+
var _this6 = this;
|
417
|
+
console.log('执行了preloadComponent');
|
383
418
|
var MAX_CLEAR_TIME = 10000;
|
384
|
-
if (Array.isArray(channelType)) {
|
385
|
-
for (var i = 0; i < channelType.length; i++) {
|
386
|
-
this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
|
419
|
+
if (Array.isArray(this.channelType)) {
|
420
|
+
for (var i = 0; i < this.channelType.length; i++) {
|
421
|
+
this._componentApp.appendPreloadIframeNodes(this.channelType[i], this.productSceneVersion);
|
387
422
|
}
|
423
|
+
this.isSuccessfullyPreloaded = true;
|
388
424
|
} else {
|
389
425
|
this.logger.logError({
|
390
426
|
title: 'performance_optimization_channelType_error'
|
391
427
|
}, {
|
392
|
-
|
428
|
+
eventMessage: this.channelType
|
393
429
|
});
|
394
430
|
}
|
395
431
|
this.timer = setTimeout(function () {
|
396
|
-
|
432
|
+
_this6.clearPreloadIframe(true);
|
397
433
|
}, MAX_CLEAR_TIME);
|
398
434
|
}
|
399
435
|
}, {
|
@@ -425,27 +461,31 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
425
461
|
}, {
|
426
462
|
key: "mountComponent",
|
427
463
|
value: function mountComponent(params, selector) {
|
428
|
-
var
|
464
|
+
var _this7 = this;
|
429
465
|
this.clearPreloadIframe();
|
466
|
+
if (!this.isSuccessfullyPreloaded) {
|
467
|
+
this.preloadComponent();
|
468
|
+
}
|
469
|
+
;
|
430
470
|
this.logger.setComponentStartTime(Date.now());
|
431
471
|
return this.parameterInitAndCheck({
|
432
472
|
params: params,
|
433
|
-
renderDisplayType:
|
473
|
+
renderDisplayType: DisplayTypeEnum.inline,
|
434
474
|
selector: selector
|
435
475
|
}).then(function (_params) {
|
436
|
-
return handleParams(_params);
|
476
|
+
return handleParams(_params, _this7);
|
437
477
|
}).catch(function (error) {
|
438
|
-
|
478
|
+
_this7.logger.logError({
|
439
479
|
title: 'sdk_error_parameter'
|
440
480
|
}, {
|
441
481
|
params: JSON.stringify(params)
|
442
482
|
}).send();
|
443
|
-
|
483
|
+
_this7._eventCenter.emit(EVENT.error.name, error);
|
444
484
|
return Promise.reject(error);
|
445
485
|
}).then(function (appendParams) {
|
446
486
|
var iframeNodesParams = appendParams.iframeNodesParams;
|
447
|
-
|
448
|
-
return
|
487
|
+
_this7.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
488
|
+
return _this7.mountComponentProcess(appendParams);
|
449
489
|
});
|
450
490
|
}
|
451
491
|
}, {
|
@@ -463,10 +503,11 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
463
503
|
return Promise.resolve();
|
464
504
|
}
|
465
505
|
var iframeNodesParams = appendParams.iframeNodesParams;
|
466
|
-
this.
|
506
|
+
if (this.options.product !== ProductSceneEnum.ELEMENT_ADDRESS) {
|
507
|
+
this.savePreviousChannel(iframeNodesParams);
|
508
|
+
}
|
467
509
|
return this.pluginAppendIframe(appendParams);
|
468
510
|
}
|
469
|
-
|
470
511
|
/**
|
471
512
|
* @description Execute payment submission process
|
472
513
|
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
@@ -475,30 +516,30 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
475
516
|
}, {
|
476
517
|
key: "submit",
|
477
518
|
value: function submit(data) {
|
478
|
-
var
|
519
|
+
var _this8 = this;
|
479
520
|
return new Promise(function (resolve, reject) {
|
480
521
|
try {
|
481
|
-
var
|
522
|
+
var _this8$getBusActionNa;
|
482
523
|
var eventCallbackId = uuid();
|
483
|
-
|
524
|
+
_this8.logger.logInfo({
|
484
525
|
title: 'sdk_event_apiSubmit'
|
485
526
|
});
|
486
|
-
var actionName = (
|
527
|
+
var actionName = (_this8$getBusActionNa = _this8.getBusActionNames()) === null || _this8$getBusActionNa === void 0 ? void 0 : _this8$getBusActionNa.submit;
|
487
528
|
if (actionName && BusManager.isSubscribed(actionName)) {
|
488
529
|
// 执行出错了,在通用拦截器返回
|
489
530
|
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
490
|
-
appendParams:
|
491
|
-
options:
|
531
|
+
appendParams: _this8._appendParams,
|
532
|
+
options: _this8.originOptions,
|
492
533
|
data: data
|
493
534
|
}))).then(function (busMessage) {
|
494
535
|
resolve(busMessage === null || busMessage === void 0 ? void 0 : busMessage.getJSONObject());
|
495
536
|
});
|
496
537
|
} else {
|
497
538
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
498
|
-
|
539
|
+
_this8._eventCenter.once(eventCallbackId, function (_data) {
|
499
540
|
resolve(_data);
|
500
541
|
});
|
501
|
-
|
542
|
+
_this8._componentApp.dispatchToApp({
|
502
543
|
context: {
|
503
544
|
event: 'submitPay',
|
504
545
|
eventCallbackId: eventCallbackId,
|
@@ -511,6 +552,19 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
511
552
|
}
|
512
553
|
});
|
513
554
|
}
|
555
|
+
|
556
|
+
// 预加载
|
557
|
+
}, {
|
558
|
+
key: "preload",
|
559
|
+
value: function preload(_options) {
|
560
|
+
this.preloadComponent();
|
561
|
+
if (this.channelType.some(function (val) {
|
562
|
+
return val === ComponentSignEnum.EASY_PAY_WALLET || val === ComponentSignEnum.EASY_PAY_APM;
|
563
|
+
})) return;
|
564
|
+
this._componentApp.AMSSDK.initSecurity({
|
565
|
+
product: this.options.product
|
566
|
+
});
|
567
|
+
}
|
514
568
|
}]);
|
515
569
|
return AMSComponent;
|
516
570
|
}(CoreInstance);
|
@@ -11,7 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
11
11
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
12
12
|
import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
13
13
|
import CheckoutApp from "../../plugin/drop-in";
|
14
|
-
import {
|
14
|
+
import { MessageName, networkModeEnum } from "../../types";
|
15
15
|
import { createIframeNode } from "../../util/createIframeNode";
|
16
16
|
export var mixinDropInConstructor = function mixinDropInConstructor(options, context) {
|
17
17
|
// Instantiate the plug-in and set render
|
@@ -57,7 +57,7 @@ export var confirmPayment = function confirmPayment(result) {
|
|
57
57
|
});
|
58
58
|
});
|
59
59
|
_this2.eventCenter.emit("".concat(BASEPLUGINID, "-handleRequestPayment"), {
|
60
|
-
name:
|
60
|
+
name: MessageName.SDK_TO_APP,
|
61
61
|
mode: _this2.options.mode,
|
62
62
|
appId: BASEPLUGINID,
|
63
63
|
instanceId: _this2._instanceId,
|