@alipay/ams-checkout 1.37.0 → 1.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/popupWindow.style.d.ts +4 -1
- package/esm/component/popupWindow.style.js +33 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +22 -2
- package/esm/constant/index.js +24 -5
- package/esm/core/component/element/elementController/index.d.ts +1 -1
- package/esm/core/component/element/elementController/index.js +29 -20
- package/esm/core/component/element/index.d.ts +0 -1
- package/esm/core/component/element/index.js +3 -6
- package/esm/core/component/element/type.d.ts +32 -33
- package/esm/core/component/element/type.js +20 -12
- package/esm/core/component/element/util.d.ts +9 -6
- package/esm/core/component/element/util.js +28 -29
- package/esm/core/component/oldElement/type.d.ts +3 -0
- package/esm/core/instance/index.js +1 -1
- package/esm/foundation/service/container/index.d.ts +2 -0
- package/esm/foundation/service/container/index.js +46 -23
- package/esm/foundation/service/container/popup.d.ts +9 -6
- package/esm/foundation/service/container/popup.js +3 -1
- package/esm/foundation/utils/redirect_utils.js +34 -18
- package/esm/plugin/component/index.js +1 -1
- package/esm/types/index.d.ts +11 -1
- package/esm/types/index.js +2 -1
- package/esm/util/redirect.js +1 -1
- package/package.json +25 -3
@@ -2,10 +2,13 @@ export declare const createCustomSheet: (curTheme?: 'dark' | 'light') => void;
|
|
2
2
|
export declare const renderPopupLoading: (container: HTMLDivElement, curTheme: 'dark' | 'light') => void;
|
3
3
|
export declare const removePopupLoading: (isShowMockup?: boolean) => void;
|
4
4
|
export declare const insertStyleSheet: () => void;
|
5
|
-
export declare
|
5
|
+
export declare function createCloseIcon(onClose: () => void): HTMLDivElement;
|
6
|
+
export declare const createModal: ({ device, url, widthPadding, loadingConfig, showCloseOnLoading, onCloseOnLoading }: {
|
6
7
|
device: any;
|
7
8
|
url: any;
|
8
9
|
widthPadding: any;
|
9
10
|
loadingConfig: any;
|
11
|
+
showCloseOnLoading: any;
|
12
|
+
onCloseOnLoading: any;
|
10
13
|
}) => Promise<HTMLIFrameElement>;
|
11
14
|
export declare const destroyModal: () => void;
|
@@ -47,6 +47,27 @@ export var insertStyleSheet = function insertStyleSheet() {
|
|
47
47
|
style.innerHTML = modalStyles;
|
48
48
|
document.head.appendChild(style);
|
49
49
|
};
|
50
|
+
export function createCloseIcon(onClose) {
|
51
|
+
var closeIcon = document.createElement('div');
|
52
|
+
closeIcon.style.position = 'absolute';
|
53
|
+
closeIcon.style.right = '16px';
|
54
|
+
closeIcon.style.top = '23px';
|
55
|
+
closeIcon.style.cursor = 'pointer';
|
56
|
+
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
57
|
+
svg.setAttribute('width', '16');
|
58
|
+
svg.setAttribute('height', '16');
|
59
|
+
svg.setAttribute('viewBox', '0 0 16 16');
|
60
|
+
svg.setAttribute('fill', 'none');
|
61
|
+
var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
62
|
+
path.setAttribute('fill-rule', 'evenodd');
|
63
|
+
path.setAttribute('clip-rule', 'evenodd');
|
64
|
+
path.setAttribute('d', 'M13.0449 2.99894L12.9494 2.91165L12.8685 2.85222L12.7802 2.7996C12.3611 2.57499 11.8556 2.64328 11.5228 2.9763L7.99909 6.50088L4.48854 2.99028L4.44701 2.95034C4.0098 2.57169 3.38048 2.57202 2.99838 2.9525L2.92363 3.03297L2.85175 3.12897L2.79916 3.21735C2.57471 3.63642 2.64292 4.14198 2.9757 4.47491L6.50186 8.00046L2.95226 11.5518C2.57141 11.9917 2.57173 12.6211 2.95197 13.0033L3.0324 13.078L3.12837 13.15L3.21674 13.2026C3.63573 13.4272 4.14123 13.3589 4.47407 13.0259L7.99909 9.49935L11.5474 13.0494C11.9944 13.4368 12.6238 13.4235 13.0212 13.0259L13.0922 12.9471L13.1559 12.8595C13.4298 12.4403 13.3789 11.8852 13.0211 11.5272L9.497 8.00115L13.0052 4.4915L13.07 4.4225C13.4304 4.00477 13.4199 3.37582 13.0449 2.99894Z');
|
65
|
+
path.setAttribute('fill', '#ABB9CC');
|
66
|
+
svg.appendChild(path);
|
67
|
+
closeIcon.appendChild(svg);
|
68
|
+
closeIcon.onclick = onClose;
|
69
|
+
return closeIcon;
|
70
|
+
}
|
50
71
|
var modalDevice = 'desktop';
|
51
72
|
// 插入弹窗
|
52
73
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
@@ -54,7 +75,9 @@ export var createModal = function createModal(_ref) {
|
|
54
75
|
var device = _ref.device,
|
55
76
|
url = _ref.url,
|
56
77
|
widthPadding = _ref.widthPadding,
|
57
|
-
loadingConfig = _ref.loadingConfig
|
78
|
+
loadingConfig = _ref.loadingConfig,
|
79
|
+
showCloseOnLoading = _ref.showCloseOnLoading,
|
80
|
+
onCloseOnLoading = _ref.onCloseOnLoading;
|
58
81
|
return new Promise(function (resolve, reject) {
|
59
82
|
try {
|
60
83
|
modalDevice = device;
|
@@ -87,6 +110,15 @@ export var createModal = function createModal(_ref) {
|
|
87
110
|
modal.style.backgroundColor = backgroundPrimary;
|
88
111
|
iframe.style.backgroundColor = backgroundPrimary;
|
89
112
|
}
|
113
|
+
|
114
|
+
// 弹窗渲染loading时关闭按钮逻辑
|
115
|
+
if (showCloseOnLoading) {
|
116
|
+
var closeIcon = createCloseIcon(onCloseOnLoading);
|
117
|
+
modal.appendChild(closeIcon);
|
118
|
+
iframe.addEventListener('load', function () {
|
119
|
+
modal.removeChild(closeIcon);
|
120
|
+
});
|
121
|
+
}
|
90
122
|
modal.appendChild(iframe);
|
91
123
|
var body = document.getElementsByTagName('body')[0];
|
92
124
|
body.appendChild(overlay);
|
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.39.0";
|
9
|
+
export declare const AMSAutoDebitAppVersion = "1.39.0";
|
10
|
+
export declare const AMSEasyPayAppVersion = "1.39.0";
|
11
|
+
export declare const AMSCashierPaymentAppVersion = "1.39.0";
|
12
|
+
export declare const AMSVaultingAppVersion = "1.39.0";
|
13
|
+
export declare const AMSPaymentElementAppVersion = "1.39.0";
|
14
|
+
export declare const ADDRESSElementAppVersion = "1.39.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.39.0'; // 兜底版本号
|
39
|
+
export var AMSAutoDebitAppVersion = '1.39.0'; // 代扣
|
40
|
+
export var AMSEasyPayAppVersion = '1.39.0'; // easypay
|
41
|
+
export var AMSCashierPaymentAppVersion = '1.39.0'; // 收银台(卡、apm)
|
42
|
+
export var AMSVaultingAppVersion = '1.39.0'; // 绑卡
|
43
|
+
export var AMSPaymentElementAppVersion = '1.39.0'; // payment element
|
44
|
+
export var ADDRESSElementAppVersion = '1.39.0'; // address element
|
package/esm/constant/index.d.ts
CHANGED
@@ -67,9 +67,9 @@ export declare const ERRORMESSAGE: {
|
|
67
67
|
message: string;
|
68
68
|
};
|
69
69
|
};
|
70
|
-
|
70
|
+
SDK_LAUNCH_PAYMENT_APP_ERROR: {
|
71
71
|
code: eventCodeEnum;
|
72
|
-
|
72
|
+
CALL_APP_URL_ERROR: {
|
73
73
|
code: eventCodeEnum;
|
74
74
|
message: string;
|
75
75
|
};
|
@@ -78,6 +78,16 @@ export declare const ERRORMESSAGE: {
|
|
78
78
|
code: eventCodeEnum;
|
79
79
|
message: string;
|
80
80
|
};
|
81
|
+
/**
|
82
|
+
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
83
|
+
*/
|
84
|
+
SDK_CALL_URL_ERROR: {
|
85
|
+
code: eventCodeEnum;
|
86
|
+
REDIRECT_ERROR: {
|
87
|
+
code: eventCodeEnum;
|
88
|
+
message: string;
|
89
|
+
};
|
90
|
+
};
|
81
91
|
};
|
82
92
|
export declare const BASEPLUGINID = "CHECKOUT";
|
83
93
|
export declare const COMPONENTPLUGINID = "COMPONENT";
|
@@ -165,6 +175,9 @@ export declare const EVENT: {
|
|
165
175
|
getGlobalData: {
|
166
176
|
name: string;
|
167
177
|
};
|
178
|
+
/**
|
179
|
+
* @deprecated 已废弃 请使用eventCallback
|
180
|
+
*/
|
168
181
|
sendMuitiAppEventToSdk: {
|
169
182
|
name: string;
|
170
183
|
};
|
@@ -225,6 +238,13 @@ export declare const EVENT: {
|
|
225
238
|
inputFocus: {
|
226
239
|
name: string;
|
227
240
|
};
|
241
|
+
/**
|
242
|
+
* 通过SDK转发web应用消息给其他web应用(用于iframe之间消息互通)
|
243
|
+
* TODO 推荐使用BusManager
|
244
|
+
*/
|
245
|
+
messageForward: {
|
246
|
+
name: string;
|
247
|
+
};
|
228
248
|
};
|
229
249
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
230
250
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
package/esm/constant/index.js
CHANGED
@@ -67,16 +67,26 @@ export var ERRORMESSAGE = {
|
|
67
67
|
message: 'Load resource timeout'
|
68
68
|
}
|
69
69
|
},
|
70
|
+
SDK_LAUNCH_PAYMENT_APP_ERROR: {
|
71
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
72
|
+
CALL_APP_URL_ERROR: {
|
73
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
74
|
+
message: 'Failed to launch app'
|
75
|
+
}
|
76
|
+
},
|
77
|
+
SDK_SUBMIT_ERROR: {
|
78
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
79
|
+
message: 'Component not created or current browser compatibility issue, not supported'
|
80
|
+
},
|
81
|
+
/**
|
82
|
+
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
83
|
+
*/
|
70
84
|
SDK_CALL_URL_ERROR: {
|
71
85
|
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
72
86
|
REDIRECT_ERROR: {
|
73
87
|
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
74
88
|
message: 'Redirect data exception'
|
75
89
|
}
|
76
|
-
},
|
77
|
-
SDK_SUBMIT_ERROR: {
|
78
|
-
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
79
|
-
message: 'Component not created or current browser compatibility issue, not supported'
|
80
90
|
}
|
81
91
|
};
|
82
92
|
export var BASEPLUGINID = 'CHECKOUT';
|
@@ -166,7 +176,9 @@ export var EVENT = {
|
|
166
176
|
getGlobalData: {
|
167
177
|
name: 'getGlobalData'
|
168
178
|
},
|
169
|
-
|
179
|
+
/**
|
180
|
+
* @deprecated 已废弃 请使用eventCallback
|
181
|
+
*/
|
170
182
|
sendMuitiAppEventToSdk: {
|
171
183
|
name: 'sendMuitiAppEventToSdk'
|
172
184
|
},
|
@@ -227,6 +239,13 @@ export var EVENT = {
|
|
227
239
|
},
|
228
240
|
inputFocus: {
|
229
241
|
name: 'onInputFocus'
|
242
|
+
},
|
243
|
+
/**
|
244
|
+
* 通过SDK转发web应用消息给其他web应用(用于iframe之间消息互通)
|
245
|
+
* TODO 推荐使用BusManager
|
246
|
+
*/
|
247
|
+
messageForward: {
|
248
|
+
name: 'onMessageForward'
|
230
249
|
}
|
231
250
|
};
|
232
251
|
export var COMPONENT_CONTAINER_ID = 'ams-component-container';
|
@@ -12,7 +12,7 @@ declare class ElementController {
|
|
12
12
|
private initService;
|
13
13
|
private initElementProcessors;
|
14
14
|
private onEventCallback;
|
15
|
-
mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string
|
15
|
+
mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string): any;
|
16
16
|
private onValidateFunc;
|
17
17
|
submitPayment(): void;
|
18
18
|
private changeLoading;
|
@@ -20,19 +20,19 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
20
20
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
21
21
|
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); }
|
22
22
|
import { cleanMockup, removeRetentionPopup } from "../../../../component/component.popup.style";
|
23
|
-
import {
|
23
|
+
import { destroyModal } from "../../../../component/popupWindow.style";
|
24
|
+
import { ERRORMESSAGE, EVENT } from "../../../../constant";
|
24
25
|
import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
|
25
26
|
import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
|
26
27
|
import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
|
27
28
|
import { IElementStatus } from "../../../../foundation";
|
28
29
|
import { AntomSDKCore } from "../../../../foundation/core";
|
29
|
-
import { destroyModal } from "../../../../component/popupWindow.style";
|
30
30
|
import { ElementProcessor } from "../../../../foundation/product-processor/element";
|
31
31
|
import { ProductSceneEnum } from "../../../../types";
|
32
32
|
import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
|
33
33
|
import { IContainerStatus } from "../elementContainerService/containerService";
|
34
34
|
import { oneAccountUpdate, sdkActionUpdate } from "../mock";
|
35
|
-
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode } from "../type";
|
35
|
+
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, MountElementType } from "../type";
|
36
36
|
import { checkCanMount, checkCanUpdate, handleRedirect, showToast } from "../util";
|
37
37
|
var TIMEOUT_DURATION = 10000;
|
38
38
|
var ElementController = /*#__PURE__*/function () {
|
@@ -100,15 +100,19 @@ var ElementController = /*#__PURE__*/function () {
|
|
100
100
|
value: function onEventCallback(_ref) {
|
101
101
|
var _this$options, _this$options$onEvent;
|
102
102
|
var code = _ref.code,
|
103
|
-
message = _ref.message
|
103
|
+
_ref$message = _ref.message,
|
104
|
+
message = _ref$message === void 0 ? '' : _ref$message,
|
105
|
+
_ref$result = _ref.result,
|
106
|
+
result = _ref$result === void 0 ? undefined : _ref$result;
|
104
107
|
this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 || (_this$options$onEvent = _this$options.onEventCallback) === null || _this$options$onEvent === void 0 || _this$options$onEvent.call(_this$options, {
|
105
108
|
code: code,
|
106
|
-
message: message
|
109
|
+
message: message,
|
110
|
+
result: result
|
107
111
|
});
|
108
112
|
}
|
109
113
|
}, {
|
110
114
|
key: "mount",
|
111
|
-
value: function mount(renderOptions, sdkSelector
|
115
|
+
value: function mount(renderOptions, sdkSelector) {
|
112
116
|
var _this = this;
|
113
117
|
return new Promise(function (resolve) {
|
114
118
|
var _checkCanMount = checkCanMount({
|
@@ -135,6 +139,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
135
139
|
_this.initTimeout = null;
|
136
140
|
_this.changeLoading(false);
|
137
141
|
_this.setControllerStatusOrView(IElementStatus.READY);
|
142
|
+
_this.onEventCallback(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CALL_APP_URL_ERROR);
|
138
143
|
_this.elementContainerService.getContainerServices().forEach(function (value) {
|
139
144
|
value.getContainerElement().remove();
|
140
145
|
});
|
@@ -147,15 +152,14 @@ var ElementController = /*#__PURE__*/function () {
|
|
147
152
|
appendAliasContainerId: true
|
148
153
|
})
|
149
154
|
};
|
150
|
-
if (cashier && renderOptions.sessionData) {
|
151
|
-
startBizFlowData.paymentSession = renderOptions.sessionData;
|
152
|
-
}
|
153
155
|
_this.setControllerStatusOrView(IElementStatus.IN_BIZ_FLOW);
|
154
156
|
_this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
|
155
157
|
_this.onEventCallback({
|
156
158
|
code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
|
157
159
|
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
158
160
|
});
|
161
|
+
clearTimeout(_this.initTimeout);
|
162
|
+
_this.initTimeout = null;
|
159
163
|
_this.changeLoading(false);
|
160
164
|
return;
|
161
165
|
});
|
@@ -278,11 +282,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
278
282
|
key: "addEventListener",
|
279
283
|
value: function addEventListener(renderCallback) {
|
280
284
|
var _this4 = this;
|
281
|
-
this.serviceMap.EventCenter.listen(ElementPaymentEvent.
|
282
|
-
|
283
|
-
|
284
|
-
(_this4$elementProcess = (_this4$elementProcess2 = _this4.elementProcessors[data.source].eventListener)[data.event]) === null || _this4$elementProcess === void 0 || _this4$elementProcess.call(_this4$elementProcess2, data.data);
|
285
|
-
}
|
285
|
+
this.serviceMap.EventCenter.listen(ElementPaymentEvent.ON_EVENT_CALLBACK, function (data) {
|
286
|
+
var _this4$onEventCallbac;
|
287
|
+
(_this4$onEventCallbac = _this4.onEventCallback) === null || _this4$onEventCallbac === void 0 || _this4$onEventCallbac.call(_this4, data);
|
286
288
|
});
|
287
289
|
this.serviceMap.EventCenter.listen(EVENT.sizeChanged.name, function (data) {
|
288
290
|
clearTimeout(_this4.initTimeout);
|
@@ -303,7 +305,8 @@ var ElementController = /*#__PURE__*/function () {
|
|
303
305
|
// }
|
304
306
|
});
|
305
307
|
this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
|
306
|
-
|
308
|
+
var onEventCallback = _this4.onEventCallback.bind(_this4);
|
309
|
+
handleRedirect(data, false, onEventCallback);
|
307
310
|
});
|
308
311
|
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
309
312
|
_this4.setControllerStatusOrView(IElementStatus.READY);
|
@@ -322,9 +325,15 @@ var ElementController = /*#__PURE__*/function () {
|
|
322
325
|
this.serviceMap.EventCenter.listen(EVENT.showToast.name, function (data) {
|
323
326
|
showToast(data);
|
324
327
|
});
|
325
|
-
this.serviceMap.EventCenter.listen(
|
326
|
-
var
|
327
|
-
|
328
|
+
this.serviceMap.EventCenter.listen(EVENT.messageForward.name, function (data) {
|
329
|
+
var source = MountElementType[data.source];
|
330
|
+
var target = MountElementType[data.target];
|
331
|
+
if (_this4.elementProcessors[source] && _this4.elementProcessors[target]) {
|
332
|
+
_this4.elementProcessors[target].eventCenter.dispatchToApp({
|
333
|
+
event: data.event,
|
334
|
+
data: data
|
335
|
+
});
|
336
|
+
}
|
328
337
|
});
|
329
338
|
}
|
330
339
|
}, {
|
@@ -361,11 +370,11 @@ var ElementController = /*#__PURE__*/function () {
|
|
361
370
|
var paymentSessionObj = paymentContext.paymentSessionObj;
|
362
371
|
var isConnect = paymentSessionObj.connectFactor.enableConnect && ((_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
|
363
372
|
if (!(paymentResult !== null && paymentResult !== void 0 && (_paymentResult$origin = paymentResult.originActionQueryResult) !== null && _paymentResult$origin !== void 0 && _paymentResult$origin.success) && isConnect) {
|
364
|
-
var _this$
|
373
|
+
var _this$onEventCallback;
|
365
374
|
clearTimeout(this.initTimeout);
|
366
375
|
this.changeLoading(false);
|
367
376
|
this.initTimeout = null;
|
368
|
-
(_this$
|
377
|
+
(_this$onEventCallback = this.onEventCallback) === null || _this$onEventCallback === void 0 || _this$onEventCallback.call(this, {
|
369
378
|
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
370
379
|
message: 'Component initialization exception.'
|
371
380
|
});
|
@@ -7,7 +7,6 @@ export declare class ElementComponent {
|
|
7
7
|
mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
|
8
8
|
mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
9
9
|
mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
|
10
|
-
mountCashier(renderOptions: any, sdkSelector: any): any;
|
11
10
|
submitPayment(): void;
|
12
11
|
destroy(): void;
|
13
12
|
}
|
@@ -11,12 +11,14 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
11
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
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 ElementController from "./elementController";
|
14
|
-
import { formatElementOption } from "./util";
|
14
|
+
import { formatElementOption, validateElementOption } from "./util";
|
15
15
|
export var ElementComponent = /*#__PURE__*/function () {
|
16
16
|
function ElementComponent(options) {
|
17
17
|
_classCallCheck(this, ElementComponent);
|
18
18
|
_defineProperty(this, "options", void 0);
|
19
19
|
_defineProperty(this, "controller", void 0);
|
20
|
+
var validate = validateElementOption(options);
|
21
|
+
if (!validate) return;
|
20
22
|
this.options = formatElementOption(options);
|
21
23
|
this.controller = new ElementController(options);
|
22
24
|
}
|
@@ -47,11 +49,6 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
47
49
|
appearance: this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.appearance
|
48
50
|
}, renderOptions), sdkSelector);
|
49
51
|
}
|
50
|
-
}, {
|
51
|
-
key: "mountCashier",
|
52
|
-
value: function mountCashier(renderOptions, sdkSelector) {
|
53
|
-
return this.controller.mount(renderOptions, sdkSelector, true);
|
54
|
-
}
|
55
52
|
}, {
|
56
53
|
key: "submitPayment",
|
57
54
|
value: function submitPayment() {
|
@@ -2,6 +2,9 @@ import { ActionForm, ConnectErrorCode, IAmount, IAmountView, IMerchantAppointPar
|
|
2
2
|
import AddressProcessor from './elementProcessor/addressProcessor';
|
3
3
|
import AuthProcessor from './elementProcessor/authProcessor';
|
4
4
|
import PaymentProcessor from './elementProcessor/paymentProcessor';
|
5
|
+
/**
|
6
|
+
* element 消息事件名
|
7
|
+
*/
|
5
8
|
export declare enum ElementPaymentEvent {
|
6
9
|
RENDER_COMPONENT = "renderComponent",
|
7
10
|
CAPTURE_ASSET = "onCaptureAsset",
|
@@ -13,9 +16,13 @@ export declare enum ElementPaymentEvent {
|
|
13
16
|
SIZE_CHANGE = "onSizeChange",
|
14
17
|
LAUNCH = "onLaunch",
|
15
18
|
CALLBACK = "callback",
|
19
|
+
/**
|
20
|
+
* @deprecated 已废弃 请使用eventCallback
|
21
|
+
*/
|
16
22
|
SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
|
17
23
|
LOG = "log",
|
18
|
-
HANDLE_PAYMENT = "handlePayment"
|
24
|
+
HANDLE_PAYMENT = "handlePayment",
|
25
|
+
ON_EVENT_CALLBACK = "onEventCallback"
|
19
26
|
}
|
20
27
|
export declare enum ElementPaymentMethod {
|
21
28
|
CONTAINER_ELEMENT = "CONTAINER_ELEMENT",
|
@@ -23,6 +30,19 @@ export declare enum ElementPaymentMethod {
|
|
23
30
|
ADDRESS_ELEMENT = "ADDRESS_ELEMENT",
|
24
31
|
PAYMENT_ELEMENT = "PAYMENT_ELEMENT"
|
25
32
|
}
|
33
|
+
export declare enum ElementType {
|
34
|
+
auth = "auth",
|
35
|
+
address = "address",
|
36
|
+
payment = "payment"
|
37
|
+
}
|
38
|
+
export declare const MountElementType: {
|
39
|
+
auth: ElementPaymentMethod;
|
40
|
+
address: ElementPaymentMethod;
|
41
|
+
payment: ElementPaymentMethod;
|
42
|
+
AUTH_ELEMENT: ElementType;
|
43
|
+
ADDRESS_ELEMENT: ElementType;
|
44
|
+
PAYMENT_ELEMENT: ElementType;
|
45
|
+
};
|
26
46
|
export declare enum ThemeType {
|
27
47
|
NostalgicGray = "nostalgicGray",
|
28
48
|
Default = "default",
|
@@ -31,27 +51,22 @@ export declare enum ThemeType {
|
|
31
51
|
GamingPurple = "gamingPurple",
|
32
52
|
AgateGreen = "agateGreen"
|
33
53
|
}
|
34
|
-
export declare enum ElementType {
|
35
|
-
auth = "auth",
|
36
|
-
address = "address",
|
37
|
-
payment = "payment"
|
38
|
-
}
|
39
54
|
export declare enum PaymentElementLayout {
|
40
55
|
Tabs = "tabs",
|
41
56
|
Accordion = "Accordion"
|
42
57
|
}
|
43
|
-
export declare enum MountElementType {
|
44
|
-
auth = "AUTH_ELEMENT",
|
45
|
-
address = "ADDRESS_ELEMENT",
|
46
|
-
payment = "PAYMENT_ELEMENT"
|
47
|
-
}
|
48
58
|
export declare const addressTheme: {
|
49
59
|
default: string;
|
50
60
|
night: string;
|
51
61
|
};
|
52
62
|
export declare enum EventCallbackCode {
|
53
63
|
SDK_CREATE_COMPONENT_ERROR = "SDK_CREATE_COMPONENT_ERROR",
|
54
|
-
SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR"
|
64
|
+
SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR",
|
65
|
+
SDK_PAYMENT_ERROR = "SDK_PAYMENT_ERROR",
|
66
|
+
SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
|
67
|
+
SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL",
|
68
|
+
SDK_PAYMENT_SUCCESSFUL = "SDK_PAYMENT_SUCCESSFUL",
|
69
|
+
SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING"
|
55
70
|
}
|
56
71
|
export declare enum ELEMENT_ENVIRONMENT {
|
57
72
|
DEV = "DEV",
|
@@ -62,23 +77,6 @@ export declare enum ELEMENT_ENVIRONMENT {
|
|
62
77
|
SANDBOX = "SANDBOX"
|
63
78
|
}
|
64
79
|
export type ELEMENT_ENVIRONMENT_TYPE = keyof typeof ELEMENT_ENVIRONMENT | (typeof ELEMENT_ENVIRONMENT)[keyof typeof ELEMENT_ENVIRONMENT];
|
65
|
-
export interface IElementOptions {
|
66
|
-
environment?: ELEMENT_ENVIRONMENT_TYPE;
|
67
|
-
locale?: string;
|
68
|
-
version?: string;
|
69
|
-
appearance?: {
|
70
|
-
theme: ThemeType.Default | ThemeType.Night;
|
71
|
-
};
|
72
|
-
onEventCallback?: ({ code, message, result }: {
|
73
|
-
code: EventCallbackCode;
|
74
|
-
message: string;
|
75
|
-
result?: any;
|
76
|
-
}) => void;
|
77
|
-
loading?: {
|
78
|
-
onStartLoading: () => void;
|
79
|
-
onEndLoading: () => void;
|
80
|
-
};
|
81
|
-
}
|
82
80
|
export interface AddressMountComponentsParams {
|
83
81
|
configParams?: AddressMountConfig;
|
84
82
|
prefillValue: Array<AddressSubmitData>;
|
@@ -95,7 +93,6 @@ export interface AddressMountComponentsParams {
|
|
95
93
|
}
|
96
94
|
interface BaseMountOptions<T = void> {
|
97
95
|
configParams?: T;
|
98
|
-
sessionData: string;
|
99
96
|
debugProps?: {
|
100
97
|
localLink: string;
|
101
98
|
};
|
@@ -178,12 +175,14 @@ export interface LinkAuthMountResult extends BaseMountResult {
|
|
178
175
|
}
|
179
176
|
export interface PaymentMountResult extends BaseMountResult {
|
180
177
|
}
|
181
|
-
|
178
|
+
/**
|
179
|
+
* connect element之间通信的类型格式
|
180
|
+
*/
|
181
|
+
export interface ConnectElementMessageDataType<T = {}> {
|
182
182
|
source?: ElementPaymentMethod;
|
183
183
|
target?: ElementPaymentMethod;
|
184
|
-
success?: boolean;
|
185
184
|
data?: T;
|
186
|
-
event?:
|
185
|
+
event?: ElementPaymentEvent;
|
187
186
|
}
|
188
187
|
export interface ValidateResult<T = {}> {
|
189
188
|
success: boolean;
|
@@ -2,6 +2,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
2
2
|
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; }
|
3
3
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
4
4
|
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); }
|
5
|
+
/**
|
6
|
+
* element 消息事件名
|
7
|
+
*/
|
5
8
|
export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
|
6
9
|
ElementPaymentEvent["RENDER_COMPONENT"] = "renderComponent";
|
7
10
|
ElementPaymentEvent["CAPTURE_ASSET"] = "onCaptureAsset";
|
@@ -16,6 +19,7 @@ export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
|
|
16
19
|
ElementPaymentEvent["SEND_MUITI_APP_EVENT_TO_SDK"] = "sendMuitiAppEventToSdk";
|
17
20
|
ElementPaymentEvent["LOG"] = "log";
|
18
21
|
ElementPaymentEvent["HANDLE_PAYMENT"] = "handlePayment";
|
22
|
+
ElementPaymentEvent["ON_EVENT_CALLBACK"] = "onEventCallback";
|
19
23
|
return ElementPaymentEvent;
|
20
24
|
}({});
|
21
25
|
export var ElementPaymentMethod = /*#__PURE__*/function (ElementPaymentMethod) {
|
@@ -25,6 +29,13 @@ export var ElementPaymentMethod = /*#__PURE__*/function (ElementPaymentMethod) {
|
|
25
29
|
ElementPaymentMethod["PAYMENT_ELEMENT"] = "PAYMENT_ELEMENT";
|
26
30
|
return ElementPaymentMethod;
|
27
31
|
}({});
|
32
|
+
export var ElementType = /*#__PURE__*/function (ElementType) {
|
33
|
+
ElementType["auth"] = "auth";
|
34
|
+
ElementType["address"] = "address";
|
35
|
+
ElementType["payment"] = "payment";
|
36
|
+
return ElementType;
|
37
|
+
}({});
|
38
|
+
export var MountElementType = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ElementType.auth, ElementPaymentMethod.AUTH_ELEMENT), ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT), ElementType.payment, ElementPaymentMethod.PAYMENT_ELEMENT), ElementPaymentMethod.AUTH_ELEMENT, ElementType.auth), ElementPaymentMethod.ADDRESS_ELEMENT, ElementType.address), ElementPaymentMethod.PAYMENT_ELEMENT, ElementType.payment);
|
28
39
|
export var ThemeType = /*#__PURE__*/function (ThemeType) {
|
29
40
|
ThemeType["NostalgicGray"] = "nostalgicGray";
|
30
41
|
ThemeType["Default"] = "default";
|
@@ -34,27 +45,20 @@ export var ThemeType = /*#__PURE__*/function (ThemeType) {
|
|
34
45
|
ThemeType["AgateGreen"] = "agateGreen";
|
35
46
|
return ThemeType;
|
36
47
|
}({});
|
37
|
-
export var ElementType = /*#__PURE__*/function (ElementType) {
|
38
|
-
ElementType["auth"] = "auth";
|
39
|
-
ElementType["address"] = "address";
|
40
|
-
ElementType["payment"] = "payment";
|
41
|
-
return ElementType;
|
42
|
-
}({});
|
43
48
|
export var PaymentElementLayout = /*#__PURE__*/function (PaymentElementLayout) {
|
44
49
|
PaymentElementLayout["Tabs"] = "tabs";
|
45
50
|
PaymentElementLayout["Accordion"] = "Accordion";
|
46
51
|
return PaymentElementLayout;
|
47
52
|
}({});
|
48
|
-
export var MountElementType = /*#__PURE__*/function (MountElementType) {
|
49
|
-
MountElementType["auth"] = "AUTH_ELEMENT";
|
50
|
-
MountElementType["address"] = "ADDRESS_ELEMENT";
|
51
|
-
MountElementType["payment"] = "PAYMENT_ELEMENT";
|
52
|
-
return MountElementType;
|
53
|
-
}({});
|
54
53
|
export var addressTheme = _defineProperty(_defineProperty({}, ThemeType.Default, 'LIGHT'), ThemeType.Night, 'NIGHT');
|
55
54
|
export var EventCallbackCode = /*#__PURE__*/function (EventCallbackCode) {
|
56
55
|
EventCallbackCode["SDK_CREATE_COMPONENT_ERROR"] = "SDK_CREATE_COMPONENT_ERROR";
|
57
56
|
EventCallbackCode["SDK_CREATEPAYMENT_PARAMETER_ERROR"] = "SDK_CREATEPAYMENT_PARAMETER_ERROR";
|
57
|
+
EventCallbackCode["SDK_PAYMENT_ERROR"] = "SDK_PAYMENT_ERROR";
|
58
|
+
EventCallbackCode["SDK_PAYMENT_FAIL"] = "SDK_PAYMENT_FAIL";
|
59
|
+
EventCallbackCode["SDK_PAYMENT_CANCEL"] = "SDK_PAYMENT_CANCEL";
|
60
|
+
EventCallbackCode["SDK_PAYMENT_SUCCESSFUL"] = "SDK_PAYMENT_SUCCESSFUL";
|
61
|
+
EventCallbackCode["SDK_PAYMENT_PROCESSING"] = "SDK_PAYMENT_PROCESSING";
|
58
62
|
return EventCallbackCode;
|
59
63
|
}({});
|
60
64
|
export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
|
@@ -73,6 +77,10 @@ export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbac
|
|
73
77
|
return AddressEventCallbackName;
|
74
78
|
}({});
|
75
79
|
|
80
|
+
/**
|
81
|
+
* connect element之间通信的类型格式
|
82
|
+
*/
|
83
|
+
|
76
84
|
// export type IMountResult = AddressMountResult | LinkAuthMountResult | PaymentMountResult;
|
77
85
|
var AccountStatusEnum = /*#__PURE__*/function (AccountStatusEnum) {
|
78
86
|
AccountStatusEnum["EFFECTIVE"] = "EFFECTIVE";
|
@@ -1,16 +1,17 @@
|
|
1
1
|
import { IElementStatus } from '../../../foundation';
|
2
2
|
import { Ianalytics, IPaymentSessionMetaData } from '../../../types';
|
3
3
|
import { ContainerController } from './elementContainerService/containerService';
|
4
|
-
import { ELEMENT_ENVIRONMENT_TYPE, IElementOptions, IToastOptions } from './type';
|
5
|
-
declare const formatElementOption: (options: IElementOptions) => {
|
4
|
+
import { ELEMENT_ENVIRONMENT_TYPE, IElementOptions, IToastOptions, EventCallbackCode } from './type';
|
5
|
+
export declare const formatElementOption: (options: IElementOptions) => {
|
6
6
|
environment: ELEMENT_ENVIRONMENT_TYPE;
|
7
|
+
sessionData: string;
|
7
8
|
locale?: string;
|
8
9
|
version?: string;
|
9
10
|
appearance?: {
|
10
11
|
theme: import("./type").ThemeType.Default | import("./type").ThemeType.Night;
|
11
12
|
};
|
12
13
|
onEventCallback?: ({ code, message, result }: {
|
13
|
-
code:
|
14
|
+
code: EventCallbackCode;
|
14
15
|
message: string;
|
15
16
|
result?: any;
|
16
17
|
}) => void;
|
@@ -18,8 +19,8 @@ declare const formatElementOption: (options: IElementOptions) => {
|
|
18
19
|
onStartLoading: () => void;
|
19
20
|
onEndLoading: () => void;
|
20
21
|
};
|
21
|
-
sessionData: string;
|
22
22
|
};
|
23
|
+
export declare const validateElementOption: (options: IElementOptions) => boolean;
|
23
24
|
/**
|
24
25
|
* 校验渲染条件
|
25
26
|
* 校验当前sdkSelector结点是否存在
|
@@ -49,7 +50,10 @@ export declare function generateIframeSrc({ paymentSessionObj, paymentSession, i
|
|
49
50
|
appVersion: string;
|
50
51
|
link?: string;
|
51
52
|
}): string;
|
52
|
-
export declare function handleRedirect(data: any, fromFastSdk
|
53
|
+
export declare function handleRedirect(data: any, fromFastSdk: boolean, eventCallback: ({ code, message }: {
|
54
|
+
code: any;
|
55
|
+
message: any;
|
56
|
+
}) => void): void;
|
53
57
|
export declare function redirect(data: {
|
54
58
|
normalUrl?: string;
|
55
59
|
schemeUrl?: string;
|
@@ -63,4 +67,3 @@ export declare const isElementMobile: () => boolean;
|
|
63
67
|
*/
|
64
68
|
export declare const isElementPad: () => boolean;
|
65
69
|
export declare const isElementPC: () => boolean;
|
66
|
-
export { formatElementOption };
|