@alipay/ams-checkout 0.0.1710212811-dev.8 → 0.0.1710840616-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/common/applepay/index.d.ts +3 -5
- package/esm/common/applepay/index.js +20 -84
- package/esm/common/applepay/interface.d.ts +0 -61
- package/esm/common/applepay/interface.js +1 -73
- package/esm/config/request.js +3 -3
- package/esm/core/applepay/index.d.ts +2 -4
- package/esm/core/applepay/index.js +6 -10
- package/esm/core/component/index.d.ts +1 -7
- package/esm/core/component/index.js +17 -91
- package/esm/core/instance/index.d.ts +0 -1
- package/esm/core/instance/index.js +1 -3
- package/esm/plugin/component/index.d.ts +1 -2
- package/esm/plugin/component/index.js +74 -42
- package/esm/request/index.js +8 -14
- package/esm/types/index.d.ts +7 -47
- package/esm/types/index.js +0 -8
- package/esm/util/versionCompare.d.ts +2 -0
- package/esm/util/versionCompare.js +75 -0
- package/package.json +1 -1
- package/esm/core/bus/ability/sdk.d.ts +0 -9
- package/esm/core/bus/ability/sdk.js +0 -55
- package/esm/core/bus/index.d.ts +0 -63
- package/esm/core/bus/index.js +0 -287
- package/esm/core/bus/interface.d.ts +0 -24
- package/esm/core/bus/interface.js +0 -31
- package/esm/plugin/applepay/index.d.ts +0 -15
- package/esm/plugin/applepay/index.js +0 -99
@@ -30,7 +30,6 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
30
30
|
function AMSSDK(options) {
|
31
31
|
_classCallCheck(this, AMSSDK);
|
32
32
|
_defineProperty(this, "options", void 0);
|
33
|
-
_defineProperty(this, "originOptions", void 0);
|
34
33
|
_defineProperty(this, "logger", void 0);
|
35
34
|
_defineProperty(this, "_eventCenter", void 0);
|
36
35
|
_defineProperty(this, "_instanceId", void 0);
|
@@ -38,7 +37,6 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
38
37
|
_defineProperty(this, "securitySdkMap", void 0);
|
39
38
|
_defineProperty(this, "plugins", void 0);
|
40
39
|
this._instanceId = uuid();
|
41
|
-
this.originOptions = options;
|
42
40
|
this.options = {};
|
43
41
|
this._eventCenter = new EventCenter();
|
44
42
|
this._initEvent(options);
|
@@ -54,7 +52,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
54
52
|
this._storageId = _storageId;
|
55
53
|
|
56
54
|
// TODO Consumption data analysis control parameters
|
57
|
-
this.logger = new Logger(LogConfig, (options === null || options === void 0 ? void 0 : options.environment)
|
55
|
+
this.logger = new Logger(LogConfig, ![environmentEnum.prod, environmentEnum.sandbox].includes(options === null || options === void 0 ? void 0 : options.environment));
|
58
56
|
this.logger.setMedta({
|
59
57
|
instanceId: this._instanceId
|
60
58
|
});
|
@@ -25,7 +25,6 @@ export default class ComponentApp {
|
|
25
25
|
private _renderDisplayType;
|
26
26
|
private _multipleCallbackEvents;
|
27
27
|
_merchantAppointParam: IMerchantAppointParam;
|
28
|
-
private _webAppHeartBeatTimeoutId;
|
29
28
|
private _webAppHeartBeatTimeoutFn;
|
30
29
|
constructor();
|
31
30
|
/**
|
@@ -98,7 +97,7 @@ export default class ComponentApp {
|
|
98
97
|
*/
|
99
98
|
dispatchToApp(payload: {
|
100
99
|
context: eventPayloadContext;
|
101
|
-
}, targetElement?: any): any;
|
100
|
+
}, targetElement?: any, sendLog?: boolean): any;
|
102
101
|
/**
|
103
102
|
* @description Subscribe to messages from SDK
|
104
103
|
*/
|
@@ -22,6 +22,7 @@ import { queryPaymentInfo, submitPayInfo } from "../../service";
|
|
22
22
|
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
|
23
23
|
import { getType, isJsonString, isPC } from "../../util";
|
24
24
|
import { isLocalMock } from "../../util/mock";
|
25
|
+
import { matchVersion } from "../../util/versionCompare";
|
25
26
|
import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
26
27
|
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
27
28
|
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
@@ -52,9 +53,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
52
53
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
53
54
|
_defineProperty(this, "_multipleCallbackEvents", void 0);
|
54
55
|
_defineProperty(this, "_merchantAppointParam", void 0);
|
55
|
-
_defineProperty(this, "_webAppHeartBeatTimeoutId", void 0);
|
56
56
|
_defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
|
57
|
-
this._appVersion = '1.
|
57
|
+
this._appVersion = '1.11.0.6';
|
58
58
|
this._isInitComponent = false;
|
59
59
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
60
60
|
this.createIframeNode = function () {
|
@@ -364,7 +364,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
364
364
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
365
365
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
366
366
|
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5;
|
367
|
-
var envInfo, params, _ref3, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, extendInfoData, _this5$_renderParams6, _this5$_renderParams7, _ref4, _ref4$productSceneVer, productSceneVersion, _ref4$productScene, productScene, _ref5, _ref5$action, _ref5$action2, _ref5$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
|
367
|
+
var envInfo, params, _ref3, _ref3$extendInfo, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, _this5$_renderParams$, skipSdkQuery, skipSdkQueryForm, extendInfoData, ifSkip, _this5$_renderParams6, _this5$_renderParams7, _ref4, _ref4$productSceneVer, productSceneVersion, _ref4$productScene, productScene, _ref5, _ref5$action, _ref5$action2, _ref5$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
|
368
368
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
369
369
|
while (1) switch (_context2.prev = _context2.next) {
|
370
370
|
case 0:
|
@@ -380,9 +380,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
380
380
|
/**
|
381
381
|
* @description Simulated or unnecessary scenarios
|
382
382
|
*/
|
383
|
-
_ref3 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, extendInfo = _ref3.extendInfo;
|
383
|
+
_ref3 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, _ref3$extendInfo = _ref3.extendInfo, extendInfo = _ref3$extendInfo === void 0 ? '' : _ref3$extendInfo;
|
384
384
|
enableVaultingApiOptimize = false;
|
385
385
|
enableEasypayApiOptimize = false;
|
386
|
+
_this5$_renderParams$ = (_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.action, skipSdkQuery = _this5$_renderParams$.skipSdkQuery, skipSdkQueryForm = _this5$_renderParams$.skipSdkQueryForm;
|
386
387
|
try {
|
387
388
|
extendInfoData = JSON.parse(extendInfo);
|
388
389
|
enableVaultingApiOptimize = extendInfoData.enableVaultingApiOptimize || false;
|
@@ -391,95 +392,123 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
391
392
|
console.log(error);
|
392
393
|
}
|
393
394
|
if (!isLocalMock()) {
|
394
|
-
_context2.next =
|
395
|
+
_context2.next = 9;
|
395
396
|
break;
|
396
397
|
}
|
397
398
|
return _context2.abrupt("return", resolve({
|
398
399
|
message: 'sdk no need to make query request',
|
399
400
|
success: true
|
400
401
|
}));
|
401
|
-
case
|
402
|
-
if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign
|
403
|
-
_context2.next =
|
402
|
+
case 9:
|
403
|
+
if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
|
404
|
+
_context2.next = 21;
|
404
405
|
break;
|
405
406
|
}
|
406
|
-
|
407
|
+
if (!enableVaultingApiOptimize) {
|
408
|
+
_context2.next = 21;
|
409
|
+
break;
|
410
|
+
}
|
411
|
+
if (!skipSdkQueryForm) {
|
412
|
+
_context2.next = 18;
|
413
|
+
break;
|
414
|
+
}
|
415
|
+
// 优先判断 skipSdkQueryForm
|
416
|
+
ifSkip = matchVersion(skipSdkQueryForm, _this5._appVersion);
|
417
|
+
if (!ifSkip) {
|
418
|
+
_context2.next = 16;
|
419
|
+
break;
|
420
|
+
}
|
421
|
+
resolve({
|
407
422
|
message: 'sdk no need to make query request',
|
408
423
|
success: true
|
409
|
-
})
|
410
|
-
|
424
|
+
});
|
425
|
+
return _context2.abrupt("return");
|
426
|
+
case 16:
|
427
|
+
_context2.next = 21;
|
428
|
+
break;
|
429
|
+
case 18:
|
430
|
+
if (!skipSdkQuery) {
|
431
|
+
_context2.next = 21;
|
432
|
+
break;
|
433
|
+
}
|
434
|
+
resolve({
|
435
|
+
message: 'sdk no need to make query request',
|
436
|
+
success: true
|
437
|
+
});
|
438
|
+
return _context2.abrupt("return");
|
439
|
+
case 21:
|
411
440
|
if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
|
412
|
-
_context2.next =
|
441
|
+
_context2.next = 27;
|
413
442
|
break;
|
414
443
|
}
|
415
444
|
params.paymentMethodType = 'CARD';
|
416
|
-
_context2.next =
|
445
|
+
_context2.next = 25;
|
417
446
|
return _this5.getDeviceIdAndLog();
|
418
|
-
case
|
447
|
+
case 25:
|
419
448
|
envInfo.deviceId = _context2.sent;
|
420
449
|
if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
|
421
450
|
envInfo.extendInfo = {
|
422
451
|
WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
|
423
452
|
};
|
424
453
|
}
|
425
|
-
case
|
454
|
+
case 27:
|
426
455
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
427
|
-
_context2.next =
|
456
|
+
_context2.next = 37;
|
428
457
|
break;
|
429
458
|
}
|
430
459
|
_ref4 = params.paymentSessionConfig || {}, _ref4$productSceneVer = _ref4.productSceneVersion, productSceneVersion = _ref4$productSceneVer === void 0 ? '' : _ref4$productSceneVer, _ref4$productScene = _ref4.productScene, productScene = _ref4$productScene === void 0 ? '' : _ref4$productScene;
|
431
460
|
_ref5 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref5$action = _ref5.action, _ref5$action2 = _ref5$action === void 0 ? {} : _ref5$action, _ref5$action2$autoDeb = _ref5$action2.autoDebitWithToken, autoDebitWithToken = _ref5$action2$autoDeb === void 0 ? false : _ref5$action2$autoDeb;
|
432
461
|
if (!((_this5$_renderParams7 = _this5._renderParams) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.action) !== null && _this5$_renderParams7 !== void 0 && _this5$_renderParams7.skipSdkQuery && enableEasypayApiOptimize)) {
|
433
|
-
_context2.next =
|
462
|
+
_context2.next = 32;
|
434
463
|
break;
|
435
464
|
}
|
436
465
|
return _context2.abrupt("return", resolve({
|
437
466
|
message: 'sdk no need to make query request',
|
438
467
|
success: true
|
439
468
|
}));
|
440
|
-
case
|
469
|
+
case 32:
|
441
470
|
if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
|
442
|
-
_context2.next =
|
471
|
+
_context2.next = 34;
|
443
472
|
break;
|
444
473
|
}
|
445
474
|
return _context2.abrupt("return", resolve({
|
446
475
|
message: 'sdk no need to make query request',
|
447
476
|
success: true
|
448
477
|
}));
|
449
|
-
case
|
450
|
-
_context2.next =
|
478
|
+
case 34:
|
479
|
+
_context2.next = 36;
|
451
480
|
return _this5.getDeviceIdAndLog();
|
452
|
-
case
|
481
|
+
case 36:
|
453
482
|
envInfo.deviceId = _context2.sent;
|
454
|
-
case
|
483
|
+
case 37:
|
455
484
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
456
|
-
_context2.next =
|
485
|
+
_context2.next = 47;
|
457
486
|
break;
|
458
487
|
}
|
459
488
|
action = ((_this5$_renderParams8 = _this5._renderParams) === null || _this5$_renderParams8 === void 0 || (_this5$_renderParams8 = _this5$_renderParams8.paymentSessionMetaData) === null || _this5$_renderParams8 === void 0 ? void 0 : _this5$_renderParams8.action) || {};
|
460
489
|
signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
461
490
|
if (!(signType === 'SMS')) {
|
462
|
-
_context2.next =
|
491
|
+
_context2.next = 42;
|
463
492
|
break;
|
464
493
|
}
|
465
494
|
return _context2.abrupt("return", resolve({
|
466
495
|
message: 'sdk no need to make query request',
|
467
496
|
success: true
|
468
497
|
}));
|
469
|
-
case
|
498
|
+
case 42:
|
470
499
|
if (!(!signType || signType !== 'REDIRECT')) {
|
471
|
-
_context2.next =
|
500
|
+
_context2.next = 44;
|
472
501
|
break;
|
473
502
|
}
|
474
503
|
return _context2.abrupt("return", resolve({
|
475
504
|
success: false
|
476
505
|
}));
|
477
|
-
case
|
478
|
-
_context2.next =
|
506
|
+
case 44:
|
507
|
+
_context2.next = 46;
|
479
508
|
return _this5.getDeviceIdAndLog();
|
480
|
-
case
|
509
|
+
case 46:
|
481
510
|
envInfo.deviceId = _context2.sent;
|
482
|
-
case
|
511
|
+
case 47:
|
483
512
|
_this5.AMSSDK.logger.logInfo({
|
484
513
|
title: 'sdk_event_sdkQuery'
|
485
514
|
}, {
|
@@ -511,7 +540,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
511
540
|
paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
|
512
541
|
}).send();
|
513
542
|
});
|
514
|
-
case
|
543
|
+
case 49:
|
515
544
|
case "end":
|
516
545
|
return _context2.stop();
|
517
546
|
}
|
@@ -1235,12 +1264,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1235
1264
|
}
|
1236
1265
|
};
|
1237
1266
|
}
|
1238
|
-
if (
|
1239
|
-
clearTimeout(
|
1240
|
-
|
1267
|
+
if (window._webAppHeartBeatTimeoutId) {
|
1268
|
+
clearTimeout(window._webAppHeartBeatTimeoutId);
|
1269
|
+
window._webAppHeartBeatTimeoutId = null;
|
1241
1270
|
}
|
1242
1271
|
if (this._webAppHeartBeatTimeoutFn) {
|
1243
|
-
|
1272
|
+
window._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
|
1244
1273
|
}
|
1245
1274
|
setTimeout(function () {
|
1246
1275
|
if (_this8.isAppAttached()) {
|
@@ -1249,7 +1278,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1249
1278
|
event: 'sdkHeartBeat',
|
1250
1279
|
data: {}
|
1251
1280
|
}
|
1252
|
-
});
|
1281
|
+
}, null, false);
|
1253
1282
|
}
|
1254
1283
|
}, TIME_DELAY_SEND_HEART_BEAT);
|
1255
1284
|
} catch (error) {
|
@@ -1299,17 +1328,20 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1299
1328
|
key: "dispatchToApp",
|
1300
1329
|
value: function dispatchToApp(payload) {
|
1301
1330
|
var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
1331
|
+
var sendLog = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
1302
1332
|
var data = Object.assign({}, payload, {
|
1303
1333
|
name: messageName.SDK_TO_APP,
|
1304
1334
|
mode: this.AMSSDK.options.mode,
|
1305
1335
|
appId: COMPONENTPLUGINID,
|
1306
1336
|
instanceId: this.AMSSDK._instanceId
|
1307
1337
|
});
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1338
|
+
if (sendLog) {
|
1339
|
+
this.AMSSDK.logger.logInfo({
|
1340
|
+
title: 'sdk_event_send_message_to_web'
|
1341
|
+
}, {
|
1342
|
+
event: data === null || data === void 0 ? void 0 : data.context.event
|
1343
|
+
}).send();
|
1344
|
+
}
|
1313
1345
|
if (targetElement && targetElement.contentWindow) {
|
1314
1346
|
return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
|
1315
1347
|
}
|
package/esm/request/index.js
CHANGED
@@ -50,8 +50,6 @@ function requestInstance(options) {
|
|
50
50
|
withCredentials: (_options$withCredenti = options.withCredentials) !== null && _options$withCredenti !== void 0 ? _options$withCredenti : true,
|
51
51
|
method: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
|
52
52
|
});
|
53
|
-
console.log('baseURL', baseURL);
|
54
|
-
console.log('_headers', _headers);
|
55
53
|
return instance.request;
|
56
54
|
}
|
57
55
|
|
@@ -99,25 +97,21 @@ function _request() {
|
|
99
97
|
})];
|
100
98
|
startTime = Date.now();
|
101
99
|
_context.prev = 5;
|
102
|
-
console.log('requestInstance options', options);
|
103
|
-
console.log('requestInstance -data', _data);
|
104
100
|
myRequest = requestInstance(options);
|
105
|
-
_context.next =
|
101
|
+
_context.next = 9;
|
106
102
|
return myRequest({
|
107
103
|
data: _data
|
108
104
|
});
|
109
|
-
case
|
105
|
+
case 9:
|
110
106
|
_yield$myRequest = _context.sent;
|
111
107
|
data = _yield$myRequest.data;
|
112
108
|
headers = _yield$myRequest.headers;
|
113
|
-
console.log('requestInstance data', data);
|
114
|
-
console.log('requestInstance headers', headers);
|
115
109
|
resData = data || {};
|
116
110
|
traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
|
117
111
|
resData.traceId = traceId || '';
|
118
112
|
handleGetWayError = fomatGetwayError(headers, traceId);
|
119
113
|
if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
|
120
|
-
_context.next =
|
114
|
+
_context.next = 21;
|
121
115
|
break;
|
122
116
|
}
|
123
117
|
errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
|
@@ -136,7 +130,7 @@ function _request() {
|
|
136
130
|
errorCode: errorCode,
|
137
131
|
success: false
|
138
132
|
}));
|
139
|
-
case
|
133
|
+
case 21:
|
140
134
|
logger.reportRPC({
|
141
135
|
name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
|
142
136
|
label: 'request',
|
@@ -147,8 +141,8 @@ function _request() {
|
|
147
141
|
traceId: traceId
|
148
142
|
}).send();
|
149
143
|
return _context.abrupt("return", resData);
|
150
|
-
case
|
151
|
-
_context.prev =
|
144
|
+
case 25:
|
145
|
+
_context.prev = 25;
|
152
146
|
_context.t0 = _context["catch"](5);
|
153
147
|
_error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
|
154
148
|
success: false,
|
@@ -170,11 +164,11 @@ function _request() {
|
|
170
164
|
errorCode: _errorCode,
|
171
165
|
errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
|
172
166
|
}));
|
173
|
-
case
|
167
|
+
case 32:
|
174
168
|
case "end":
|
175
169
|
return _context.stop();
|
176
170
|
}
|
177
|
-
}, _callee, null, [[5,
|
171
|
+
}, _callee, null, [[5, 25]]);
|
178
172
|
}));
|
179
173
|
return _request.apply(this, arguments);
|
180
174
|
}
|
package/esm/types/index.d.ts
CHANGED
@@ -133,19 +133,23 @@ export interface IpaymentSessionMetaData {
|
|
133
133
|
action?: {
|
134
134
|
autoDebitWithToken: boolean;
|
135
135
|
skipSdkQuery: boolean;
|
136
|
+
skipSdkQueryForm?: {
|
137
|
+
value: boolean;
|
138
|
+
version: string;
|
139
|
+
platform: string;
|
140
|
+
};
|
136
141
|
};
|
137
142
|
paymentSessionFactor?: {
|
138
|
-
|
143
|
+
applePay?: {
|
139
144
|
merchantCapabilities?: string[];
|
140
145
|
supportedNetworks?: string[];
|
141
146
|
};
|
142
147
|
merchantInfo?: {
|
143
148
|
registeredCountry?: string;
|
144
149
|
partnerId?: string;
|
145
|
-
merchantName?: string;
|
146
150
|
};
|
147
151
|
order?: {
|
148
|
-
orderDescription
|
152
|
+
orderDescription?: string;
|
149
153
|
};
|
150
154
|
paymentAmount?: {
|
151
155
|
value?: string;
|
@@ -157,43 +161,6 @@ export interface IpaymentSessionMetaData {
|
|
157
161
|
paymentMethodViewMetaData?: any;
|
158
162
|
paymentRequestId?: string;
|
159
163
|
supportedLanguages?: any;
|
160
|
-
/**
|
161
|
-
* 当前为苹果分期场景的信息
|
162
|
-
*/
|
163
|
-
recurringInfo?: {
|
164
|
-
/**
|
165
|
-
* 代扣协议开始日期 不传为当前系统时间
|
166
|
-
*/
|
167
|
-
startDate?: number;
|
168
|
-
/**
|
169
|
-
* 代扣协议结束日期 不传不限制结束时间
|
170
|
-
*/
|
171
|
-
endDate?: number;
|
172
|
-
/**
|
173
|
-
* 付款时间间隔单位,支持:"year" "month" "day" "hour" "minute" 不传默认month
|
174
|
-
*/
|
175
|
-
intervalUnit?: string;
|
176
|
-
/**
|
177
|
-
* 付款时间间隔。比如每过6个月付款一次,intervalCount就是6, 不传默认为1
|
178
|
-
*/
|
179
|
-
intervalCount?: number;
|
180
|
-
/**
|
181
|
-
* 分期标题信息
|
182
|
-
*/
|
183
|
-
title?: string;
|
184
|
-
/**
|
185
|
-
* 分期管理页面
|
186
|
-
*/
|
187
|
-
managementURL?: string;
|
188
|
-
/**
|
189
|
-
* 苹果通知ipay MAPN信息变更的地址
|
190
|
-
*/
|
191
|
-
tokenNotificationURL?: string;
|
192
|
-
/**
|
193
|
-
* 分期协议描述
|
194
|
-
*/
|
195
|
-
agreementDescription?: string;
|
196
|
-
};
|
197
164
|
};
|
198
165
|
}
|
199
166
|
export declare enum localeEnum {
|
@@ -471,11 +438,4 @@ export interface CallbackEventInfo {
|
|
471
438
|
export interface MultipleCallbackEvents {
|
472
439
|
[key: string]: CallbackEventInfo;
|
473
440
|
}
|
474
|
-
export declare enum PaymentMethodTypeEnum {
|
475
|
-
ApplePay = "ApplePay"
|
476
|
-
}
|
477
|
-
export declare enum ApplePaySubTypeEnum {
|
478
|
-
ApplePayRecurringPayment = "ApplePayRecurringPayment"
|
479
|
-
}
|
480
|
-
export type SubPaymentMethodTypeEnum = ApplePaySubTypeEnum;
|
481
441
|
export {};
|
package/esm/types/index.js
CHANGED
@@ -164,12 +164,4 @@ export var RedirectType = /*#__PURE__*/function (RedirectType) {
|
|
164
164
|
RedirectType["NormalUrl"] = "NormalUrl";
|
165
165
|
RedirectType["Unknown"] = "Unknown";
|
166
166
|
return RedirectType;
|
167
|
-
}({});
|
168
|
-
export var PaymentMethodTypeEnum = /*#__PURE__*/function (PaymentMethodTypeEnum) {
|
169
|
-
PaymentMethodTypeEnum["ApplePay"] = "ApplePay";
|
170
|
-
return PaymentMethodTypeEnum;
|
171
|
-
}({});
|
172
|
-
export var ApplePaySubTypeEnum = /*#__PURE__*/function (ApplePaySubTypeEnum) {
|
173
|
-
ApplePaySubTypeEnum["ApplePayRecurringPayment"] = "ApplePayRecurringPayment";
|
174
|
-
return ApplePaySubTypeEnum;
|
175
167
|
}({});
|
@@ -4,3 +4,5 @@
|
|
4
4
|
* @param v2
|
5
5
|
*/
|
6
6
|
export declare function compareVersion(v1: string, v2: string): 1 | 0 | -1;
|
7
|
+
export declare function isVersionInRange(currentVersion: any, minVersion: any, maxVersion: any): boolean;
|
8
|
+
export declare function matchVersion(config: any, currentVersion: any): boolean;
|
@@ -1,3 +1,9 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
1
7
|
/**
|
2
8
|
* 返回值0标识一样大,1表示v1大,-1表示v2大
|
3
9
|
* @param v1
|
@@ -42,4 +48,73 @@ export function compareVersion(v1, v2) {
|
|
42
48
|
} else {
|
43
49
|
return 1;
|
44
50
|
}
|
51
|
+
}
|
52
|
+
export function isVersionInRange(currentVersion, minVersion, maxVersion) {
|
53
|
+
function splitVersion(version) {
|
54
|
+
return version.split('.').map(function (num) {
|
55
|
+
return parseInt(num, 10);
|
56
|
+
});
|
57
|
+
}
|
58
|
+
function compareVersions(v1, v2) {
|
59
|
+
for (var i = 0; i < Math.max(v1.length, v2.length); i++) {
|
60
|
+
var num1 = v1[i] === undefined ? 0 : v1[i];
|
61
|
+
var num2 = v2[i] === undefined ? 0 : v2[i];
|
62
|
+
if (num1 > num2) return 1;
|
63
|
+
if (num1 < num2) return -1;
|
64
|
+
}
|
65
|
+
return 0;
|
66
|
+
}
|
67
|
+
var current = splitVersion(currentVersion);
|
68
|
+
var min = minVersion ? splitVersion(minVersion) : null;
|
69
|
+
var max = maxVersion ? splitVersion(maxVersion) : null;
|
70
|
+
if (min && compareVersions(current, min) < 0) {
|
71
|
+
// 当前版本小于最小允许版本
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
if (max && compareVersions(current, max) > 0) {
|
75
|
+
// 当前版本大于最大允许版本
|
76
|
+
return false;
|
77
|
+
}
|
78
|
+
// 当前版本在允许的版本范围内
|
79
|
+
return true;
|
80
|
+
}
|
81
|
+
export function matchVersion(config, currentVersion) {
|
82
|
+
var value = config.value,
|
83
|
+
version = config.version,
|
84
|
+
platform = config.platform;
|
85
|
+
var CURRENT_PLATFORM = 'WEB';
|
86
|
+
var isMatchVersion = false;
|
87
|
+
var isMatchPlatform = false;
|
88
|
+
|
89
|
+
// 平台判断
|
90
|
+
if (platform) {
|
91
|
+
var platformList = platform.split('|').map(function (platform) {
|
92
|
+
return platform.toLocaleUpperCase();
|
93
|
+
});
|
94
|
+
isMatchPlatform = platformList.includes(CURRENT_PLATFORM);
|
95
|
+
} else {
|
96
|
+
// 没有表示平台全匹配
|
97
|
+
isMatchPlatform = true;
|
98
|
+
}
|
99
|
+
// 版本判断
|
100
|
+
if (!version) {
|
101
|
+
// 为空全匹配
|
102
|
+
isMatchVersion = true;
|
103
|
+
} else if (version.indexOf('|') !== -1) {
|
104
|
+
// | 范围匹配
|
105
|
+
var _version$split = version.split('|'),
|
106
|
+
_version$split2 = _slicedToArray(_version$split, 2),
|
107
|
+
_version$split2$ = _version$split2[0],
|
108
|
+
minVersion = _version$split2$ === void 0 ? '' : _version$split2$,
|
109
|
+
_version$split2$2 = _version$split2[1],
|
110
|
+
maxVersion = _version$split2$2 === void 0 ? '' : _version$split2$2;
|
111
|
+
isMatchVersion = isVersionInRange(currentVersion, minVersion, maxVersion);
|
112
|
+
} else if (version.indexOf(',') !== -1) {
|
113
|
+
// , 枚举匹配
|
114
|
+
var versionList = version.split(',');
|
115
|
+
isMatchVersion = versionList.includes(currentVersion);
|
116
|
+
} else {
|
117
|
+
isMatchVersion = version === currentVersion;
|
118
|
+
}
|
119
|
+
return value && isMatchPlatform && isMatchVersion;
|
45
120
|
}
|
package/package.json
CHANGED
@@ -1,9 +0,0 @@
|
|
1
|
-
import { BusContext, BusMessage, BusSubscriber } from "../index";
|
2
|
-
import { callOnEventCallback } from "../../../types";
|
3
|
-
export declare class SDKCallbackBusSubscriber extends BusSubscriber {
|
4
|
-
private _onEventCallback?;
|
5
|
-
constructor(onEventCallback?: callOnEventCallback);
|
6
|
-
actionNames(): string[];
|
7
|
-
protected onEventCallback(message: BusMessage): void;
|
8
|
-
onMessage(context: BusContext, message: BusMessage): void;
|
9
|
-
}
|
@@ -1,55 +0,0 @@
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
4
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
5
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
6
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
7
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
8
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
9
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
10
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
11
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
12
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
14
|
-
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); }
|
15
|
-
import { SDKCallbackActionEnum } from "../interface";
|
16
|
-
import { BusSubscriber } from "../index";
|
17
|
-
export var SDKCallbackBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
18
|
-
_inherits(SDKCallbackBusSubscriber, _BusSubscriber);
|
19
|
-
var _super = _createSuper(SDKCallbackBusSubscriber);
|
20
|
-
function SDKCallbackBusSubscriber(onEventCallback) {
|
21
|
-
var _this;
|
22
|
-
_classCallCheck(this, SDKCallbackBusSubscriber);
|
23
|
-
_this = _super.call(this);
|
24
|
-
_defineProperty(_assertThisInitialized(_this), "_onEventCallback", void 0);
|
25
|
-
_this._onEventCallback = onEventCallback;
|
26
|
-
return _this;
|
27
|
-
}
|
28
|
-
_createClass(SDKCallbackBusSubscriber, [{
|
29
|
-
key: "actionNames",
|
30
|
-
value: function actionNames() {
|
31
|
-
return Object.values(SDKCallbackActionEnum);
|
32
|
-
}
|
33
|
-
}, {
|
34
|
-
key: "onEventCallback",
|
35
|
-
value: function onEventCallback(message) {
|
36
|
-
var data = message.getJSONObject();
|
37
|
-
console.log("onEventCallback", message);
|
38
|
-
if (this._onEventCallback && data) {
|
39
|
-
this._onEventCallback(data);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}, {
|
43
|
-
key: "onMessage",
|
44
|
-
value: function onMessage(context, message) {
|
45
|
-
switch (message.getAction()) {
|
46
|
-
case SDKCallbackActionEnum.onEventCallback:
|
47
|
-
this.onEventCallback(message);
|
48
|
-
break;
|
49
|
-
default:
|
50
|
-
throw new Error("Unknown action: " + message.getAction());
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}]);
|
54
|
-
return SDKCallbackBusSubscriber;
|
55
|
-
}(BusSubscriber);
|