@alipay/ams-checkout 0.0.1700804278-dev.1 → 0.0.1701393225-dev.3
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/common/applepay/index.d.ts +48 -0
- package/esm/common/applepay/index.js +172 -0
- package/esm/common/applepay/interface.d.ts +102 -0
- package/esm/common/applepay/interface.js +1 -0
- package/esm/config/index.d.ts +1 -0
- package/esm/config/index.js +8 -0
- package/esm/core/applepay/index.d.ts +30 -0
- package/esm/core/applepay/index.js +315 -0
- package/esm/core/component/index.d.ts +6 -2
- package/esm/core/component/index.js +22 -5
- package/esm/core/instance/index.d.ts +23 -10
- package/esm/core/instance/index.js +136 -57
- package/esm/index.d.ts +12 -7
- package/esm/index.js +52 -2
- package/esm/plugin/component/cashierApp.js +2 -1
- package/esm/plugin/component/index.d.ts +3 -1
- package/esm/plugin/component/index.js +249 -125
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +21 -18
- package/esm/request/utils.js +1 -4
- package/esm/service/index.d.ts +11 -8
- package/esm/service/index.js +92 -2
- package/esm/types/index.d.ts +116 -13
- package/esm/types/index.js +20 -5
- package/esm/util/index.d.ts +6 -21
- package/esm/util/index.js +43 -45
- package/esm/util/security.d.ts +25 -8
- package/esm/util/security.js +165 -112
- package/esm/util/versionCompare.d.ts +10 -0
- package/esm/util/versionCompare.js +50 -0
- package/package.json +56 -1
package/esm/request/index.js
CHANGED
@@ -15,12 +15,13 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
15
|
* 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.
|
16
16
|
*/
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
|
+
import axios from 'axios';
|
18
19
|
import { sdkVersion } from "../config/index";
|
19
20
|
import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
|
20
21
|
import { errorEnum } from "../types";
|
21
22
|
import { get } from "../util/get";
|
22
|
-
import
|
23
|
-
import {
|
23
|
+
import { device, isPC, queryParse, safeJson } from "../util";
|
24
|
+
import { fomatGetwayError } from "./utils";
|
24
25
|
var _queryParse = queryParse(),
|
25
26
|
_sandbox = _queryParse._sandbox;
|
26
27
|
function requestInstance(options) {
|
@@ -47,8 +48,10 @@ function requestInstance(options) {
|
|
47
48
|
timeout: (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : 15000,
|
48
49
|
headers: _headers,
|
49
50
|
withCredentials: (_options$withCredenti = options.withCredentials) !== null && _options$withCredenti !== void 0 ? _options$withCredenti : true,
|
50
|
-
method: 'POST'
|
51
|
+
method: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
|
51
52
|
});
|
53
|
+
console.log('baseURL', baseURL);
|
54
|
+
console.log('_headers', _headers);
|
52
55
|
return instance.request;
|
53
56
|
}
|
54
57
|
|
@@ -88,29 +91,33 @@ function _request() {
|
|
88
91
|
// eslint-disable-next-line no-empty
|
89
92
|
} catch (error) {}
|
90
93
|
if (envInfo.terminalType === 'WAP') envInfo.osType = device.iOS ? 'IOS' : 'ANDROID';
|
91
|
-
_data =
|
94
|
+
_data = [_objectSpread(_objectSpread({}, requestData), {}, {
|
92
95
|
envInfo: envInfo,
|
93
96
|
extParams: {
|
94
97
|
refUrl: window.location.href
|
95
98
|
}
|
96
|
-
})]
|
99
|
+
})];
|
97
100
|
startTime = Date.now();
|
98
101
|
_context.prev = 5;
|
102
|
+
console.log('requestInstance options', options);
|
103
|
+
console.log('requestInstance -data', _data);
|
99
104
|
myRequest = requestInstance(options);
|
100
|
-
_context.next =
|
105
|
+
_context.next = 11;
|
101
106
|
return myRequest({
|
102
107
|
data: _data
|
103
108
|
});
|
104
|
-
case
|
109
|
+
case 11:
|
105
110
|
_yield$myRequest = _context.sent;
|
106
111
|
data = _yield$myRequest.data;
|
107
112
|
headers = _yield$myRequest.headers;
|
113
|
+
console.log('requestInstance data', data);
|
114
|
+
console.log('requestInstance headers', headers);
|
108
115
|
resData = data || {};
|
109
116
|
traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
|
110
117
|
resData.traceId = traceId || '';
|
111
118
|
handleGetWayError = fomatGetwayError(headers, traceId);
|
112
119
|
if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
|
113
|
-
_context.next =
|
120
|
+
_context.next = 25;
|
114
121
|
break;
|
115
122
|
}
|
116
123
|
errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
|
@@ -123,15 +130,13 @@ function _request() {
|
|
123
130
|
code: errorCode,
|
124
131
|
msg: errorMessage,
|
125
132
|
traceId: traceId
|
126
|
-
}, {
|
127
|
-
// TODO Concerned input data
|
128
133
|
}).send();
|
129
134
|
throw new Error(JSON.stringify({
|
130
135
|
errorMessage: errorMessage,
|
131
136
|
errorCode: errorCode,
|
132
137
|
success: false
|
133
138
|
}));
|
134
|
-
case
|
139
|
+
case 25:
|
135
140
|
logger.reportRPC({
|
136
141
|
name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
|
137
142
|
label: 'request',
|
@@ -142,8 +147,8 @@ function _request() {
|
|
142
147
|
traceId: traceId
|
143
148
|
}).send();
|
144
149
|
return _context.abrupt("return", resData);
|
145
|
-
case
|
146
|
-
_context.prev =
|
150
|
+
case 29:
|
151
|
+
_context.prev = 29;
|
147
152
|
_context.t0 = _context["catch"](5);
|
148
153
|
_error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
|
149
154
|
success: false,
|
@@ -158,20 +163,18 @@ function _request() {
|
|
158
163
|
time: Date.now() - startTime,
|
159
164
|
success: false,
|
160
165
|
code: _errorCode,
|
161
|
-
msg: _error === null || _error === void 0 ? void 0 : _error.message
|
162
|
-
}, {
|
163
|
-
// TODO Concerned input data
|
166
|
+
msg: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t0)
|
164
167
|
}).send();
|
165
168
|
return _context.abrupt("return", Promise.reject({
|
166
169
|
success: false,
|
167
170
|
errorCode: _errorCode,
|
168
171
|
errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
|
169
172
|
}));
|
170
|
-
case
|
173
|
+
case 36:
|
171
174
|
case "end":
|
172
175
|
return _context.stop();
|
173
176
|
}
|
174
|
-
}, _callee, null, [[5,
|
177
|
+
}, _callee, null, [[5, 29]]);
|
175
178
|
}));
|
176
179
|
return _request.apply(this, arguments);
|
177
180
|
}
|
package/esm/request/utils.js
CHANGED
@@ -5,11 +5,9 @@
|
|
5
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
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
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
9
9
|
import { errorEnum } from "../types";
|
10
10
|
import { get } from "../util/get";
|
11
|
-
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
13
11
|
export var safeJson = function safeJson(data, obj) {
|
14
12
|
try {
|
15
13
|
return JSON.parse(data) || obj;
|
@@ -19,7 +17,6 @@ export var safeJson = function safeJson(data, obj) {
|
|
19
17
|
};
|
20
18
|
|
21
19
|
// 判断header 中的resultStatus
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
23
20
|
export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
|
24
21
|
var resultStatus = get(headers, 'Result-Status') || get(headers, 'result-status', '');
|
25
22
|
// 请求静态数据情况
|
package/esm/service/index.d.ts
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
import { ApplePayPaymentSessionRequest, ApplePayPaymentSessionResult, CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
|
2
|
+
import { Logger } from '../util/logger';
|
3
|
+
export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
|
4
|
+
export declare function antomConfig(options: RequestConfig, logger: Logger): Promise<any>;
|
5
|
+
export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
|
1
6
|
/**
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
+
* Get merchant session by Apple Pay
|
8
|
+
* @param paymentSessionData
|
9
|
+
* @param params
|
10
|
+
* @param options
|
11
|
+
* @param logger
|
7
12
|
*/
|
8
|
-
|
9
|
-
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, IrequestConfig } from '../types';
|
10
|
-
export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: IrequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
|
13
|
+
export declare function getApplePayPaymentSession(paymentSessionData: string, params: ApplePayPaymentSessionRequest, options: RequestConfig, logger: Logger): Promise<ApplePayPaymentSessionResult>;
|
package/esm/service/index.js
CHANGED
@@ -14,7 +14,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
14
14
|
* 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
|
15
15
|
* 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.
|
16
16
|
*/
|
17
|
-
|
17
|
+
import { marmotConfigMap } from "../config";
|
18
18
|
import { request } from "../request";
|
19
19
|
export function queryPaymentInfo(_x, _x2, _x3) {
|
20
20
|
return _queryPaymentInfo.apply(this, arguments);
|
@@ -28,7 +28,6 @@ function _queryPaymentInfo() {
|
|
28
28
|
hostSign = ((params === null || params === void 0 ? void 0 : params.paymentSessionData) || '').split('&&')[1] || '';
|
29
29
|
return _context.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
|
30
30
|
hostSign: hostSign,
|
31
|
-
needEnvInfo: true,
|
32
31
|
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
33
32
|
}), logger));
|
34
33
|
case 2:
|
@@ -38,4 +37,95 @@ function _queryPaymentInfo() {
|
|
38
37
|
}, _callee);
|
39
38
|
}));
|
40
39
|
return _queryPaymentInfo.apply(this, arguments);
|
40
|
+
}
|
41
|
+
export function antomConfig(_x4, _x5) {
|
42
|
+
return _antomConfig.apply(this, arguments);
|
43
|
+
}
|
44
|
+
function _antomConfig() {
|
45
|
+
_antomConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, logger) {
|
46
|
+
var res, json;
|
47
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
48
|
+
while (1) switch (_context2.prev = _context2.next) {
|
49
|
+
case 0:
|
50
|
+
_context2.prev = 0;
|
51
|
+
_context2.next = 3;
|
52
|
+
return fetch(marmotConfigMap[options.env]);
|
53
|
+
case 3:
|
54
|
+
res = _context2.sent;
|
55
|
+
_context2.next = 6;
|
56
|
+
return res.json();
|
57
|
+
case 6:
|
58
|
+
json = _context2.sent;
|
59
|
+
logger.logInfo({
|
60
|
+
title: 'Successfully obtained marmot emergency configuration'
|
61
|
+
});
|
62
|
+
return _context2.abrupt("return", json);
|
63
|
+
case 11:
|
64
|
+
_context2.prev = 11;
|
65
|
+
_context2.t0 = _context2["catch"](0);
|
66
|
+
logger.logError({
|
67
|
+
title: 'Abnormal acquisition of marmot emergency configuration'
|
68
|
+
});
|
69
|
+
return _context2.abrupt("return", '{}');
|
70
|
+
case 15:
|
71
|
+
case "end":
|
72
|
+
return _context2.stop();
|
73
|
+
}
|
74
|
+
}, _callee2, null, [[0, 11]]);
|
75
|
+
}));
|
76
|
+
return _antomConfig.apply(this, arguments);
|
77
|
+
}
|
78
|
+
export function submitPayInfo(_x6, _x7, _x8) {
|
79
|
+
return _submitPayInfo.apply(this, arguments);
|
80
|
+
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Get merchant session by Apple Pay
|
84
|
+
* @param paymentSessionData
|
85
|
+
* @param params
|
86
|
+
* @param options
|
87
|
+
* @param logger
|
88
|
+
*/
|
89
|
+
function _submitPayInfo() {
|
90
|
+
_submitPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params, options, logger) {
|
91
|
+
var hostSign;
|
92
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
93
|
+
while (1) switch (_context3.prev = _context3.next) {
|
94
|
+
case 0:
|
95
|
+
hostSign = ((params === null || params === void 0 ? void 0 : params.paymentSessionData) || '').split('&&')[1] || '';
|
96
|
+
return _context3.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
|
97
|
+
hostSign: hostSign,
|
98
|
+
needEnvInfo: true,
|
99
|
+
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
100
|
+
}), logger));
|
101
|
+
case 2:
|
102
|
+
case "end":
|
103
|
+
return _context3.stop();
|
104
|
+
}
|
105
|
+
}, _callee3);
|
106
|
+
}));
|
107
|
+
return _submitPayInfo.apply(this, arguments);
|
108
|
+
}
|
109
|
+
export function getApplePayPaymentSession(_x9, _x10, _x11, _x12) {
|
110
|
+
return _getApplePayPaymentSession.apply(this, arguments);
|
111
|
+
}
|
112
|
+
function _getApplePayPaymentSession() {
|
113
|
+
_getApplePayPaymentSession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(paymentSessionData, params, options, logger) {
|
114
|
+
var hostSign;
|
115
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
116
|
+
while (1) switch (_context4.prev = _context4.next) {
|
117
|
+
case 0:
|
118
|
+
hostSign = (paymentSessionData || '').split('&&')[1] || '';
|
119
|
+
console.log('getApplePayPaymentSession hostSign', hostSign);
|
120
|
+
return _context4.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
|
121
|
+
hostSign: hostSign,
|
122
|
+
'Operation-Type': 'com.ipay.iexpcashier.cashier.createApplePayPaymentSession'
|
123
|
+
}), logger));
|
124
|
+
case 3:
|
125
|
+
case "end":
|
126
|
+
return _context4.stop();
|
127
|
+
}
|
128
|
+
}, _callee4);
|
129
|
+
}));
|
130
|
+
return _getApplePayPaymentSession.apply(this, arguments);
|
41
131
|
}
|
package/esm/types/index.d.ts
CHANGED
@@ -22,7 +22,9 @@ export interface IoptionsParams {
|
|
22
22
|
analytics?: {
|
23
23
|
enabled: boolean;
|
24
24
|
};
|
25
|
-
|
25
|
+
product?: string;
|
26
|
+
}
|
27
|
+
export interface IApplePayOptionsParams extends Pick<IoptionsParams, 'locale' | 'environment' | 'onEventCallback' | 'analytics'> {
|
26
28
|
}
|
27
29
|
export type Iselector = string;
|
28
30
|
export declare enum renderDisplayTypeEnum {
|
@@ -50,13 +52,22 @@ export declare enum productSceneEnum {
|
|
50
52
|
'EASY_PAY' = "EASY_PAY",
|
51
53
|
'CASHIER_PAYMENT' = "CASHIER_PAYMENT",
|
52
54
|
'AUTO_DEBIT' = "AUTO_DEBIT",
|
53
|
-
'VAULTING' = "VAULTING"
|
55
|
+
'VAULTING' = "VAULTING",
|
56
|
+
'FLASH_BUY' = "FLASH_BUY",
|
57
|
+
'CARD_APPLE_PAY' = "CARD_APPLE_PAY"
|
54
58
|
}
|
55
59
|
export declare enum paymentMethodCategoryTypeEnum {
|
56
60
|
'CARD' = "CARD",
|
57
61
|
'WALLET' = "WALLET",
|
58
62
|
'BANK' = "BANK"
|
59
63
|
}
|
64
|
+
export interface DeviceIdParameter {
|
65
|
+
scene?: string;
|
66
|
+
productScene?: productSceneEnum;
|
67
|
+
paymentMethodCategoryType?: paymentMethodCategoryTypeEnum;
|
68
|
+
tokenCollectTime?: string;
|
69
|
+
dataPollingInterval?: string;
|
70
|
+
}
|
60
71
|
export interface IcreateComponent {
|
61
72
|
sessionData: string;
|
62
73
|
paymentSessionData?: string;
|
@@ -94,6 +105,14 @@ export interface IpaymentSecurityConfig {
|
|
94
105
|
dataPollingInterval?: string;
|
95
106
|
workSpaceId: string;
|
96
107
|
}
|
108
|
+
export interface IsecurityConfig {
|
109
|
+
scene: string;
|
110
|
+
h5gateway: string;
|
111
|
+
}
|
112
|
+
export interface InitSecurityConfig {
|
113
|
+
product: productSceneEnum;
|
114
|
+
region?: string;
|
115
|
+
}
|
97
116
|
export interface IpaymentSessionMetaData {
|
98
117
|
clientId?: string;
|
99
118
|
renderDisplayType?: string;
|
@@ -104,6 +123,27 @@ export interface IpaymentSessionMetaData {
|
|
104
123
|
paymentMethodInfoView?: any;
|
105
124
|
action?: {
|
106
125
|
autoDebitWithToken: boolean;
|
126
|
+
skipSdkQuery: boolean;
|
127
|
+
};
|
128
|
+
paymentSessionFactor?: {
|
129
|
+
applePay?: {
|
130
|
+
merchantCapabilities?: string[];
|
131
|
+
supportedNetworks?: string[];
|
132
|
+
};
|
133
|
+
merchantInfo?: {
|
134
|
+
registeredCountry?: string;
|
135
|
+
partnerId?: string;
|
136
|
+
};
|
137
|
+
order?: {
|
138
|
+
orderDescription?: string;
|
139
|
+
};
|
140
|
+
paymentAmount?: {
|
141
|
+
value?: string;
|
142
|
+
currency?: string;
|
143
|
+
};
|
144
|
+
paymentMethodInfo?: {
|
145
|
+
paymentMethodType?: string;
|
146
|
+
};
|
107
147
|
};
|
108
148
|
}
|
109
149
|
export declare enum localeEnum {
|
@@ -216,6 +256,7 @@ export interface AMSCheckoutOptions {
|
|
216
256
|
networkMode: string;
|
217
257
|
mode: string;
|
218
258
|
analytics?: Ianalytics;
|
259
|
+
product: string;
|
219
260
|
}
|
220
261
|
export interface Ianalytics {
|
221
262
|
enabled: boolean;
|
@@ -239,7 +280,7 @@ export declare enum errorEnum {
|
|
239
280
|
SIGNIN = "SIGNIN",
|
240
281
|
GETSIGNPARAMSERROR = "GETSIGNPARAMSERROR"
|
241
282
|
}
|
242
|
-
export interface
|
283
|
+
export interface RequestConfig {
|
243
284
|
env?: string;
|
244
285
|
baseURL?: string;
|
245
286
|
timeout?: number;
|
@@ -251,8 +292,11 @@ export interface IrequestConfig {
|
|
251
292
|
beforerRequest?: () => void;
|
252
293
|
afterRequest?: () => void;
|
253
294
|
needEnvInfo?: boolean;
|
254
|
-
locale?: string;
|
255
295
|
hostSign?: string;
|
296
|
+
appId?: string;
|
297
|
+
sandbox?: boolean;
|
298
|
+
deviceId?: string;
|
299
|
+
locale?: string;
|
256
300
|
envInfo?: Record<string, any>;
|
257
301
|
}
|
258
302
|
export interface CashierSdkActionQueryRequest {
|
@@ -262,6 +306,29 @@ export interface CashierSdkActionQueryRequest {
|
|
262
306
|
notRedirectAfterComplete?: boolean;
|
263
307
|
extParams?: any;
|
264
308
|
}
|
309
|
+
export interface CashierSubmitPayRequest {
|
310
|
+
/**
|
311
|
+
* @description payment method type
|
312
|
+
*/
|
313
|
+
paymentMethodType?: string;
|
314
|
+
/**
|
315
|
+
* @description payment factors
|
316
|
+
*/
|
317
|
+
paymentFactors?: Record<string, string>;
|
318
|
+
/**
|
319
|
+
* @description 需要验证的场景
|
320
|
+
*/
|
321
|
+
verifyFactors?: Record<string, string>;
|
322
|
+
paymentSessionData: string;
|
323
|
+
paymentSessionConfig?: any;
|
324
|
+
}
|
325
|
+
export interface CashierSubmitPayRequest {
|
326
|
+
paymentMethodType?: string;
|
327
|
+
paymentFactors?: Record<string, string>;
|
328
|
+
verifyFactors?: Record<string, string>;
|
329
|
+
paymentSessionData: string;
|
330
|
+
paymentSessionConfig?: any;
|
331
|
+
}
|
265
332
|
export interface CashierSdkActionQueryResult {
|
266
333
|
supportedLanguages?: any[];
|
267
334
|
amountConfirmRequired?: boolean;
|
@@ -279,6 +346,47 @@ export interface CashierSdkActionQueryResult {
|
|
279
346
|
schemeUrl?: string;
|
280
347
|
authUrl?: string;
|
281
348
|
}
|
349
|
+
/**
|
350
|
+
* Get App Pay Payment Session Request.
|
351
|
+
*/
|
352
|
+
export interface ApplePayPaymentSessionRequest {
|
353
|
+
validateUrl: string;
|
354
|
+
paymentSessionData: string;
|
355
|
+
}
|
356
|
+
/**
|
357
|
+
* Get App Pay Payment Session Result.
|
358
|
+
*/
|
359
|
+
export interface ApplePayPaymentSessionResult {
|
360
|
+
merchantSessionObject: string;
|
361
|
+
success: boolean;
|
362
|
+
errorCode?: string;
|
363
|
+
errorMessage?: string;
|
364
|
+
message?: string;
|
365
|
+
}
|
366
|
+
export declare enum redirectTypeEnum {
|
367
|
+
UNSAFE_BROWSER = "UNSAFE_BROWSER",
|
368
|
+
SAFETY_BROWSER = "SAFETY_BROWSER",
|
369
|
+
INVOKE_SDK = "INVOKE_SDK"
|
370
|
+
}
|
371
|
+
export interface ActionForm {
|
372
|
+
parameters: any;
|
373
|
+
redirectUrl: any;
|
374
|
+
elementValue?: string;
|
375
|
+
redirectType?: redirectTypeEnum;
|
376
|
+
}
|
377
|
+
export interface CashierSubmitPayResult {
|
378
|
+
success: boolean;
|
379
|
+
resultCode?: string;
|
380
|
+
resultMessage?: string;
|
381
|
+
errorActions?: Record<string, string>;
|
382
|
+
errorCode?: string;
|
383
|
+
errorMessage?: string;
|
384
|
+
extendInfo?: Record<string, string>;
|
385
|
+
actionForm?: ActionForm;
|
386
|
+
normalUrl?: string;
|
387
|
+
errorStatus?: string;
|
388
|
+
message?: string;
|
389
|
+
}
|
282
390
|
export declare enum eventCodeEnum {
|
283
391
|
SDK_START_OF_LOADING = "SDK_START_OF_LOADING",
|
284
392
|
SDK_END_OF_LOADING = "SDK_END_OF_LOADING",
|
@@ -287,7 +395,10 @@ export declare enum eventCodeEnum {
|
|
287
395
|
SDK_INIT_PARAMETER_ERROR = "SDK_INIT_PARAMETER_ERROR",
|
288
396
|
SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
|
289
397
|
SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
|
290
|
-
SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS"
|
398
|
+
SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS",
|
399
|
+
SDK_PAYMENT_FINISH = "SDK_PAYMENT_FINISH",
|
400
|
+
SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
|
401
|
+
SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL"
|
291
402
|
}
|
292
403
|
export interface ThreedData {
|
293
404
|
data: any;
|
@@ -296,14 +407,6 @@ export interface ThreedData {
|
|
296
407
|
pti?: number;
|
297
408
|
pt?: number;
|
298
409
|
}
|
299
|
-
export declare enum SecuritySceneEnum {
|
300
|
-
CARD = "CARD",
|
301
|
-
EASYPAY = "EASYPAY"
|
302
|
-
}
|
303
|
-
export interface IsecurityConfig {
|
304
|
-
scene: string;
|
305
|
-
region: string;
|
306
|
-
}
|
307
410
|
export declare enum RedirectType {
|
308
411
|
ApplinkUrl = "ApplinkUrl",
|
309
412
|
SchemeUrl = "SchemeUrl",
|
package/esm/types/index.js
CHANGED
@@ -29,6 +29,8 @@ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
|
|
29
29
|
productSceneEnum["CASHIER_PAYMENT"] = "CASHIER_PAYMENT";
|
30
30
|
productSceneEnum["AUTO_DEBIT"] = "AUTO_DEBIT";
|
31
31
|
productSceneEnum["VAULTING"] = "VAULTING";
|
32
|
+
productSceneEnum["FLASH_BUY"] = "FLASH_BUY";
|
33
|
+
productSceneEnum["CARD_APPLE_PAY"] = "CARD_APPLE_PAY";
|
32
34
|
return productSceneEnum;
|
33
35
|
}({});
|
34
36
|
export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodCategoryTypeEnum) {
|
@@ -124,6 +126,21 @@ export var errorEnum = /*#__PURE__*/function (errorEnum) {
|
|
124
126
|
errorEnum["GETSIGNPARAMSERROR"] = "GETSIGNPARAMSERROR";
|
125
127
|
return errorEnum;
|
126
128
|
}({});
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Get App Pay Payment Session Request.
|
132
|
+
*/
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Get App Pay Payment Session Result.
|
136
|
+
*/
|
137
|
+
|
138
|
+
export var redirectTypeEnum = /*#__PURE__*/function (redirectTypeEnum) {
|
139
|
+
redirectTypeEnum["UNSAFE_BROWSER"] = "UNSAFE_BROWSER";
|
140
|
+
redirectTypeEnum["SAFETY_BROWSER"] = "SAFETY_BROWSER";
|
141
|
+
redirectTypeEnum["INVOKE_SDK"] = "INVOKE_SDK";
|
142
|
+
return redirectTypeEnum;
|
143
|
+
}({}); // 拉SDK
|
127
144
|
export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
|
128
145
|
eventCodeEnum["SDK_START_OF_LOADING"] = "SDK_START_OF_LOADING";
|
129
146
|
eventCodeEnum["SDK_END_OF_LOADING"] = "SDK_END_OF_LOADING";
|
@@ -133,13 +150,11 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
|
|
133
150
|
eventCodeEnum["SDK_CREATECOMPONENT_ERROR"] = "SDK_CREATECOMPONENT_ERROR";
|
134
151
|
eventCodeEnum["SDK_CALL_URL_ERROR"] = "SDK_CALL_URL_ERROR";
|
135
152
|
eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
|
153
|
+
eventCodeEnum["SDK_PAYMENT_FINISH"] = "SDK_PAYMENT_FINISH";
|
154
|
+
eventCodeEnum["SDK_PAYMENT_FAIL"] = "SDK_PAYMENT_FAIL";
|
155
|
+
eventCodeEnum["SDK_PAYMENT_CANCEL"] = "SDK_PAYMENT_CANCEL";
|
136
156
|
return eventCodeEnum;
|
137
157
|
}({});
|
138
|
-
export var SecuritySceneEnum = /*#__PURE__*/function (SecuritySceneEnum) {
|
139
|
-
SecuritySceneEnum["CARD"] = "CARD";
|
140
|
-
SecuritySceneEnum["EASYPAY"] = "EASYPAY";
|
141
|
-
return SecuritySceneEnum;
|
142
|
-
}({});
|
143
158
|
export var RedirectType = /*#__PURE__*/function (RedirectType) {
|
144
159
|
RedirectType["ApplinkUrl"] = "ApplinkUrl";
|
145
160
|
RedirectType["SchemeUrl"] = "SchemeUrl";
|
package/esm/util/index.d.ts
CHANGED
@@ -4,7 +4,6 @@
|
|
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 { errorEnum } from '../types';
|
8
7
|
declare const getType: (target: any) => string;
|
9
8
|
declare class EventCenter {
|
10
9
|
private events;
|
@@ -28,28 +27,14 @@ declare const device: {
|
|
28
27
|
isMobile: boolean;
|
29
28
|
};
|
30
29
|
declare const safeJson: (data: any, obj: any) => any;
|
31
|
-
declare const fomatGetwayError: (headers: Record<string, any>, traceId: string) => {
|
32
|
-
success: boolean;
|
33
|
-
traceId: string;
|
34
|
-
errorCode: errorEnum;
|
35
|
-
resultStatus: any;
|
36
|
-
errorMessage?: undefined;
|
37
|
-
result?: undefined;
|
38
|
-
} | {
|
39
|
-
success: boolean;
|
40
|
-
traceId: string;
|
41
|
-
errorCode: errorEnum;
|
42
|
-
errorMessage: string;
|
43
|
-
result: {
|
44
|
-
resultStatus: any;
|
45
|
-
tips: string;
|
46
|
-
memo: string;
|
47
|
-
};
|
48
|
-
resultStatus: any;
|
49
|
-
};
|
50
30
|
declare const isPC: () => boolean;
|
51
31
|
declare const queryParse: (url?: string) => Record<string, any>;
|
52
32
|
declare const getDesignFontSize: () => number;
|
53
33
|
declare const amsSetSize: (event?: any, dom?: any) => void;
|
54
34
|
declare const addSetFontSizeEvent: () => void;
|
55
|
-
|
35
|
+
/**
|
36
|
+
* @description get or set STORAGE
|
37
|
+
*/
|
38
|
+
declare const getOrSetStorageId: (key: string, value?: string) => string;
|
39
|
+
declare const checkTimeElapsed: () => boolean;
|
40
|
+
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, };
|
package/esm/util/index.js
CHANGED
@@ -12,8 +12,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
12
12
|
* 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.
|
13
13
|
*/
|
14
14
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
15
|
-
|
16
|
-
import { get } from "./get";
|
15
|
+
|
17
16
|
var getType = function getType(target) {
|
18
17
|
return Object.prototype.toString.call(target).slice(8, -1).toLowerCase();
|
19
18
|
};
|
@@ -160,48 +159,6 @@ var safeJson = function safeJson(data, obj) {
|
|
160
159
|
return obj;
|
161
160
|
}
|
162
161
|
};
|
163
|
-
|
164
|
-
// 判断header 中的resultStatus
|
165
|
-
var fomatGetwayError = function fomatGetwayError(headers, traceId) {
|
166
|
-
var resultStatus = get(headers, 'Result-Status') || get(headers, 'result-status', '');
|
167
|
-
// 请求静态数据情况
|
168
|
-
if (!resultStatus) return null;
|
169
|
-
// 未登录
|
170
|
-
if (+resultStatus === 2000) {
|
171
|
-
return {
|
172
|
-
success: false,
|
173
|
-
traceId: traceId,
|
174
|
-
errorCode: errorEnum.LOGIN,
|
175
|
-
resultStatus: resultStatus
|
176
|
-
};
|
177
|
-
}
|
178
|
-
// 网关超时
|
179
|
-
if (+resultStatus === 4001) {
|
180
|
-
return {
|
181
|
-
success: false,
|
182
|
-
traceId: traceId,
|
183
|
-
errorCode: errorEnum.TIMEOUT,
|
184
|
-
resultStatus: resultStatus
|
185
|
-
};
|
186
|
-
}
|
187
|
-
if (+resultStatus !== 1000) {
|
188
|
-
var tips = get(headers, 'Tips') || get(headers, 'tips', '');
|
189
|
-
var memo = get(headers, 'Memo') || get(headers, 'memo', '');
|
190
|
-
return {
|
191
|
-
success: false,
|
192
|
-
traceId: traceId,
|
193
|
-
errorCode: errorEnum.GATEWAY,
|
194
|
-
errorMessage: decodeURIComponent(tips || ''),
|
195
|
-
result: {
|
196
|
-
resultStatus: resultStatus || '',
|
197
|
-
tips: decodeURIComponent(tips || ''),
|
198
|
-
memo: decodeURIComponent(memo || '')
|
199
|
-
},
|
200
|
-
resultStatus: resultStatus
|
201
|
-
};
|
202
|
-
}
|
203
|
-
return null;
|
204
|
-
};
|
205
162
|
var isPC = function isPC() {
|
206
163
|
var userAgentInfo = navigator.userAgent;
|
207
164
|
var agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPod'];
|
@@ -248,4 +205,45 @@ var addSetFontSizeEvent = function addSetFontSizeEvent() {
|
|
248
205
|
window.addEventListener('pageShow', amsSetSize);
|
249
206
|
window.addEventListener('DOMContentLoaded', amsSetSize);
|
250
207
|
};
|
251
|
-
|
208
|
+
|
209
|
+
/**
|
210
|
+
* @description get or set STORAGE
|
211
|
+
*/
|
212
|
+
var getOrSetStorageId = function getOrSetStorageId(key, value) {
|
213
|
+
try {
|
214
|
+
if (key && !value) {
|
215
|
+
var storageValue = window.localStorage.getItem(key);
|
216
|
+
if (storageValue) {
|
217
|
+
return storageValue;
|
218
|
+
} else return '';
|
219
|
+
}
|
220
|
+
if (key && value) {
|
221
|
+
window.localStorage.setItem(key, value);
|
222
|
+
}
|
223
|
+
} catch (error) {
|
224
|
+
return '';
|
225
|
+
}
|
226
|
+
};
|
227
|
+
var checkTimeElapsed = function checkTimeElapsed() {
|
228
|
+
var key = 'antomSDKConfiglastCallTime';
|
229
|
+
var currentTime = new Date().getTime();
|
230
|
+
try {
|
231
|
+
var lastCallTime = localStorage.getItem(key);
|
232
|
+
if (lastCallTime) {
|
233
|
+
var elapsedTime = currentTime - parseInt(lastCallTime);
|
234
|
+
if (elapsedTime >= 10 * 60 * 1000) {
|
235
|
+
// 记录当前调用时间
|
236
|
+
localStorage.setItem(key, currentTime.toString());
|
237
|
+
// 超过10分钟
|
238
|
+
return true;
|
239
|
+
}
|
240
|
+
return false;
|
241
|
+
}
|
242
|
+
} catch (error) {
|
243
|
+
/* empty */
|
244
|
+
}
|
245
|
+
// 记录当前调用时间
|
246
|
+
localStorage.setItem(key, currentTime.toString());
|
247
|
+
return true;
|
248
|
+
};
|
249
|
+
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed };
|