@alipay/ams-checkout 1.20.0 → 1.21.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/config/index.d.ts +11 -0
- package/esm/config/index.js +20 -1
- package/esm/constant/index.d.ts +14 -1
- package/esm/constant/index.js +13 -0
- package/esm/core/component/address.d.ts +8 -0
- package/esm/core/component/address.js +72 -0
- package/esm/core/component/index.d.ts +5 -2
- package/esm/core/component/index.js +70 -56
- package/esm/core/instance/index.d.ts +2 -0
- package/esm/core/instance/index.js +65 -2
- package/esm/index.d.ts +9 -9
- package/esm/index.js +44 -8
- package/esm/plugin/applepay/component.js +1 -1
- package/esm/plugin/component/cashierApp.d.ts +3 -3
- package/esm/plugin/component/cashierApp.js +33 -3
- package/esm/plugin/component/channel.js +1 -0
- package/esm/plugin/component/component.inline.style.d.ts +8 -9
- package/esm/plugin/component/component.inline.style.js +87 -6
- package/esm/plugin/component/component.popup.style.d.ts +1 -0
- package/esm/plugin/component/component.popup.style.js +3 -0
- package/esm/plugin/component/index.d.ts +3 -1
- package/esm/plugin/component/index.js +143 -88
- package/esm/plugin/component/popupWindow.style.d.ts +5 -2
- package/esm/plugin/component/popupWindow.style.js +70 -14
- 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 +1 -0
- package/esm/plugin/type.d.ts +1 -0
- package/esm/types/index.d.ts +100 -4
- package/esm/types/index.js +14 -0
- package/esm/util/index.d.ts +2 -1
- package/esm/util/index.js +5 -0
- package/esm/util/security.d.ts +1 -0
- package/esm/util/security.js +1 -1
- package/package.json +1 -1
package/esm/config/index.d.ts
CHANGED
@@ -1,3 +1,14 @@
|
|
1
1
|
export declare const marmotMap: Record<string, string>;
|
2
2
|
export declare const marmotConfigMap: Record<string, string>;
|
3
|
+
export declare const elementAppMarmotMap: Record<string, string>;
|
3
4
|
export declare const sdkVersion: string;
|
5
|
+
/**
|
6
|
+
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
7
|
+
*/
|
8
|
+
export declare const AMSCheckoutAppVersion = "1.21.0";
|
9
|
+
export declare const AMSAutoDebitAppVersion = "1.21.0";
|
10
|
+
export declare const AMSEasyPayAppVersion = "1.21.0";
|
11
|
+
export declare const AMSCashierPaymentAppVersion = "1.21.0";
|
12
|
+
export declare const AMSVaultingAppVersion = "1.21.0";
|
13
|
+
export declare const AMSPaymentElementAppVersion = "1.21.0";
|
14
|
+
export declare const ADDRESSElementAppVersion = "1.21.0";
|
package/esm/config/index.js
CHANGED
@@ -22,4 +22,23 @@ export var marmotConfigMap = {
|
|
22
22
|
light_sandbox: 'https://config.marmot-cloud.com/config/data/antom-sdk-config/en_US.json',
|
23
23
|
prod: 'https://config.marmot-cloud.com/config/data/antom-sdk-config/en_US.json'
|
24
24
|
};
|
25
|
-
export var
|
25
|
+
export var elementAppMarmotMap = {
|
26
|
+
dev: 'http://page.alipay.net/page/antom-web-checkout-v2',
|
27
|
+
sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2',
|
28
|
+
pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2',
|
29
|
+
sandbox: 'https://ac.alipay.com/page/antom-web-checkout-v2',
|
30
|
+
light_sandbox: 'https://ac.alipay.com/page/antom-web-checkout-v2',
|
31
|
+
prod: 'https://ac.alipay.com/page/antom-web-checkout-v2'
|
32
|
+
};
|
33
|
+
export var sdkVersion = json.version;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
37
|
+
*/
|
38
|
+
export var AMSCheckoutAppVersion = '1.21.0'; // 兜底版本号
|
39
|
+
export var AMSAutoDebitAppVersion = '1.21.0'; // 代扣
|
40
|
+
export var AMSEasyPayAppVersion = '1.21.0'; // easypay
|
41
|
+
export var AMSCashierPaymentAppVersion = '1.21.0'; // 收银台(卡、apm)
|
42
|
+
export var AMSVaultingAppVersion = '1.21.0'; // 绑卡
|
43
|
+
export var AMSPaymentElementAppVersion = '1.21.0'; // payment element
|
44
|
+
export var ADDRESSElementAppVersion = '1.21.0'; // address element
|
package/esm/constant/index.d.ts
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
5
5
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
6
6
|
*/
|
7
|
-
import { eventCodeEnum } from
|
7
|
+
import { eventCodeEnum } from '../types';
|
8
8
|
export declare const ERRORMESSAGE: {
|
9
9
|
DOMAIN_NOT_IN_WHITE_LIST: {
|
10
10
|
code: eventCodeEnum;
|
@@ -167,6 +167,18 @@ export declare const EVENT: {
|
|
167
167
|
appHeartBeat: {
|
168
168
|
name: string;
|
169
169
|
};
|
170
|
+
beforeSubmit: {
|
171
|
+
name: string;
|
172
|
+
uniqueKey: string;
|
173
|
+
};
|
174
|
+
beforeSubmitDone: {
|
175
|
+
name: string;
|
176
|
+
uniqueKey: string;
|
177
|
+
};
|
178
|
+
onChange: {
|
179
|
+
name: string;
|
180
|
+
uniqueKey: string;
|
181
|
+
};
|
170
182
|
};
|
171
183
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
172
184
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
@@ -175,6 +187,7 @@ export declare const COMPONENT_CLOSE_BLOCK_ID = "asm-component-close-block";
|
|
175
187
|
export declare const COMPONENT_RETENTION_ID = "ams-component-retention";
|
176
188
|
export declare const MOCKUP_ID = "ams-component-mockup";
|
177
189
|
export declare const LOADING_ID = "ams-component-loading";
|
190
|
+
export declare const POPUPLOADING_ID = "ams-component-popup-loading";
|
178
191
|
export declare const LISTENER_PREFIX = "_ams_sdk_component_listener";
|
179
192
|
export declare const INLINE_BASE_STYLE_ID = "ams-inline-component-style";
|
180
193
|
export declare const INLINE_IMG_CLASSNAME = "inline-loading";
|
package/esm/constant/index.js
CHANGED
@@ -166,6 +166,18 @@ export var EVENT = {
|
|
166
166
|
},
|
167
167
|
appHeartBeat: {
|
168
168
|
name: 'appHeartBeat'
|
169
|
+
},
|
170
|
+
beforeSubmit: {
|
171
|
+
name: 'beforeSubmit',
|
172
|
+
uniqueKey: 'userBeforeSubmit'
|
173
|
+
},
|
174
|
+
beforeSubmitDone: {
|
175
|
+
name: 'beforeSubmitDone',
|
176
|
+
uniqueKey: 'userBeforeSubmitDone'
|
177
|
+
},
|
178
|
+
onChange: {
|
179
|
+
name: 'onChange',
|
180
|
+
uniqueKey: 'userChange'
|
169
181
|
}
|
170
182
|
};
|
171
183
|
export var COMPONENT_CONTAINER_ID = 'ams-component-container';
|
@@ -175,6 +187,7 @@ export var COMPONENT_CLOSE_BLOCK_ID = 'asm-component-close-block';
|
|
175
187
|
export var COMPONENT_RETENTION_ID = 'ams-component-retention';
|
176
188
|
export var MOCKUP_ID = 'ams-component-mockup';
|
177
189
|
export var LOADING_ID = 'ams-component-loading';
|
190
|
+
export var POPUPLOADING_ID = 'ams-component-popup-loading'; // popup弹窗loading
|
178
191
|
export var LISTENER_PREFIX = '_ams_sdk_component_listener';
|
179
192
|
export var INLINE_BASE_STYLE_ID = 'ams-inline-component-style';
|
180
193
|
export var INLINE_IMG_CLASSNAME = 'inline-loading';
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { IoptionsParams } from '../../types';
|
2
|
+
import { AMSComponent } from './index';
|
3
|
+
export declare class AddressComponent extends AMSComponent {
|
4
|
+
constructor(options: IoptionsParams & {
|
5
|
+
appVersion: string;
|
6
|
+
});
|
7
|
+
getValue(hasValidate?: boolean): Promise<unknown>;
|
8
|
+
}
|
@@ -0,0 +1,72 @@
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3
|
+
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); } }
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
6
|
+
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); }
|
7
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
8
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
9
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
10
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
11
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
12
|
+
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; } }
|
13
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
14
|
+
/**
|
15
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
16
|
+
*
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
18
|
+
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
19
|
+
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
20
|
+
*/
|
21
|
+
import { v4 as uuid } from 'uuid';
|
22
|
+
import { BusManager, BusMessage } from "../bus";
|
23
|
+
import { AMSComponent } from "./index";
|
24
|
+
export var AddressComponent = /*#__PURE__*/function (_AMSComponent) {
|
25
|
+
_inherits(AddressComponent, _AMSComponent);
|
26
|
+
var _super = _createSuper(AddressComponent);
|
27
|
+
function AddressComponent(options) {
|
28
|
+
_classCallCheck(this, AddressComponent);
|
29
|
+
return _super.call(this, options);
|
30
|
+
}
|
31
|
+
_createClass(AddressComponent, [{
|
32
|
+
key: "getValue",
|
33
|
+
value: function getValue(hasValidate) {
|
34
|
+
var _this = this;
|
35
|
+
return new Promise(function (resolve, reject) {
|
36
|
+
try {
|
37
|
+
var _this$getBusActionNam;
|
38
|
+
var eventCallbackId = uuid();
|
39
|
+
_this.logger.logInfo({
|
40
|
+
title: 'sdk_event_apiGetValue'
|
41
|
+
});
|
42
|
+
var actionName = (_this$getBusActionNam = _this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.getValue;
|
43
|
+
if (actionName && BusManager.isSubscribed(actionName)) {
|
44
|
+
// 执行出错了,在通用拦截器返回
|
45
|
+
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
46
|
+
appendParams: _this._appendParams,
|
47
|
+
options: _this.originOptions,
|
48
|
+
data: hasValidate
|
49
|
+
}))).then(function (busMessage) {
|
50
|
+
resolve(busMessage === null || busMessage === void 0 ? void 0 : busMessage.getJSONObject());
|
51
|
+
});
|
52
|
+
} else {
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
54
|
+
_this._eventCenter.once(eventCallbackId, function (_data) {
|
55
|
+
resolve(_data);
|
56
|
+
});
|
57
|
+
_this._componentApp.dispatchToApp({
|
58
|
+
context: {
|
59
|
+
event: 'getValue',
|
60
|
+
eventCallbackId: eventCallbackId,
|
61
|
+
data: hasValidate
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
} catch (error) {
|
66
|
+
reject(error);
|
67
|
+
}
|
68
|
+
});
|
69
|
+
}
|
70
|
+
}]);
|
71
|
+
return AddressComponent;
|
72
|
+
}(AMSComponent);
|
@@ -3,12 +3,15 @@ import { componentSignEnum, IcreateComponent, IoptionsParams, IpaymentSessionMet
|
|
3
3
|
import CoreInstance from '../instance/index';
|
4
4
|
export declare const getComponentSign: (params: IpaymentSessionMetaData) => componentSignEnum;
|
5
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
11
|
channelType: componentSignEnum[];
|
9
12
|
productSceneVersion: string;
|
10
13
|
timer: any;
|
11
|
-
constructor(options:
|
14
|
+
constructor(options: IAMSComponentOptions);
|
12
15
|
private parameterInitAndCheck;
|
13
16
|
private pluginAppendIframe;
|
14
17
|
private savePreviousChannel;
|
@@ -31,7 +34,7 @@ export declare class AMSComponent extends CoreInstance {
|
|
31
34
|
createComponent(params: IcreateComponent): Promise<void>;
|
32
35
|
private createComponentProcess;
|
33
36
|
preloadComponent(channelType: any, productSceneVersion: any): void;
|
34
|
-
clearPreloadIframe
|
37
|
+
private clearPreloadIframe;
|
35
38
|
/**
|
36
39
|
* @description Create and render components in the specified element area
|
37
40
|
* @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.
|
@@ -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 { componentSignEnum, environmentEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
|
43
|
+
import { componentSignEnum, ComponentSignEnumV2, environmentEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } 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 {
|
@@ -85,7 +91,7 @@ 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
97
|
renderDisplayType: renderDisplayTypeEnum.popup
|
@@ -95,6 +101,15 @@ var handleParams = function handleParams(params) {
|
|
95
101
|
parseData = _handleSessionData2[0],
|
96
102
|
sessionData = _handleSessionData2[1];
|
97
103
|
var componentSign = getComponentSign(parseData);
|
104
|
+
if (_toConsumableArray(Object.values(ComponentSignEnumV2)).includes(componentSign) && _params.renderDisplayType === renderDisplayTypeEnum.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
|
+
}
|
98
113
|
if (componentSign === componentSignEnum.NONE) {
|
99
114
|
// eslint-disable-next-line prefer-promise-reject-errors
|
100
115
|
return Promise.reject({
|
@@ -118,22 +133,23 @@ 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
|
-
|
129
|
-
|
140
|
+
_defineProperty(_assertThisInitialized(_this2), "channelType", void 0);
|
141
|
+
_defineProperty(_assertThisInitialized(_this2), "productSceneVersion", void 0);
|
142
|
+
_defineProperty(_assertThisInitialized(_this2), "timer", void 0);
|
143
|
+
var ComponentPlugin = new ComponentApp({
|
144
|
+
appVersion: options.appVersion
|
145
|
+
});
|
130
146
|
ComponentPlugin.setRender(createIframeNode);
|
131
147
|
ComponentPlugin.setPreloadRender(createPreloadIframeNode);
|
132
148
|
// Register Cashier Application Plug in
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
return
|
149
|
+
_this2._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
|
150
|
+
_this2._componentApp = _this2._getPlugin(COMPONENTPLUGINID);
|
151
|
+
_this2.registerBusAbility();
|
152
|
+
return _this2;
|
137
153
|
}
|
138
154
|
_createClass(AMSComponent, [{
|
139
155
|
key: "parameterInitAndCheck",
|
@@ -147,7 +163,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
147
163
|
selector: selector,
|
148
164
|
renderDisplayType: renderDisplayType
|
149
165
|
}, params);
|
150
|
-
if (_params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
|
166
|
+
if (this.options.product !== productSceneEnum.ELEMENT_ADDRESS && _params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
|
151
167
|
return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
|
152
168
|
}
|
153
169
|
if (this.options.networkMode === networkModeEnum.proxy) {
|
@@ -225,7 +241,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
225
241
|
localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
|
226
242
|
}
|
227
243
|
}
|
228
|
-
|
229
244
|
/**
|
230
245
|
* 初始化 Bus总线的能力
|
231
246
|
*/
|
@@ -233,12 +248,12 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
233
248
|
key: "registerBusAbility",
|
234
249
|
value: function registerBusAbility() {
|
235
250
|
var _this$originOptions,
|
236
|
-
|
251
|
+
_this3 = this;
|
237
252
|
BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== environmentEnum.prod, this.logger);
|
238
253
|
BusManager.clear();
|
239
254
|
BusManager.addInterceptor({
|
240
255
|
onPublishException: function onPublishException(message, e) {
|
241
|
-
|
256
|
+
_this3.logger.logError({
|
242
257
|
title: 'onBusPublishException'
|
243
258
|
}, _objectSpread(_objectSpread({}, message), {}, {
|
244
259
|
errorMessage: JSON.stringify(e)
|
@@ -247,12 +262,12 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
247
262
|
});
|
248
263
|
// subscribe basic ablility
|
249
264
|
BusManager.subscribe(new SDKCallbackBusSubscriber(function (state) {
|
250
|
-
var
|
251
|
-
(
|
265
|
+
var _this3$_componentApp;
|
266
|
+
(_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);
|
252
267
|
}));
|
253
268
|
BusManager.subscribe(new SecurityBusSubscriber(function (deviceIdParameter, isPolling) {
|
254
|
-
var
|
255
|
-
return (
|
269
|
+
var _this3$_componentApp2;
|
270
|
+
return (_this3$_componentApp2 = _this3._componentApp) === null || _this3$_componentApp2 === void 0 ? void 0 : _this3$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
|
256
271
|
}));
|
257
272
|
BusManager.subscribe(new TrackerBusSubscriber(this.logger));
|
258
273
|
// subscribe plugin
|
@@ -267,7 +282,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
267
282
|
}
|
268
283
|
var paymentChannelMatcher = item.paymentChannelMatcher;
|
269
284
|
if (paymentChannelMatcher) {
|
270
|
-
|
285
|
+
_this3._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
|
271
286
|
}
|
272
287
|
var sessionMatcher = item.sessionMatcher;
|
273
288
|
if (sessionMatcher) {
|
@@ -275,19 +290,18 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
275
290
|
if (sessionMatcher.paymentMethodTypes) {
|
276
291
|
sessionMatcher.paymentMethodTypes.forEach(function (paymentMethodType) {
|
277
292
|
var subPluginKey = pluginKey + paymentMethodType;
|
278
|
-
|
293
|
+
_this3._registerPlugin(subPluginKey, item.busActionNames);
|
279
294
|
});
|
280
295
|
} else {
|
281
|
-
|
296
|
+
_this3._registerPlugin(pluginKey, item.busActionNames);
|
282
297
|
}
|
283
298
|
}
|
284
299
|
var optInit = item === null || item === void 0 || (_item$busActionNames = item.busActionNames) === null || _item$busActionNames === void 0 ? void 0 : _item$busActionNames.optional_init;
|
285
300
|
if (optInit) {
|
286
|
-
BusManager.publish(new BusMessage(optInit, JSON.stringify(
|
301
|
+
BusManager.publish(new BusMessage(optInit, JSON.stringify(_this3.originOptions)));
|
287
302
|
}
|
288
303
|
});
|
289
304
|
}
|
290
|
-
|
291
305
|
/**
|
292
306
|
* To determine whether the corresponding payment method is available,
|
293
307
|
* only the channel described in the document will be called, and it will be returned as available by default
|
@@ -298,14 +312,14 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
298
312
|
}, {
|
299
313
|
key: "canMakePayments",
|
300
314
|
value: function canMakePayments(paymentMethod, subPaymentMethod) {
|
301
|
-
var
|
315
|
+
var _this4 = this;
|
302
316
|
// 判断支付方式是否可用
|
303
317
|
return new Promise(function (resolve) {
|
304
|
-
var
|
318
|
+
var _this4$_getPlugin;
|
305
319
|
if (!paymentMethod) {
|
306
320
|
return resolve(true);
|
307
321
|
}
|
308
|
-
var actionName = (
|
322
|
+
var actionName = (_this4$_getPlugin = _this4._getPlugin(paymentMethod)) === null || _this4$_getPlugin === void 0 ? void 0 : _this4$_getPlugin.canMakePayments;
|
309
323
|
if (actionName && BusManager.isSubscribed(actionName)) {
|
310
324
|
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
311
325
|
paymentMethod: paymentMethod,
|
@@ -315,7 +329,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
315
329
|
}).then(function (message) {
|
316
330
|
resolve(message.getJSONObject());
|
317
331
|
}).catch(function (e) {
|
318
|
-
|
332
|
+
_this4.logger.logInfo({
|
319
333
|
title: 'canMakePayments_error'
|
320
334
|
}, {
|
321
335
|
params: JSON.stringify(e)
|
@@ -327,7 +341,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
327
341
|
}
|
328
342
|
});
|
329
343
|
}
|
330
|
-
|
331
344
|
/**
|
332
345
|
* @description Create component application
|
333
346
|
* @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.
|
@@ -335,26 +348,26 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
335
348
|
}, {
|
336
349
|
key: "createComponent",
|
337
350
|
value: function createComponent(params) {
|
338
|
-
var
|
351
|
+
var _this5 = this;
|
339
352
|
this.clearPreloadIframe();
|
340
353
|
this.logger.setComponentStartTime(Date.now());
|
341
354
|
return this.parameterInitAndCheck({
|
342
355
|
params: params,
|
343
356
|
renderDisplayType: renderDisplayTypeEnum.popup
|
344
357
|
}).then(function (_params) {
|
345
|
-
return handleParams(_params);
|
358
|
+
return handleParams(_params, _this5);
|
346
359
|
}).catch(function (error) {
|
347
|
-
|
360
|
+
_this5.logger.logError({
|
348
361
|
title: 'sdk_error_parameter'
|
349
362
|
}, {
|
350
363
|
params: JSON.stringify(params)
|
351
364
|
}).send();
|
352
|
-
|
365
|
+
_this5._eventCenter.emit(EVENT.error.name, error);
|
353
366
|
return Promise.reject(error);
|
354
367
|
}).then(function (appendParams) {
|
355
368
|
var iframeNodesParams = appendParams.iframeNodesParams;
|
356
|
-
|
357
|
-
return
|
369
|
+
_this5.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
370
|
+
return _this5.createComponentProcess(appendParams);
|
358
371
|
});
|
359
372
|
}
|
360
373
|
}, {
|
@@ -378,7 +391,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
378
391
|
}, {
|
379
392
|
key: "preloadComponent",
|
380
393
|
value: function preloadComponent(channelType, productSceneVersion) {
|
381
|
-
var
|
394
|
+
var _this6 = this;
|
382
395
|
this.channelType = channelType;
|
383
396
|
this.productSceneVersion = productSceneVersion;
|
384
397
|
var MAX_CLEAR_TIME = 10000;
|
@@ -394,7 +407,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
394
407
|
});
|
395
408
|
}
|
396
409
|
this.timer = setTimeout(function () {
|
397
|
-
|
410
|
+
_this6.clearPreloadIframe(true);
|
398
411
|
}, MAX_CLEAR_TIME);
|
399
412
|
}
|
400
413
|
}, {
|
@@ -426,7 +439,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
426
439
|
}, {
|
427
440
|
key: "mountComponent",
|
428
441
|
value: function mountComponent(params, selector) {
|
429
|
-
var
|
442
|
+
var _this7 = this;
|
430
443
|
this.clearPreloadIframe();
|
431
444
|
this.logger.setComponentStartTime(Date.now());
|
432
445
|
return this.parameterInitAndCheck({
|
@@ -434,19 +447,19 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
434
447
|
renderDisplayType: renderDisplayTypeEnum.inline,
|
435
448
|
selector: selector
|
436
449
|
}).then(function (_params) {
|
437
|
-
return handleParams(_params);
|
450
|
+
return handleParams(_params, _this7);
|
438
451
|
}).catch(function (error) {
|
439
|
-
|
452
|
+
_this7.logger.logError({
|
440
453
|
title: 'sdk_error_parameter'
|
441
454
|
}, {
|
442
455
|
params: JSON.stringify(params)
|
443
456
|
}).send();
|
444
|
-
|
457
|
+
_this7._eventCenter.emit(EVENT.error.name, error);
|
445
458
|
return Promise.reject(error);
|
446
459
|
}).then(function (appendParams) {
|
447
460
|
var iframeNodesParams = appendParams.iframeNodesParams;
|
448
|
-
|
449
|
-
return
|
461
|
+
_this7.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
462
|
+
return _this7.mountComponentProcess(appendParams);
|
450
463
|
});
|
451
464
|
}
|
452
465
|
}, {
|
@@ -464,10 +477,11 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
464
477
|
return Promise.resolve();
|
465
478
|
}
|
466
479
|
var iframeNodesParams = appendParams.iframeNodesParams;
|
467
|
-
this.
|
480
|
+
if (this.options.product !== productSceneEnum.ELEMENT_ADDRESS) {
|
481
|
+
this.savePreviousChannel(iframeNodesParams);
|
482
|
+
}
|
468
483
|
return this.pluginAppendIframe(appendParams);
|
469
484
|
}
|
470
|
-
|
471
485
|
/**
|
472
486
|
* @description Execute payment submission process
|
473
487
|
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
@@ -476,30 +490,30 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
476
490
|
}, {
|
477
491
|
key: "submit",
|
478
492
|
value: function submit(data) {
|
479
|
-
var
|
493
|
+
var _this8 = this;
|
480
494
|
return new Promise(function (resolve, reject) {
|
481
495
|
try {
|
482
|
-
var
|
496
|
+
var _this8$getBusActionNa;
|
483
497
|
var eventCallbackId = uuid();
|
484
|
-
|
498
|
+
_this8.logger.logInfo({
|
485
499
|
title: 'sdk_event_apiSubmit'
|
486
500
|
});
|
487
|
-
var actionName = (
|
501
|
+
var actionName = (_this8$getBusActionNa = _this8.getBusActionNames()) === null || _this8$getBusActionNa === void 0 ? void 0 : _this8$getBusActionNa.submit;
|
488
502
|
if (actionName && BusManager.isSubscribed(actionName)) {
|
489
503
|
// 执行出错了,在通用拦截器返回
|
490
504
|
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
491
|
-
appendParams:
|
492
|
-
options:
|
505
|
+
appendParams: _this8._appendParams,
|
506
|
+
options: _this8.originOptions,
|
493
507
|
data: data
|
494
508
|
}))).then(function (busMessage) {
|
495
509
|
resolve(busMessage === null || busMessage === void 0 ? void 0 : busMessage.getJSONObject());
|
496
510
|
});
|
497
511
|
} else {
|
498
512
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
499
|
-
|
513
|
+
_this8._eventCenter.once(eventCallbackId, function (_data) {
|
500
514
|
resolve(_data);
|
501
515
|
});
|
502
|
-
|
516
|
+
_this8._componentApp.dispatchToApp({
|
503
517
|
context: {
|
504
518
|
event: 'submitPay',
|
505
519
|
eventCallbackId: eventCallbackId,
|
@@ -6,6 +6,7 @@
|
|
6
6
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
7
7
|
*/
|
8
8
|
import { ComponentActionNamesType } from 'src/plugin/type';
|
9
|
+
import ComponentApp from '../../plugin/component';
|
9
10
|
import type { AMSCheckoutOptions, IAppendParams, InitSecurityConfig, IoptionsParams } from '../../types/index';
|
10
11
|
import { EventCenter } from '../../util/index';
|
11
12
|
import { Logger } from '../../util/logger';
|
@@ -18,6 +19,7 @@ export default class AMSSDK {
|
|
18
19
|
_instanceId: string;
|
19
20
|
_storageId: string;
|
20
21
|
_appendParams: IAppendParams;
|
22
|
+
_componentApp: ComponentApp;
|
21
23
|
protected securitySdkMap: Map<string, Security>;
|
22
24
|
protected plugins: Map<string, any>;
|
23
25
|
constructor(options: IoptionsParams);
|