@alipay/ams-checkout 0.0.1697942541-dev.5 → 0.0.1698315116-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/constant/index.d.ts +0 -10
- package/esm/constant/index.js +0 -10
- package/esm/core/component/index.js +2 -2
- package/esm/plugin/component/index.d.ts +1 -4
- package/esm/plugin/component/index.js +22 -65
- package/esm/types/index.d.ts +5 -26
- package/esm/types/index.js +0 -1
- package/package.json +1 -1
- package/esm/plugin/component/popupWindow.style.d.ts +0 -6
- package/esm/plugin/component/popupWindow.style.js +0 -54
package/esm/constant/index.d.ts
CHANGED
@@ -140,15 +140,6 @@ export declare const EVENT: {
|
|
140
140
|
dismissLoading: {
|
141
141
|
name: string;
|
142
142
|
};
|
143
|
-
popupWindow: {
|
144
|
-
name: string;
|
145
|
-
};
|
146
|
-
closePopup: {
|
147
|
-
name: string;
|
148
|
-
};
|
149
|
-
threedReady: {
|
150
|
-
name: string;
|
151
|
-
};
|
152
143
|
};
|
153
144
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
154
145
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
@@ -160,7 +151,6 @@ export declare const LOADING_ID = "ams-component-loading";
|
|
160
151
|
export declare const LISTENER_PREFIX = "_ams_sdk_component_listener";
|
161
152
|
export declare const INLINE_BASE_STYLE_ID = "ams-inline-component-style";
|
162
153
|
export declare const INLINE_IMG_CLASSNAME = "inline-loading";
|
163
|
-
export declare const AMSPOPUP_PREFIX = "ams-popup";
|
164
154
|
export declare const LOADTIME_LIMIT = 15000;
|
165
155
|
export declare const ANIMATION_TIME = 300;
|
166
156
|
export declare const closeImg = "https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg";
|
package/esm/constant/index.js
CHANGED
@@ -139,15 +139,6 @@ export var EVENT = {
|
|
139
139
|
},
|
140
140
|
dismissLoading: {
|
141
141
|
name: 'dismissLoading'
|
142
|
-
},
|
143
|
-
popupWindow: {
|
144
|
-
name: 'popupWindow'
|
145
|
-
},
|
146
|
-
closePopup: {
|
147
|
-
name: 'closePopup'
|
148
|
-
},
|
149
|
-
threedReady: {
|
150
|
-
name: 'threedReady'
|
151
142
|
}
|
152
143
|
};
|
153
144
|
export var COMPONENT_CONTAINER_ID = 'ams-component-container';
|
@@ -160,7 +151,6 @@ export var LOADING_ID = 'ams-component-loading';
|
|
160
151
|
export var LISTENER_PREFIX = '_ams_sdk_component_listener';
|
161
152
|
export var INLINE_BASE_STYLE_ID = 'ams-inline-component-style';
|
162
153
|
export var INLINE_IMG_CLASSNAME = 'inline-loading';
|
163
|
-
export var AMSPOPUP_PREFIX = 'ams-popup';
|
164
154
|
export var LOADTIME_LIMIT = 15000;
|
165
155
|
export var ANIMATION_TIME = 300;
|
166
156
|
export var closeImg = 'https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg';
|
@@ -72,7 +72,7 @@ var handleParams = function handleParams(params) {
|
|
72
72
|
paymentSessionMetaData: {},
|
73
73
|
renderDisplayType: renderDisplayTypeEnum.popup
|
74
74
|
}, params);
|
75
|
-
var _handleSessionData = handleSessionData(_params.sessionData
|
75
|
+
var _handleSessionData = handleSessionData(_params.sessionData),
|
76
76
|
_handleSessionData2 = _slicedToArray(_handleSessionData, 2),
|
77
77
|
parseData = _handleSessionData2[0],
|
78
78
|
sessionData = _handleSessionData2[1];
|
@@ -119,7 +119,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
119
119
|
selector: selector,
|
120
120
|
renderDisplayType: renderDisplayType
|
121
121
|
}, params);
|
122
|
-
if (_params && !_params.sessionData
|
122
|
+
if (_params && !_params.sessionData) {
|
123
123
|
return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
|
124
124
|
}
|
125
125
|
if (this.options.networkMode === networkModeEnum.proxy) {
|
@@ -9,8 +9,6 @@ export default class ComponentApp {
|
|
9
9
|
_performanceData: any[];
|
10
10
|
_loadAppPromiseResolve: ((value: boolean) => void) | null;
|
11
11
|
_isInitComponent: boolean;
|
12
|
-
private _threedData?;
|
13
|
-
private popupWindow?;
|
14
12
|
private appDomain;
|
15
13
|
private createIframeNode;
|
16
14
|
private _selector;
|
@@ -53,7 +51,6 @@ export default class ComponentApp {
|
|
53
51
|
private createApp;
|
54
52
|
private listener;
|
55
53
|
private resizeListener;
|
56
|
-
private createPopupWindow;
|
57
54
|
/**
|
58
55
|
* @description Initialize subscription iframe message
|
59
56
|
*/
|
@@ -76,7 +73,7 @@ export default class ComponentApp {
|
|
76
73
|
*/
|
77
74
|
dispatchToApp(payload: {
|
78
75
|
context: eventPayloadContext;
|
79
|
-
}
|
76
|
+
}): any;
|
80
77
|
/**
|
81
78
|
* @description Subscribe to messages from SDK
|
82
79
|
*/
|
@@ -16,18 +16,16 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
16
16
|
*/
|
17
17
|
/* eslint-disable no-console */
|
18
18
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
19
|
-
import APDID from '@alipay/jshield-apdid';
|
20
|
-
import { marmotMap } from "../../config/index";
|
21
19
|
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
|
22
20
|
import { queryPaymentInfo } from "../../service";
|
23
21
|
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
|
24
22
|
import { getType, isJsonString, isPC, queryParse } from "../../util";
|
25
23
|
import { isLocalMock } from "../../util/mock";
|
26
|
-
import { getAppname, getSecurityHost } from "../../util/security";
|
27
24
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
28
25
|
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
29
26
|
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
30
|
-
import
|
27
|
+
import APDID from '@alipay/jshield-apdid';
|
28
|
+
import { getSecurityHost, getAppname } from "../../util/security";
|
31
29
|
var _ref = queryParse() || {},
|
32
30
|
preinit = _ref.preinit,
|
33
31
|
rebuild = _ref.rebuild,
|
@@ -43,8 +41,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
43
41
|
_defineProperty(this, "_performanceData", []);
|
44
42
|
_defineProperty(this, "_loadAppPromiseResolve", null);
|
45
43
|
_defineProperty(this, "_isInitComponent", void 0);
|
46
|
-
_defineProperty(this, "_threedData", void 0);
|
47
|
-
_defineProperty(this, "popupWindow", void 0);
|
48
44
|
_defineProperty(this, "appDomain", void 0);
|
49
45
|
_defineProperty(this, "createIframeNode", void 0);
|
50
46
|
_defineProperty(this, "_selector", void 0);
|
@@ -55,7 +51,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
55
51
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
56
52
|
_defineProperty(this, "_clickEventName", void 0);
|
57
53
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
58
|
-
this._appVersion = '1.5.
|
54
|
+
this._appVersion = '1.5.8';
|
59
55
|
this._isInitComponent = false;
|
60
56
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
61
57
|
this.createIframeNode = function () {
|
@@ -117,7 +113,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
117
113
|
APDID.initToken(appName, {
|
118
114
|
host: h5gateway
|
119
115
|
}, function (success, tokenResult, msg) {
|
120
|
-
console.log(
|
116
|
+
console.log("initToken result tokenResult", JSON.stringify(tokenResult));
|
121
117
|
});
|
122
118
|
}
|
123
119
|
|
@@ -149,7 +145,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
149
145
|
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
150
146
|
var container = createInlineBaseElement(this._selector);
|
151
147
|
if (container) this.renderInlineLoading(renderParams, container);
|
152
|
-
insertStyleSheet();
|
153
148
|
}
|
154
149
|
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
155
150
|
createBaseElement(this.platform, this.closeBtnFunc.bind(this));
|
@@ -215,11 +210,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
215
210
|
value: Date.now()
|
216
211
|
});
|
217
212
|
this._actionQueryPromise = new Promise(function (resolve, reject) {
|
218
|
-
var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3
|
213
|
+
var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
|
219
214
|
var params = {
|
220
215
|
paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.sessionData) || '',
|
221
|
-
paymentSessionConfig: (_this3$_renderParams2 = _this3._renderParams) === null || _this3$_renderParams2 === void 0 || (_this3$_renderParams2 = _this3$_renderParams2.paymentSessionMetaData) === null || _this3$_renderParams2 === void 0 ? void 0 : _this3$_renderParams2.paymentSessionConfig
|
222
|
-
notRedirectAfterComplete: ((_this3$_renderParams3 = _this3._renderParams) === null || _this3$_renderParams3 === void 0 ? void 0 : _this3$_renderParams3.notRedirectAfterComplete) === true
|
216
|
+
paymentSessionConfig: (_this3$_renderParams2 = _this3._renderParams) === null || _this3$_renderParams2 === void 0 || (_this3$_renderParams2 = _this3$_renderParams2.paymentSessionMetaData) === null || _this3$_renderParams2 === void 0 ? void 0 : _this3$_renderParams2.paymentSessionConfig
|
223
217
|
};
|
224
218
|
/**
|
225
219
|
* @description card
|
@@ -229,10 +223,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
229
223
|
}
|
230
224
|
var needDeviceId = false;
|
231
225
|
var waitTime = '3000';
|
232
|
-
var securityConfig = (_this3$
|
226
|
+
var securityConfig = (_this3$_renderParams3 = _this3._renderParams) === null || _this3$_renderParams3 === void 0 || (_this3$_renderParams3 = _this3$_renderParams3.paymentSessionMetaData) === null || _this3$_renderParams3 === void 0 ? void 0 : _this3$_renderParams3.securityConfig;
|
233
227
|
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign && securityConfig) {
|
234
|
-
var _this3$
|
235
|
-
var extendInfo = ((_this3$
|
228
|
+
var _this3$_renderParams4;
|
229
|
+
var extendInfo = ((_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 || (_this3$_renderParams4 = _this3$_renderParams4.paymentSessionMetaData) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.extendInfo) || '';
|
236
230
|
var info = JSON.parse(extendInfo);
|
237
231
|
if ((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false') {
|
238
232
|
needDeviceId = true;
|
@@ -244,13 +238,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
244
238
|
* @description easyPay
|
245
239
|
*/
|
246
240
|
if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
|
247
|
-
var _this3$
|
241
|
+
var _this3$_renderParams5;
|
248
242
|
var _ref2 = params.paymentSessionConfig || {},
|
249
243
|
_ref2$productSceneVer = _ref2.productSceneVersion,
|
250
244
|
productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
|
251
245
|
_ref2$productScene = _ref2.productScene,
|
252
246
|
productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
|
253
|
-
var _ref3 = ((_this3$
|
247
|
+
var _ref3 = ((_this3$_renderParams5 = _this3._renderParams) === null || _this3$_renderParams5 === void 0 ? void 0 : _this3$_renderParams5.paymentSessionMetaData) || {},
|
254
248
|
_ref3$action = _ref3.action,
|
255
249
|
_ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
|
256
250
|
_ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
|
@@ -268,8 +262,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
268
262
|
* @description autoDebit
|
269
263
|
*/
|
270
264
|
if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
|
271
|
-
var _this3$
|
272
|
-
var action = ((_this3$
|
265
|
+
var _this3$_renderParams6, _action$web, _action$wap;
|
266
|
+
var action = ((_this3$_renderParams6 = _this3._renderParams) === null || _this3$_renderParams6 === void 0 || (_this3$_renderParams6 = _this3$_renderParams6.paymentSessionMetaData) === null || _this3$_renderParams6 === void 0 ? void 0 : _this3$_renderParams6.action) || {};
|
273
267
|
var 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;
|
274
268
|
if (signType === 'SMS') {
|
275
269
|
return resolve({
|
@@ -307,11 +301,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
307
301
|
resolve(res);
|
308
302
|
}
|
309
303
|
}).catch(function (err) {
|
310
|
-
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
|
311
|
-
return resolve({
|
312
|
-
success: false
|
313
|
-
});
|
314
|
-
}
|
315
304
|
_this3.dispatchToSDK(EVENT.error.name, {
|
316
305
|
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
|
317
306
|
});
|
@@ -411,6 +400,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
411
400
|
if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) {
|
412
401
|
return;
|
413
402
|
}
|
403
|
+
// TODO
|
404
|
+
// 如果带有callback标识,则从map结构中取出callbackfunc,执行,执行后在map结构中删除
|
414
405
|
this._handleAppMessage(data);
|
415
406
|
} else {
|
416
407
|
console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
|
@@ -433,18 +424,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
433
424
|
}
|
434
425
|
});
|
435
426
|
}
|
436
|
-
}, {
|
437
|
-
key: "createPopupWindow",
|
438
|
-
value: function createPopupWindow(data) {
|
439
|
-
var _this$_renderParams2;
|
440
|
-
this._threedData = data;
|
441
|
-
var sessionData = encodeURIComponent((_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.sessionData);
|
442
|
-
var threedPageUrl = "".concat(marmotMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&instanceId=").concat(this.AMSSDK._instanceId);
|
443
|
-
this.popupWindow = createModal({
|
444
|
-
device: this.platform,
|
445
|
-
url: threedPageUrl
|
446
|
-
});
|
447
|
-
}
|
448
427
|
|
449
428
|
/**
|
450
429
|
* @description Initialize subscription iframe message
|
@@ -471,28 +450,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
471
450
|
}, {
|
472
451
|
key: "_handleAppMessage",
|
473
452
|
value: function _handleAppMessage(data) {
|
474
|
-
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name
|
453
|
+
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name];
|
475
454
|
if (!eventKeyMap.includes(data.context.event)) {
|
476
455
|
return;
|
477
456
|
}
|
478
|
-
if (data.context.event === EVENT.closePopup.name) {
|
479
|
-
destroyModal();
|
480
|
-
return;
|
481
|
-
}
|
482
|
-
if (data.context.event === EVENT.threedReady.name) {
|
483
|
-
this.dispatchToApp({
|
484
|
-
context: {
|
485
|
-
event: 'renderThreedPage',
|
486
|
-
data: this._threedData
|
487
|
-
}
|
488
|
-
}, this.popupWindow);
|
489
|
-
return;
|
490
|
-
}
|
491
|
-
if (data.context.event === EVENT.popupWindow.name) {
|
492
|
-
var _data$context;
|
493
|
-
this.createPopupWindow((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
|
494
|
-
return;
|
495
|
-
}
|
496
457
|
if (data.context.event === EVENT.dismissLoading.name) {
|
497
458
|
var _data$context$data;
|
498
459
|
this.dispatchToSDK(EVENT.eventCallback.name, {
|
@@ -683,16 +644,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
683
644
|
}, {
|
684
645
|
key: "dispatchToApp",
|
685
646
|
value: function dispatchToApp(payload) {
|
686
|
-
var element = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
687
647
|
var data = Object.assign({}, payload, {
|
688
648
|
name: messageName.SDK_TO_APP,
|
689
649
|
mode: this.AMSSDK.options.mode,
|
690
650
|
appId: COMPONENTPLUGINID,
|
691
651
|
instanceId: this.AMSSDK._instanceId
|
692
652
|
});
|
693
|
-
|
694
|
-
return element.contentWindow.postMessage(JSON.stringify(data), '*');
|
695
|
-
}
|
653
|
+
// TODO 如果存在回调函数,则增加callBack标识,并存入map。map可以设置
|
696
654
|
if (this.app && this.app.contentWindow) {
|
697
655
|
return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
698
656
|
}
|
@@ -721,7 +679,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
721
679
|
key: "sendRenderEvent",
|
722
680
|
value: function () {
|
723
681
|
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
724
|
-
var _this$
|
682
|
+
var _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, _this$_renderParams5, res;
|
725
683
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
726
684
|
while (1) switch (_context.prev = _context.next) {
|
727
685
|
case 0:
|
@@ -745,12 +703,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
745
703
|
event: 'renderComponent',
|
746
704
|
data: {
|
747
705
|
queryResult: res,
|
748
|
-
sessionResult: (_this$
|
749
|
-
paymentSessionData: (_this$
|
706
|
+
sessionResult: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionMetaData,
|
707
|
+
paymentSessionData: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData,
|
750
708
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
751
|
-
renderDisplayType: (_this$
|
752
|
-
appearance: (_this$
|
753
|
-
notRedirectAfterComplete: ((_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.notRedirectAfterComplete) === true,
|
709
|
+
renderDisplayType: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.renderDisplayType,
|
710
|
+
appearance: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.appearance,
|
754
711
|
envInfo: {
|
755
712
|
screenHeight: screen.height,
|
756
713
|
screenWidth: screen.width
|
package/esm/types/index.d.ts
CHANGED
@@ -58,9 +58,7 @@ export declare enum paymentMethodCategoryTypeEnum {
|
|
58
58
|
}
|
59
59
|
export interface IcreateComponent {
|
60
60
|
sessionData: string;
|
61
|
-
paymentSessionData?: string;
|
62
61
|
appearance?: Record<string, any>;
|
63
|
-
notRedirectAfterComplete?: boolean;
|
64
62
|
}
|
65
63
|
export interface IappendIframeNodesParams extends IcreateComponent {
|
66
64
|
paymentSessionMetaData: IpaymentSessionMetaData;
|
@@ -68,12 +66,12 @@ export interface IappendIframeNodesParams extends IcreateComponent {
|
|
68
66
|
selector?: Iselector;
|
69
67
|
}
|
70
68
|
export interface IbillingAddress {
|
71
|
-
region
|
72
|
-
address1
|
69
|
+
region?: string;
|
70
|
+
address1?: string;
|
73
71
|
address2?: string;
|
74
|
-
city
|
72
|
+
city?: string;
|
75
73
|
state?: string;
|
76
|
-
zipCode
|
74
|
+
zipCode?: string;
|
77
75
|
}
|
78
76
|
export interface Isubmit {
|
79
77
|
billingAddress?: IbillingAddress;
|
@@ -145,16 +143,6 @@ export declare enum platformEnum {
|
|
145
143
|
desktop = "desktop",
|
146
144
|
mobile = "mobile"
|
147
145
|
}
|
148
|
-
type EventCallbackResult = {
|
149
|
-
result: {
|
150
|
-
resultCode: string;
|
151
|
-
resultStatus: string;
|
152
|
-
resultMessage: string;
|
153
|
-
};
|
154
|
-
paymentResultCode?: string;
|
155
|
-
paymentResultMessage?: string;
|
156
|
-
paymentStatus?: string;
|
157
|
-
} & Record<string, any>;
|
158
146
|
/**
|
159
147
|
* @description Create an event handler, called when an error occurs in AMSCheckout.
|
160
148
|
*/
|
@@ -175,8 +163,7 @@ export type callOnLog = (state: {
|
|
175
163
|
*/
|
176
164
|
export type callOnEventCallback = (state: {
|
177
165
|
code: string;
|
178
|
-
message
|
179
|
-
result?: EventCallbackResult;
|
166
|
+
message: string;
|
180
167
|
}) => void;
|
181
168
|
export type callonPaymentMethodSelected = (state: {
|
182
169
|
paymentMethodType: string;
|
@@ -256,7 +243,6 @@ export interface CashierSdkActionQueryRequest {
|
|
256
243
|
paymentSessionData: string;
|
257
244
|
paymentSessionConfig?: IpaymentSessionConfig;
|
258
245
|
paymentMethodType?: string;
|
259
|
-
notRedirectAfterComplete?: boolean;
|
260
246
|
extParams?: any;
|
261
247
|
}
|
262
248
|
export interface CashierSdkActionQueryResult {
|
@@ -286,13 +272,6 @@ export declare enum eventCodeEnum {
|
|
286
272
|
SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
|
287
273
|
SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS"
|
288
274
|
}
|
289
|
-
export interface ThreedData {
|
290
|
-
data: any;
|
291
|
-
method: string;
|
292
|
-
targetUrl: string;
|
293
|
-
pti?: number;
|
294
|
-
pt?: number;
|
295
|
-
}
|
296
275
|
declare global {
|
297
276
|
interface Window {
|
298
277
|
[key: string]: any;
|
package/esm/types/index.js
CHANGED
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@alipay/ams-checkout","version":"0.0.
|
1
|
+
{"name":"@alipay/ams-checkout","version":"0.0.1698315116-dev.0","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@alipay/jshield-apdid":"^2.0.3","@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import { AMSPOPUP_PREFIX, ANIMATION_TIME } from "../../constant";
|
2
|
-
|
3
|
-
// CSS样式字符串
|
4
|
-
var modalStyles = "\n .".concat(AMSPOPUP_PREFIX, "modal {\n /* \u6DFB\u52A0\u5F39\u7A97\u6837\u5F0F */\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n\n .").concat(AMSPOPUP_PREFIX, "overlay {\n /* \u6DFB\u52A0\u8499\u5C42\u6837\u5F0F */\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: 999;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeIn {\n /* \u6DFB\u52A0\u6DE1\u5165\u52A8\u753B */\n animation: fadeIn ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeOut {\n /* \u6DFB\u52A0\u6DE1\u51FA\u52A8\u753B */\n animation: fadeOut ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n /* \u5B9A\u4E49\u6DE1\u5165\u52A8\u753B */\n @keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-webkit-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-moz-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u51FA\u52A8\u753B */\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-webkit-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-moz-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n");
|
5
|
-
|
6
|
-
// 创建和插入样式表
|
7
|
-
export var insertStyleSheet = function insertStyleSheet() {
|
8
|
-
var style = document.createElement('style');
|
9
|
-
style.innerHTML = modalStyles;
|
10
|
-
document.head.appendChild(style);
|
11
|
-
};
|
12
|
-
|
13
|
-
// 插入弹窗
|
14
|
-
export var createModal = function createModal(_ref) {
|
15
|
-
var device = _ref.device,
|
16
|
-
url = _ref.url;
|
17
|
-
var overlay = document.createElement('div');
|
18
|
-
overlay.classList.add("".concat(AMSPOPUP_PREFIX, "overlay"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
|
19
|
-
var modal = document.createElement('div');
|
20
|
-
modal.classList.add("".concat(AMSPOPUP_PREFIX, "modal"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
|
21
|
-
if (device === 'desktop') {
|
22
|
-
modal.style.width = '600px';
|
23
|
-
modal.style.height = '464px';
|
24
|
-
modal.style.borderRadius = '12px';
|
25
|
-
} else {
|
26
|
-
modal.style.width = 'calc(100% - 16px)';
|
27
|
-
modal.style.height = '80%';
|
28
|
-
modal.style.borderRadius = '8px';
|
29
|
-
}
|
30
|
-
var iframe = document.createElement('iframe');
|
31
|
-
iframe.src = url; // 替换为实际的 URL 地址
|
32
|
-
iframe.style.border = 'none';
|
33
|
-
iframe.style.width = '100%';
|
34
|
-
iframe.style.height = '100%';
|
35
|
-
modal.appendChild(iframe);
|
36
|
-
var body = document.getElementsByTagName('body')[0];
|
37
|
-
body.appendChild(overlay);
|
38
|
-
body.appendChild(modal);
|
39
|
-
return iframe;
|
40
|
-
};
|
41
|
-
|
42
|
-
// 销毁弹窗
|
43
|
-
export var destroyModal = function destroyModal() {
|
44
|
-
var overlay = document.querySelector(".".concat(AMSPOPUP_PREFIX, "overlay"));
|
45
|
-
var modal = document.querySelector(".".concat(AMSPOPUP_PREFIX, "modal"));
|
46
|
-
overlay.classList.remove("".concat(AMSPOPUP_PREFIX, "fadeIn"));
|
47
|
-
overlay.classList.add("".concat(AMSPOPUP_PREFIX, "fadeOut"));
|
48
|
-
modal.classList.remove("".concat(AMSPOPUP_PREFIX, "fadeIn"));
|
49
|
-
modal.classList.add("".concat(AMSPOPUP_PREFIX, "fadeOut"));
|
50
|
-
setTimeout(function () {
|
51
|
-
overlay.parentNode.removeChild(overlay);
|
52
|
-
modal.parentNode.removeChild(modal);
|
53
|
-
}, ANIMATION_TIME);
|
54
|
-
};
|