@alipay/ams-checkout 0.0.1693912790-dev.4 → 0.0.1694400497-dev.1

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.
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
- * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
6
- * 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.
7
- */
8
1
  import ComponentApp from '../../plugin/component';
9
2
  import { IcreateComponent, IoptionsParams, Iselector } from '../../types';
10
3
  import CoreInstance from '../instance/index';
@@ -27,5 +20,5 @@ export declare class AMSComponent extends CoreInstance {
27
20
  * @description Execute payment submission process
28
21
  * @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
29
22
  */
30
- submit(): void;
23
+ submit(): Promise<unknown>;
31
24
  }
@@ -25,7 +25,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
25
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
26
26
  * 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.
27
27
  */
28
-
28
+ import { v4 as uuid } from 'uuid';
29
29
  import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
30
30
  import ComponentApp from "../../plugin/component";
31
31
  import { componentSignEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
@@ -186,16 +186,25 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
186
186
  }, {
187
187
  key: "submit",
188
188
  value: function submit() {
189
- try {
190
- this._componentApp.dispatchToApp({
191
- context: {
192
- event: 'submitPay',
193
- data: {}
194
- }
195
- });
196
- } catch (error) {
197
- console.error(error);
198
- }
189
+ var _this4 = this;
190
+ return new Promise(function (resolve, reject) {
191
+ try {
192
+ var eventCallbackId = uuid();
193
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
194
+ _this4._eventCenter.once(eventCallbackId, function (_data) {
195
+ resolve(_data);
196
+ });
197
+ _this4._componentApp.dispatchToApp({
198
+ context: {
199
+ event: 'submitPay',
200
+ eventCallbackId: eventCallbackId,
201
+ data: {}
202
+ }
203
+ });
204
+ } catch (error) {
205
+ reject(error);
206
+ }
207
+ });
199
208
  }
200
209
  }]);
201
210
  return AMSComponent;
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
- * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
6
- * 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.
7
- */
8
1
  import { IcreatePaymentParams, IoptionsParams } from '../../types';
9
2
  export declare const mixinDropInConstructor: (options: IoptionsParams, context: any) => void;
10
3
  /**
@@ -8,7 +8,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
8
8
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
9
9
  * 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.
10
10
  */
11
-
11
+ /* eslint-disable @typescript-eslint/no-explicit-any */
12
12
  import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
13
13
  import CheckoutApp from "../../plugin/drop-in";
14
14
  import { messageName, networkModeEnum } from "../../types";
