@alipay/ams-checkout 0.0.1694675458-dev.0 → 0.0.1694675458-dev.2

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.
@@ -12,8 +12,8 @@ var _queryParse = queryParse(),
12
12
  groupId = _queryParse.groupId,
13
13
  host = _queryParse.requestHost;
14
14
  export var requestHost = {
15
- local: 'http://imgs-1164.gz00b.dev.alipay.net/mgw.htm',
16
- dev: host || 'http://imgs-1164.gz00b.dev.alipay.net/mgw.htm',
15
+ local: 'http://imgs-6517.sggz00b.dev.alipay.net/mgw.htm',
16
+ dev: host || 'http://imgs-6517.sggz00b.dev.alipay.net/mgw.htm',
17
17
  sit: host || 'http://imgs-9.sggz00a.test.alipay.net/mgw.htm',
18
18
  pre: 'https://imgs-sea-pre.alipay.com/mgw.htm',
19
19
  prod: 'https://imgs-sea-global.alipay.com/mgw.htm',
@@ -22,7 +22,7 @@ export var requestHost = {
22
22
  export var clientId = '5J5Y8X4E2Y25GR00690';
23
23
  export var tntInstId = 'ALIPW3SG';
24
24
  export var appId = 'ANTOM_PAYMENT_WEB';
25
- export var sofaId = groupId || 'GROUP_20230523202227';
25
+ export var sofaId = groupId || 'GROUP_20230913102142';
26
26
  export var hostSignMap = function hostSignMap(hostSign, env) {
27
27
  var map = {
28
28
  SG: 'https://imgs-sea-global.alipay.com/mgw.htm',
@@ -1,12 +1,5 @@
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
- import { IcreateComponent, IoptionsParams, Iselector } from '../../types';
2
+ import { IcreateComponent, IoptionsParams, Iselector, Isubmit } from '../../types';
10
3
  import CoreInstance from '../instance/index';
11
4
  export declare class AMSComponent extends CoreInstance {
12
5
  _componentApp: ComponentApp;
@@ -15,17 +8,17 @@ export declare class AMSComponent extends CoreInstance {
15
8
  private pluginAppendIframe;
16
9
  /**
17
10
  * @description Create component application
18
- * @param params - The data source created by the component, necessary paymentSessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
11
+ * @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
19
12
  */
20
13
  createComponent(params: IcreateComponent): Promise<void>;
21
14
  /**
22
15
  * @description Create and render components in the specified element area
23
- * @param params - The data source created by the component, necessary paymentSessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
16
+ * @param params - The data source created by the component, necessary sessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
24
17
  */
25
18
  mountComponent(params: IcreateComponent, selector: Iselector): Promise<void>;
26
19
  /**
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(data?: Isubmit): 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";
@@ -41,12 +41,12 @@ var getComponentSign = function getComponentSign(params) {
41
41
  paymentMethodCategoryType = _params$paymentSessio4 === void 0 ? '' : _params$paymentSessio4;
42
42
  return productScene && paymentMethodCategoryType ? "".concat(productScene, "_").concat(paymentMethodCategoryType) : componentSignEnum.NONE;
43
43
  };
44
- var parsePaymentSessionData = function parsePaymentSessionData(paymentSessionData) {
44
+ var parseSessionData = function parseSessionData(sessionData) {
45
45
  try {
46
- return [JSON.parse(atob(paymentSessionData.split('&&')[3])), paymentSessionData.split('&&').slice(0, 3).join('&&')];
46
+ return [JSON.parse(atob(sessionData.split('&&')[3])), sessionData.split('&&').slice(0, 3).join('&&')];
47
47
  } catch (error) {
48
- console.error('Parsing paymentSessionData is abnormal and may affect the payment link. Please ensure to use the new version of SDK.');
49
- return [{}, paymentSessionData];
48
+ console.error('Parsing sessionData is abnormal and may affect the payment link. Please ensure to use the new version of SDK.');
49
+ return [{}, sessionData];
50
50
  }
51
51
  };
52
52
 
@@ -59,23 +59,23 @@ var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
59
59
  }
60
60
  }
61
61
  };
62
- var handlePaymentSessionData = function handlePaymentSessionData(originPaymentSessionData) {
63
- var _parsePaymentSessionD = parsePaymentSessionData(originPaymentSessionData),
64
- _parsePaymentSessionD2 = _slicedToArray(_parsePaymentSessionD, 2),
65
- parseData = _parsePaymentSessionD2[0],
66
- paymentSessionData = _parsePaymentSessionD2[1];
62
+ var handleSessionData = function handleSessionData(originSessionData) {
63
+ var _parseSessionData = parseSessionData(originSessionData),
64
+ _parseSessionData2 = _slicedToArray(_parseSessionData, 2),
65
+ parseData = _parseSessionData2[0],
66
+ sessionData = _parseSessionData2[1];
67
67
  resetEasyPaySceneVersion(parseData);
68
- return [parseData, paymentSessionData];
68
+ return [parseData, sessionData];
69
69
  };
70
70
  var handleParams = function handleParams(params) {
71
71
  var _params = Object.assign({
72
72
  paymentSessionMetaData: {},
73
73
  renderDisplayType: renderDisplayTypeEnum.popup
74
74
  }, params);
75
- var _handlePaymentSession = handlePaymentSessionData(_params.paymentSessionData),
76
- _handlePaymentSession2 = _slicedToArray(_handlePaymentSession, 2),
77
- parseData = _handlePaymentSession2[0],
78
- paymentSessionData = _handlePaymentSession2[1];
75
+ var _handleSessionData = handleSessionData(_params.sessionData),
76
+ _handleSessionData2 = _slicedToArray(_handleSessionData, 2),
77
+ parseData = _handleSessionData2[0],
78
+ sessionData = _handleSessionData2[1];
79
79
  var componentSign = getComponentSign(parseData);
80
80
  if (componentSign === componentSignEnum.NONE) {
81
81
  // eslint-disable-next-line prefer-promise-reject-errors
@@ -84,7 +84,7 @@ var handleParams = function handleParams(params) {
84
84
  message: "Abnormal response data, interface failure, or unsupported payment method"
85
85
  });
86
86
  }
87
- _params.paymentSessionData = paymentSessionData;
87
+ _params.sessionData = sessionData;
88
88
  _params.paymentSessionMetaData = parseData;
89
89
  return Promise.resolve({
90
90
  iframeNodesParams: _params,
@@ -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.paymentSessionData) {
122
+ if (_params && !_params.sessionData) {
123
123
  return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
124
124
  }
125
125
  if (this.options.networkMode === networkModeEnum.proxy) {
@@ -140,7 +140,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
140
140
 
141
141
  /**
142
142
  * @description Create component application
143
- * @param params - The data source created by the component, necessary paymentSessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
143
+ * @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
144
144
  */
145
145
  }, {
146
146
  key: "createComponent",
@@ -160,7 +160,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
160
160
  }
161
161
  /**
162
162
  * @description Create and render components in the specified element area
163
- * @param params - The data source created by the component, necessary paymentSessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
163
+ * @param params - The data source created by the component, necessary sessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
164
164
  */
165
165
  }, {
166
166
  key: "mountComponent",
@@ -185,17 +185,26 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
185
185
  */
186
186
  }, {
187
187
  key: "submit",
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
- }
188
+ value: function submit(data) {
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: 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,6 @@
1
1
  import { componentSignEnum, Ianalytics } from '../../types';
2
- export declare const getAppPath: (environment: string | undefined, appVersion: string, componentSign: componentSignEnum, productSceneVersion: string, extendInfo: string) => any;
2
+ import { renderDisplayTypeEnum } from '../../types/index';
3
+ export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productSceneVersion: string, extendInfo: string) => any;
3
4
  export declare const getAppDomain: (domainParams: {
4
5
  environment: string;
5
6
  appVersion: string;
@@ -16,6 +17,7 @@ export declare const getIframeUrl: (iframeParams: {
16
17
  extendInfo: string;
17
18
  locale: string;
18
19
  instanceId: string;
20
+ renderDisplayType: renderDisplayTypeEnum;
19
21
  }) => string;
20
22
  /**
21
23
  * @description Create iframe
@@ -22,7 +22,7 @@ var getAppVersion = function getAppVersion(_extendInfo) {
22
22
  };
23
23
  var getFinalProductSceneVersion = function getFinalProductSceneVersion(componentSign, productSceneVersion) {
24
24
  var _signSupportMap;
25
- var signSupportMap = (_signSupportMap = {}, _defineProperty(_signSupportMap, componentSignEnum.NONE, ['']), _defineProperty(_signSupportMap, componentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), _signSupportMap);
25
+ var signSupportMap = (_signSupportMap = {}, _defineProperty(_signSupportMap, componentSignEnum.NONE, ['']), _defineProperty(_signSupportMap, componentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), _defineProperty(_signSupportMap, componentSignEnum.VAULTING_CARD, ['1.0']), _signSupportMap);
26
26
  var supportProductSceneVersion = signSupportMap[componentSign];
27
27
  // 从左到右,从旧到新
28
28
  var isSupport = supportProductSceneVersion.find(function (it) {
@@ -69,7 +69,8 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
69
69
  appVersion = iframeParams.appVersion,
70
70
  extendInfo = iframeParams.extendInfo,
71
71
  locale = iframeParams.locale,
72
- instanceId = iframeParams.instanceId;
72
+ instanceId = iframeParams.instanceId,
73
+ renderDisplayType = iframeParams.renderDisplayType;
73
74
  var path = getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo || '');
74
75
  var initialScale = 1;
75
76
  var scale = getViewPort('initial-scale') || initialScale;
@@ -80,8 +81,10 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
80
81
  requestHost = _queryParse$requestHo === void 0 ? '' : _queryParse$requestHo,
81
82
  _queryParse$groupId = _queryParse.groupId,
82
83
  groupId = _queryParse$groupId === void 0 ? '' : _queryParse$groupId,
83
- LOCAL_MOCK = _queryParse.LOCAL_MOCK;
84
+ LOCAL_MOCK = _queryParse.LOCAL_MOCK,
85
+ _displayType = _queryParse._displayType;
84
86
  var urlParams = Object.assign({}, {
87
+ displayType: renderDisplayType,
85
88
  locale: locale,
86
89
  scale: scale,
87
90
  instanceId: instanceId,
@@ -94,6 +97,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
94
97
  if (groupId) urlParams.groupId = groupId;
95
98
  if (environment === 'light_sandbox' || _light_sandbox === 'true') urlParams.sandbox = 'true';
96
99
  if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
100
+ if (_displayType) urlParams.displayType = _displayType;
97
101
  var locationSearch = serialize(urlParams);
98
102
  return "".concat(path, "?").concat(locationSearch);
99
103
  };
@@ -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 | undefined;
11
+ export declare const createInlineBaseElement: (selector: string) => HTMLDivElement;
@@ -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 | undefined;
3
+ export declare const createBaseElement: (platform: platformEnum, closeBtnFunc: () => void) => HTMLDivElement;
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,6 +32,7 @@ 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;
35
36
  /**
36
37
  * @description render iframe content
37
38
  */
@@ -58,7 +59,7 @@ export default class ComponentApp {
58
59
  /**
59
60
  * @description Processing messages from iframe
60
61
  */
61
- _handleAppMessage(data: eventPlayload): void;
62
+ _handleAppMessage(data: eventPayload): void;
62
63
  private handleSizeChanged;
63
64
  private handleRedirect;
64
65
  private handleDeclareInfo;
@@ -66,15 +67,12 @@ export default class ComponentApp {
66
67
  /**
67
68
  * @description Send message to SDK
68
69
  */
69
- dispatchToSDK(event: string, data: any): void;
70
+ dispatchToSDK(event: string, data: any, eventCallbackId?: string): void;
70
71
  /**
71
72
  * @description Send message to iframe
72
73
  */
73
74
  dispatchToApp(payload: {
74
- context: {
75
- event: string;
76
- data: any;
77
- };
75
+ context: eventPayloadContext;
78
76
  }): any;
79
77
  /**
80
78
  * @description Subscribe to messages from SDK
@@ -15,16 +15,23 @@ 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 } from "../../util";
22
+ import { getType, isJsonString, isPC, queryParse } 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
- var _window = window,
27
- innerHeight = _window.innerHeight;
27
+ import APDID from '@alipay/jshield-apdid';
28
+ import { getSecurityHost, getAppname } from "../../util/security";
29
+ var _ref = queryParse() || {},
30
+ preinit = _ref.preinit,
31
+ rebuild = _ref.rebuild,
32
+ scene = _ref.scene,
33
+ region = _ref.region;
34
+ window.changingPageHeight = window.innerHeight;
28
35
  var ComponentApp = /*#__PURE__*/function () {
29
36
  function ComponentApp() {
30
37
  _classCallCheck(this, ComponentApp);
@@ -86,6 +93,29 @@ var ComponentApp = /*#__PURE__*/function () {
86
93
  value: function setRender(renderFunc) {
87
94
  this.createIframeNode = renderFunc;
88
95
  }
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
+ }
89
119
 
90
120
  /**
91
121
  * @description render iframe content
@@ -104,6 +134,7 @@ var ComponentApp = /*#__PURE__*/function () {
104
134
  if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
105
135
  this._renderDisplayType = renderParams.renderDisplayType;
106
136
  var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
137
+ this.initAPSecurity();
107
138
  this._performanceData.push({
108
139
  key: 'sdk_create_component',
109
140
  value: Date.now()
@@ -179,32 +210,45 @@ var ComponentApp = /*#__PURE__*/function () {
179
210
  value: Date.now()
180
211
  });
181
212
  this._actionQueryPromise = new Promise(function (resolve, reject) {
182
- var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
213
+ var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3, _this3$_renderParams4, _this3$_renderParams5;
183
214
  var params = {
184
- paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.paymentSessionData) || '',
215
+ paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.sessionData) || '',
185
216
  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
186
217
  };
187
218
  /**
188
219
  * @description card
189
220
  */
190
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
221
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign || componentSignEnum.VAULTING_CARD === _this3._componentSign) {
191
222
  params.paymentMethodType = 'CARD';
192
223
  }
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
+ needDeviceId = true;
233
+ waitTime = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.tokenCollectTime;
234
+ }
235
+ }
236
+
193
237
  /**
194
238
  * @description easyPay
195
239
  */
196
240
  if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
197
- var _this3$_renderParams4;
198
- var _ref = params.paymentSessionConfig || {},
199
- _ref$productSceneVers = _ref.productSceneVersion,
200
- productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
201
- _ref$productScene = _ref.productScene,
202
- productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
203
- var _ref2 = ((_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.paymentSessionMetaData) || {},
204
- _ref2$action = _ref2.action,
205
- _ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
206
- _ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
207
- autoDebitWithToken = _ref2$action2$autoDeb === void 0 ? false : _ref2$action2$autoDeb;
241
+ var _this3$_renderParams8;
242
+ var _ref2 = params.paymentSessionConfig || {},
243
+ _ref2$productSceneVer = _ref2.productSceneVersion,
244
+ productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
245
+ _ref2$productScene = _ref2.productScene,
246
+ productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
247
+ var _ref3 = ((_this3$_renderParams8 = _this3._renderParams) === null || _this3$_renderParams8 === void 0 ? void 0 : _this3$_renderParams8.paymentSessionMetaData) || {},
248
+ _ref3$action = _ref3.action,
249
+ _ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
250
+ _ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
251
+ autoDebitWithToken = _ref3$action2$autoDeb === void 0 ? false : _ref3$action2$autoDeb;
208
252
  if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
209
253
  // if EASY_PAY 2.0 , no need to query payment request
210
254
  return resolve({
@@ -218,8 +262,8 @@ var ComponentApp = /*#__PURE__*/function () {
218
262
  * @description autoDebit
219
263
  */
220
264
  if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
221
- var _this3$_renderParams5, _this3$_renderParams6, _action$web, _action$wap;
222
- 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) || {};
265
+ var _this3$_renderParams9, _this3$_renderParams10, _action$web, _action$wap;
266
+ var action = ((_this3$_renderParams9 = _this3._renderParams) === null || _this3$_renderParams9 === void 0 ? void 0 : (_this3$_renderParams10 = _this3$_renderParams9.paymentSessionMetaData) === null || _this3$_renderParams10 === void 0 ? void 0 : _this3$_renderParams10.action) || {};
223
267
  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;
224
268
  if (signType === 'SMS') {
225
269
  return resolve({
@@ -243,7 +287,9 @@ var ComponentApp = /*#__PURE__*/function () {
243
287
  }
244
288
  queryPaymentInfo(params, {
245
289
  env: _this3.AMSSDK.options.env.environment,
246
- locale: _this3.AMSSDK.options.locale
290
+ locale: _this3.AMSSDK.options.locale,
291
+ needDeviceId: needDeviceId,
292
+ waitTime: waitTime
247
293
  }).then(function (res) {
248
294
  _this3._performanceData.push({
249
295
  key: 'sdk_action_query_end',
@@ -323,6 +369,7 @@ var ComponentApp = /*#__PURE__*/function () {
323
369
  });
324
370
  this.app = createIframe(this.AMSSDK.options.mode, this.platform);
325
371
  this.app.src = getIframeUrl({
372
+ renderDisplayType: renderParams.renderDisplayType,
326
373
  componentSign: this._componentSign,
327
374
  analytics: this.AMSSDK.options.analytics,
328
375
  productSceneVersion: productSceneVersion,
@@ -363,15 +410,16 @@ var ComponentApp = /*#__PURE__*/function () {
363
410
  }
364
411
  }, {
365
412
  key: "resizeListener",
366
- value: function resizeListener() {
413
+ value: function resizeListener(e) {
414
+ var _e$target, _e$target2;
367
415
  var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
368
416
  cashier.style.transition = 'none';
369
417
  this.dispatchToApp({
370
418
  context: {
371
419
  event: 'renderResize',
372
420
  data: {
373
- heightOfVisible: window.innerHeight,
374
- widthOfVisible: window.innerWidth
421
+ heightOfVisible: (e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.innerHeight) || window.innerHeight,
422
+ widthOfVisible: (e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.innerWidth) || window.innerWidth
375
423
  }
376
424
  }
377
425
  });
@@ -455,7 +503,7 @@ var ComponentApp = /*#__PURE__*/function () {
455
503
  }
456
504
 
457
505
  // The plug-in communicates with the sdk after processing
458
- this.dispatchToSDK(data.context.event, data.context.data);
506
+ this.dispatchToSDK(data.context.event, data.context.data, data.context.eventCallbackId);
459
507
  }
460
508
  }, {
461
509
  key: "handleSizeChanged",
@@ -562,9 +610,9 @@ var ComponentApp = /*#__PURE__*/function () {
562
610
  }
563
611
  }, {
564
612
  key: "handleDeclareInfo",
565
- value: function handleDeclareInfo(_ref3) {
566
- var _ref3$closeDialogData = _ref3.closeDialogData,
567
- closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
613
+ value: function handleDeclareInfo(_ref4) {
614
+ var _ref4$closeDialogData = _ref4.closeDialogData,
615
+ closeDialogData = _ref4$closeDialogData === void 0 ? {} : _ref4$closeDialogData;
568
616
  _handleDeclareInfo({
569
617
  closeDialogData: closeDialogData
570
618
  });
@@ -585,8 +633,9 @@ var ComponentApp = /*#__PURE__*/function () {
585
633
  */
586
634
  }, {
587
635
  key: "dispatchToSDK",
588
- value: function dispatchToSDK(event, data) {
636
+ value: function dispatchToSDK(event, data, eventCallbackId) {
589
637
  this.AMSSDK._eventCenter.emit(event, data);
638
+ if (eventCallbackId) this.AMSSDK._eventCenter.emit(eventCallbackId, data);
590
639
  }
591
640
 
592
641
  /**
@@ -630,7 +679,7 @@ var ComponentApp = /*#__PURE__*/function () {
630
679
  key: "sendRenderEvent",
631
680
  value: function () {
632
681
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
633
- var _this$_renderParams, _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, res;
682
+ var _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, _this$_renderParams5, res;
634
683
  return _regeneratorRuntime().wrap(function _callee$(_context) {
635
684
  while (1) switch (_context.prev = _context.next) {
636
685
  case 0:
@@ -654,11 +703,11 @@ var ComponentApp = /*#__PURE__*/function () {
654
703
  event: 'renderComponent',
655
704
  data: {
656
705
  queryResult: res,
657
- sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
658
- paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
659
- heightOfVisible: Math.max(innerHeight, window.innerHeight),
660
- renderDisplayType: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.renderDisplayType,
661
- appearance: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.appearance,
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,
708
+ heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
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,
662
711
  envInfo: {
663
712
  screenHeight: screen.height,
664
713
  screenWidth: screen.width