@alipay/ams-checkout 1.31.1 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/foundation/core/index.js +3 -0
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +2 -0
- package/esm/foundation/product-processor/easysafepay/deps.js +3 -1
- package/esm/foundation/product-processor/easysafepay/index.d.ts +3 -0
- package/esm/foundation/product-processor/easysafepay/index.js +42 -26
- package/esm/foundation/service/log/types.d.ts +1 -0
- package/esm/foundation/service/requester/requester.js +5 -4
- package/package.json +1 -1
package/esm/config/index.d.ts
CHANGED
@@ -5,10 +5,10 @@ export declare const sdkVersion: string;
|
|
5
5
|
/**
|
6
6
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
7
7
|
*/
|
8
|
-
export declare const AMSCheckoutAppVersion = "1.
|
9
|
-
export declare const AMSAutoDebitAppVersion = "1.
|
10
|
-
export declare const AMSEasyPayAppVersion = "1.
|
11
|
-
export declare const AMSCashierPaymentAppVersion = "1.
|
12
|
-
export declare const AMSVaultingAppVersion = "1.
|
13
|
-
export declare const AMSPaymentElementAppVersion = "1.
|
14
|
-
export declare const ADDRESSElementAppVersion = "1.
|
8
|
+
export declare const AMSCheckoutAppVersion = "1.33.0";
|
9
|
+
export declare const AMSAutoDebitAppVersion = "1.33.0";
|
10
|
+
export declare const AMSEasyPayAppVersion = "1.33.0";
|
11
|
+
export declare const AMSCashierPaymentAppVersion = "1.33.0";
|
12
|
+
export declare const AMSVaultingAppVersion = "1.33.0";
|
13
|
+
export declare const AMSPaymentElementAppVersion = "1.33.0";
|
14
|
+
export declare const ADDRESSElementAppVersion = "1.33.0";
|
package/esm/config/index.js
CHANGED
@@ -35,10 +35,10 @@ export var sdkVersion = json.version;
|
|
35
35
|
/**
|
36
36
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
37
37
|
*/
|
38
|
-
export var AMSCheckoutAppVersion = '1.
|
39
|
-
export var AMSAutoDebitAppVersion = '1.
|
40
|
-
export var AMSEasyPayAppVersion = '1.
|
41
|
-
export var AMSCashierPaymentAppVersion = '1.
|
42
|
-
export var AMSVaultingAppVersion = '1.
|
43
|
-
export var AMSPaymentElementAppVersion = '1.
|
44
|
-
export var ADDRESSElementAppVersion = '1.
|
38
|
+
export var AMSCheckoutAppVersion = '1.33.0'; // 兜底版本号
|
39
|
+
export var AMSAutoDebitAppVersion = '1.33.0'; // 代扣
|
40
|
+
export var AMSEasyPayAppVersion = '1.33.0'; // easypay
|
41
|
+
export var AMSCashierPaymentAppVersion = '1.33.0'; // 收银台(卡、apm)
|
42
|
+
export var AMSVaultingAppVersion = '1.33.0'; // 绑卡
|
43
|
+
export var AMSPaymentElementAppVersion = '1.33.0'; // payment element
|
44
|
+
export var ADDRESSElementAppVersion = '1.33.0'; // address element
|
package/esm/constant/index.d.ts
CHANGED
package/esm/constant/index.js
CHANGED
@@ -151,6 +151,9 @@ export var AntomSDKCore = /*#__PURE__*/function () {
|
|
151
151
|
return _ref2.apply(this, arguments);
|
152
152
|
};
|
153
153
|
}());
|
154
|
+
eventCenter.listen(EVENT.destroy.name, function (data) {
|
155
|
+
_this.destroy();
|
156
|
+
});
|
154
157
|
eventCenter.listen(EVENT.closeCallback.name, function () {
|
155
158
|
var _options$onClose;
|
156
159
|
(_options$onClose = options.onClose) === null || _options$onClose === void 0 || _options$onClose.call(options);
|
@@ -16,3 +16,5 @@ export type { RequesterService } from '../../service/requester/requester';
|
|
16
16
|
export type { SecurityService } from '../../service/security';
|
17
17
|
export { ProductInfoCacheUtil } from '../../utils/payment_product_utils';
|
18
18
|
export * as WebAppUrlUtil from '../../utils/web_app_url_utils';
|
19
|
+
export { eventCodeEnum } from '../../../types';
|
20
|
+
export { EVENT } from '../../../constant';
|
@@ -9,4 +9,6 @@ export { ServiceProvider } from "../../service";
|
|
9
9
|
export { LogService } from "../../service/log";
|
10
10
|
export { ProductInfoCacheUtil } from "../../utils/payment_product_utils";
|
11
11
|
import * as _WebAppUrlUtil from "../../utils/web_app_url_utils";
|
12
|
-
export { _WebAppUrlUtil as WebAppUrlUtil };
|
12
|
+
export { _WebAppUrlUtil as WebAppUrlUtil };
|
13
|
+
export { eventCodeEnum } from "../../../types";
|
14
|
+
export { EVENT } from "../../../constant";
|
@@ -4,11 +4,14 @@ export declare class EasySafePayProcessor implements ProductProcessor {
|
|
4
4
|
private initConfig;
|
5
5
|
private logger;
|
6
6
|
private securityService;
|
7
|
+
private eventCenter;
|
7
8
|
private instanceId;
|
8
9
|
private hostSign;
|
9
10
|
private allowSubmitPayCallAhead;
|
10
11
|
private channelBehavior?;
|
11
12
|
private SECURITY_SDK_INIT_TIMEOUT;
|
13
|
+
private SDK_REQUEST_TIMEOUT;
|
14
|
+
private LOAD_APP_RESOURCES_TIMEOUT;
|
12
15
|
init(config: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
13
16
|
startBizFlow(paymentContext: PaymentContext): Promise<BizFlowStartBehavior>;
|
14
17
|
private buildWebAppUrl;
|
@@ -17,7 +17,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
17
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
18
18
|
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); }
|
19
19
|
import PreloadHelper from "../../../foundation/utils/preload_helper";
|
20
|
-
import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, PaymentMethodCategoryTypeEnum, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil } from "./deps";
|
20
|
+
import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, PaymentMethodCategoryTypeEnum, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil, EVENT, eventCodeEnum } from "./deps";
|
21
21
|
export var EasySafePayProcessor = /*#__PURE__*/function () {
|
22
22
|
function EasySafePayProcessor() {
|
23
23
|
_classCallCheck(this, EasySafePayProcessor);
|
@@ -25,6 +25,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
25
25
|
_defineProperty(this, "initConfig", void 0);
|
26
26
|
_defineProperty(this, "logger", void 0);
|
27
27
|
_defineProperty(this, "securityService", void 0);
|
28
|
+
_defineProperty(this, "eventCenter", void 0);
|
28
29
|
_defineProperty(this, "instanceId", void 0);
|
29
30
|
// 服务端接口区域信息,请求时决定API域名
|
30
31
|
_defineProperty(this, "hostSign", void 0);
|
@@ -32,6 +33,8 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
32
33
|
_defineProperty(this, "allowSubmitPayCallAhead", void 0);
|
33
34
|
_defineProperty(this, "channelBehavior", void 0);
|
34
35
|
_defineProperty(this, "SECURITY_SDK_INIT_TIMEOUT", 18000);
|
36
|
+
_defineProperty(this, "SDK_REQUEST_TIMEOUT", 15000);
|
37
|
+
_defineProperty(this, "LOAD_APP_RESOURCES_TIMEOUT", 15000);
|
35
38
|
}
|
36
39
|
_createClass(EasySafePayProcessor, [{
|
37
40
|
key: "init",
|
@@ -40,6 +43,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
40
43
|
this.instanceId = instanceId;
|
41
44
|
this.logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
|
42
45
|
this.securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
|
46
|
+
this.eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
43
47
|
|
44
48
|
// preload web app
|
45
49
|
PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, this.initConfig.environment);
|
@@ -162,9 +166,12 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
162
166
|
key: "sendRequestAndWaitWebLaunch",
|
163
167
|
value: function sendRequestAndWaitWebLaunch() {
|
164
168
|
var _this = this;
|
165
|
-
var
|
166
|
-
|
167
|
-
|
169
|
+
var webLaunchPromise = new Promise(function (resolve, reject) {
|
170
|
+
var t = setTimeout(function () {
|
171
|
+
reject(new Error('Load resource timeout'));
|
172
|
+
}, _this.LOAD_APP_RESOURCES_TIMEOUT);
|
173
|
+
_this.eventCenter.listen('onLaunch', function (res) {
|
174
|
+
clearTimeout(t);
|
168
175
|
resolve(res);
|
169
176
|
});
|
170
177
|
});
|
@@ -177,7 +184,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
177
184
|
submitRes = _ref2[1],
|
178
185
|
_webLaunchRes = _ref2[2];
|
179
186
|
var logMetaData = _this.logger.getLogConfig().mdata;
|
180
|
-
eventCenter.dispatchToApp({
|
187
|
+
_this.eventCenter.dispatchToApp({
|
181
188
|
event: 'renderComponent',
|
182
189
|
data: {
|
183
190
|
sessionResult: (_this$paymentContext = _this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSessionObj,
|
@@ -207,6 +214,14 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
207
214
|
})
|
208
215
|
}
|
209
216
|
});
|
217
|
+
}).catch(function (error) {
|
218
|
+
_this.eventCenter.emit(EVENT.destroy.name, {});
|
219
|
+
_this.eventCenter.emit(EVENT.eventCallback.name, {
|
220
|
+
code: eventCodeEnum.SDK_INTERNAL_ERROR,
|
221
|
+
result: {
|
222
|
+
message: error === null || error === void 0 ? void 0 : error.message
|
223
|
+
}
|
224
|
+
});
|
210
225
|
});
|
211
226
|
}
|
212
227
|
}, {
|
@@ -270,25 +285,26 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
270
285
|
_context2.t0 = requester;
|
271
286
|
_context2.t1 = submitParams;
|
272
287
|
_context2.t2 = this.initConfig.environment;
|
273
|
-
_context2.
|
288
|
+
_context2.t3 = this.SDK_REQUEST_TIMEOUT;
|
289
|
+
_context2.next = 20;
|
274
290
|
return this.acquireApdidToken();
|
275
|
-
case
|
276
|
-
_context2.
|
277
|
-
_context2.
|
278
|
-
deviceId: _context2.
|
291
|
+
case 20:
|
292
|
+
_context2.t4 = _context2.sent;
|
293
|
+
_context2.t5 = {
|
294
|
+
deviceId: _context2.t4
|
279
295
|
};
|
280
|
-
_context2.
|
281
|
-
_context2.
|
296
|
+
_context2.t6 = this.hostSign;
|
297
|
+
_context2.t7 = {
|
282
298
|
env: _context2.t2,
|
283
|
-
timeout:
|
284
|
-
envInfo: _context2.
|
285
|
-
hostSign: _context2.
|
299
|
+
timeout: _context2.t3,
|
300
|
+
envInfo: _context2.t5,
|
301
|
+
hostSign: _context2.t6,
|
286
302
|
needEnvInfo: true,
|
287
303
|
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
288
304
|
};
|
289
|
-
_context2.next =
|
290
|
-
return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.
|
291
|
-
case
|
305
|
+
_context2.next = 26;
|
306
|
+
return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t7);
|
307
|
+
case 26:
|
292
308
|
res = _context2.sent;
|
293
309
|
this.logger.logInfo({
|
294
310
|
title: 'sdk_event_submitPayEnd'
|
@@ -298,23 +314,23 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
298
314
|
rpcTraceId: res.traceId
|
299
315
|
});
|
300
316
|
return _context2.abrupt("return", res);
|
301
|
-
case
|
302
|
-
_context2.prev =
|
303
|
-
_context2.
|
317
|
+
case 31:
|
318
|
+
_context2.prev = 31;
|
319
|
+
_context2.t8 = _context2["catch"](13);
|
304
320
|
this.logger.logError({
|
305
321
|
title: 'sdk_event_submitPay_failed'
|
306
322
|
}, {
|
307
323
|
config: JSON.stringify(submitParams.paymentSessionConfig),
|
308
|
-
errorMessage: _context2.
|
324
|
+
errorMessage: JSON.stringify(_context2.t8),
|
309
325
|
requestId: requestBizId,
|
310
|
-
rpcTraceId: _context2.
|
326
|
+
rpcTraceId: _context2.t8 === null || _context2.t8 === void 0 ? void 0 : _context2.t8.traceId
|
311
327
|
});
|
312
|
-
|
313
|
-
case
|
328
|
+
return _context2.abrupt("return", null);
|
329
|
+
case 35:
|
314
330
|
case "end":
|
315
331
|
return _context2.stop();
|
316
332
|
}
|
317
|
-
}, _callee2, this, [[13,
|
333
|
+
}, _callee2, this, [[13, 31]]);
|
318
334
|
}));
|
319
335
|
function processSubmitPay() {
|
320
336
|
return _processSubmitPay.apply(this, arguments);
|
@@ -86,7 +86,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
86
86
|
time: Date.now() - startTime,
|
87
87
|
success: false,
|
88
88
|
code: errorCode,
|
89
|
-
|
89
|
+
errorMessage: errorMessage,
|
90
90
|
traceId: traceId
|
91
91
|
});
|
92
92
|
throw new Error(JSON.stringify({
|
@@ -102,7 +102,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
102
102
|
time: Date.now() - startTime,
|
103
103
|
success: true,
|
104
104
|
code: 'SUCCESS',
|
105
|
-
|
105
|
+
errorMessage: '',
|
106
106
|
traceId: traceId
|
107
107
|
});
|
108
108
|
return _context.abrupt("return", resData);
|
@@ -124,13 +124,14 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
124
124
|
time: Date.now() - startTime,
|
125
125
|
success: false,
|
126
126
|
code: _errorCode,
|
127
|
-
|
127
|
+
errorMessage: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.errorMessage) || _context.t0)
|
128
128
|
});
|
129
129
|
return _context.abrupt("return", Promise.reject({
|
130
130
|
success: false,
|
131
131
|
errorCode: _errorCode,
|
132
132
|
traceId: traceId,
|
133
|
-
|
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
|
134
135
|
}));
|
135
136
|
case 31:
|
136
137
|
case "end":
|