@@ -49,8 +49,8 @@ export var createPayment = function createPayment(params) {
49
49
  export var confirmPayment = function confirmPayment(result) {
50
50
  var _this2 = this;
51
51
  return new Promise(function (resolve, reject) {
52
- _this2.eventCenter.once('onRedirect', function (playload) {
53
- _this2._redirect(playload).then(function () {
52
+ _this2.eventCenter.once('onRedirect', function (payload) {
53
+ _this2._redirect(payload).then(function () {
54
54
  resolve();
55
55
  }).catch(function (err) {
56
56
  reject(err);
@@ -73,21 +73,21 @@ export var confirmPayment = function confirmPayment(result) {
73
73
  */
74
74
  export var _subscribeFromCheckoutPlugin = function _subscribeFromCheckoutPlugin() {
75
75
  var _this3 = this;
76
- var eventKeyMap = new Map([[EVENT.error.name, function (playload) {
77
- _this3.eventCenter.emit(EVENT.error.name, playload.context.data);
78
- }], [EVENT.ready.name, function (playload) {
79
- _this3.eventCenter.emit(EVENT.ready.name, playload.context.data);
80
- }], [EVENT.redirect.name, function (playload) {
81
- _this3.eventCenter.emit(EVENT.redirect.name, playload.context.data);
82
- }], [EVENT.paymentMethodSelected.name, function (playload) {
83
- _this3.checkoutState.paymentMethodType = playload.context.data.paymentMethodType;
76
+ var eventKeyMap = new Map([[EVENT.error.name, function (payload) {
77
+ _this3.eventCenter.emit(EVENT.error.name, payload.context.data);
78
+ }], [EVENT.ready.name, function (payload) {
79
+ _this3.eventCenter.emit(EVENT.ready.name, payload.context.data);
80
+ }], [EVENT.redirect.name, function (payload) {
81
+ _this3.eventCenter.emit(EVENT.redirect.name, payload.context.data);
82
+ }], [EVENT.paymentMethodSelected.name, function (payload) {
83
+ _this3.checkoutState.paymentMethodType = payload.context.data.paymentMethodType;
84
84
  _this3.eventCenter.emit(EVENT.paymentMethodSelected.name, {
85
- paymentMethodType: playload.context.data.paymentMethodType
85
+ paymentMethodType: payload.context.data.paymentMethodType
86
86
  });
87
- }], [EVENT.sizeChanged.name, function (playload) {
88
- _this3.eventCenter.emit(EVENT.sizeChanged.name, playload.context.data);
89
- }], [EVENT.log.name, function (playload) {
90
- _this3.eventCenter.emit(EVENT.log.name, playload.context.data);
87
+ }], [EVENT.sizeChanged.name, function (payload) {
88
+ _this3.eventCenter.emit(EVENT.sizeChanged.name, payload.context.data);
89
+ }], [EVENT.log.name, function (payload) {
90
+ _this3.eventCenter.emit(EVENT.log.name, payload.context.data);
91
91
  }]]);
92
92
  var _iterator = _createForOfIteratorHelper(eventKeyMap.keys()),
93
93
  _step;
@@ -15,6 +15,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
15
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
16
16
  * 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.
17
17
  */
18
+ /* eslint-disable @typescript-eslint/no-explicit-any */
18
19
  import { v4 as uuid } from 'uuid';
19
20
  import { ERRORMESSAGE, EVENT } from "../../constant";
20
21
  import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } from "../../types/index";
@@ -1,5 +1,5 @@
1
1
  import { componentSignEnum, Ianalytics } from '../../types';
2
- export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productSceneVersion: string, extendInfo: string) => any;
2
+ export declare const getAppPath: (environment: string | undefined, appVersion: string, componentSign: componentSignEnum, productSceneVersion: string, extendInfo: string) => any;
3
3
  export declare const getAppDomain: (domainParams: {
4
4
  environment: string;
5
5
  appVersion: string;
@@ -8,4 +8,4 @@
8
8
  import { platformEnum } from '../../types';
9
9
  export declare const inlineComponentAddCss: () => void;
10
10
  export declare const addInlineLoading: (_selector: HTMLDivElement, platform: platformEnum) => void;
11
- export declare const createInlineBaseElement: (selector: string) => HTMLDivElement;
11
+ export declare const createInlineBaseElement: (selector: string) => HTMLDivElement | undefined;
@@ -1,6 +1,6 @@
1
1
  import { platformEnum } from '../../types';
2
2
  export declare const componentAddCSS: () => void;
3
- export declare const createBaseElement: (platform: platformEnum, closeBtnFunc: () => void) => HTMLDivElement;
3
+ export declare const createBaseElement: (platform: platformEnum, closeBtnFunc: () => void) => HTMLDivElement | undefined;
4
4
  export declare const createCloseBtn: (platform: platformEnum, closeBtnFunc: () => void) => void;
5
5
  export declare const createRetentionPopup: (platform: platformEnum, remainBtnFunc: () => void, leaveBtnFunc: () => void) => void;
6
6
  export declare const hideRetentionPopup: () => void;
@@ -113,6 +113,8 @@ export var addPopupLoading = function addPopupLoading() {
113
113
  var body = document.getElementsByTagName('body')[0];
114
114
  body === null || body === void 0 ? void 0 : body.appendChild(loading);
115
115
  };
116
+
117
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
116
118
  export var handleDeclareInfo = function handleDeclareInfo(_ref) {
117
119
  var _ref$closeDialogData = _ref.closeDialogData,
118
120
  closeDialogData = _ref$closeDialogData === void 0 ? {} : _ref$closeDialogData;
@@ -1,5 +1,5 @@
1
1
  import type AMSCheckout from '../../core/instance';
2
- import type { eventPlayload, IappendIframeNodesParams, Iselector } from '../../types';
2
+ import type { eventPayload, eventPayloadContext, IappendIframeNodesParams, Iselector } from '../../types';
3
3
  import { componentSignEnum, platformEnum, renderDisplayTypeEnum } from '../../types';
4
4
  type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
5
5
  export default class ComponentApp {
@@ -7,7 +7,7 @@ export default class ComponentApp {
7
7
  AMSSDK: AMSCheckout;
8
8
  platform: platformEnum;
9
9
  _performanceData: any[];
10
- _loadAppPromiseResolve: ((value: Boolean) => void) | null;
10
+ _loadAppPromiseResolve: ((value: boolean) => void) | null;
11
11
  _isInitComponent: boolean;
12
12
  private appDomain;
13
13
  private createIframeNode;
@@ -32,7 +32,6 @@ export default class ComponentApp {
32
32
  * @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
33
33
  */
34
34
  setRender(renderFunc: IrenderFuncParams): void;
35
- initAPSecurity(): void;
36
35
  /**
37
36
  * @description render iframe content
38
37
  */
@@ -59,7 +58,7 @@ export default class ComponentApp {
59
58
  /**
60
59
  * @description Processing messages from iframe
61
60
  */
62
- _handleAppMessage(data: eventPlayload): void;
61
+ _handleAppMessage(data: eventPayload): void;
63
62
  private handleSizeChanged;
64
63
  private handleRedirect;
65
64
  private handleDeclareInfo;
@@ -67,15 +66,12 @@ export default class ComponentApp {
67
66
  /**
68
67
  * @description Send message to SDK
69
68
  */
70
- dispatchToSDK(event: string, data: any): void;
69
+ dispatchToSDK(event: string, data: any, eventCallbackId?: string): void;
71
70
  /**
72
71
  * @description Send message to iframe
73
72
  */
74
73
  dispatchToApp(payload: {
75
- context: {
76
- event: string;
77
- data: any;
78
- };
74
+ context: eventPayloadContext;
79
75
  }): any;
80
76
  /**
81
77
  * @description Subscribe to messages from SDK
@@ -15,21 +15,15 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
15
  * 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.
16
16
  */
17
17
  /* eslint-disable no-console */
18
+ /* eslint-disable @typescript-eslint/no-explicit-any */
18
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";
19
20
  import { queryPaymentInfo } from "../../service";
20
21
  import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
21
- import { getType, isJsonString, isPC, queryParse } from "../../util";
22
+ import { getType, isJsonString, isPC } from "../../util";
22
23
  import { isLocalMock } from "../../util/mock";
23
24
  import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
24
25
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
25
26
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
26
- import APDID from '@alipay/jshield-apdid';
27
- import { getSecurityHost, getAppname } from "../../util/security";
28
- var _ref = queryParse() || {},
29
- preinit = _ref.preinit,
30
- rebuild = _ref.rebuild,
31
- scene = _ref.scene,
32
- region = _ref.region;
33
27
  var _window = window,
34
28
  innerHeight = _window.innerHeight;
35
29
  var ComponentApp = /*#__PURE__*/function () {
@@ -51,7 +45,7 @@ var ComponentApp = /*#__PURE__*/function () {
51
45
  _defineProperty(this, "_componentSign", componentSignEnum.NONE);
52
46
  _defineProperty(this, "_clickEventName", void 0);
53
47
  _defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
54
- this._appVersion = '1.5.3';
48
+ this._appVersion = '1.5.4';
55
49
  this._isInitComponent = false;
56
50
  this._selector = "#".concat(COMPONENT_SECTION_ID);
57
51
  this.createIframeNode = function () {
@@ -93,29 +87,6 @@ var ComponentApp = /*#__PURE__*/function () {
93
87
  value: function setRender(renderFunc) {
94
88
  this.createIframeNode = renderFunc;
95
89
  }
96
- }, {
97
- key: "initAPSecurity",
98
- value: function initAPSecurity() {
99
- var _this$_renderParams, _this$_renderParams$p;
100
- if (componentSignEnum.CASHIER_PAYMENT_CARD !== this._componentSign) {
101
- return;
102
- }
103
- var securityConfig = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : (_this$_renderParams$p = _this$_renderParams.paymentSessionMetaData) === null || _this$_renderParams$p === void 0 ? void 0 : _this$_renderParams$p.securityConfig;
104
- if (!securityConfig) {
105
- return;
106
- }
107
- var appName = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName;
108
- var h5gateway = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway;
109
- if (preinit === 'true' || rebuild === 'true') {
110
- appName = getAppname(scene);
111
- h5gateway = getSecurityHost(region);
112
- }
113
- APDID.initToken(appName, {
114
- host: h5gateway
115
- }, function (success, tokenResult, msg) {
116
- console.log("initToken result tokenResult", JSON.stringify(tokenResult));
117
- });
118
- }
119
90
 
120
91
  /**
121
92
  * @description render iframe content
@@ -134,7 +105,6 @@ var ComponentApp = /*#__PURE__*/function () {
134
105
  if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
135
106
  this._renderDisplayType = renderParams.renderDisplayType;
136
107
  var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
137
- this.initAPSecurity();
138
108
  this._performanceData.push({
139
109
  key: 'sdk_create_component',
140
110
  value: Date.now()
@@ -210,7 +180,7 @@ var ComponentApp = /*#__PURE__*/function () {
210
180
  value: Date.now()
211
181
  });
212
182
  this._actionQueryPromise = new Promise(function (resolve, reject) {
213
- var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3, _this3$_renderParams4, _this3$_renderParams5;
183
+ var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
214
184
  var params = {
215
185
  paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.paymentSessionData) || '',
216
186
  paymentSessionConfig: (_this3$_renderParams2 = _this3._renderParams) === null || _this3$_renderParams2 === void 0 ? void 0 : (_this3$_renderParams3 = _this3$_renderParams2.paymentSessionMetaData) === null || _this3$_renderParams3 === void 0 ? void 0 : _this3$_renderParams3.paymentSessionConfig
@@ -221,35 +191,21 @@ var ComponentApp = /*#__PURE__*/function () {
221
191
  if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
222
192
  params.paymentMethodType = 'CARD';
223
193
  }
224
- var needDeviceId = false;
225
- var waitTime = '3000';
226
- var securityConfig = (_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : (_this3$_renderParams5 = _this3$_renderParams4.paymentSessionMetaData) === null || _this3$_renderParams5 === void 0 ? void 0 : _this3$_renderParams5.securityConfig;
227
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign && securityConfig) {
228
- var _this3$_renderParams6, _this3$_renderParams7;
229
- var extendInfo = ((_this3$_renderParams6 = _this3._renderParams) === null || _this3$_renderParams6 === void 0 ? void 0 : (_this3$_renderParams7 = _this3$_renderParams6.paymentSessionMetaData) === null || _this3$_renderParams7 === void 0 ? void 0 : _this3$_renderParams7.extendInfo) || '';
230
- var info = JSON.parse(extendInfo);
231
- if ((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false') {
232
- var _this3$_renderParams8, _this3$_renderParams9, _this3$_renderParams10;
233
- needDeviceId = true;
234
- waitTime = (_this3$_renderParams8 = _this3._renderParams) === null || _this3$_renderParams8 === void 0 ? void 0 : (_this3$_renderParams9 = _this3$_renderParams8.paymentSessionMetaData) === null || _this3$_renderParams9 === void 0 ? void 0 : (_this3$_renderParams10 = _this3$_renderParams9.securityConfig) === null || _this3$_renderParams10 === void 0 ? void 0 : _this3$_renderParams10.tokenCollectTime;
235
- }
236
- }
237
-
238
194
  /**
239
195
  * @description easyPay
240
196
  */
241
197
  if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
242
- var _this3$_renderParams11;
243
- var _ref2 = params.paymentSessionConfig || {},
244
- _ref2$productSceneVer = _ref2.productSceneVersion,
245
- productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
246
- _ref2$productScene = _ref2.productScene,
247
- productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
248
- var _ref3 = ((_this3$_renderParams11 = _this3._renderParams) === null || _this3$_renderParams11 === void 0 ? void 0 : _this3$_renderParams11.paymentSessionMetaData) || {},
249
- _ref3$action = _ref3.action,
250
- _ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
251
- _ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
252
- autoDebitWithToken = _ref3$action2$autoDeb === void 0 ? false : _ref3$action2$autoDeb;
198
+ var _this3$_renderParams4;
199
+ var _ref = params.paymentSessionConfig || {},
200
+ _ref$productSceneVers = _ref.productSceneVersion,
201
+ productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
202
+ _ref$productScene = _ref.productScene,
203
+ productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
204
+ var _ref2 = ((_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.paymentSessionMetaData) || {},
205
+ _ref2$action = _ref2.action,
206
+ _ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
207
+ _ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
208
+ autoDebitWithToken = _ref2$action2$autoDeb === void 0 ? false : _ref2$action2$autoDeb;
253
209
  if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
254
210
  // if EASY_PAY 2.0 , no need to query payment request
255
211
  return resolve({
@@ -263,8 +219,8 @@ var ComponentApp = /*#__PURE__*/function () {
263
219
  * @description autoDebit
264
220
  */
265
221
  if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
266
- var _this3$_renderParams12, _this3$_renderParams13, _action$web, _action$wap;
267
- var action = ((_this3$_renderParams12 = _this3._renderParams) === null || _this3$_renderParams12 === void 0 ? void 0 : (_this3$_renderParams13 = _this3$_renderParams12.paymentSessionMetaData) === null || _this3$_renderParams13 === void 0 ? void 0 : _this3$_renderParams13.action) || {};
222
+ var _this3$_renderParams5, _this3$_renderParams6, _action$web, _action$wap;
223
+ var action = ((_this3$_renderParams5 = _this3._renderParams) === null || _this3$_renderParams5 === void 0 ? void 0 : (_this3$_renderParams6 = _this3$_renderParams5.paymentSessionMetaData) === null || _this3$_renderParams6 === void 0 ? void 0 : _this3$_renderParams6.action) || {};
268
224
  var signType = isPC() ? action === null || action === void 0 ? void 0 : (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 ? void 0 : (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
269
225
  if (signType === 'SMS') {
270
226
  return resolve({
@@ -288,9 +244,7 @@ var ComponentApp = /*#__PURE__*/function () {
288
244
  }
289
245
  queryPaymentInfo(params, {
290
246
  env: _this3.AMSSDK.options.env.environment,
291
- locale: _this3.AMSSDK.options.locale,
292
- needDeviceId: needDeviceId,
293
- waitTime: waitTime
247
+ locale: _this3.AMSSDK.options.locale
294
248
  }).then(function (res) {
295
249
  _this3._performanceData.push({
296
250
  key: 'sdk_action_query_end',
@@ -502,7 +456,7 @@ var ComponentApp = /*#__PURE__*/function () {
502
456
  }
503
457
 
504
458
  // The plug-in communicates with the sdk after processing
505
- this.dispatchToSDK(data.context.event, data.context.data);
459
+ this.dispatchToSDK(data.context.event, data.context.data, data.context.eventCallbackId);
506
460
  }
507
461
  }, {
508
462
  key: "handleSizeChanged",
@@ -609,9 +563,9 @@ var ComponentApp = /*#__PURE__*/function () {
609
563
  }
610
564
  }, {
611
565
  key: "handleDeclareInfo",
612
- value: function handleDeclareInfo(_ref4) {
613
- var _ref4$closeDialogData = _ref4.closeDialogData,
614
- closeDialogData = _ref4$closeDialogData === void 0 ? {} : _ref4$closeDialogData;
566
+ value: function handleDeclareInfo(_ref3) {
567
+ var _ref3$closeDialogData = _ref3.closeDialogData,
568
+ closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
615
569
  _handleDeclareInfo({
616
570
  closeDialogData: closeDialogData
617
571
  });
@@ -632,8 +586,9 @@ var ComponentApp = /*#__PURE__*/function () {
632
586
  */
633
587
  }, {
634
588
  key: "dispatchToSDK",
635
- value: function dispatchToSDK(event, data) {
589
+ value: function dispatchToSDK(event, data, eventCallbackId) {
636
590
  this.AMSSDK._eventCenter.emit(event, data);
591
+ if (eventCallbackId) this.AMSSDK._eventCenter.emit(eventCallbackId, data);
637
592
  }
638
593
 
639
594
  /**
@@ -677,7 +632,7 @@ var ComponentApp = /*#__PURE__*/function () {
677
632
  key: "sendRenderEvent",
678
633
  value: function () {
679
634
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
680
- var _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, _this$_renderParams5, res;
635
+ var _this$_renderParams, _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, res;
681
636
  return _regeneratorRuntime().wrap(function _callee$(_context) {
682
637
  while (1) switch (_context.prev = _context.next) {
683
638
  case 0:
@@ -701,11 +656,11 @@ var ComponentApp = /*#__PURE__*/function () {
701
656
  event: 'renderComponent',
702
657
  data: {
703
658
  queryResult: res,
704
- sessionResult: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionMetaData,
705
- paymentSessionData: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.paymentSessionData,
659
+ sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
660
+ paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
706
661
  heightOfVisible: Math.max(innerHeight, window.innerHeight),
707
- renderDisplayType: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.renderDisplayType,
708
- appearance: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.appearance,
662
+ renderDisplayType: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.renderDisplayType,
663
+ appearance: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.appearance,
709
664
  envInfo: {
710
665
  screenHeight: screen.height,
711
666
  screenWidth: screen.width
@@ -1,5 +1,5 @@
1
1
  import type AMSCheckout from '../../core/instance';
2
- import type { IcreatePaymentParams, eventPlayload } from '../../types';
2
+ import type { IcreatePaymentParams, eventPayload } from '../../types';
3
3
  export default class CheckoutApp {
4
4
  app: any;
5
5
  paymentMethodsResult: any;
@@ -47,15 +47,15 @@ export default class CheckoutApp {
47
47
  /**
48
48
  * @description Processing messages from iframe
49
49
  */
50
- _handleAppMessage(data: eventPlayload): void;
50
+ _handleAppMessage(data: eventPayload): void;
51
51
  /**
52
52
  * @description Send message to SDK
53
53
  */
54
- _dispatchToSDK(data: eventPlayload): void;
54
+ _dispatchToSDK(data: eventPayload): void;
55
55
  /**
56
56
  * @description Send message to iframe
57
57
  */
58
- _dispatchToApp(data: eventPlayload): void;
58
+ _dispatchToApp(data: eventPayload): void;
59
59
  /**
60
60
  * @description Subscribe to messages from SDK
61
61
  */
@@ -67,5 +67,5 @@ export default class CheckoutApp {
67
67
  /**
68
68
  * @description Send the post submission processing event, and the cashier applies the consumption result
69
69
  */
70
- _handleRequestPayment(data: eventPlayload): void;
70
+ _handleRequestPayment(data: eventPayload): void;
71
71
  }
@@ -11,6 +11,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
11
11
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
12
12
  * 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.
13
13
  */
14
+ /* eslint-disable @typescript-eslint/no-explicit-any */
14
15
  import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
15
16
  import { messageName } from "../../types";
16
17
  import { getOrigin, getType, getViewPort, isDom, isJsonString, serialize } from "../../util";
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
- * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
6
- * 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.
7
- */
8
1
  import { IrequestConfig } from '../types';
9
2
  /**
10
3
  *
@@ -14,12 +14,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
14
14
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
15
15
  * 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.
16
16
  */
17
-
17
+ /* eslint-disable @typescript-eslint/no-explicit-any */
18
18
  import { sdkVersion } from "../config/index";
19
19
  import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
20
20
  import { errorEnum } from "../types";
21
21
  import { get } from "../util/get";
22
- import { getApdidToken, getAppname } from "../util/security";
23
22
  import axios from 'axios';
24
23
  import { device, fomatGetwayError, isPC, queryParse, safeJson } from "../util";
25
24
  var _queryParse = queryParse(),
@@ -64,7 +63,7 @@ export function request(_x, _x2) {
64
63
  }
65
64
  function _request() {
66
65
  _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestData, options) {
67
- var myRequest, startTime, envInfo, deviceId, _navigator, _data, _yield$myRequest, data, headers, resData, traceId, handleGetWayError, _error$message, _error, timeoutCode, errorCode;
66
+ var myRequest, startTime, envInfo, _navigator, _data, _yield$myRequest, data, headers, resData, traceId, handleGetWayError, _error$message, _error, timeoutCode, errorCode;
68
67
  return _regeneratorRuntime().wrap(function _callee$(_context) {
69
68
  while (1) switch (_context.prev = _context.next) {
70
69
  case 0:
@@ -84,16 +83,6 @@ function _request() {
84
83
  screenHeight: screen.height,
85
84
  timeZoneOffset: new Date().getTimezoneOffset()
86
85
  };
87
- if (!(options !== null && options !== void 0 && options.needDeviceId)) {
88
- _context.next = 8;
89
- break;
90
- }
91
- _context.next = 6;
92
- return getApdidToken(getAppname('Card'), options === null || options === void 0 ? void 0 : options.waitTime);
93
- case 6:
94
- deviceId = _context.sent;
95
- envInfo.deviceId = deviceId;
96
- case 8:
97
86
  try {
98
87
  envInfo.browserInfo.browserJavaEnabled = ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.javaEnabled()) || false;
99
88
  // eslint-disable-next-line no-empty
@@ -105,12 +94,12 @@ function _request() {
105
94
  refUrl: window.location.href
106
95
  }
107
96
  })] : [requestData];
108
- _context.prev = 11;
109
- _context.next = 14;
97
+ _context.prev = 6;
98
+ _context.next = 9;
110
99
  return myRequest({
111
100
  data: _data
112
101
  });
113
- case 14:
102
+ case 9:
114
103
  _yield$myRequest = _context.sent;
115
104
  data = _yield$myRequest.data;
116
105
  headers = _yield$myRequest.headers;
@@ -119,7 +108,7 @@ function _request() {
119
108
  resData.traceId = traceId || '';
120
109
  handleGetWayError = fomatGetwayError(headers, traceId);
121
110
  if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
122
- _context.next = 23;
111
+ _context.next = 18;
123
112
  break;
124
113
  }
125
114
  throw new Error(JSON.stringify({
@@ -127,13 +116,11 @@ function _request() {
127
116
  errorCode: handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode,
128
117
  success: false
129
118
  }));
130
- case 23:
119
+ case 18:
131
120
  return _context.abrupt("return", resData);
132
- case 26:
133
- _context.prev = 26;
134
- _context.t0 = _context["catch"](11);
135
- // eslint-disable-next-line no-console
136
- console.log('request error', _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message);
121
+ case 21:
122
+ _context.prev = 21;
123
+ _context.t0 = _context["catch"](6);
137
124
  _error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
138
125
  success: false,
139
126
  errorCode: errorEnum.SYSTEM,
@@ -146,11 +133,11 @@ function _request() {
146
133
  errorCode: errorCode,
147
134
  errorMessage: ''
148
135
  }));
149
- case 33:
136
+ case 27:
150
137
  case "end":
151
138
  return _context.stop();
152
139
  }
153
- }, _callee, null, [[11, 26]]);
140
+ }, _callee, null, [[6, 21]]);
154
141
  }));
155
142
  return _request.apply(this, arguments);
156
143
  }
@@ -25,4 +25,4 @@ export declare const fomatGetwayError: (headers: Record<string, any>, traceId: s
25
25
  memo: string;
26
26
  };
27
27
  resultStatus: any;
28
- };
28
+ } | null;
@@ -8,6 +8,8 @@
8
8
 
9
9
  import { errorEnum } from "../types";
10
10
  import { get } from "../util/get";
11
+
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
13
  export var safeJson = function safeJson(data, obj) {
12
14
  try {
13
15
  return JSON.parse(data) || obj;