@alipay/ams-checkout 0.0.1757298389-dev.2 → 0.0.1757298389-dev.21
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/README.md +17 -1
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/component.popup.style.d.ts +1 -0
- package/esm/component/component.popup.style.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +60 -0
- package/esm/constant/index.js +68 -1
- package/esm/core/component/element/EventCenter/index.d.ts +29 -0
- package/esm/core/component/element/EventCenter/index.js +155 -0
- package/esm/core/component/element/elementContainerService/containerService.js +3 -2
- package/esm/core/component/element/elementController/index.d.ts +16 -4
- package/esm/core/component/element/elementController/index.js +497 -280
- package/esm/core/component/element/elementProcessor/addressProcessor.js +3 -3
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +20 -14
- package/esm/core/component/element/index.d.ts +3 -5
- package/esm/core/component/element/index.js +9 -3
- package/esm/core/component/element/mock.js +1 -0
- package/esm/core/component/element/type.d.ts +55 -5
- package/esm/core/component/element/type.js +59 -2
- package/esm/core/component/element/util.d.ts +20 -5
- package/esm/core/component/element/util.js +49 -7
- package/esm/core/component/index.d.ts +4 -1
- package/esm/core/component/index.js +105 -2
- package/esm/foundation/service/log/keys.js +2 -0
- package/esm/foundation/service/requester/requester.js +2 -3
- package/esm/index.d.ts +10 -1
- package/esm/index.js +15 -1
- package/esm/plugin/component/channel.js +5 -3
- package/esm/plugin/component/index.d.ts +2 -0
- package/esm/plugin/component/index.js +24 -8
- package/esm/plugin/paypal/index.js +5 -2
- package/esm/types/index.d.ts +13 -1
- package/esm/types/index.js +1 -1
- package/esm/util/spm-map.d.ts +8 -0
- package/esm/util/spm-map.js +5 -1
- package/package.json +13 -8
- package/esm/core/component/oldElement/components/address.d.ts +0 -19
- package/esm/core/component/oldElement/components/address.js +0 -68
- package/esm/core/component/oldElement/components/auth.d.ts +0 -17
- package/esm/core/component/oldElement/components/auth.js +0 -60
- package/esm/core/component/oldElement/components/payment.d.ts +0 -19
- package/esm/core/component/oldElement/components/payment.js +0 -74
- package/esm/core/component/oldElement/index.d.ts +0 -59
- package/esm/core/component/oldElement/index.js +0 -956
- package/esm/core/component/oldElement/mock.d.ts +0 -6
- package/esm/core/component/oldElement/mock.js +0 -567
- package/esm/core/component/oldElement/type.d.ts +0 -354
- package/esm/core/component/oldElement/type.js +0 -81
- package/esm/core/component/oldElement/utils.d.ts +0 -13
- package/esm/core/component/oldElement/utils.js +0 -6
|
@@ -35,7 +35,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
35
35
|
* 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.
|
|
36
36
|
*/
|
|
37
37
|
import { v4 as uuid } from 'uuid';
|
|
38
|
-
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
|
38
|
+
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT, SENDEVENT } from "../../constant";
|
|
39
|
+
import PreloadHelper from "../../foundation/utils/preload_helper";
|
|
39
40
|
import { ApplePayBusSubscriber } from "../../plugin/applepay";
|
|
40
41
|
import ComponentApp from "../../plugin/component";
|
|
41
42
|
import { ExtendPlugin } from "../../plugin/const";
|
|
@@ -50,7 +51,6 @@ import { SecurityBusSubscriber } from "../bus/ability/security";
|
|
|
50
51
|
import { TrackerBusSubscriber } from "../bus/ability/tracker";
|
|
51
52
|
import CoreInstance from "../instance/index";
|
|
52
53
|
import { loadChannelPneumaticControl } from "./appPreloadProcessing";
|
|
53
|
-
import PreloadHelper from "../../foundation/utils/preload_helper";
|
|
54
54
|
export var getComponentSign = function getComponentSign(params) {
|
|
55
55
|
var _params$paymentSessio = params.paymentSessionConfig,
|
|
56
56
|
_params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
|
|
@@ -140,6 +140,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
|
140
140
|
_defineProperty(_assertThisInitialized(_this2), "channelType", void 0);
|
|
141
141
|
_defineProperty(_assertThisInitialized(_this2), "productSceneVersion", void 0);
|
|
142
142
|
_defineProperty(_assertThisInitialized(_this2), "timer", void 0);
|
|
143
|
+
_defineProperty(_assertThisInitialized(_this2), "_validateResolveMap", new Map());
|
|
143
144
|
var ComponentPlugin = new ComponentApp({
|
|
144
145
|
appVersion: options.appVersion
|
|
145
146
|
});
|
|
@@ -526,6 +527,108 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
|
526
527
|
}
|
|
527
528
|
});
|
|
528
529
|
}
|
|
530
|
+
|
|
531
|
+
// 预留给AMSVaulting复用
|
|
532
|
+
}, {
|
|
533
|
+
key: "_validateFields",
|
|
534
|
+
value: function _validateFields() {
|
|
535
|
+
var _this9 = this;
|
|
536
|
+
return new Promise(function (resolve) {
|
|
537
|
+
// 收银台应用渲染表单后,才允许发送校验消息,三端约定一致
|
|
538
|
+
if (!_this9._componentApp.shouldValidateFields()) {
|
|
539
|
+
resolve({
|
|
540
|
+
isValid: false
|
|
541
|
+
});
|
|
542
|
+
_this9.logger.logInfo({
|
|
543
|
+
title: 'sdk_event_validateFields'
|
|
544
|
+
}, {
|
|
545
|
+
processResult: 'notRenderComponent'
|
|
546
|
+
});
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
var timeoutId;
|
|
550
|
+
var validationPromise = new Promise(function (validationResolve) {
|
|
551
|
+
var eventCallbackId = uuid();
|
|
552
|
+
_this9._validateResolveMap.set(eventCallbackId, validationResolve);
|
|
553
|
+
// 发送validateFields消息
|
|
554
|
+
_this9._sendMessageToAPP({
|
|
555
|
+
event: SENDEVENT.validateFields.name,
|
|
556
|
+
data: {},
|
|
557
|
+
eventCallbackId: eventCallbackId
|
|
558
|
+
});
|
|
559
|
+
var isValidationResult = function isValidationResult(data) {
|
|
560
|
+
return _typeof(data) === 'object' && data !== null && typeof data.isValid === 'boolean';
|
|
561
|
+
};
|
|
562
|
+
var callback = /*#__PURE__*/function () {
|
|
563
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload) {
|
|
564
|
+
var currentEventCallbackId, currentResolve, result;
|
|
565
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
566
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
567
|
+
case 0:
|
|
568
|
+
currentEventCallbackId = (payload === null || payload === void 0 ? void 0 : payload.eventCallbackId) || ''; // 事件一一对应,处理异步商户调用多次可能导致乱序的问题
|
|
569
|
+
currentResolve = _this9._validateResolveMap.get(currentEventCallbackId);
|
|
570
|
+
result = {
|
|
571
|
+
isValid: false
|
|
572
|
+
};
|
|
573
|
+
if (isValidationResult(payload === null || payload === void 0 ? void 0 : payload.data)) {
|
|
574
|
+
result = payload === null || payload === void 0 ? void 0 : payload.data;
|
|
575
|
+
}
|
|
576
|
+
_this9.logger.logInfo({
|
|
577
|
+
title: 'sdk_event_validateFields'
|
|
578
|
+
}, {
|
|
579
|
+
processResult: result.isValid ? 'true' : 'false'
|
|
580
|
+
});
|
|
581
|
+
// 收银台应用保证数据格式,三端SDK负责透传
|
|
582
|
+
if (!!currentResolve) {
|
|
583
|
+
currentResolve(result);
|
|
584
|
+
_this9._validateResolveMap.delete(currentEventCallbackId);
|
|
585
|
+
}
|
|
586
|
+
case 6:
|
|
587
|
+
case "end":
|
|
588
|
+
return _context2.stop();
|
|
589
|
+
}
|
|
590
|
+
}, _callee2);
|
|
591
|
+
}));
|
|
592
|
+
return function callback(_x2) {
|
|
593
|
+
return _ref5.apply(this, arguments);
|
|
594
|
+
};
|
|
595
|
+
}();
|
|
596
|
+
// 接收收银台应用的返回validateFieldsResult消息
|
|
597
|
+
// validateFieldsResultForward处理订阅eventCallbackId为空的问题
|
|
598
|
+
_this9._overrideSubscription(EVENT.validateFieldsResult.forwardName, callback, EVENT.validateFieldsResult.uniqueKey);
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// 兜底场景,三端约定超时时间15秒,兼容cpf网络校验超时场景
|
|
602
|
+
var timeoutPromise = new Promise(function (timeoutResolve) {
|
|
603
|
+
timeoutId = setTimeout(function () {
|
|
604
|
+
_this9.logger.logInfo({
|
|
605
|
+
title: 'sdk_event_validateFields'
|
|
606
|
+
}, {
|
|
607
|
+
processResult: 'timeout'
|
|
608
|
+
});
|
|
609
|
+
timeoutResolve({
|
|
610
|
+
isValid: false
|
|
611
|
+
});
|
|
612
|
+
}, 15000);
|
|
613
|
+
});
|
|
614
|
+
Promise.race([validationPromise, timeoutPromise]).then(function (result) {
|
|
615
|
+
clearTimeout(timeoutId);
|
|
616
|
+
resolve(result);
|
|
617
|
+
}).catch(function () {
|
|
618
|
+
clearTimeout(timeoutId);
|
|
619
|
+
resolve({
|
|
620
|
+
isValid: false
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}, {
|
|
626
|
+
key: "_sendMessageToAPP",
|
|
627
|
+
value: function _sendMessageToAPP(eventContext) {
|
|
628
|
+
this._componentApp.dispatchToApp({
|
|
629
|
+
context: eventContext
|
|
630
|
+
});
|
|
631
|
+
}
|
|
529
632
|
}]);
|
|
530
633
|
return AMSComponent;
|
|
531
634
|
}(CoreInstance);
|
|
@@ -12,8 +12,7 @@ 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 { errorEnum } from "./deps";
|
|
16
|
-
import { appId, device, fomatGetwayError, get, hostSignMap, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
|
|
15
|
+
import { appId, device, errorEnum, fomatGetwayError, get, hostSignMap, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* @author congle.zzq <congle.zzq@alipay.com>
|
|
@@ -116,7 +115,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
|
116
115
|
errorMessage: _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message
|
|
117
116
|
});
|
|
118
117
|
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
|
|
119
|
-
_errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode)
|
|
118
|
+
_errorCode = timeoutCode || (_error === null || _error === void 0 ? void 0 : _error.errorCode);
|
|
120
119
|
this.reportRequestTimeCost({
|
|
121
120
|
title: 'a3753.b101271.c388193.d521387',
|
|
122
121
|
name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
|
package/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AddressComponent } from './core/component/address';
|
|
2
2
|
import { ElementComponent } from './core/component/element';
|
|
3
3
|
import { AMSComponent } from './core/component/index';
|
|
4
|
-
import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions } from './types';
|
|
4
|
+
import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions, ValidationResult } from './types';
|
|
5
5
|
export { AMSCheckoutPage } from './core/component/ckp';
|
|
6
6
|
export * from './types';
|
|
7
7
|
export declare class AMSCheckout extends AMSComponent {
|
|
@@ -14,6 +14,15 @@ export declare class AMSAutoDebitPay extends AMSCheckout {
|
|
|
14
14
|
export declare class AMSCashierPayment extends AMSCheckout {
|
|
15
15
|
constructor(options: IoptionsParams);
|
|
16
16
|
static preload(options?: IPreloadOptions): void;
|
|
17
|
+
/**
|
|
18
|
+
* Form validation function
|
|
19
|
+
* If the form is currently displayed:
|
|
20
|
+
* - Successful validation: isValid is true
|
|
21
|
+
* - Failed validation: isValid is false, and error messages are displayed on the form page
|
|
22
|
+
* If not on the form display page, isValid returns false
|
|
23
|
+
* @returns {Promise<ValidationResult>} Returns a Promise containing the validation result
|
|
24
|
+
*/
|
|
25
|
+
validateFields(): Promise<ValidationResult>;
|
|
17
26
|
}
|
|
18
27
|
export declare class AMSVaulting extends AMSCheckout {
|
|
19
28
|
constructor(options: IoptionsParams);
|
package/esm/index.js
CHANGED
|
@@ -111,7 +111,21 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout2) {
|
|
|
111
111
|
}
|
|
112
112
|
return _super3.call(this, _options, currentChannelType);
|
|
113
113
|
}
|
|
114
|
-
_createClass(AMSCashierPayment,
|
|
114
|
+
_createClass(AMSCashierPayment, [{
|
|
115
|
+
key: "validateFields",
|
|
116
|
+
value:
|
|
117
|
+
/**
|
|
118
|
+
* Form validation function
|
|
119
|
+
* If the form is currently displayed:
|
|
120
|
+
* - Successful validation: isValid is true
|
|
121
|
+
* - Failed validation: isValid is false, and error messages are displayed on the form page
|
|
122
|
+
* If not on the form display page, isValid returns false
|
|
123
|
+
* @returns {Promise<ValidationResult>} Returns a Promise containing the validation result
|
|
124
|
+
*/
|
|
125
|
+
function validateFields() {
|
|
126
|
+
return this._validateFields();
|
|
127
|
+
}
|
|
128
|
+
}], [{
|
|
115
129
|
key: "preload",
|
|
116
130
|
value: function preload() {
|
|
117
131
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
@@ -8,14 +8,14 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
8
8
|
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; }
|
|
9
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
10
|
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); }
|
|
11
|
+
import { MODE } from "../../constant/easysafepay";
|
|
11
12
|
import { BusManager, BusMessage } from "../../core/bus";
|
|
12
13
|
import { SecuritySDKActionEnum } from "../../core/bus/interface";
|
|
14
|
+
import { getDoubleFaUrlFromSession } from "../../foundation/utils/web_app_url_utils";
|
|
13
15
|
import { getApplePayPaymentSession, submitPayInfo } from "../../service";
|
|
14
16
|
import { EnvironmentEnum } from "../../types";
|
|
15
17
|
import { device, isEmpty } from "../../util";
|
|
16
18
|
import { APPLE_PAY_RECURRING_VERSION, APPLE_PAY_VERSION } from "../applepay/interface";
|
|
17
|
-
import { getDoubleFaUrlFromSession } from "../../foundation/utils/web_app_url_utils";
|
|
18
|
-
import { MODE } from "../../constant/easysafepay";
|
|
19
19
|
var APPLEPAYERRORENUM = /*#__PURE__*/function (APPLEPAYERRORENUM) {
|
|
20
20
|
APPLEPAYERRORENUM["APPLE_PAY_MISSING_DATA"] = "APPLE_PAY_MISSING_DATA";
|
|
21
21
|
APPLEPAYERRORENUM["APPLE_PAY_NOT_SUPPORTED"] = "APPLE_PAY_NOT_SUPPORTED";
|
|
@@ -112,6 +112,9 @@ export var handleGooglePay = function handleGooglePay(data) {
|
|
|
112
112
|
reject(err);
|
|
113
113
|
});
|
|
114
114
|
};
|
|
115
|
+
script.onerror = function (err) {
|
|
116
|
+
reject(err);
|
|
117
|
+
};
|
|
115
118
|
});
|
|
116
119
|
};
|
|
117
120
|
export var ApplePaySdk = /*#__PURE__*/function () {
|
|
@@ -297,7 +300,6 @@ export var ApplePaySdk = /*#__PURE__*/function () {
|
|
|
297
300
|
title: 'a3753.b103030.c386485.d507498'
|
|
298
301
|
});
|
|
299
302
|
}
|
|
300
|
-
_this.abortSession();
|
|
301
303
|
reject({
|
|
302
304
|
errorCode: APPLEPAYERRORENUM.APPLE_PAY_CANCEL
|
|
303
305
|
});
|
|
@@ -28,6 +28,7 @@ export default class ComponentApp {
|
|
|
28
28
|
private _isAppWebview;
|
|
29
29
|
_merchantAppointParam: IMerchantAppointParam;
|
|
30
30
|
private _webAppHeartBeatTimeoutFn;
|
|
31
|
+
private _hasRenderComponent;
|
|
31
32
|
constructor(componentOption?: {
|
|
32
33
|
appVersion?: string;
|
|
33
34
|
});
|
|
@@ -126,5 +127,6 @@ export default class ComponentApp {
|
|
|
126
127
|
private showRetentionPopup;
|
|
127
128
|
private hideRetentionPopupFunc;
|
|
128
129
|
private submitForm;
|
|
130
|
+
shouldValidateFields(): boolean;
|
|
129
131
|
}
|
|
130
132
|
export {};
|
|
@@ -17,13 +17,13 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
17
17
|
* 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.
|
|
18
18
|
*/
|
|
19
19
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
|
+
import { ElementPaymentMethod } from "../../core/component/element/type";
|
|
20
21
|
import { v4 as uuid } from 'uuid';
|
|
21
22
|
import { sdkVersion } from "../../config";
|
|
22
23
|
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID, POPUP_LOADTIME_LOG_LIMIT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../constant";
|
|
23
|
-
import { ElementPaymentMethod } from "../../core/component/oldElement/type";
|
|
24
24
|
import { queryPaymentInfo, submitPayInfo } from "../../service";
|
|
25
25
|
import { ComponentSignEnum, DisplayTypeEnum, eventCodeEnum, MessageName, PlatformEnum, ProductSceneEnum, RedirectType, TargetEnum } from "../../types";
|
|
26
|
-
import { getType, isJsonString, isPC } from "../../util";
|
|
26
|
+
import { device, getType, isJsonString, isPC } from "../../util";
|
|
27
27
|
import { getBackScheme } from "../../util/getBackScheme";
|
|
28
28
|
import { isLocalMock } from "../../util/mock";
|
|
29
29
|
import { matchVersion } from "../../util/versionCompare";
|
|
@@ -62,6 +62,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
|
62
62
|
_defineProperty(this, "_isAppWebview", void 0);
|
|
63
63
|
_defineProperty(this, "_merchantAppointParam", void 0);
|
|
64
64
|
_defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
|
|
65
|
+
_defineProperty(this, "_hasRenderComponent", false);
|
|
65
66
|
this._appVersion = componentOption.appVersion;
|
|
66
67
|
this._isInitComponent = false;
|
|
67
68
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
|
@@ -71,7 +72,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
|
71
72
|
this.createPreloadIframeNode = function () {
|
|
72
73
|
return Promise.resolve();
|
|
73
74
|
};
|
|
74
|
-
this.platform =
|
|
75
|
+
this.platform = device.isMobile ? PlatformEnum.mobile : PlatformEnum.desktop;
|
|
75
76
|
this._isRetention = true;
|
|
76
77
|
this._appLocationSearch = '';
|
|
77
78
|
this._performanceData.push({
|
|
@@ -673,6 +674,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
|
673
674
|
message: res === null || res === void 0 ? void 0 : res.errorMessage
|
|
674
675
|
};
|
|
675
676
|
_this5.dispatchToSDK(EVENT.error.name, createComponentError);
|
|
677
|
+
_this5.dispatchToSDK(EVENT.eventCallback.name, createComponentError);
|
|
676
678
|
if ((res === null || res === void 0 || (_res$errorActions = res.errorActions) === null || _res$errorActions === void 0 ? void 0 : _res$errorActions.showType) === 'NONE') {
|
|
677
679
|
// 抛错销毁SDK,不展示错误页面
|
|
678
680
|
reject(createComponentError);
|
|
@@ -684,6 +686,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
|
684
686
|
if (ComponentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign) {
|
|
685
687
|
// 通用操作:抛CREATECOMPONENT_ERROR错误码给商户,商户升级到新版本需要处理CREATECOMPONENT_ERROR逻辑
|
|
686
688
|
_this5.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.NETWORK_REQUEST_ERROR);
|
|
689
|
+
_this5.dispatchToSDK(EVENT.eventCallback.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.NETWORK_REQUEST_ERROR);
|
|
687
690
|
}
|
|
688
691
|
if ([ComponentSignEnum.CASHIER_PAYMENT_CARD, ComponentSignEnum.VAULTING_CARD, ComponentSignEnum.CASHIER_PAYMENT_APM].includes(_this5._componentSign)) {
|
|
689
692
|
return resolve({
|
|
@@ -1407,6 +1410,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
|
1407
1410
|
});
|
|
1408
1411
|
return;
|
|
1409
1412
|
}
|
|
1413
|
+
if (data.context.event === EVENT.validateFieldsResult.name) {
|
|
1414
|
+
// 将validateFieldsResult事件转发到subsribe处理,解决subsribe拿不到eventCallbackId的问题
|
|
1415
|
+
this.AMSSDK._eventCenter.emit(EVENT.validateFieldsResult.forwardName, data.context);
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1410
1419
|
// log event before sending the callback
|
|
1411
1420
|
this.logEventCallback(data, 'sdk_event_event_callback');
|
|
1412
1421
|
try {
|
|
@@ -1842,6 +1851,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
|
1842
1851
|
return this._actionSubmitPromise;
|
|
1843
1852
|
case 9:
|
|
1844
1853
|
submitRes = _context8.sent;
|
|
1854
|
+
this._hasRenderComponent = true;
|
|
1845
1855
|
this._performanceData.push({
|
|
1846
1856
|
key: 'sdk_render_component',
|
|
1847
1857
|
value: Date.now()
|
|
@@ -1897,16 +1907,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
|
1897
1907
|
}
|
|
1898
1908
|
});
|
|
1899
1909
|
// eslint-disable-next-line no-empty
|
|
1900
|
-
_context8.next =
|
|
1910
|
+
_context8.next = 19;
|
|
1901
1911
|
break;
|
|
1902
|
-
case
|
|
1903
|
-
_context8.prev =
|
|
1912
|
+
case 17:
|
|
1913
|
+
_context8.prev = 17;
|
|
1904
1914
|
_context8.t0 = _context8["catch"](0);
|
|
1905
|
-
case
|
|
1915
|
+
case 19:
|
|
1906
1916
|
case "end":
|
|
1907
1917
|
return _context8.stop();
|
|
1908
1918
|
}
|
|
1909
|
-
}, _callee8, this, [[0,
|
|
1919
|
+
}, _callee8, this, [[0, 17]]);
|
|
1910
1920
|
}));
|
|
1911
1921
|
function sendRenderEvent() {
|
|
1912
1922
|
return _sendRenderEvent.apply(this, arguments);
|
|
@@ -1933,6 +1943,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
|
1933
1943
|
this._performanceData = [];
|
|
1934
1944
|
this._isInitComponent = false;
|
|
1935
1945
|
this.app = null;
|
|
1946
|
+
this._hasRenderComponent = false;
|
|
1936
1947
|
if (immediately) this.cleanElement();else {
|
|
1937
1948
|
setTimeout(function () {
|
|
1938
1949
|
_this10.cleanElement();
|
|
@@ -2019,6 +2030,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
|
2019
2030
|
form.submit();
|
|
2020
2031
|
}, 0);
|
|
2021
2032
|
}
|
|
2033
|
+
}, {
|
|
2034
|
+
key: "shouldValidateFields",
|
|
2035
|
+
value: function shouldValidateFields() {
|
|
2036
|
+
return this._hasRenderComponent;
|
|
2037
|
+
}
|
|
2022
2038
|
}]);
|
|
2023
2039
|
return ComponentApp;
|
|
2024
2040
|
}();
|
|
@@ -82,7 +82,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
|
82
82
|
}
|
|
83
83
|
return Promise.resolve(paypalPluginProps);
|
|
84
84
|
});
|
|
85
|
-
// 加载paypal资源
|
|
85
|
+
// 加载paypal资源 TODO
|
|
86
86
|
_defineProperty(_assertThisInitialized(_this), "loadPaypalResource", function (paypalPluginProps) {
|
|
87
87
|
return new Promise(function (resolve, reject) {
|
|
88
88
|
var _paypalPluginProps$ap;
|
|
@@ -265,6 +265,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
|
265
265
|
return _ref6.apply(this, arguments);
|
|
266
266
|
};
|
|
267
267
|
}());
|
|
268
|
+
// TODO
|
|
268
269
|
_defineProperty(_assertThisInitialized(_this), "destroyComponent", /*#__PURE__*/function () {
|
|
269
270
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(context, message) {
|
|
270
271
|
var data;
|
|
@@ -373,7 +374,9 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
|
373
374
|
}
|
|
374
375
|
}, {
|
|
375
376
|
key: "onMessage",
|
|
376
|
-
value:
|
|
377
|
+
value:
|
|
378
|
+
// TODO
|
|
379
|
+
function onMessage(context, message) {
|
|
377
380
|
switch (message.getAction()) {
|
|
378
381
|
case PaypalActionEnum.mountComponent:
|
|
379
382
|
this.renderPaypalButton(context, message);
|
package/esm/types/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { IApplePayContactField } from '../plugin/applepay/interface';
|
|
9
9
|
export type onChange = () => onCnageResult;
|
|
10
|
-
export { ElementType, PaymentElementLayout, ThemeType
|
|
10
|
+
export { type IElementOptions, ElementType, PaymentElementLayout, ThemeType } from '../core/component/element/type';
|
|
11
11
|
interface onCnageResult {
|
|
12
12
|
complete: boolean;
|
|
13
13
|
addressValue: AddressItem[];
|
|
@@ -40,6 +40,9 @@ export interface IoptionsParams {
|
|
|
40
40
|
mode?: string;
|
|
41
41
|
securityRegion?: 'US' | 'SG' | 'DE';
|
|
42
42
|
}
|
|
43
|
+
export interface ValidationResult {
|
|
44
|
+
isValid: boolean;
|
|
45
|
+
}
|
|
43
46
|
export interface IPreloadOptions {
|
|
44
47
|
environment?: string;
|
|
45
48
|
securityRegion?: 'US' | 'SG' | 'DE';
|
|
@@ -591,6 +594,10 @@ export interface CashierSdkActionQueryResult {
|
|
|
591
594
|
channelOrderId?: string;
|
|
592
595
|
};
|
|
593
596
|
errorActions?: Record<string, string>;
|
|
597
|
+
orderAmountView?: IAmountView;
|
|
598
|
+
paymentAmountView?: IAmountView;
|
|
599
|
+
paymentMethods?: IPaymentMethod[];
|
|
600
|
+
savedPaymentMethods?: IPaymentMethod[];
|
|
594
601
|
}
|
|
595
602
|
export interface CashierSdkActionQuerySessionResult extends IPaymentSessionMetaData {
|
|
596
603
|
success: boolean;
|
|
@@ -829,3 +836,8 @@ export declare enum EventLoggingEventId {
|
|
|
829
836
|
LeaveAnyWay = "LeaveAnyWay",
|
|
830
837
|
ContinuePaying = "ContinuePaying"
|
|
831
838
|
}
|
|
839
|
+
export interface ErrorMessage {
|
|
840
|
+
code: string;
|
|
841
|
+
message: string;
|
|
842
|
+
[key: string]: ErrorMessage | string;
|
|
843
|
+
}
|
package/esm/types/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
10
10
|
|
|
11
|
-
export { ElementType, PaymentElementLayout, ThemeType } from "../core/component/
|
|
11
|
+
export { ElementType, PaymentElementLayout, ThemeType } from "../core/component/element/type";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* SDK options
|
package/esm/util/spm-map.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export declare const ELEMENT_SPM_MAP: {
|
|
|
7
7
|
auto_apple_pay_start: string;
|
|
8
8
|
auto_apple_pay_failed: string;
|
|
9
9
|
auto_apple_pay_success: string;
|
|
10
|
+
sdk_element_handleHeartBeat: string;
|
|
11
|
+
sdk_element_handleInterAction: string;
|
|
12
|
+
sdk_element_callback_error: string;
|
|
13
|
+
sdk_element_missKeyData: string;
|
|
10
14
|
};
|
|
11
15
|
export declare const SPM_MAP: {
|
|
12
16
|
sdk_event_mount_element: string;
|
|
@@ -17,6 +21,10 @@ export declare const SPM_MAP: {
|
|
|
17
21
|
auto_apple_pay_start: string;
|
|
18
22
|
auto_apple_pay_failed: string;
|
|
19
23
|
auto_apple_pay_success: string;
|
|
24
|
+
sdk_element_handleHeartBeat: string;
|
|
25
|
+
sdk_element_handleInterAction: string;
|
|
26
|
+
sdk_element_callback_error: string;
|
|
27
|
+
sdk_element_missKeyData: string;
|
|
20
28
|
sdk_error_runtime_error: string;
|
|
21
29
|
sdk_event_sdkQuery_failed: string;
|
|
22
30
|
container_error_error_insert_js: string;
|
package/esm/util/spm-map.js
CHANGED
|
@@ -14,7 +14,11 @@ export var ELEMENT_SPM_MAP = {
|
|
|
14
14
|
multiple_instance_error: 'a3753.b101271.c403950',
|
|
15
15
|
auto_apple_pay_start: 'a3753.b107385.c398110',
|
|
16
16
|
auto_apple_pay_failed: 'a3753.b107385.c398111',
|
|
17
|
-
auto_apple_pay_success: 'a3753.b107385.c398112'
|
|
17
|
+
auto_apple_pay_success: 'a3753.b107385.c398112',
|
|
18
|
+
sdk_element_handleHeartBeat: 'a3753.b101271.c388217.d624449',
|
|
19
|
+
sdk_element_handleInterAction: 'a3753.b101271.c388217.d630402',
|
|
20
|
+
sdk_element_callback_error: 'a3753.b101271.c388217.d630403',
|
|
21
|
+
sdk_element_missKeyData: 'a3753.b101271.c388217.d630404'
|
|
18
22
|
};
|
|
19
23
|
export var SPM_MAP = _objectSpread({
|
|
20
24
|
sdk_error_runtime_error: 'a3753.b101271.c388188.d512342',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alipay/ams-checkout",
|
|
3
|
-
"version": "0.0.1757298389-dev.
|
|
3
|
+
"version": "0.0.1757298389-dev.21",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "esm/index.js",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "father build",
|
|
18
18
|
"build:w": "father dev",
|
|
19
|
-
"ci": "
|
|
20
|
-
"cov": "jest --coverage",
|
|
19
|
+
"ci": "tnpm run cov",
|
|
20
|
+
"cov": "jest --coverage --silent",
|
|
21
21
|
"dev": "father dev",
|
|
22
22
|
"format": "prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"",
|
|
23
23
|
"lint": "eslint ./src",
|
|
24
|
-
"test": "jest --silent",
|
|
24
|
+
"test": "jest --coverage --silent",
|
|
25
25
|
"tsc": "tsc --noEmit"
|
|
26
26
|
},
|
|
27
27
|
"commitlint": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"uuid": "^9.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
+
"@ali/ci": "^4.72.0",
|
|
50
51
|
"@babel/core": "^7.20.7",
|
|
51
52
|
"@babel/preset-env": "^7.20.2",
|
|
52
53
|
"@commitlint/cli": "^17.3.0",
|
|
@@ -55,13 +56,13 @@
|
|
|
55
56
|
"@testing-library/react": "^9.5.0",
|
|
56
57
|
"@types/jest": "^29.2.4",
|
|
57
58
|
"@types/uuid": "^9.0.0",
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "
|
|
59
|
-
"@typescript-eslint/parser": "^
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
60
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
60
61
|
"babel-jest": "^29.3.1",
|
|
61
62
|
"babel-loader": "^9.1.0",
|
|
62
63
|
"babel-plugin-import": "^1.13.0",
|
|
63
|
-
"eslint": "^8.
|
|
64
|
-
"eslint-plugin-prettier": "
|
|
64
|
+
"eslint": "^8.56.0",
|
|
65
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
65
66
|
"father": "^4.2.3",
|
|
66
67
|
"jest": "^29.5.0",
|
|
67
68
|
"jest-environment-jsdom": "^29.3.1",
|
|
@@ -77,5 +78,9 @@
|
|
|
77
78
|
},
|
|
78
79
|
"publishConfig": {
|
|
79
80
|
"access": "public"
|
|
81
|
+
},
|
|
82
|
+
"ci": {
|
|
83
|
+
"resourceClass": "L",
|
|
84
|
+
"type": "aci"
|
|
80
85
|
}
|
|
81
86
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AddressMountComponentsParams } from '../type';
|
|
2
|
-
interface ElementAddressMountOptions extends Omit<AddressMountComponentsParams, 'type'> {
|
|
3
|
-
selector: string;
|
|
4
|
-
}
|
|
5
|
-
export declare class ElementAddressComponent {
|
|
6
|
-
private sdk;
|
|
7
|
-
private elementContainer;
|
|
8
|
-
private isConnect;
|
|
9
|
-
constructor();
|
|
10
|
-
create(options: {
|
|
11
|
-
environment: string;
|
|
12
|
-
locale: string;
|
|
13
|
-
appVersion: string;
|
|
14
|
-
}, isConnect: boolean): void;
|
|
15
|
-
mount(options: ElementAddressMountOptions): Promise<HTMLIFrameElement | undefined>;
|
|
16
|
-
update(): void;
|
|
17
|
-
unmount(): void;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1,68 +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 _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; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
-
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); }
|
|
8
|
-
import { AddressComponent } from "../../address";
|
|
9
|
-
export var ElementAddressComponent = /*#__PURE__*/function () {
|
|
10
|
-
function ElementAddressComponent() {
|
|
11
|
-
_classCallCheck(this, ElementAddressComponent);
|
|
12
|
-
_defineProperty(this, "sdk", void 0);
|
|
13
|
-
_defineProperty(this, "elementContainer", void 0);
|
|
14
|
-
_defineProperty(this, "isConnect", void 0);
|
|
15
|
-
}
|
|
16
|
-
_createClass(ElementAddressComponent, [{
|
|
17
|
-
key: "create",
|
|
18
|
-
value: function create(options, isConnect) {
|
|
19
|
-
this.isConnect = isConnect;
|
|
20
|
-
this.sdk = new AddressComponent(options);
|
|
21
|
-
}
|
|
22
|
-
}, {
|
|
23
|
-
key: "mount",
|
|
24
|
-
value: function mount(options) {
|
|
25
|
-
var _this = this;
|
|
26
|
-
var elementContainer = document.querySelector(options.selector);
|
|
27
|
-
if (this.isConnect) {
|
|
28
|
-
elementContainer.style.display = 'none';
|
|
29
|
-
}
|
|
30
|
-
return new Promise(function (resolve) {
|
|
31
|
-
_this.sdk.mountComponent({
|
|
32
|
-
sessionData: options.sessionData,
|
|
33
|
-
elementProps: options.elementProps,
|
|
34
|
-
configParams: options.configParams,
|
|
35
|
-
appearance: options.appearance,
|
|
36
|
-
prefillValue: options.prefillValue,
|
|
37
|
-
appendAliasContainerId: true
|
|
38
|
-
}, options.selector).then(function () {
|
|
39
|
-
var _elementContainer$get;
|
|
40
|
-
_this.elementContainer = elementContainer;
|
|
41
|
-
var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
|
|
42
|
-
resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
|
|
43
|
-
}, function () {
|
|
44
|
-
resolve(undefined);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}, {
|
|
49
|
-
key: "update",
|
|
50
|
-
value: function update() {
|
|
51
|
-
if (this.elementContainer && this.isConnect) {
|
|
52
|
-
this.elementContainer.style.display = '';
|
|
53
|
-
}
|
|
54
|
-
// 下发数据
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "unmount",
|
|
58
|
-
value: function unmount() {
|
|
59
|
-
var _this$elementContaine, _this$elementContaine2;
|
|
60
|
-
var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
|
|
61
|
-
if (containers !== null && containers !== void 0 && containers[0]) {
|
|
62
|
-
var _containers$, _containers$$remove;
|
|
63
|
-
(_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}]);
|
|
67
|
-
return ElementAddressComponent;
|
|
68
|
-
}();
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { LinkAuthMountOptions } from '../type';
|
|
2
|
-
interface ElementAuthMountOptions extends Omit<LinkAuthMountOptions, 'type' | 'elementProps'> {
|
|
3
|
-
selector: string;
|
|
4
|
-
url: string;
|
|
5
|
-
}
|
|
6
|
-
export declare class ElementAuthComponent {
|
|
7
|
-
private elementContainer;
|
|
8
|
-
constructor();
|
|
9
|
-
create(options: {
|
|
10
|
-
environment: string;
|
|
11
|
-
locale: string;
|
|
12
|
-
}): void;
|
|
13
|
-
mount(options: ElementAuthMountOptions): Promise<HTMLIFrameElement | undefined>;
|
|
14
|
-
update(height?: number): void;
|
|
15
|
-
unmount(): void;
|
|
16
|
-
}
|
|
17
|
-
export {};
|