@alipay/ams-checkout 0.0.1726734012-dev.1 → 0.0.1726734012-dev.11
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 +14 -7
- package/esm/core/component/index.js +136 -78
- package/esm/core/drop-in/index.js +2 -2
- package/esm/core/instance/index.d.ts +2 -1
- package/esm/core/instance/index.js +27 -12
- 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 +332 -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 +21 -12
- package/esm/index.js +116 -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 +384 -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 +339 -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,7 @@ 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: {
|
53
|
+
securityRegion?: 'US' | 'SG' | 'DE';
|
54
|
+
}): void;
|
48
55
|
}
|
@@ -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,30 @@ 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
|
+
;
|
338
353
|
this.clearPreloadIframe();
|
339
354
|
this.logger.setComponentStartTime(Date.now());
|
340
355
|
return this.parameterInitAndCheck({
|
341
356
|
params: params,
|
342
|
-
renderDisplayType:
|
357
|
+
renderDisplayType: DisplayTypeEnum.popup
|
343
358
|
}).then(function (_params) {
|
344
|
-
return handleParams(_params);
|
359
|
+
return handleParams(_params, _this5);
|
345
360
|
}).catch(function (error) {
|
346
|
-
|
361
|
+
_this5.logger.logError({
|
347
362
|
title: 'sdk_error_parameter'
|
348
363
|
}, {
|
349
364
|
params: JSON.stringify(params)
|
350
365
|
}).send();
|
351
|
-
|
366
|
+
_this5._eventCenter.emit(EVENT.error.name, error);
|
352
367
|
return Promise.reject(error);
|
353
368
|
}).then(function (appendParams) {
|
354
369
|
var iframeNodesParams = appendParams.iframeNodesParams;
|
355
|
-
|
356
|
-
return
|
370
|
+
_this5.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
371
|
+
return _this5.createComponentProcess(appendParams);
|
357
372
|
});
|
358
373
|
}
|
359
374
|
}, {
|
@@ -374,26 +389,45 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
374
389
|
this.savePreviousChannel(iframeNodesParams);
|
375
390
|
return this.pluginAppendIframe(appendParams);
|
376
391
|
}
|
392
|
+
|
393
|
+
// preloadComponent(channelType, productSceneVersion) {
|
394
|
+
// this.channelType = channelType;
|
395
|
+
// this.productSceneVersion = productSceneVersion;
|
396
|
+
// const MAX_CLEAR_TIME = 10000;
|
397
|
+
|
398
|
+
// if (Array.isArray(channelType)) {
|
399
|
+
// for (let i = 0; i < channelType.length; i++) {
|
400
|
+
// this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
|
401
|
+
// }
|
402
|
+
// } else {
|
403
|
+
// this.logger.logError(
|
404
|
+
// { title: 'performance_optimization_channelType_error' },
|
405
|
+
// { eventMessage: channelType }
|
406
|
+
// );
|
407
|
+
// }
|
408
|
+
// this.timer = setTimeout(() => {
|
409
|
+
// this.clearPreloadIframe(true);
|
410
|
+
// }, MAX_CLEAR_TIME);
|
411
|
+
// }
|
377
412
|
}, {
|
378
413
|
key: "preloadComponent",
|
379
|
-
value: function preloadComponent(
|
380
|
-
var
|
381
|
-
this.channelType = channelType;
|
382
|
-
this.productSceneVersion = productSceneVersion;
|
414
|
+
value: function preloadComponent() {
|
415
|
+
var _this6 = this;
|
383
416
|
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);
|
417
|
+
if (Array.isArray(this.channelType)) {
|
418
|
+
for (var i = 0; i < this.channelType.length; i++) {
|
419
|
+
this._componentApp.appendPreloadIframeNodes(this.channelType[i], this.productSceneVersion);
|
387
420
|
}
|
421
|
+
this.isSuccessfullyPreloaded = true;
|
388
422
|
} else {
|
389
423
|
this.logger.logError({
|
390
424
|
title: 'performance_optimization_channelType_error'
|
391
425
|
}, {
|
392
|
-
|
426
|
+
eventMessage: this.channelType
|
393
427
|
});
|
394
428
|
}
|
395
429
|
this.timer = setTimeout(function () {
|
396
|
-
|
430
|
+
_this6.clearPreloadIframe(true);
|
397
431
|
}, MAX_CLEAR_TIME);
|
398
432
|
}
|
399
433
|
}, {
|
@@ -425,27 +459,31 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
425
459
|
}, {
|
426
460
|
key: "mountComponent",
|
427
461
|
value: function mountComponent(params, selector) {
|
428
|
-
var
|
462
|
+
var _this7 = this;
|
429
463
|
this.clearPreloadIframe();
|
464
|
+
if (!this.isSuccessfullyPreloaded) {
|
465
|
+
this.preloadComponent();
|
466
|
+
}
|
467
|
+
;
|
430
468
|
this.logger.setComponentStartTime(Date.now());
|
431
469
|
return this.parameterInitAndCheck({
|
432
470
|
params: params,
|
433
|
-
renderDisplayType:
|
471
|
+
renderDisplayType: DisplayTypeEnum.inline,
|
434
472
|
selector: selector
|
435
473
|
}).then(function (_params) {
|
436
|
-
return handleParams(_params);
|
474
|
+
return handleParams(_params, _this7);
|
437
475
|
}).catch(function (error) {
|
438
|
-
|
476
|
+
_this7.logger.logError({
|
439
477
|
title: 'sdk_error_parameter'
|
440
478
|
}, {
|
441
479
|
params: JSON.stringify(params)
|
442
480
|
}).send();
|
443
|
-
|
481
|
+
_this7._eventCenter.emit(EVENT.error.name, error);
|
444
482
|
return Promise.reject(error);
|
445
483
|
}).then(function (appendParams) {
|
446
484
|
var iframeNodesParams = appendParams.iframeNodesParams;
|
447
|
-
|
448
|
-
return
|
485
|
+
_this7.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
486
|
+
return _this7.mountComponentProcess(appendParams);
|
449
487
|
});
|
450
488
|
}
|
451
489
|
}, {
|
@@ -463,10 +501,11 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
463
501
|
return Promise.resolve();
|
464
502
|
}
|
465
503
|
var iframeNodesParams = appendParams.iframeNodesParams;
|
466
|
-
this.
|
504
|
+
if (this.options.product !== ProductSceneEnum.ELEMENT_ADDRESS) {
|
505
|
+
this.savePreviousChannel(iframeNodesParams);
|
506
|
+
}
|
467
507
|
return this.pluginAppendIframe(appendParams);
|
468
508
|
}
|
469
|
-
|
470
509
|
/**
|
471
510
|
* @description Execute payment submission process
|
472
511
|
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
@@ -475,30 +514,30 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
475
514
|
}, {
|
476
515
|
key: "submit",
|
477
516
|
value: function submit(data) {
|
478
|
-
var
|
517
|
+
var _this8 = this;
|
479
518
|
return new Promise(function (resolve, reject) {
|
480
519
|
try {
|
481
|
-
var
|
520
|
+
var _this8$getBusActionNa;
|
482
521
|
var eventCallbackId = uuid();
|
483
|
-
|
522
|
+
_this8.logger.logInfo({
|
484
523
|
title: 'sdk_event_apiSubmit'
|
485
524
|
});
|
486
|
-
var actionName = (
|
525
|
+
var actionName = (_this8$getBusActionNa = _this8.getBusActionNames()) === null || _this8$getBusActionNa === void 0 ? void 0 : _this8$getBusActionNa.submit;
|
487
526
|
if (actionName && BusManager.isSubscribed(actionName)) {
|
488
527
|
// 执行出错了,在通用拦截器返回
|
489
528
|
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
490
|
-
appendParams:
|
491
|
-
options:
|
529
|
+
appendParams: _this8._appendParams,
|
530
|
+
options: _this8.originOptions,
|
492
531
|
data: data
|
493
532
|
}))).then(function (busMessage) {
|
494
533
|
resolve(busMessage === null || busMessage === void 0 ? void 0 : busMessage.getJSONObject());
|
495
534
|
});
|
496
535
|
} else {
|
497
536
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
498
|
-
|
537
|
+
_this8._eventCenter.once(eventCallbackId, function (_data) {
|
499
538
|
resolve(_data);
|
500
539
|
});
|
501
|
-
|
540
|
+
_this8._componentApp.dispatchToApp({
|
502
541
|
context: {
|
503
542
|
event: 'submitPay',
|
504
543
|
eventCallbackId: eventCallbackId,
|
@@ -511,6 +550,25 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
511
550
|
}
|
512
551
|
});
|
513
552
|
}
|
553
|
+
|
554
|
+
// 预加载
|
555
|
+
}, {
|
556
|
+
key: "preload",
|
557
|
+
value: function preload(_options) {
|
558
|
+
try {
|
559
|
+
var _this$channelType;
|
560
|
+
this.preloadComponent();
|
561
|
+
if (this.channelType && (_this$channelType = this.channelType) !== null && _this$channelType !== void 0 && _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
|
+
securityRegion: _options.securityRegion
|
567
|
+
});
|
568
|
+
} catch (err) {
|
569
|
+
console.log('web-sdk error', err);
|
570
|
+
}
|
571
|
+
}
|
514
572
|
}]);
|
515
573
|
return AMSComponent;
|
516
574
|
}(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,
|
@@ -33,7 +33,7 @@ export default class AMSSDK {
|
|
33
33
|
* @param product Product Scenarios
|
34
34
|
* @param scene Scenario of the product (compatible with old version parameters, about to be deleted)
|
35
35
|
*/
|
36
|
-
initSecurity({ product, scene, }: InitSecurityConfig & {
|
36
|
+
initSecurity({ product, scene, securityRegion, }: InitSecurityConfig & {
|
37
37
|
scene?: string;
|
38
38
|
}): void;
|
39
39
|
/**
|
@@ -79,6 +79,7 @@ export default class AMSSDK {
|
|
79
79
|
normalUrl?: string;
|
80
80
|
schemeUrl?: string;
|
81
81
|
applinkUrl?: string;
|
82
|
+
callAppJudgeTime?: number;
|
82
83
|
}): Promise<void>;
|
83
84
|
/**
|
84
85
|
* @description Overlay Subscription
|