@alipay/ams-checkout 0.0.1713838058-dev.3 → 0.0.1713844123-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/core/bus/index.d.ts +1 -1
- package/esm/core/bus/interface.d.ts +1 -5
- package/esm/core/bus/interface.js +1 -6
- package/esm/core/component/index.js +9 -11
- package/esm/core/instance/index.d.ts +1 -8
- package/esm/core/instance/index.js +11 -18
- package/esm/plugin/applepay/component.d.ts +1 -1
- package/esm/plugin/applepay/component.js +5 -5
- package/esm/plugin/applepay/index.d.ts +1 -1
- package/esm/plugin/applepay/index.js +6 -6
- package/esm/plugin/component/cashierApp.d.ts +2 -6
- package/esm/plugin/component/cashierApp.js +13 -69
- package/esm/plugin/component/channel.d.ts +20 -0
- package/esm/plugin/component/channel.js +38 -0
- package/esm/plugin/component/component.popup.style.d.ts +4 -1
- package/esm/plugin/component/component.popup.style.js +7 -1
- package/esm/plugin/component/index.js +119 -110
- package/esm/plugin/const.js +4 -18
- package/esm/plugin/type.d.ts +2 -2
- package/esm/request/index.js +2 -2
- package/esm/types/index.d.ts +6 -53
- package/esm/types/index.js +1 -18
- package/esm/util/index.d.ts +1 -2
- package/esm/util/index.js +2 -4
- package/esm/util/logger.d.ts +0 -8
- package/esm/util/logger.js +3 -34
- package/esm/util/versionCompare.d.ts +1 -8
- package/esm/util/versionCompare.js +0 -22
- package/package.json +1 -1
- package/esm/plugin/paypal/index.d.ts +0 -20
- package/esm/plugin/paypal/index.js +0 -389
- package/esm/plugin/utils.d.ts +0 -6
- package/esm/plugin/utils.js +0 -21
- package/esm/util/debug.d.ts +0 -1
- package/esm/util/debug.js +0 -9
- package/esm/util/storage.d.ts +0 -2
- package/esm/util/storage.js +0 -23
- package/esm/util/upgrade.d.ts +0 -39
- package/esm/util/upgrade.js +0 -115
package/esm/core/bus/index.d.ts
CHANGED
@@ -4,11 +4,7 @@ export declare enum PaymentActionEnum {
|
|
4
4
|
export declare enum ApplePayActionEnum {
|
5
5
|
canMakePayments = "plugin_CARD_APPLE_PAY_available",
|
6
6
|
createComponent = "plugin_CARD_APPLE_PAY_createComponent",
|
7
|
-
|
8
|
-
}
|
9
|
-
export declare enum PaypalActionEnum {
|
10
|
-
mountComponent = "plugin_Paypal_mountComponent",
|
11
|
-
destroyComponent = "plugin_Paypal_destroyComponent"
|
7
|
+
destoryComponent = "plugin_CARD_APPLE_PAY_destoryComponent"
|
12
8
|
}
|
13
9
|
export declare enum SDKCallbackActionEnum {
|
14
10
|
onEventCallback = "onEventCallback"
|
@@ -5,14 +5,9 @@ export var PaymentActionEnum = /*#__PURE__*/function (PaymentActionEnum) {
|
|
5
5
|
export var ApplePayActionEnum = /*#__PURE__*/function (ApplePayActionEnum) {
|
6
6
|
ApplePayActionEnum["canMakePayments"] = "plugin_CARD_APPLE_PAY_available";
|
7
7
|
ApplePayActionEnum["createComponent"] = "plugin_CARD_APPLE_PAY_createComponent";
|
8
|
-
ApplePayActionEnum["
|
8
|
+
ApplePayActionEnum["destoryComponent"] = "plugin_CARD_APPLE_PAY_destoryComponent";
|
9
9
|
return ApplePayActionEnum;
|
10
10
|
}({});
|
11
|
-
export var PaypalActionEnum = /*#__PURE__*/function (PaypalActionEnum) {
|
12
|
-
PaypalActionEnum["mountComponent"] = "plugin_Paypal_mountComponent";
|
13
|
-
PaypalActionEnum["destroyComponent"] = "plugin_Paypal_destroyComponent";
|
14
|
-
return PaypalActionEnum;
|
15
|
-
}({});
|
16
11
|
export var SDKCallbackActionEnum = /*#__PURE__*/function (SDKCallbackActionEnum) {
|
17
12
|
SDKCallbackActionEnum["onEventCallback"] = "onEventCallback";
|
18
13
|
return SDKCallbackActionEnum;
|
@@ -29,19 +29,18 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
29
|
*/
|
30
30
|
import { v4 as uuid } from 'uuid';
|
31
31
|
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
32
|
-
import { ApplePayBusSubscriber } from "../../plugin/applepay";
|
33
32
|
import ComponentApp from "../../plugin/component";
|
34
|
-
import { ExtendPlugin } from "../../plugin/const";
|
35
|
-
import { PaypalBusSubscriber } from "../../plugin/paypal";
|
36
33
|
import { componentSignEnum, environmentEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
|
37
34
|
import { getOrSetStorageId, isPC, parseBase64ToString } from "../../util";
|
38
35
|
import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
|
39
36
|
import { getSecurityConfigStorageKey } from "../../util/security";
|
37
|
+
import CoreInstance from "../instance/index";
|
40
38
|
import { BusManager, BusMessage } from "../bus";
|
41
39
|
import { SDKCallbackBusSubscriber } from "../bus/ability/callback";
|
40
|
+
import { ApplePayBusSubscriber } from "../../plugin/applepay";
|
42
41
|
import { SecurityBusSubscriber } from "../bus/ability/security";
|
43
42
|
import { TrackerBusSubscriber } from "../bus/ability/tracker";
|
44
|
-
import
|
43
|
+
import { ExtendPlugin } from "../../plugin/const";
|
45
44
|
export var getComponentSign = function getComponentSign(params) {
|
46
45
|
var _params$paymentSessio = params.paymentSessionConfig,
|
47
46
|
_params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
|
@@ -65,7 +64,11 @@ var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
|
|
65
64
|
if (isPC() && parseData !== null && parseData !== void 0 && parseData.paymentSessionConfig) {
|
66
65
|
var productScene = parseData.paymentSessionConfig.productScene;
|
67
66
|
if (productScene === productSceneEnum.EASY_PAY) {
|
68
|
-
|
67
|
+
var _parseData$paymentMet;
|
68
|
+
// 非TOSS渠道,在PC场景需要改成1.0
|
69
|
+
if ('BANKTRANSFER_QUICKPAY' !== (parseData === null || parseData === void 0 || (_parseData$paymentMet = parseData.paymentMethodInfoView) === null || _parseData$paymentMet === void 0 ? void 0 : _parseData$paymentMet.paymentMethodType)) {
|
70
|
+
parseData.paymentSessionConfig.productSceneVersion = '1.0';
|
71
|
+
}
|
69
72
|
}
|
70
73
|
}
|
71
74
|
};
|
@@ -231,7 +234,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
231
234
|
BusManager.subscribe(new TrackerBusSubscriber(this.logger));
|
232
235
|
// subscribe plugin
|
233
236
|
BusManager.subscribe(new ApplePayBusSubscriber(this.logger));
|
234
|
-
BusManager.subscribe(new PaypalBusSubscriber(this.logger));
|
235
237
|
|
236
238
|
// register bus plugin
|
237
239
|
ExtendPlugin.forEach(function (item) {
|
@@ -267,7 +269,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
267
269
|
* only the channel described in the document will be called, and it will be returned as available by default
|
268
270
|
* @param paymentMethod - described in the document
|
269
271
|
* @param subPaymentMethod - described in the document
|
270
|
-
* @returns
|
272
|
+
* @returns
|
271
273
|
*/
|
272
274
|
}, {
|
273
275
|
key: "canMakePayments",
|
@@ -325,8 +327,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
325
327
|
_this4._eventCenter.emit(EVENT.error.name, error);
|
326
328
|
return Promise.reject(error);
|
327
329
|
}).then(function (appendParams) {
|
328
|
-
var iframeNodesParams = appendParams.iframeNodesParams;
|
329
|
-
_this4.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
330
330
|
return _this4.createComponentProcess(appendParams);
|
331
331
|
});
|
332
332
|
}
|
@@ -416,8 +416,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
416
416
|
_this6._eventCenter.emit(EVENT.error.name, error);
|
417
417
|
return Promise.reject(error);
|
418
418
|
}).then(function (appendParams) {
|
419
|
-
var iframeNodesParams = appendParams.iframeNodesParams;
|
420
|
-
_this6.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
421
419
|
return _this6.mountComponentProcess(appendParams);
|
422
420
|
});
|
423
421
|
}
|
@@ -1,15 +1,8 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
-
*
|
4
|
-
* 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:
|
5
|
-
* 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
|
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
|
-
*/
|
8
|
-
import { ComponentActionNamesType } from 'src/plugin/type';
|
9
1
|
import type { AMSCheckoutOptions, IAppendParams, InitSecurityConfig, IoptionsParams } from '../../types/index';
|
10
2
|
import { EventCenter } from '../../util/index';
|
11
3
|
import { Logger } from '../../util/logger';
|
12
4
|
import { Security } from '../../util/security';
|
5
|
+
import { ComponentActionNamesType } from 'src/plugin/type';
|
13
6
|
export default class AMSSDK {
|
14
7
|
options: AMSCheckoutOptions;
|
15
8
|
originOptions: IoptionsParams;
|
@@ -16,7 +16,6 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
16
16
|
* 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.
|
17
17
|
*/
|
18
18
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
19
|
-
|
20
19
|
import { v4 as uuid } from 'uuid';
|
21
20
|
import { sdkVersion } from "../../config/index";
|
22
21
|
import { ERRORMESSAGE, EVENT } from "../../constant";
|
@@ -25,8 +24,8 @@ import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, productSceneEnu
|
|
25
24
|
import { checkTimeElapsed, device, EventCenter, getOrSetStorageId, getType, queryParse, safeJson } from "../../util/index";
|
26
25
|
import CallApp from "../../util/intl-callapp/es/main";
|
27
26
|
import { LogConfig, Logger } from "../../util/logger";
|
28
|
-
import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security, SecurityRegionEnum } from "../../util/security";
|
29
27
|
import { compareVersion } from "../../util/versionCompare";
|
28
|
+
import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security, SecurityRegionEnum } from "../../util/security";
|
30
29
|
import { BusManager, BusMessage } from "../bus";
|
31
30
|
var AMSSDK = /*#__PURE__*/function () {
|
32
31
|
function AMSSDK(options) {
|
@@ -58,16 +57,13 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
58
57
|
|
59
58
|
// TODO Consumption data analysis control parameters
|
60
59
|
this.logger = new Logger(LogConfig, ![environmentEnum.prod, environmentEnum.sandbox].includes(options === null || options === void 0 ? void 0 : options.environment));
|
61
|
-
Logger.setInstance(this.logger);
|
62
60
|
this.logger.setMedta({
|
63
61
|
instanceId: this._instanceId
|
64
62
|
});
|
65
63
|
this.logger.initTracker();
|
66
|
-
this.logger.setComponentStartTime(Date.now());
|
67
|
-
this.logger.setTrackId(this._instanceId);
|
68
64
|
this.logger.logInfo({
|
69
65
|
title: 'NEW_AMSSDK_BY_MECHANT',
|
70
|
-
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale)
|
66
|
+
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale, "}")
|
71
67
|
}).send();
|
72
68
|
this.preInitSecurity(options);
|
73
69
|
}
|
@@ -91,7 +87,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
91
87
|
var matchingConfig = config['pl_sec'].find(function (item) {
|
92
88
|
var _item$v, _item$v2, _item$platform;
|
93
89
|
var minVersion = item === null || item === void 0 || (_item$v = item.v) === null || _item$v === void 0 ? void 0 : _item$v.split('|')[0];
|
94
|
-
var maxVersion = (item === null || item === void 0 || (_item$v2 = item.v) === null || _item$v2 === void 0 ? void 0 : _item$v2.split('|')[1]) || '
|
90
|
+
var maxVersion = (item === null || item === void 0 || (_item$v2 = item.v) === null || _item$v2 === void 0 ? void 0 : _item$v2.split('|')[1]) || '999.9.9';
|
95
91
|
var matchVersion = compareVersion(sdkVersion, minVersion) >= 0 && compareVersion(maxVersion, sdkVersion) >= 0;
|
96
92
|
return ((item === null || item === void 0 || (_item$platform = item.platform) === null || _item$platform === void 0 ? void 0 : _item$platform.includes('Web')) || (item === null || item === void 0 ? void 0 : item.platform) === '') && (item === null || item === void 0 ? void 0 : item.product) === product && (!(item !== null && item !== void 0 && item.v) || matchVersion);
|
97
93
|
});
|
@@ -114,13 +110,11 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
114
110
|
this.logger.logInfo({
|
115
111
|
title: 'sdk_event_apiOnDestroy'
|
116
112
|
}).send();
|
117
|
-
var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.
|
113
|
+
var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.destoryComponent;
|
118
114
|
if (actionName && BusManager.isSubscribed(actionName)) {
|
119
|
-
var _this$_appendParams;
|
120
115
|
// 执行出错了,在通用拦截器返回
|
121
116
|
BusManager.publish(new BusMessage(actionName, JSON.stringify({
|
122
|
-
options: this.originOptions
|
123
|
-
selector: (_this$_appendParams = this._appendParams) === null || _this$_appendParams === void 0 || (_this$_appendParams = _this$_appendParams.iframeNodesParams) === null || _this$_appendParams === void 0 ? void 0 : _this$_appendParams.selector
|
117
|
+
options: this.originOptions
|
124
118
|
})));
|
125
119
|
}
|
126
120
|
var _iterator = _createForOfIteratorHelper(this.plugins.values()),
|
@@ -322,14 +316,14 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
322
316
|
key: "_registerPlugin",
|
323
317
|
value: function _registerPlugin(pluginId, plugin) {
|
324
318
|
this.plugins.set(pluginId, plugin);
|
325
|
-
|
326
|
-
|
319
|
+
try {
|
320
|
+
if (plugin.applyPlugin) {
|
327
321
|
plugin.applyPlugin(this);
|
328
|
-
} catch (error) {
|
329
|
-
this.plugins.delete(pluginId);
|
330
|
-
if (getType(error) === 'error') throw error;
|
331
|
-
throw new Error("Failed to register plug-in\uFF1A".concat(pluginId, " Exception in the apply function of the plug-in"));
|
332
322
|
}
|
323
|
+
} catch (error) {
|
324
|
+
this.plugins.delete(pluginId);
|
325
|
+
if (getType(error) === 'error') throw error;
|
326
|
+
throw new Error("Failed to register plug-in\uFF1A".concat(pluginId, " Exception in the apply function of the plug-in"));
|
333
327
|
}
|
334
328
|
}
|
335
329
|
/**
|
@@ -344,7 +338,6 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
344
338
|
}
|
345
339
|
return this.plugins.get(pluginId);
|
346
340
|
}
|
347
|
-
|
348
341
|
/**
|
349
342
|
* @description Execute to open app or jump link
|
350
343
|
*/
|
@@ -14,7 +14,7 @@ export declare enum ApplePayComponentEvent {
|
|
14
14
|
sdk_event_appleOnvalidatemerchant = "sdk_event_appleOnvalidatemerchant",
|
15
15
|
sdk_event_appleSubmitToken = "sdk_event_appleSubmitToken",
|
16
16
|
sdk_event_applePaymentResult = "sdk_event_applePaymentResult",
|
17
|
-
|
17
|
+
sdk_event_appleDestoryComponent = "sdk_event_appleDestoryComponent"
|
18
18
|
}
|
19
19
|
/**
|
20
20
|
* Apple pay Component
|
@@ -27,7 +27,7 @@ export var ApplePayComponentEvent = /*#__PURE__*/function (ApplePayComponentEven
|
|
27
27
|
ApplePayComponentEvent["sdk_event_appleOnvalidatemerchant"] = "sdk_event_appleOnvalidatemerchant";
|
28
28
|
ApplePayComponentEvent["sdk_event_appleSubmitToken"] = "sdk_event_appleSubmitToken";
|
29
29
|
ApplePayComponentEvent["sdk_event_applePaymentResult"] = "sdk_event_applePaymentResult";
|
30
|
-
ApplePayComponentEvent["
|
30
|
+
ApplePayComponentEvent["sdk_event_appleDestoryComponent"] = "sdk_event_appleDestoryComponent";
|
31
31
|
return ApplePayComponentEvent;
|
32
32
|
}({});
|
33
33
|
|
@@ -55,8 +55,8 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
55
55
|
|
56
56
|
/**
|
57
57
|
* Is Apple Pay Enabled
|
58
|
-
* @param subTypeEnum
|
59
|
-
* @returns
|
58
|
+
* @param subTypeEnum
|
59
|
+
* @returns
|
60
60
|
*/
|
61
61
|
_createClass(ApplePayComponent, [{
|
62
62
|
key: "canMakePayments",
|
@@ -66,8 +66,8 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
66
66
|
|
67
67
|
/**
|
68
68
|
* Is Apple Pay Enabled
|
69
|
-
* @param subTypeEnum
|
70
|
-
* @returns
|
69
|
+
* @param subTypeEnum
|
70
|
+
* @returns
|
71
71
|
*/
|
72
72
|
}, {
|
73
73
|
key: "isAppPayEnabled",
|
@@ -12,6 +12,6 @@ export declare class ApplePayBusSubscriber extends BusSubscriber {
|
|
12
12
|
protected onOptionalInit(context: BusContext, message: BusMessage): void;
|
13
13
|
protected onCanMakePayments(context: BusContext, message: BusMessage): void;
|
14
14
|
protected onCreateComponent(context: BusContext, message: BusMessage): void;
|
15
|
-
protected
|
15
|
+
protected onDestoryComponent(context: BusContext, message: BusMessage): void;
|
16
16
|
onMessage(context: BusContext, message: BusMessage): void;
|
17
17
|
}
|
@@ -80,13 +80,13 @@ export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
80
80
|
this.applePay.submitPay(appendParams);
|
81
81
|
}
|
82
82
|
}, {
|
83
|
-
key: "
|
84
|
-
value: function
|
83
|
+
key: "onDestoryComponent",
|
84
|
+
value: function onDestoryComponent(context, message) {
|
85
85
|
this.applePay = null;
|
86
|
-
console.log('
|
86
|
+
console.log('onDestoryComponent', context, message);
|
87
87
|
this.logger.logInfo({
|
88
88
|
name: 'APPLE_PAY',
|
89
|
-
title: ApplePayComponentEvent.
|
89
|
+
title: ApplePayComponentEvent.sdk_event_appleDestoryComponent
|
90
90
|
}, {
|
91
91
|
biz: 'sdk',
|
92
92
|
type: 'funnel'
|
@@ -105,8 +105,8 @@ export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
105
105
|
case ApplePayActionEnum.createComponent:
|
106
106
|
this.onCreateComponent(context, message);
|
107
107
|
break;
|
108
|
-
case ApplePayActionEnum.
|
109
|
-
this.
|
108
|
+
case ApplePayActionEnum.destoryComponent:
|
109
|
+
this.onDestoryComponent(context, message);
|
110
110
|
break;
|
111
111
|
default:
|
112
112
|
console.log("Unknown action: " + message.getAction());
|
@@ -1,18 +1,15 @@
|
|
1
|
-
import { componentSignEnum, Ianalytics
|
2
|
-
export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum,
|
1
|
+
import { renderDisplayTypeEnum, componentSignEnum, Ianalytics } from '../../types';
|
2
|
+
export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productSceneVersion: string, extendInfo: string) => any;
|
3
3
|
export declare const getAppDomain: (domainParams: {
|
4
4
|
environment: string;
|
5
5
|
appVersion: string;
|
6
6
|
componentSign: componentSignEnum;
|
7
|
-
productScene: string;
|
8
7
|
productSceneVersion: string;
|
9
8
|
extendInfo: string;
|
10
|
-
mid: string;
|
11
9
|
}) => string;
|
12
10
|
export declare const getIframeUrl: (iframeParams: {
|
13
11
|
componentSign: componentSignEnum;
|
14
12
|
analytics?: Ianalytics;
|
15
|
-
productScene: string;
|
16
13
|
productSceneVersion: string;
|
17
14
|
environment: string;
|
18
15
|
appVersion: string;
|
@@ -22,7 +19,6 @@ export declare const getIframeUrl: (iframeParams: {
|
|
22
19
|
renderDisplayType: renderDisplayTypeEnum;
|
23
20
|
isPreload?: string;
|
24
21
|
hostSign?: string;
|
25
|
-
mid: string;
|
26
22
|
}) => {
|
27
23
|
path: string;
|
28
24
|
locationSearch: string;
|
@@ -10,46 +10,18 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
10
10
|
* 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.
|
11
11
|
*/
|
12
12
|
import { marmotMap, sdkVersion } from "../../config/index";
|
13
|
-
import { componentSignEnum } from "../../types";
|
14
|
-
import { isDebugLog } from "../../util/debug";
|
15
13
|
import { getViewPort, queryParse, serialize } from "../../util/index";
|
16
|
-
import {
|
17
|
-
|
18
|
-
var getAppVersion = function getAppVersion(_extendInfo, productScene, mid) {
|
14
|
+
import { componentSignEnum } from "../../types";
|
15
|
+
var getAppVersion = function getAppVersion(_extendInfo) {
|
19
16
|
try {
|
20
|
-
var
|
21
|
-
|
22
|
-
sdkVersion: sdkVersion,
|
23
|
-
productScene: productScene,
|
24
|
-
mid: mid
|
25
|
-
});
|
26
|
-
// 有sessionData加载时
|
27
|
-
(_Logger$getInstance = Logger.getInstance()) === null || _Logger$getInstance === void 0 || _Logger$getInstance.logInfo({
|
28
|
-
title: 'sdk_event_appUpgradeInfo'
|
29
|
-
}, {
|
30
|
-
appUpgradeVersion: appVersion,
|
31
|
-
appUpgraded: appVersion ? true : false,
|
32
|
-
isPreload: _extendInfo ? false : true,
|
33
|
-
extendInfo: _extendInfo,
|
34
|
-
productScene: productScene,
|
35
|
-
mid: mid
|
36
|
-
});
|
37
|
-
// 没有匹配到版本,查询上次的加载版本
|
38
|
-
if (!appVersion) {
|
39
|
-
appVersion = getLastAppVersion(productScene);
|
40
|
-
return appVersion;
|
41
|
-
}
|
42
|
-
// 不为空时代表是有sessionData,因此要保存当前版本
|
43
|
-
if (_extendInfo) {
|
44
|
-
setLastAppVersion(productScene, appVersion);
|
45
|
-
}
|
46
|
-
return appVersion;
|
17
|
+
var info = JSON.parse(_extendInfo);
|
18
|
+
return info.versionMap.web[sdkVersion].targetWebVerison;
|
47
19
|
} catch (error) {
|
48
20
|
return '';
|
49
21
|
}
|
50
22
|
};
|
51
23
|
var getFinalProductSceneVersion = function getFinalProductSceneVersion(componentSign, productSceneVersion) {
|
52
|
-
var signSupportMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, componentSignEnum.NONE, ['']), componentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), componentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), componentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), componentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), componentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), componentSignEnum.VAULTING_CARD, ['1.0']);
|
24
|
+
var signSupportMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, componentSignEnum.NONE, ['']), componentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), componentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), componentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), componentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), componentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), componentSignEnum.EASY_PAY_APM, ['2.0']), componentSignEnum.VAULTING_CARD, ['1.0']);
|
53
25
|
var supportProductSceneVersion = signSupportMap[componentSign];
|
54
26
|
// 从左到右,从旧到新
|
55
27
|
var isSupport = supportProductSceneVersion.find(function (it) {
|
@@ -62,26 +34,13 @@ export var getAppPath = function getAppPath() {
|
|
62
34
|
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
63
35
|
var appVersion = arguments.length > 1 ? arguments[1] : undefined;
|
64
36
|
var componentSign = arguments.length > 2 ? arguments[2] : undefined;
|
65
|
-
var
|
66
|
-
var
|
67
|
-
var extendInfo = arguments.length > 5 ? arguments[5] : undefined;
|
68
|
-
var mid = arguments.length > 6 ? arguments[6] : undefined;
|
37
|
+
var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
|
38
|
+
var extendInfo = arguments.length > 4 ? arguments[4] : undefined;
|
69
39
|
var _ref = queryParse() || {},
|
70
40
|
urlTestHost = _ref.host;
|
71
|
-
var
|
72
|
-
var finalAppVersion = upgradeAppVersion || appVersion;
|
73
|
-
// 当有升级版本时,更新到全局字段
|
74
|
-
if (upgradeAppVersion) {
|
75
|
-
var _Logger$getInstance2;
|
76
|
-
(_Logger$getInstance2 = Logger.getInstance()) === null || _Logger$getInstance2 === void 0 || _Logger$getInstance2.setMedta({
|
77
|
-
webAppVersion: finalAppVersion
|
78
|
-
});
|
79
|
-
}
|
80
|
-
if (isDebugLog()) {
|
81
|
-
console.log('appUpgrade#getAppPath#finalAppVersion', finalAppVersion);
|
82
|
-
console.log('appUpgrade#getAppPath#extendInfo', extendInfo, mid);
|
83
|
-
}
|
41
|
+
var finalAppVersion = getAppVersion(extendInfo) || appVersion;
|
84
42
|
var finalProductSceneVersion = getFinalProductSceneVersion(componentSign, productSceneVersion);
|
43
|
+
|
85
44
|
// only for test while testurl?host=https://xxxxx.test.html
|
86
45
|
if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
|
87
46
|
return urlTestHost;
|
@@ -92,12 +51,10 @@ export var getAppDomain = function getAppDomain(domainParams) {
|
|
92
51
|
var environment = domainParams.environment,
|
93
52
|
appVersion = domainParams.appVersion,
|
94
53
|
componentSign = domainParams.componentSign,
|
95
|
-
productScene = domainParams.productScene,
|
96
54
|
productSceneVersion = domainParams.productSceneVersion,
|
97
|
-
extendInfo = domainParams.extendInfo
|
98
|
-
mid = domainParams.mid;
|
55
|
+
extendInfo = domainParams.extendInfo;
|
99
56
|
var reg = /^https?:\/\/([^/<>\s]+\.?)*/;
|
100
|
-
var macth = reg.exec(getAppPath(environment, appVersion, componentSign,
|
57
|
+
var macth = reg.exec(getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo));
|
101
58
|
return macth && macth[0] || '';
|
102
59
|
};
|
103
60
|
export var getIframeUrl = function getIframeUrl(iframeParams) {
|
@@ -106,7 +63,6 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
106
63
|
analytics = _iframeParams$analyti === void 0 ? {
|
107
64
|
enabled: true
|
108
65
|
} : _iframeParams$analyti,
|
109
|
-
productScene = iframeParams.productScene,
|
110
66
|
productSceneVersion = iframeParams.productSceneVersion,
|
111
67
|
environment = iframeParams.environment,
|
112
68
|
appVersion = iframeParams.appVersion,
|
@@ -117,15 +73,8 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
117
73
|
_iframeParams$isPrelo = iframeParams.isPreload,
|
118
74
|
isPreload = _iframeParams$isPrelo === void 0 ? '' : _iframeParams$isPrelo,
|
119
75
|
_iframeParams$hostSig = iframeParams.hostSign,
|
120
|
-
hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig
|
121
|
-
|
122
|
-
mid = _iframeParams$mid === void 0 ? '' : _iframeParams$mid;
|
123
|
-
var path = getAppPath(environment, appVersion, componentSign, productScene, productSceneVersion, extendInfo || '', mid);
|
124
|
-
var appMatched = getMatchAppVersion(extendInfo, {
|
125
|
-
sdkVersion: sdkVersion,
|
126
|
-
productScene: productScene,
|
127
|
-
mid: mid
|
128
|
-
}) ? 'true' : 'false';
|
76
|
+
hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig;
|
77
|
+
var path = getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo || '');
|
129
78
|
var initialScale = 1;
|
130
79
|
var scale = getViewPort('initial-scale') || initialScale;
|
131
80
|
var _queryParse = queryParse(),
|
@@ -142,7 +91,6 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
142
91
|
locale: locale,
|
143
92
|
scale: scale,
|
144
93
|
instanceId: instanceId,
|
145
|
-
appMatched: appMatched,
|
146
94
|
analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
|
147
95
|
sdkVersion: sdkVersion,
|
148
96
|
refUrl: window.location.href,
|
@@ -158,10 +106,6 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
158
106
|
if (_displayType) urlParams.displayType = _displayType;
|
159
107
|
if (isPreload) urlParams.isPreload = isPreload;
|
160
108
|
var locationSearch = serialize(urlParams);
|
161
|
-
if (isDebugLog()) {
|
162
|
-
console.log('appUpgrade#getIframeUrl#appMatched', appMatched);
|
163
|
-
console.log('appUpgrade#getIframeUrl#url', path, locationSearch);
|
164
|
-
}
|
165
109
|
return {
|
166
110
|
path: path,
|
167
111
|
locationSearch: locationSearch
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import type { IpaymentSessionMetaData } from "src/types";
|
2
|
+
type IChannelBehavior = {
|
3
|
+
usePaymentSessionAsQueryResult: boolean;
|
4
|
+
submitPayInSdk: boolean;
|
5
|
+
createIframeNode: boolean;
|
6
|
+
loadApp: boolean;
|
7
|
+
buildSubmitPayExtParams?: (params: GetDoubleFaParams) => any;
|
8
|
+
allowClickOutsideClose?: boolean;
|
9
|
+
};
|
10
|
+
type GetDoubleFaParams = {
|
11
|
+
instanceId: string;
|
12
|
+
paymentSessionData: string;
|
13
|
+
locale: string;
|
14
|
+
paymentMethodType: string;
|
15
|
+
env: string;
|
16
|
+
sdkVersion: string;
|
17
|
+
};
|
18
|
+
export declare function getChannelBehavior(paymentSessionMetaData?: IpaymentSessionMetaData): IChannelBehavior | undefined;
|
19
|
+
export declare function getDoubleFaUrl(params: GetDoubleFaParams): string;
|
20
|
+
export {};
|
@@ -0,0 +1,38 @@
|
|
1
|
+
export function getChannelBehavior(paymentSessionMetaData) {
|
2
|
+
var _paymentSessionMetaDa, _paymentSessionMetaDa2, _paymentSessionMetaDa3, _paymentSessionMetaDa4;
|
3
|
+
if ('BANKTRANSFER_QUICKPAY' === (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType) && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa2 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa2 === void 0 ? void 0 : _paymentSessionMetaDa2.productScene) === 'EASY_PAY' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa3 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa3 === void 0 ? void 0 : _paymentSessionMetaDa3.paymentMethodCategoryType) === 'APM' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa4 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa4 === void 0 ? void 0 : _paymentSessionMetaDa4.productSceneVersion) === '2.0') {
|
4
|
+
return {
|
5
|
+
usePaymentSessionAsQueryResult: true,
|
6
|
+
submitPayInSdk: true,
|
7
|
+
createIframeNode: true,
|
8
|
+
loadApp: true,
|
9
|
+
allowClickOutsideClose: true,
|
10
|
+
buildSubmitPayExtParams: function buildSubmitPayExtParams(params) {
|
11
|
+
var callBackUrl = getDoubleFaUrl(params);
|
12
|
+
return {
|
13
|
+
callBackUrl: callBackUrl
|
14
|
+
};
|
15
|
+
}
|
16
|
+
};
|
17
|
+
}
|
18
|
+
return undefined;
|
19
|
+
}
|
20
|
+
export function getDoubleFaUrl(params) {
|
21
|
+
var instanceId = params.instanceId,
|
22
|
+
paymentMethodType = params.paymentMethodType,
|
23
|
+
paymentSessionData = params.paymentSessionData,
|
24
|
+
locale = params.locale,
|
25
|
+
env = params.env,
|
26
|
+
sdkVersion = params.sdkVersion;
|
27
|
+
var isLandscapeOrientation = false; // Web 不含横屏
|
28
|
+
|
29
|
+
var DOUBLE_FA_URL_MAPPING = {
|
30
|
+
local: "http://page.alipay.net/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
|
31
|
+
dev: "http://page.alipay.net/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
|
32
|
+
sit: "http://page.test.alipay.net/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
|
33
|
+
pre: "https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html"),
|
34
|
+
prod: "https://ac.alipay.com/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html")
|
35
|
+
};
|
36
|
+
var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
|
37
|
+
return "".concat(doubleFaBaseUrl, "?scene=cashierResultPage&instanceId=").concat(instanceId, "&paymentSessionData=").concat(encodeURIComponent(paymentSessionData), "&isLandscape=").concat(isLandscapeOrientation ? 'true' : '', "&pmt=").concat(paymentMethodType, "&locale=").concat(locale, "&sdkVersion=").concat(sdkVersion);
|
38
|
+
}
|
@@ -5,7 +5,10 @@ export declare const createCloseBtn: (platform: platformEnum, closeBtnFunc: () =
|
|
5
5
|
export declare const createRetentionPopup: (platform: platformEnum, remainBtnFunc: () => void, leaveBtnFunc: () => void) => void;
|
6
6
|
export declare const hideRetentionPopup: () => void;
|
7
7
|
export declare const removeRetentionPopup: (platform: platformEnum, remainBtnFunc: () => void, leaveBtnFunc: () => void) => void;
|
8
|
-
export declare const createMockup: (
|
8
|
+
export declare const createMockup: (options: {
|
9
|
+
platform: platformEnum;
|
10
|
+
onClickOutside: () => void;
|
11
|
+
}) => void;
|
9
12
|
export declare const addPopupLoading: () => void;
|
10
13
|
export declare const handleDeclareInfo: ({ closeDialogData }: {
|
11
14
|
closeDialogData: any;
|
@@ -89,7 +89,8 @@ export var removeRetentionPopup = function removeRetentionPopup(platform, remain
|
|
89
89
|
}
|
90
90
|
(_document$getElementB = document.getElementById(COMPONENT_RETENTION_ID)) === null || _document$getElementB === void 0 || _document$getElementB.remove();
|
91
91
|
};
|
92
|
-
export var createMockup = function createMockup() {
|
92
|
+
export var createMockup = function createMockup(options) {
|
93
|
+
var clickEventName = (options === null || options === void 0 ? void 0 : options.platform) === platformEnum.mobile ? 'touchend' : 'click';
|
93
94
|
var body = document.getElementsByTagName('body')[0];
|
94
95
|
body.style.overflow = 'hidden';
|
95
96
|
var mockup = document.createElement('div');
|
@@ -102,6 +103,11 @@ export var createMockup = function createMockup() {
|
|
102
103
|
mockup.style.background = 'rgba(0,0,0,0.5)';
|
103
104
|
mockup.style.display = 'none';
|
104
105
|
mockup.id = MOCKUP_ID;
|
106
|
+
// let click to close
|
107
|
+
mockup.addEventListener(clickEventName, function () {
|
108
|
+
var _options$onClickOutsi;
|
109
|
+
options === null || options === void 0 || (_options$onClickOutsi = options.onClickOutside) === null || _options$onClickOutsi === void 0 || _options$onClickOutsi.call(options);
|
110
|
+
});
|
105
111
|
body.appendChild(mockup);
|
106
112
|
};
|
107
113
|
export var addPopupLoading = function addPopupLoading() {
|