@alipay/ams-checkout 0.0.1755258862-dev.7 → 0.0.1756796178-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/component/channel.d.ts +3 -1
- package/esm/component/channel.js +26 -62
- package/esm/component/component.inline.style.js +2 -2
- package/esm/component/popupWindow.style.d.ts +4 -1
- package/esm/component/popupWindow.style.js +37 -2
- package/esm/config/index.d.ts +8 -8
- package/esm/config/index.js +8 -8
- package/esm/constant/easysafepay.d.ts +16 -0
- package/esm/constant/easysafepay.js +19 -0
- package/esm/constant/index.d.ts +41 -2
- package/esm/constant/index.js +43 -5
- package/esm/core/component/ckp/index.d.ts +2 -0
- package/esm/core/component/ckp/index.js +41 -5
- package/esm/core/component/element/elementContainerService/containerService.d.ts +33 -0
- package/esm/core/component/element/elementContainerService/containerService.js +123 -0
- package/esm/core/component/element/elementContainerService/index.d.ts +20 -0
- package/esm/core/component/element/elementContainerService/index.js +63 -0
- package/esm/core/component/element/elementController/index.d.ts +27 -0
- package/esm/core/component/element/elementController/index.js +493 -0
- package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +20 -0
- package/esm/core/component/element/elementProcessor/addressProcessor.js +160 -0
- package/esm/core/component/element/elementProcessor/authProcessor.d.ts +20 -0
- package/esm/core/component/element/elementProcessor/authProcessor.js +125 -0
- package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +41 -0
- package/esm/core/component/element/elementProcessor/baseElementProcessor.js +96 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +20 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +380 -0
- package/esm/core/component/element/index.d.ts +7 -46
- package/esm/core/component/element/index.js +31 -923
- package/esm/core/component/element/mock.d.ts +4 -0
- package/esm/core/component/element/mock.js +365 -1
- package/esm/core/component/element/type.d.ts +74 -34
- package/esm/core/component/element/type.js +20 -12
- package/esm/core/component/element/util.d.ts +69 -0
- package/esm/core/component/element/util.js +477 -0
- package/esm/core/component/index.d.ts +5 -1
- package/esm/core/component/index.js +1 -2
- package/esm/core/component/oldElement/index.d.ts +59 -0
- package/esm/core/component/oldElement/index.js +956 -0
- package/esm/core/component/oldElement/mock.d.ts +6 -0
- package/esm/core/component/oldElement/mock.js +567 -0
- package/esm/core/component/oldElement/type.d.ts +354 -0
- package/esm/core/component/oldElement/type.js +81 -0
- package/esm/core/instance/index.d.ts +1 -1
- package/esm/core/instance/index.js +1 -1
- package/esm/foundation/core/index.d.ts +9 -1
- package/esm/foundation/core/index.js +153 -53
- package/esm/foundation/index.d.ts +20 -0
- package/esm/foundation/index.js +13 -2
- package/esm/foundation/product-processor/autoDebit/deps.d.ts +14 -0
- package/esm/foundation/product-processor/autoDebit/deps.js +12 -0
- package/esm/foundation/product-processor/autoDebit/index.d.ts +48 -0
- package/esm/foundation/product-processor/autoDebit/index.js +466 -0
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +3 -1
- package/esm/foundation/product-processor/easysafepay/deps.js +3 -1
- package/esm/foundation/product-processor/easysafepay/index.d.ts +5 -0
- package/esm/foundation/product-processor/easysafepay/index.js +271 -169
- package/esm/foundation/product-processor/element/index.d.ts +7 -0
- package/esm/foundation/product-processor/element/index.js +24 -0
- package/esm/foundation/service/container/index.d.ts +14 -3
- package/esm/foundation/service/container/index.js +178 -25
- package/esm/foundation/service/container/popup.d.ts +10 -7
- package/esm/foundation/service/container/popup.js +3 -1
- package/esm/foundation/service/event-center.js +1 -0
- package/esm/foundation/service/log/keys.js +3 -1
- package/esm/foundation/service/log/types.d.ts +1 -0
- package/esm/foundation/service/requester/requester.js +20 -109
- package/esm/foundation/utils/preload_helper.d.ts +2 -2
- package/esm/foundation/utils/preload_helper.js +8 -6
- package/esm/foundation/utils/redirect_utils.js +34 -18
- package/esm/foundation/utils/web_app_url_utils.d.ts +71 -1
- package/esm/foundation/utils/web_app_url_utils.js +219 -8
- package/esm/index.d.ts +8 -5
- package/esm/index.js +103 -53
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/cashierApp.js +5 -5
- package/esm/plugin/component/channel.d.ts +3 -1
- package/esm/plugin/component/channel.js +10 -12
- package/esm/plugin/component/index.js +49 -45
- package/esm/plugin/type.d.ts +1 -1
- package/esm/request/index.js +2 -2
- package/esm/types/index.d.ts +37 -3
- package/esm/types/index.js +10 -2
- package/esm/util/index.d.ts +12 -1
- package/esm/util/index.js +39 -3
- package/esm/util/redirect.d.ts +6 -0
- package/esm/util/redirect.js +54 -0
- package/esm/util/spm-map.d.ts +18 -4
- package/esm/util/spm-map.js +20 -6
- package/package.json +27 -4
- /package/esm/core/component/{element → oldElement}/components/address.d.ts +0 -0
- /package/esm/core/component/{element → oldElement}/components/address.js +0 -0
- /package/esm/core/component/{element → oldElement}/components/auth.d.ts +0 -0
- /package/esm/core/component/{element → oldElement}/components/auth.js +0 -0
- /package/esm/core/component/{element → oldElement}/components/payment.d.ts +0 -0
- /package/esm/core/component/{element → oldElement}/components/payment.js +0 -0
- /package/esm/core/component/{element → oldElement}/utils.d.ts +0 -0
- /package/esm/core/component/{element → oldElement}/utils.js +0 -0
@@ -12,20 +12,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
12
12
|
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); }
|
13
13
|
import axios from 'axios';
|
14
14
|
import { ServiceProvider } from '..';
|
15
|
-
// import { lightSandboxMap, appId, hostSignMap, requestHost, sofaId, tntInstId } from '../../../config/request';
|
16
|
-
// import { device, isPC, queryParse, safeJson } from '../../../util';
|
17
|
-
// import { fomatGetwayError } from '../../../request/utils';
|
18
|
-
// import { get } from '../../../util/get';
|
19
|
-
// import { PaymentContext, Service } from '../../index';
|
20
|
-
// import { sdkVersion } from '../../../config/index';
|
21
|
-
// import type { LogService } from '../log';
|
22
|
-
// import type { IoptionsParams, RequestConfig } from '../../../types';
|
23
|
-
// import type { LogExtra, LogPayload } from '../log/types';
|
24
|
-
// import type { SDKMetaData } from '../../index';
|
25
|
-
// import { errorEnum } from '../../../types';
|
26
|
-
|
27
15
|
import { errorEnum } from "./deps";
|
28
|
-
import { device, fomatGetwayError, get,
|
16
|
+
import { appId, device, fomatGetwayError, get, hostSignMap, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
|
29
17
|
|
30
18
|
/**
|
31
19
|
* @author congle.zzq <congle.zzq@alipay.com>
|
@@ -62,10 +50,6 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
62
50
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
63
51
|
while (1) switch (_context.prev = _context.next) {
|
64
52
|
case 0:
|
65
|
-
console.log('[DEBUG] - request start', {
|
66
|
-
requestData: requestData,
|
67
|
-
options: options
|
68
|
-
});
|
69
53
|
envInfo = this.getEnvInfo(options);
|
70
54
|
_data = [_objectSpread(_objectSpread({}, requestData), {}, {
|
71
55
|
envInfo: envInfo,
|
@@ -75,29 +59,22 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
75
59
|
})];
|
76
60
|
startTime = Date.now();
|
77
61
|
traceId = '';
|
78
|
-
_context.prev =
|
79
|
-
console.log('[DEBUG] - createRequestInstance start', options);
|
62
|
+
_context.prev = 4;
|
80
63
|
myRequest = this.createRequestInstance(options);
|
81
|
-
|
82
|
-
console.log('[DEBUG] - request payload:', _data);
|
83
|
-
_context.next = 12;
|
64
|
+
_context.next = 8;
|
84
65
|
return myRequest({
|
85
66
|
data: _data
|
86
67
|
});
|
87
|
-
case
|
68
|
+
case 8:
|
88
69
|
_yield$myRequest = _context.sent;
|
89
70
|
data = _yield$myRequest.data;
|
90
71
|
headers = _yield$myRequest.headers;
|
91
72
|
resData = data || {};
|
92
|
-
console.log('[DEBUG] - request response:', {
|
93
|
-
resData: resData,
|
94
|
-
headers: headers
|
95
|
-
});
|
96
73
|
traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
|
97
74
|
resData.traceId = traceId || '';
|
98
75
|
handleGetWayError = fomatGetwayError(headers, traceId);
|
99
76
|
if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
|
100
|
-
_context.next =
|
77
|
+
_context.next = 20;
|
101
78
|
break;
|
102
79
|
}
|
103
80
|
errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
|
@@ -109,7 +86,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
109
86
|
time: Date.now() - startTime,
|
110
87
|
success: false,
|
111
88
|
code: errorCode,
|
112
|
-
|
89
|
+
errorMessage: errorMessage,
|
113
90
|
traceId: traceId
|
114
91
|
});
|
115
92
|
throw new Error(JSON.stringify({
|
@@ -117,7 +94,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
117
94
|
errorCode: errorCode,
|
118
95
|
success: false
|
119
96
|
}));
|
120
|
-
case
|
97
|
+
case 20:
|
121
98
|
this.reportRequestTimeCost({
|
122
99
|
title: 'a3753.b101271.c388193.d521387',
|
123
100
|
name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
|
@@ -125,14 +102,13 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
125
102
|
time: Date.now() - startTime,
|
126
103
|
success: true,
|
127
104
|
code: 'SUCCESS',
|
128
|
-
|
105
|
+
errorMessage: '',
|
129
106
|
traceId: traceId
|
130
107
|
});
|
131
108
|
return _context.abrupt("return", resData);
|
132
|
-
case
|
133
|
-
_context.prev =
|
134
|
-
_context.t0 = _context["catch"](
|
135
|
-
console.log('[DEBUG] - request error:', _context.t0);
|
109
|
+
case 24:
|
110
|
+
_context.prev = 24;
|
111
|
+
_context.t0 = _context["catch"](4);
|
136
112
|
_error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
|
137
113
|
success: false,
|
138
114
|
errorCode: errorEnum.SYSTEM,
|
@@ -148,19 +124,20 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
148
124
|
time: Date.now() - startTime,
|
149
125
|
success: false,
|
150
126
|
code: _errorCode,
|
151
|
-
|
127
|
+
errorMessage: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.errorMessage) || _context.t0)
|
152
128
|
});
|
153
129
|
return _context.abrupt("return", Promise.reject({
|
154
130
|
success: false,
|
155
131
|
errorCode: _errorCode,
|
156
132
|
traceId: traceId,
|
157
|
-
|
133
|
+
stack: _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.stack,
|
134
|
+
errorMessage: _error === null || _error === void 0 ? void 0 : _error.errorMessage
|
158
135
|
}));
|
159
|
-
case
|
136
|
+
case 31:
|
160
137
|
case "end":
|
161
138
|
return _context.stop();
|
162
139
|
}
|
163
|
-
}, _callee, this, [[
|
140
|
+
}, _callee, this, [[4, 24]]);
|
164
141
|
}));
|
165
142
|
function request(_x, _x2) {
|
166
143
|
return _request.apply(this, arguments);
|
@@ -172,7 +149,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
172
149
|
value: function getEnvInfo(options) {
|
173
150
|
var _options$envInfo;
|
174
151
|
var envInfo = _objectSpread(_objectSpread({
|
175
|
-
terminalType:
|
152
|
+
terminalType: device.isMobile ? 'WAP' : 'WEB',
|
176
153
|
browserInfo: {
|
177
154
|
browserJavaScriptEnabled: true,
|
178
155
|
browserLanguage: navigator.language,
|
@@ -209,97 +186,31 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
209
186
|
}, {
|
210
187
|
key: "createRequestInstance",
|
211
188
|
value: function createRequestInstance(options) {
|
212
|
-
var _options$timeout, _options$withCredenti
|
213
|
-
console.log('[DEBUG] - createRequestInstance options:', options);
|
189
|
+
var _options$timeout, _options$withCredenti;
|
214
190
|
var date = new Date(); // 获取当前时间
|
215
191
|
var timestamp = date.getTime(); // 获取时间戳
|
216
192
|
var utcTimestamp = timestamp + date.getTimezoneOffset() * 60 * 1000; // 获取 UTC 时间戳
|
217
193
|
var env = options.env || 'prod';
|
218
|
-
var _queryParse2 = queryParse(),
|
219
|
-
_light_sandbox = _queryParse2._light_sandbox,
|
220
|
-
groupId = _queryParse2.groupId,
|
221
|
-
host = _queryParse2.requestHost;
|
222
|
-
var requestHost = {
|
223
|
-
local: 'http://imgs-63.sggz00b.dev.alipay.net/mgw.htm',
|
224
|
-
dev: host || 'http://imgs-63.sggz00b.dev.alipay.net/mgw.htm',
|
225
|
-
sit: host || 'http://imgs-9.sggz00a.test.alipay.net/mgw.htm',
|
226
|
-
pre: 'https://imgs-sea-pre.alipay.com/mgw.htm',
|
227
|
-
prod: 'https://imgs-sea-global.alipay.com/mgw.htm',
|
228
|
-
sandbox: 'https://imgs-sea-global.alipay.com/mgw.htm'
|
229
|
-
};
|
230
|
-
var tntInstId = 'ALIPW3SG';
|
231
|
-
var appId = 'ANTOM_PAYMENT_WEB';
|
232
|
-
var sofaId = groupId || 'GROUP_20240627151021';
|
233
|
-
var hostSignMap = function hostSignMap(hostSign, env) {
|
234
|
-
var map = {
|
235
|
-
SG: 'https://imgs-sea-global.alipay.com/mgw.htm',
|
236
|
-
US: 'https://imgs-na-global.alipay.com/mgw.htm',
|
237
|
-
DE: 'https://imgs-de-global.alipay.com/mgw.htm'
|
238
|
-
};
|
239
|
-
var preMap = {
|
240
|
-
SG: 'https://imgs-sea-pre.alipay.com/mgw.htm',
|
241
|
-
US: 'https://imgs-pre.alipay.com/mgw.htm',
|
242
|
-
DE: 'https://imgs-de-pre.alipay.com/mgw.htm'
|
243
|
-
};
|
244
|
-
if (env === 'prod' || env === 'sandbox' || env === 'light_sandbox') {
|
245
|
-
return map[hostSign || 'SG'];
|
246
|
-
} else if (env === 'pre') {
|
247
|
-
return preMap[hostSign || 'SG'];
|
248
|
-
} else return '';
|
249
|
-
};
|
250
|
-
var lightSandboxMap = function lightSandboxMap() {
|
251
|
-
var operationType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
252
|
-
var env = arguments.length > 1 ? arguments[1] : undefined;
|
253
|
-
var map = {
|
254
|
-
pre: 'https://imgs-sea-pre.alipay.com/mgw.htm',
|
255
|
-
sit: host || 'http://imgs-9.sggz00a.test.alipay.net/mgw.htm',
|
256
|
-
dev: host || 'http://imgs-13.sggz00b.stable.alipay.net/mgw.htm'
|
257
|
-
};
|
258
|
-
var typeMap = {
|
259
|
-
'com.ipay.iexpcashier.sdkAction.query': 'com.ipay.iopensandbox.sdk.paymentSession.query'
|
260
|
-
};
|
261
|
-
var appId = 'SDK_MOCK_SANDBOX';
|
262
|
-
var sofaId = groupId || 'GROUP_20230315210531';
|
263
|
-
if (typeMap[operationType] && env === 'light_sandbox' || _light_sandbox === 'true') return {
|
264
|
-
appId: appId,
|
265
|
-
sofaId: sofaId,
|
266
|
-
baseURL: map[env],
|
267
|
-
'Operation-Type': typeMap[operationType]
|
268
|
-
};else return {
|
269
|
-
appId: '',
|
270
|
-
sofaId: '',
|
271
|
-
baseURL: '',
|
272
|
-
'Operation-Type': ''
|
273
|
-
};
|
274
|
-
};
|
275
194
|
var lightSandboxConfig = lightSandboxMap(options['Operation-Type'], env); // light_sandbox
|
276
|
-
|
195
|
+
|
277
196
|
var baseURL = options.baseURL || lightSandboxConfig.baseURL || hostSignMap(options === null || options === void 0 ? void 0 : options.hostSign, env) || requestHost[env];
|
278
197
|
var _headers = _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
279
198
|
appId: lightSandboxConfig.appId || appId,
|
280
199
|
workspaceId: options.env === 'pre' ? 'pre' : 'default'
|
281
200
|
}, "x-cors-".concat(appId.toLowerCase(), "-default"), '1'), "version", '2.0'), 'sofa-group-name', lightSandboxConfig.sofaId || sofaId), 'Operation-Type', lightSandboxConfig['Operation-Type'] || options['Operation-Type'] || ''), 'Client-Time', utcTimestamp), "tntInstId", tntInstId), 'sdk-version', sdkVersion || ''), options.headers);
|
282
|
-
console.log('[DEBUG] - createRequestInstance headers:', _headers);
|
283
201
|
// sandbox 影子链路
|
284
202
|
if (this.sandboxFlag === 'true' || env === 'sandbox') {
|
285
203
|
_headers['load-test'] = true;
|
286
204
|
_headers.sofaPenAttrs = 'instMock=O&loadMode=2';
|
287
205
|
}
|
288
206
|
if (env !== 'dev') delete _headers['sofa-group-name'];
|
289
|
-
|
207
|
+
var instance = axios.create({
|
290
208
|
baseURL: baseURL,
|
291
209
|
timeout: (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : 15000,
|
292
210
|
headers: _headers,
|
293
211
|
withCredentials: (_options$withCredenti = options.withCredentials) !== null && _options$withCredenti !== void 0 ? _options$withCredenti : true,
|
294
212
|
method: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
|
295
213
|
});
|
296
|
-
var instance = axios.create({
|
297
|
-
baseURL: baseURL,
|
298
|
-
timeout: (_options$timeout2 = options.timeout) !== null && _options$timeout2 !== void 0 ? _options$timeout2 : 15000,
|
299
|
-
headers: _headers,
|
300
|
-
withCredentials: (_options$withCredenti2 = options.withCredentials) !== null && _options$withCredenti2 !== void 0 ? _options$withCredenti2 : true,
|
301
|
-
method: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
|
302
|
-
});
|
303
214
|
return instance.request;
|
304
215
|
}
|
305
216
|
}]);
|
@@ -4,10 +4,10 @@ export default class PreloadHelper {
|
|
4
4
|
static isWebAppPreloaded: boolean;
|
5
5
|
static isSecuritySDKPreloaded: boolean;
|
6
6
|
private static securitySdkMap;
|
7
|
-
static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string): void;
|
7
|
+
static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string, useV2?: boolean): void;
|
8
8
|
static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
|
9
9
|
static getSecuritySdk(scene: any): Security;
|
10
|
-
static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string): {
|
10
|
+
static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string, useV2?: boolean): {
|
11
11
|
preloadUrl: string;
|
12
12
|
containerId: string;
|
13
13
|
};
|
@@ -8,7 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
8
8
|
import { sdkVersion } from "../../config";
|
9
9
|
import { createPreloadIframe } from "../service/container/utils";
|
10
10
|
import { ProductSceneEnum } from "../../types";
|
11
|
-
import { getWebAppUrl } from "../utils/web_app_url_utils";
|
11
|
+
import { getWebAppUrl, getWebAppV2Url } from "../utils/web_app_url_utils";
|
12
12
|
import { ProductInfoCacheUtil } from "../utils/payment_product_utils";
|
13
13
|
import { getWebAppVersion } from "./payment_context_utils";
|
14
14
|
import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security } from "../../util/security";
|
@@ -22,12 +22,13 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
22
22
|
key: "preloadWebApp",
|
23
23
|
value: function preloadWebApp(productScene, paymentMethodCategoryType) {
|
24
24
|
var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'prod';
|
25
|
+
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
25
26
|
try {
|
26
27
|
if (this.isWebAppPreloaded) {
|
27
28
|
console.log('[web-sdk] web app already preloaded');
|
28
29
|
return;
|
29
30
|
}
|
30
|
-
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
|
31
|
+
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment, useV2),
|
31
32
|
preloadUrl = _this$buildWebAppPrel.preloadUrl,
|
32
33
|
containerId = _this$buildWebAppPrel.containerId;
|
33
34
|
var preloadIframe = createPreloadIframe(containerId);
|
@@ -89,6 +90,7 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
89
90
|
}, {
|
90
91
|
key: "buildWebAppPreloadUrl",
|
91
92
|
value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
|
93
|
+
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
92
94
|
var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
|
93
95
|
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
|
94
96
|
if (previousProductInfo) {
|
@@ -101,16 +103,16 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
101
103
|
webAppVersion: ''
|
102
104
|
};
|
103
105
|
sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
|
104
|
-
|
105
|
-
sdkMetaData.webAppVersion = "1.31.0";
|
106
|
-
var preloadUrl = getWebAppUrl({
|
106
|
+
var preloadUrlParams = {
|
107
107
|
environment: environment,
|
108
108
|
sdkMetaData: sdkMetaData,
|
109
109
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
110
110
|
isPreload: true,
|
111
|
+
productScene: productScene,
|
111
112
|
productSceneVersion: productSceneVersion,
|
112
113
|
query: undefined
|
113
|
-
}
|
114
|
+
};
|
115
|
+
var preloadUrl = useV2 ? getWebAppV2Url(preloadUrlParams) : getWebAppUrl(preloadUrlParams);
|
114
116
|
return {
|
115
117
|
preloadUrl: preloadUrl,
|
116
118
|
containerId: containerId
|
@@ -69,26 +69,42 @@ export var redirect = function redirect(payload, instanceId) {
|
|
69
69
|
successCallback(payload, type, evokeAppBy.url, serviceProvider);
|
70
70
|
}
|
71
71
|
});
|
72
|
+
var callApplinkUrl = function callApplinkUrl() {
|
73
|
+
try {
|
74
|
+
callAppLib.open({
|
75
|
+
link: payload.applinkUrl,
|
76
|
+
fallback: function fallback() {
|
77
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
78
|
+
// Applink evoke failed, try to use scheme url
|
79
|
+
callSchemeUrl();
|
80
|
+
}
|
81
|
+
});
|
82
|
+
} catch (error) {
|
83
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
84
|
+
// Applink evoke failed, try to use scheme url
|
85
|
+
callSchemeUrl();
|
86
|
+
}
|
87
|
+
};
|
72
88
|
var callSchemeUrl = function callSchemeUrl() {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
89
|
+
try {
|
90
|
+
callAppLib.open({
|
91
|
+
scheme: payload.schemeUrl,
|
92
|
+
fallback: function fallback() {
|
93
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
94
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
95
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
96
|
+
window.location.href = payload.url;
|
97
|
+
}
|
98
|
+
});
|
99
|
+
} catch (error) {
|
100
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
101
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
102
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
103
|
+
window.location.href = payload.url;
|
104
|
+
}
|
82
105
|
};
|
83
106
|
if (payload.applinkUrl) {
|
84
|
-
|
85
|
-
link: payload.applinkUrl,
|
86
|
-
fallback: function fallback() {
|
87
|
-
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
88
|
-
// Applink evoke failed, try to use scheme url
|
89
|
-
callSchemeUrl();
|
90
|
-
}
|
91
|
-
});
|
107
|
+
callApplinkUrl();
|
92
108
|
} else if (payload.schemeUrl) {
|
93
109
|
callSchemeUrl();
|
94
110
|
}
|
@@ -116,7 +132,7 @@ var successCallback = function successCallback(payload, type, url, serviceProvid
|
|
116
132
|
};
|
117
133
|
var failCallback = function failCallback(payload, type, url, serviceProvider) {
|
118
134
|
serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
|
119
|
-
code: eventCodeEnum.
|
135
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
120
136
|
message: "Failed to open app,applinkUrl: ".concat(payload === null || payload === void 0 ? void 0 : payload.applinkUrl, " schemeUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.schemeUrl, " normalUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.url)
|
121
137
|
});
|
122
138
|
serviceProvider.getService('Log').logInfo({
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { ESP_PAGE_NAME } from '../../constant/easysafepay';
|
2
|
+
import { DisplayTypeEnum, IPaymentSessionMetaData, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from '../../types';
|
2
3
|
import { SDKMetaData } from '../index';
|
3
4
|
/**
|
4
5
|
* Tell the SDK which version of the Web App to load.
|
@@ -16,6 +17,16 @@ export interface WebAppMatchConfig {
|
|
16
17
|
mid?: string;
|
17
18
|
greyscale?: string;
|
18
19
|
}
|
20
|
+
/**
|
21
|
+
* Tell the SDK which Web App URL to load.
|
22
|
+
* Sent by server inside paymentSession.
|
23
|
+
*/
|
24
|
+
export interface WebAppUrlMatchConfig {
|
25
|
+
minSDKVersion: string;
|
26
|
+
url: string;
|
27
|
+
doubleFa: string;
|
28
|
+
mids?: string[];
|
29
|
+
}
|
19
30
|
export interface QueryParams {
|
20
31
|
displayType: DisplayTypeEnum;
|
21
32
|
locale: string;
|
@@ -27,20 +38,79 @@ export interface QueryParams {
|
|
27
38
|
export declare const getWebAppUrlInfo: (params: {
|
28
39
|
environment: string;
|
29
40
|
sdkMetaData: SDKMetaData;
|
41
|
+
productScene: ProductSceneEnum;
|
30
42
|
productSceneVersion: string;
|
31
43
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
32
44
|
isPreload?: boolean;
|
33
45
|
query: QueryParams;
|
46
|
+
v2Url?: string;
|
34
47
|
}) => {
|
35
48
|
path: string;
|
36
49
|
locationSearch: string;
|
37
50
|
};
|
51
|
+
export declare const getWebAppV2Url: (params: {
|
52
|
+
environment: string;
|
53
|
+
sdkMetaData: SDKMetaData;
|
54
|
+
productScene: ProductSceneEnum;
|
55
|
+
productSceneVersion: string;
|
56
|
+
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
57
|
+
isPreload?: boolean;
|
58
|
+
query: QueryParams;
|
59
|
+
mid?: string;
|
60
|
+
extendInfo?: string;
|
61
|
+
}) => string;
|
38
62
|
export declare const getWebAppUrl: (params: {
|
39
63
|
environment: string;
|
40
64
|
sdkMetaData: SDKMetaData;
|
65
|
+
productScene: ProductSceneEnum;
|
41
66
|
productSceneVersion: string;
|
42
67
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
43
68
|
isPreload?: boolean;
|
44
69
|
query: QueryParams;
|
70
|
+
v2Url?: string;
|
45
71
|
}) => string;
|
46
72
|
export declare const parseWebAppMatchConfig: (extendInfo: string) => WebAppMatchConfig[];
|
73
|
+
export declare const parseWebAppUrlMatchConfig: (extendInfo: string) => WebAppUrlMatchConfig[];
|
74
|
+
/**
|
75
|
+
* Save the current checkout URL to localStorage for the specified product scene.
|
76
|
+
*
|
77
|
+
* @param productScene - The product scene for which the checkout URL should be saved.
|
78
|
+
*/
|
79
|
+
export declare const saveLocalCheckoutUrl: (productScene: ProductSceneEnum, url: string) => void;
|
80
|
+
/**
|
81
|
+
* 获取从外部动态下发的V2AppUrl.
|
82
|
+
*
|
83
|
+
* @param config - sessionData解析来的checkoutInfo列表.
|
84
|
+
*/
|
85
|
+
export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, configs: WebAppUrlMatchConfig[], env: string) => string;
|
86
|
+
/**
|
87
|
+
* 获取ESP从sessionData.checkoutInfo内动态下发的Url.
|
88
|
+
*/
|
89
|
+
export declare const matchEasySafePayV2Url: (params: {
|
90
|
+
configs: WebAppUrlMatchConfig[];
|
91
|
+
mid: string;
|
92
|
+
env: string;
|
93
|
+
pageName: ESP_PAGE_NAME;
|
94
|
+
}) => string;
|
95
|
+
/**
|
96
|
+
* Retrieve the saved checkout URL from localStorage for the specified product scene.
|
97
|
+
* If no url is found, a default checkout url string is returned.
|
98
|
+
*
|
99
|
+
* @param productScene - The product scene for which the checkout URL should be retrieved.
|
100
|
+
*/
|
101
|
+
export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, environment: string) => string;
|
102
|
+
/**
|
103
|
+
* Provide default checkout URL for the specified product scene.
|
104
|
+
* Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
|
105
|
+
*
|
106
|
+
* @param productScene - The product scene for which the default checkout URL should be provided.
|
107
|
+
*/
|
108
|
+
export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
|
109
|
+
/**
|
110
|
+
* V2应用EasySafePay 热更新兜底URL构建规则
|
111
|
+
* 1. 兜底URL版本与sdk版本保持一致
|
112
|
+
* 2. DEV环境下html新增版本前缀
|
113
|
+
**/
|
114
|
+
export declare const getDefaultEasySafePayPageUrl: (pageName: ESP_PAGE_NAME, env: string) => string;
|
115
|
+
/**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/
|
116
|
+
export declare const getDoubleFaUrlFromSession: (paymentSessionObj: IPaymentSessionMetaData, env?: string) => string;
|