@alipay/ams-checkout 0.0.1694400497-dev.1 → 1.3.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.
Files changed (73) hide show
  1. package/{esm/config/request.d.ts → dist/esm/config/index.d.ts} +1 -0
  2. package/{esm/config/request.js → dist/esm/config/index.js} +3 -1
  3. package/{esm → dist/esm}/constant/index.d.ts +32 -54
  4. package/{esm → dist/esm}/constant/index.js +32 -54
  5. package/dist/esm/core/component/index.d.ts +17 -0
  6. package/dist/esm/core/component/index.js +146 -0
  7. package/dist/esm/core/drop-in/index.d.ts +29 -0
  8. package/{esm → dist/esm}/core/drop-in/index.js +19 -19
  9. package/{esm → dist/esm}/core/instance/index.d.ts +23 -6
  10. package/{esm → dist/esm}/core/instance/index.js +75 -32
  11. package/{esm/config/index.js → dist/esm/index.d.ts} +15 -10
  12. package/{esm → dist/esm}/index.js +30 -8
  13. package/dist/esm/plugin/component/appPath.d.ts +2 -0
  14. package/dist/esm/plugin/component/appPath.js +75 -0
  15. package/{esm/plugin/component/component.inline.style.d.ts → dist/esm/plugin/component/component.style.d.ts} +1 -4
  16. package/dist/esm/plugin/component/component.style.js +15 -0
  17. package/{esm → dist/esm}/plugin/component/index.d.ts +45 -33
  18. package/{esm → dist/esm}/plugin/component/index.js +450 -316
  19. package/{esm → dist/esm}/plugin/drop-in/index.d.ts +9 -7
  20. package/{esm → dist/esm}/plugin/drop-in/index.js +3 -4
  21. package/{esm → dist/esm/request}/index.d.ts +8 -9
  22. package/{esm → dist/esm}/request/index.js +13 -11
  23. package/{esm → dist/esm}/request/utils.d.ts +3 -3
  24. package/{esm → dist/esm}/request/utils.js +4 -6
  25. package/dist/esm/service/index.d.ts +2 -0
  26. package/{esm → dist/esm}/types/index.d.ts +48 -116
  27. package/dist/esm/types/index.js +94 -0
  28. package/dist/esm/util/createIframeNode.d.ts +5 -0
  29. package/dist/esm/util/createIframeNode.js +35 -0
  30. package/{esm → dist/esm}/util/get.js +0 -7
  31. package/{esm → dist/esm}/util/index.d.ts +4 -6
  32. package/{esm → dist/esm}/util/index.js +13 -29
  33. package/dist/esm/util/mock.js +4 -0
  34. package/dist/umd/ams-checkout.min.js +1 -1
  35. package/package.json +1 -1
  36. package/esm/config/index.d.ts +0 -2
  37. package/esm/core/component/index.d.ts +0 -24
  38. package/esm/core/component/index.js +0 -211
  39. package/esm/core/drop-in/index.d.ts +0 -22
  40. package/esm/image/skeleton.svg +0 -18
  41. package/esm/plugin/component/cashierApp.d.ts +0 -23
  42. package/esm/plugin/component/cashierApp.js +0 -123
  43. package/esm/plugin/component/component.inline.style.js +0 -38
  44. package/esm/plugin/component/component.popup.style.d.ts +0 -12
  45. package/esm/plugin/component/component.popup.style.js +0 -165
  46. package/esm/request/index.d.ts +0 -8
  47. package/esm/service/index.d.ts +0 -2
  48. package/esm/types/index.js +0 -134
  49. package/esm/util/createIframeNode.d.ts +0 -5
  50. package/esm/util/createIframeNode.js +0 -42
  51. package/esm/util/mock.js +0 -3
  52. /package/{esm → dist/esm}/image/cta.svg +0 -0
  53. /package/{esm → dist/esm}/service/index.js +0 -0
  54. /package/{esm → dist/esm}/util/get.d.ts +0 -0
  55. /package/{esm → dist/esm}/util/intl-callapp/es/browser.d.ts +0 -0
  56. /package/{esm → dist/esm}/util/intl-callapp/es/browser.js +0 -0
  57. /package/{esm → dist/esm}/util/intl-callapp/es/evoke.d.ts +0 -0
  58. /package/{esm → dist/esm}/util/intl-callapp/es/evoke.js +0 -0
  59. /package/{esm → dist/esm}/util/intl-callapp/es/generate.d.ts +0 -0
  60. /package/{esm → dist/esm}/util/intl-callapp/es/generate.js +0 -0
  61. /package/{esm → dist/esm}/util/intl-callapp/es/index.d.ts +0 -0
  62. /package/{esm → dist/esm}/util/intl-callapp/es/index.js +0 -0
  63. /package/{esm → dist/esm}/util/intl-callapp/es/main.d.ts +0 -0
  64. /package/{esm → dist/esm}/util/intl-callapp/es/main.js +0 -0
  65. /package/{esm → dist/esm}/util/intl-callapp/es/openWallet.d.ts +0 -0
  66. /package/{esm → dist/esm}/util/intl-callapp/es/openWallet.js +0 -0
  67. /package/{esm → dist/esm}/util/intl-callapp/es/types.d.ts +0 -0
  68. /package/{esm → dist/esm}/util/intl-callapp/es/types.js +0 -0
  69. /package/{esm → dist/esm}/util/intl-callapp/es/utils/config.d.ts +0 -0
  70. /package/{esm → dist/esm}/util/intl-callapp/es/utils/config.js +0 -0
  71. /package/{esm → dist/esm}/util/intl-callapp/es/utils/index.d.ts +0 -0
  72. /package/{esm → dist/esm}/util/intl-callapp/es/utils/index.js +0 -0
  73. /package/{esm → dist/esm}/util/mock.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import type AMSCheckout from '../../core/instance';
2
- import type { IcreatePaymentParams, eventPayload } from '../../types';
2
+ import type { createPaymentParams, eventPlayload } from '../../types';
3
3
  export default class CheckoutApp {
4
4
  app: any;
5
5
  paymentMethodsResult: any;
@@ -16,11 +16,13 @@ export default class CheckoutApp {
16
16
  /**
17
17
  * @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
18
18
  */
19
- setRender(createIframeNode: any): void;
19
+ setRender(createIframeNode: (context: CheckoutApp, renderParams: {
20
+ selector: string | HTMLElement;
21
+ }) => Promise<void>): void;
20
22
  /**
21
23
  * @description High order function of rendering capability
22
24
  */
23
- render(renderParams: IcreatePaymentParams): Promise<void>;
25
+ render(renderParams: createPaymentParams): Promise<void>;
24
26
  /**
25
27
  * @description Cancel listening and destroy the dom
26
28
  */
@@ -47,15 +49,15 @@ export default class CheckoutApp {
47
49
  /**
48
50
  * @description Processing messages from iframe
49
51
  */
50
- _handleAppMessage(data: eventPayload): void;
52
+ _handleAppMessage(data: eventPlayload): void;
51
53
  /**
52
54
  * @description Send message to SDK
53
55
  */
54
- _dispatchToSDK(data: eventPayload): void;
56
+ _dispatchToSDK(data: eventPlayload): void;
55
57
  /**
56
58
  * @description Send message to iframe
57
59
  */
58
- _dispatchToApp(data: eventPayload): void;
60
+ _dispatchToApp(data: eventPlayload): void;
59
61
  /**
60
62
  * @description Subscribe to messages from SDK
61
63
  */
@@ -67,5 +69,5 @@ export default class CheckoutApp {
67
69
  /**
68
70
  * @description Send the post submission processing event, and the cashier applies the consumption result
69
71
  */
70
- _handleRequestPayment(data: eventPayload): void;
72
+ _handleRequestPayment(data: eventPlayload): void;
71
73
  }
@@ -11,7 +11,6 @@ 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 */
15
14
  import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
16
15
  import { messageName } from "../../types";
17
16
  import { getOrigin, getType, getViewPort, isDom, isJsonString, serialize } from "../../util";
@@ -186,7 +185,7 @@ var CheckoutApp = /*#__PURE__*/function () {
186
185
  id = 'checkout-dropin';
187
186
  break;
188
187
  case 'COMPONENT':
189
- id = 'ams-checkout-component';
188
+ id = 'checkout-component';
190
189
  break;
191
190
  }
192
191
  return id;
@@ -265,7 +264,7 @@ var CheckoutApp = /*#__PURE__*/function () {
265
264
  appId: BASEPLUGINID,
266
265
  instanceId: this.AMSSDK._instanceId
267
266
  }, data);
268
- this.AMSSDK._eventCenter.emit("".concat(BASEPLUGINID, "-").concat(data.context.event), _data);
267
+ this.AMSSDK.eventCenter.emit("".concat(BASEPLUGINID, "-").concat(data.context.event), _data);
269
268
  }
270
269
  /**
271
270
  * @description Send message to iframe
@@ -289,7 +288,7 @@ var CheckoutApp = /*#__PURE__*/function () {
289
288
  for (var key in eventKeyMap) {
290
289
  // eslint-disable-next-line no-prototype-builtins
291
290
  if (eventKeyMap.hasOwnProperty(key)) {
292
- this.AMSSDK._eventCenter.on("".concat(BASEPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
291
+ this.AMSSDK.eventCenter.on("".concat(BASEPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
293
292
  }
294
293
  }
295
294
  }
@@ -5,12 +5,11 @@
5
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
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
7
  */
8
- import { AMSComponent } from './core/component/index';
9
- import { IoptionsParams } from './types';
10
- export * from './types';
11
- export declare class AMSCheckout extends AMSComponent {
12
- }
13
- export declare class AMSAutoDebit extends AMSCheckout {
14
- constructor(options: IoptionsParams);
15
- }
16
- export default AMSCheckout;
8
+ import { RequestConfig } from '../types';
9
+ /**
10
+ *
11
+ * @param requestData 请求参数
12
+ * @param options 请求配置
13
+ * @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
14
+ */
15
+ export declare function request(requestData: Record<string, any> | undefined, options: RequestConfig): Promise<any>;
@@ -14,12 +14,12 @@ 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
- /* eslint-disable @typescript-eslint/no-explicit-any */
18
- import { sdkVersion } from "../config/index";
19
- import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
20
- import { errorEnum } from "../types";
17
+
18
+ import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config";
19
+ import { ERROR } from "../types";
21
20
  import { get } from "../util/get";
22
21
  import axios from 'axios';
22
+ import json from "../../package.json";
23
23
  import { device, fomatGetwayError, isPC, queryParse, safeJson } from "../util";
24
24
  var _queryParse = queryParse(),
25
25
  _sandbox = _queryParse._sandbox;
@@ -35,7 +35,7 @@ function requestInstance(options) {
35
35
  var _headers = _objectSpread((_objectSpread2 = {
36
36
  appId: lightSandboxConfig.appId || appId,
37
37
  workspaceId: options.env === 'pre' ? 'pre' : 'default'
38
- }, _defineProperty(_objectSpread2, "x-cors-".concat(appId.toLowerCase(), "-default"), '1'), _defineProperty(_objectSpread2, "version", '2.0'), _defineProperty(_objectSpread2, 'sofa-group-name', lightSandboxConfig.sofaId || sofaId), _defineProperty(_objectSpread2, 'Operation-Type', lightSandboxConfig['Operation-Type'] || options['Operation-Type'] || ''), _defineProperty(_objectSpread2, 'Client-Time', utcTimestamp), _defineProperty(_objectSpread2, "tntInstId", tntInstId), _defineProperty(_objectSpread2, 'sdk-version', sdkVersion || ''), _objectSpread2), options.headers);
38
+ }, _defineProperty(_objectSpread2, "x-cors-".concat(appId.toLowerCase(), "-default"), '1'), _defineProperty(_objectSpread2, "version", '2.0'), _defineProperty(_objectSpread2, 'sofa-group-name', lightSandboxConfig.sofaId || sofaId), _defineProperty(_objectSpread2, 'Operation-Type', lightSandboxConfig['Operation-Type'] || options['Operation-Type'] || ''), _defineProperty(_objectSpread2, 'Client-Time', utcTimestamp), _defineProperty(_objectSpread2, "tntInstId", tntInstId), _defineProperty(_objectSpread2, 'sdk-version', json.version || ''), _objectSpread2), options.headers);
39
39
  // sandbox 影子链路
40
40
  if (_sandbox === 'true' || env === 'sandbox') {
41
41
  _headers['load-test'] = true;
@@ -77,7 +77,7 @@ function _request() {
77
77
  browserUserAgent: navigator.userAgent,
78
78
  browserColorDepth: screen.colorDepth
79
79
  },
80
- locale: options.locale || 'en_US',
80
+ locale: window._amsSdkLanguage || 'en_US',
81
81
  deviceLanguage: navigator.language,
82
82
  screenWidth: screen.width,
83
83
  screenHeight: screen.height,
@@ -121,19 +121,21 @@ function _request() {
121
121
  case 21:
122
122
  _context.prev = 21;
123
123
  _context.t0 = _context["catch"](6);
124
+ // eslint-disable-next-line no-console
125
+ console.log('request error', _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message);
124
126
  _error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
125
127
  success: false,
126
- errorCode: errorEnum.SYSTEM,
128
+ errorCode: ERROR.SYSTEM,
127
129
  errorMessage: ''
128
130
  });
129
- timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
131
+ timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? ERROR.TIMEOUT : '';
130
132
  errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
131
- return _context.abrupt("return", Promise.reject({
133
+ return _context.abrupt("return", {
132
134
  success: false,
133
135
  errorCode: errorCode,
134
136
  errorMessage: ''
135
- }));
136
- case 27:
137
+ });
138
+ case 28:
137
139
  case "end":
138
140
  return _context.stop();
139
141
  }
@@ -5,19 +5,19 @@
5
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
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
7
  */
8
- import { errorEnum } from '../types';
8
+ import { ERROR } from '../types';
9
9
  export declare const safeJson: (data: any, obj: any) => any;
10
10
  export declare const fomatGetwayError: (headers: Record<string, any>, traceId: string) => {
11
11
  success: boolean;
12
12
  traceId: string;
13
- errorCode: errorEnum;
13
+ errorCode: ERROR;
14
14
  resultStatus: any;
15
15
  errorMessage?: undefined;
16
16
  result?: undefined;
17
17
  } | {
18
18
  success: boolean;
19
19
  traceId: string;
20
- errorCode: errorEnum;
20
+ errorCode: ERROR;
21
21
  errorMessage: string;
22
22
  result: {
23
23
  resultStatus: any;
@@ -6,10 +6,8 @@
6
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
7
  */
8
8
 
9
- import { errorEnum } from "../types";
9
+ import { ERROR } from "../types";
10
10
  import { get } from "../util/get";
11
-
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
11
  export var safeJson = function safeJson(data, obj) {
14
12
  try {
15
13
  return JSON.parse(data) || obj;
@@ -28,7 +26,7 @@ export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
28
26
  return {
29
27
  success: false,
30
28
  traceId: traceId,
31
- errorCode: errorEnum.LOGIN,
29
+ errorCode: ERROR.LOGIN,
32
30
  resultStatus: resultStatus
33
31
  };
34
32
  }
@@ -37,7 +35,7 @@ export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
37
35
  return {
38
36
  success: false,
39
37
  traceId: traceId,
40
- errorCode: errorEnum.TIMEOUT,
38
+ errorCode: ERROR.TIMEOUT,
41
39
  resultStatus: resultStatus
42
40
  };
43
41
  }
@@ -47,7 +45,7 @@ export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
47
45
  return {
48
46
  success: false,
49
47
  traceId: traceId,
50
- errorCode: errorEnum.GATEWAY,
48
+ errorCode: ERROR.GATEWAY,
51
49
  errorMessage: decodeURIComponent(tips || ''),
52
50
  result: {
53
51
  resultStatus: resultStatus || '',
@@ -0,0 +1,2 @@
1
+ import { RequestConfig } from '../types';
2
+ export declare function queryPaymentInfo(params?: Record<string, any>, options?: RequestConfig): Promise<any>;
@@ -8,41 +8,35 @@
8
8
  /**
9
9
  * SDK options
10
10
  */
11
- export interface IoptionsParams {
11
+ export interface optionsParams {
12
12
  environment?: string;
13
13
  locale?: string;
14
+ onReady?: any;
14
15
  onError?: callOnError;
15
16
  onSizeChanged?: callOnSizeChanged;
16
17
  onPaymentMethodSelected?: callonPaymentMethodSelected;
17
18
  onLog?: callOnLog;
18
- onEventCallback?: callOnEventCallback;
19
- onClose?: callOnClose;
19
+ onEventCallback?: (state: any) => void;
20
+ onClose?: () => void;
20
21
  networkMode?: string;
21
22
  mode?: string;
22
23
  analytics?: {
23
24
  enabled: boolean;
24
25
  };
25
26
  }
26
- export type Iselector = string;
27
- export declare enum renderDisplayTypeEnum {
28
- 'popup' = "popup",
29
- 'inline' = "inline"
30
- }
31
- export interface IcreatePaymentParams {
27
+ export interface createPaymentParams {
32
28
  paymentMethodsResult?: any;
33
29
  paymentSessionData?: string;
34
- selector: Iselector;
30
+ selector: string | HTMLElement;
35
31
  appearance?: {
36
- displayType?: checkoutDisplayEnum;
32
+ displayType?: checkoutDisplay;
37
33
  backgroundColor?: string;
38
34
  };
39
35
  }
40
- export declare enum componentSignEnum {
41
- 'EASY_PAY_WALLET' = "EASY_PAY_WALLET",
42
- 'CASHIER_PAYMENT_CARD' = "CASHIER_PAYMENT_CARD",
43
- 'CASHIER_PAYMENT_BANK' = "CASHIER_PAYMENT_BANK",
44
- 'AUTO_DEBIT_WALLET' = "AUTO_DEBIT_WALLET",
45
- 'NONE' = "NONE"
36
+ export declare enum componentNameEnum {
37
+ 'card' = "card",
38
+ 'easyPay' = "easyPay",
39
+ 'autoDebit' = "autoDebit"
46
40
  }
47
41
  export declare enum productSceneEnum {
48
42
  'EASY_PAY' = "EASY_PAY",
@@ -51,25 +45,22 @@ export declare enum productSceneEnum {
51
45
  }
52
46
  export declare enum paymentMethodCategoryTypeEnum {
53
47
  'CARD' = "CARD",
54
- 'WALLET' = "WALLET",
55
- 'BANK' = "BANK"
48
+ 'WALLET' = "WALLET"
56
49
  }
57
50
  export interface IcreateComponent {
58
51
  paymentSessionData: string;
52
+ selector?: string | HTMLElement;
59
53
  appearance?: Record<string, any>;
60
54
  }
61
55
  export interface IappendIframeNodesParams extends IcreateComponent {
62
- paymentSessionMetaData: IpaymentSessionMetaData;
63
- renderDisplayType: renderDisplayTypeEnum;
64
- selector?: Iselector;
65
- }
66
- interface IpaymentSessionConfig {
67
- productScene: productSceneEnum;
68
- paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
69
- productSceneVersion: string;
56
+ paymentSessionMetaData?: IpaymentSessionMetaData;
70
57
  }
71
58
  export interface IpaymentSessionMetaData {
72
- paymentSessionConfig?: IpaymentSessionConfig;
59
+ paymentSessionConfig?: {
60
+ productScene: productSceneEnum;
61
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
62
+ productSceneVersion?: string;
63
+ };
73
64
  moneyView?: any;
74
65
  extendInfo?: string;
75
66
  paymentMethodInfoView?: any;
@@ -80,111 +71,81 @@ export interface IpaymentSessionMetaData {
80
71
  export declare enum localeEnum {
81
72
  'en-US' = "en-US"
82
73
  }
83
- export declare enum checkoutDisplayEnum {
74
+ export declare enum checkoutDisplay {
84
75
  horizon = "horizon",
85
76
  vertical = "vertical"
86
77
  }
87
- export declare enum modeEnum {
78
+ export declare enum mode {
88
79
  dropin = "dropin",
89
80
  component = "component"
90
81
  }
91
- export declare enum networkModeEnum {
82
+ export declare enum networkMode {
92
83
  proxy = "proxy",
93
84
  session = "session"
94
85
  }
95
- export interface IcheckoutState {
96
- paymentMethodType?: string;
86
+ export interface checkoutState {
87
+ paymentMethodType: string;
97
88
  }
98
- export declare enum environmentEnum {
89
+ export declare enum environment {
99
90
  sandbox = "sandbox",
100
91
  prod = "prod",
101
92
  light_sandbox = "light_sandbox"
102
93
  }
103
- export declare enum osTypeEnum {
94
+ export declare enum osType {
104
95
  IOS = "IOS",
105
96
  ANDROID = "ANDROID",
106
97
  ELSE = "ELSE"
107
98
  }
108
- export declare enum terminalTypeEnum {
99
+ export declare enum terminalType {
109
100
  WEB = "WEB",
110
101
  WAP = "WAP",
111
102
  APP = "APP",
112
103
  MINI_APP = "MINI_APP"
113
104
  }
114
- export interface Ienv {
115
- osType?: osTypeEnum;
116
- terminalType: terminalTypeEnum;
105
+ export interface env {
106
+ osType?: osType;
107
+ terminalType: terminalType;
117
108
  environment: string;
118
109
  }
119
- export declare enum platformEnum {
120
- desktop = "desktop",
121
- mobile = "mobile"
122
- }
123
- /**
124
- * @description Create an event handler, called when an error occurs in AMSCheckout.
125
- */
126
110
  export type callOnError = (state: {
127
- code: string;
128
- message: string;
111
+ errorMessage: string;
112
+ errorCode: string;
129
113
  stack?: any;
130
114
  }) => void;
131
- /**
132
- * @description Create an event handler, called when the general log triggers during the SDK runtime.
133
- */
134
- export type callOnLog = (state: {
135
- code: string;
136
- message: string;
137
- }) => void;
138
- /**
139
- * @description Create an event handler, during the running of the sdk, some events are called after execution, and the specific event code is returned.
140
- */
141
- export type callOnEventCallback = (state: {
142
- code: string;
143
- message: string;
144
- }) => void;
145
115
  export type callonPaymentMethodSelected = (state: {
146
116
  paymentMethodType: string;
147
117
  }) => void;
148
118
  export type callOnSizeChanged = (state: {
149
- width: number;
150
- height: number;
119
+ width: string;
120
+ height: string;
151
121
  }) => void;
152
- /**
153
- * @description Create an event handler, In pop-up layer mode, the user clicks the semi floating layer close button and is called.
154
- */
155
- export type callOnClose = () => void;
122
+ export type callOnLog = (msg: string) => void;
156
123
  export declare enum messageName {
157
124
  SDK_TO_APP = "SDK_TO_APP",
158
125
  APP_TO_SDK = "APP_TO_SDK",
159
126
  APP_TO_APP = "APP_TO_APP"
160
127
  }
161
- export interface eventPayload {
128
+ export interface eventPlayload {
162
129
  name: messageName;
163
130
  mode?: string;
164
131
  appId?: string;
165
132
  instanceId: string;
166
- context: eventPayloadContext;
167
- }
168
- export interface eventPayloadContext {
169
- event: string;
170
- data: any;
171
- eventCallbackId?: string;
133
+ context: {
134
+ event: string;
135
+ data: any;
136
+ };
172
137
  }
173
138
  export interface AMSCheckoutOptions {
174
- env: Ienv;
139
+ env: env;
175
140
  locale: string;
176
141
  networkMode: string;
177
142
  mode: string;
178
143
  analytics?: Ianalytics;
179
144
  }
180
- export interface Ianalytics {
145
+ interface Ianalytics {
181
146
  enabled: boolean;
182
147
  }
183
- export declare enum targetEnum {
184
- BLANK = "_blank",
185
- SELF = "_self"
186
- }
187
- export declare enum errorEnum {
148
+ export declare enum ERROR {
188
149
  PARAMS = "PARAMS",
189
150
  TIMEOUT = "TIMEOUT",
190
151
  NETWORK = "NETWORK",
@@ -199,7 +160,7 @@ export declare enum errorEnum {
199
160
  SIGNIN = "SIGNIN",
200
161
  GETSIGNPARAMSERROR = "GETSIGNPARAMSERROR"
201
162
  }
202
- export interface IrequestConfig {
163
+ export interface RequestConfig {
203
164
  env?: string;
204
165
  baseURL?: string;
205
166
  timeout?: number;
@@ -214,42 +175,13 @@ export interface IrequestConfig {
214
175
  locale?: string;
215
176
  hostSign?: string;
216
177
  }
217
- export interface CashierSdkActionQueryRequest {
218
- paymentSessionData: string;
219
- paymentSessionConfig?: IpaymentSessionConfig;
220
- paymentMethodType?: string;
221
- extParams?: any;
222
- }
223
- export interface CashierSdkActionQueryResult {
224
- supportedLanguages?: any[];
225
- amountConfirmRequired?: boolean;
226
- orderAmount?: Record<string, string>;
227
- paymentMethodView?: Record<string, string>;
228
- autoDebitWithToken?: boolean;
229
- success: boolean;
230
- errorCode?: string;
231
- errorMessage?: string;
232
- message?: string;
233
- errorStatus?: string;
234
- redirectUrl?: string;
235
- normalUrl?: string;
236
- applinkUrl?: string;
237
- schemeUrl?: string;
238
- authUrl?: string;
239
- }
240
- export declare enum eventCodeEnum {
241
- SDK_START_OF_LOADING = "SDK_START_OF_LOADING",
242
- SDK_END_OF_LOADING = "SDK_END_OF_LOADING",
243
- SDK_INTERNAL_ERROR = "SDK_INTERNAL_ERROR",
244
- SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR",
245
- SDK_INIT_PARAMETER_ERROR = "SDK_INIT_PARAMETER_ERROR",
246
- SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
247
- SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
248
- SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS"
249
- }
250
178
  declare global {
251
179
  interface Window {
252
180
  [key: string]: any;
253
181
  }
254
182
  }
183
+ export declare enum Target {
184
+ BLANK = "_blank",
185
+ SELF = "_self"
186
+ }
255
187
  export {};
@@ -0,0 +1,94 @@
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
+
9
+ /**
10
+ * SDK options
11
+ */
12
+
13
+ export var componentNameEnum = /*#__PURE__*/function (componentNameEnum) {
14
+ componentNameEnum["card"] = "card";
15
+ componentNameEnum["easyPay"] = "easyPay";
16
+ componentNameEnum["autoDebit"] = "autoDebit";
17
+ return componentNameEnum;
18
+ }({});
19
+ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
20
+ productSceneEnum["EASY_PAY"] = "EASY_PAY";
21
+ productSceneEnum["CASHIER_PAYMENT"] = "CASHIER_PAYMENT";
22
+ productSceneEnum["AUTO_DEBIT"] = "AUTO_DEBIT";
23
+ return productSceneEnum;
24
+ }({});
25
+ export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodCategoryTypeEnum) {
26
+ paymentMethodCategoryTypeEnum["CARD"] = "CARD";
27
+ paymentMethodCategoryTypeEnum["WALLET"] = "WALLET";
28
+ return paymentMethodCategoryTypeEnum;
29
+ }({});
30
+ export var localeEnum = /*#__PURE__*/function (localeEnum) {
31
+ localeEnum["en-US"] = "en-US";
32
+ return localeEnum;
33
+ }({});
34
+ export var checkoutDisplay = /*#__PURE__*/function (checkoutDisplay) {
35
+ checkoutDisplay["horizon"] = "horizon";
36
+ checkoutDisplay["vertical"] = "vertical";
37
+ return checkoutDisplay;
38
+ }({});
39
+ export var mode = /*#__PURE__*/function (mode) {
40
+ mode["dropin"] = "dropin";
41
+ mode["component"] = "component";
42
+ return mode;
43
+ }({});
44
+ export var networkMode = /*#__PURE__*/function (networkMode) {
45
+ networkMode["proxy"] = "proxy";
46
+ networkMode["session"] = "session";
47
+ return networkMode;
48
+ }({});
49
+ export var environment = /*#__PURE__*/function (environment) {
50
+ environment["sandbox"] = "sandbox";
51
+ environment["prod"] = "prod";
52
+ environment["light_sandbox"] = "light_sandbox";
53
+ return environment;
54
+ }({});
55
+ export var osType = /*#__PURE__*/function (osType) {
56
+ osType["IOS"] = "IOS";
57
+ osType["ANDROID"] = "ANDROID";
58
+ osType["ELSE"] = "ELSE";
59
+ return osType;
60
+ }({});
61
+ export var terminalType = /*#__PURE__*/function (terminalType) {
62
+ terminalType["WEB"] = "WEB";
63
+ terminalType["WAP"] = "WAP";
64
+ terminalType["APP"] = "APP";
65
+ terminalType["MINI_APP"] = "MINI_APP";
66
+ return terminalType;
67
+ }({});
68
+ export var messageName = /*#__PURE__*/function (messageName) {
69
+ messageName["SDK_TO_APP"] = "SDK_TO_APP";
70
+ messageName["APP_TO_SDK"] = "APP_TO_SDK";
71
+ messageName["APP_TO_APP"] = "APP_TO_APP";
72
+ return messageName;
73
+ }({});
74
+ export var ERROR = /*#__PURE__*/function (ERROR) {
75
+ ERROR["PARAMS"] = "PARAMS";
76
+ ERROR["TIMEOUT"] = "TIMEOUT";
77
+ ERROR["NETWORK"] = "NETWORK";
78
+ ERROR["SYSTEM"] = "SYSTEM";
79
+ ERROR["LOGIN"] = "LOGIN";
80
+ ERROR["GATEWAY"] = "GATEWAY";
81
+ ERROR["VALIDATION"] = "VALIDATION";
82
+ ERROR["TAOBAOBINDALIPAY"] = "TAOBAOBINDALIPAY";
83
+ ERROR["REGISTERWALLET"] = "REGISTERWALLET";
84
+ ERROR["NOALIPAYID"] = "NOALIPAYID";
85
+ ERROR["TRUSTLOGINERROR"] = "TRUSTLOGINERROR";
86
+ ERROR["SIGNIN"] = "SIGNIN";
87
+ ERROR["GETSIGNPARAMSERROR"] = "GETSIGNPARAMSERROR";
88
+ return ERROR;
89
+ }({});
90
+ export var Target = /*#__PURE__*/function (Target) {
91
+ Target["BLANK"] = "_blank";
92
+ Target["SELF"] = "_self";
93
+ return Target;
94
+ }({});
@@ -0,0 +1,5 @@
1
+ import { createPaymentParams, IcreateComponent } from '../types';
2
+ /**
3
+ * @description context中需要包含app节点,用于插入params.selector中
4
+ */
5
+ export declare const createIframeNode: (context: any, params: createPaymentParams | IcreateComponent) => Promise<void>;
@@ -0,0 +1,35 @@
1
+ import { getType } from '.';
2
+ import { ERRORMESSAGE, EVENT } from "../constant";
3
+ import { messageName } from "../types";
4
+ /**
5
+ * @description context中需要包含app节点,用于插入params.selector中
6
+ */
7
+ export var createIframeNode = function createIframeNode(context, params) {
8
+ return new Promise(function (resolve, reject) {
9
+ var dorpinDom = null;
10
+ if (getType(params.selector) === 'string') {
11
+ dorpinDom = document.querySelector(params.selector);
12
+ }
13
+ if (dorpinDom === null) {
14
+ var error = {
15
+ errorCode: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.errorCode,
16
+ errorMessage: "Failed to execute 'querySelector' on 'Document': ".concat(params.selector, " is not a valid selector")
17
+ };
18
+ reject(error);
19
+ context._dispatchToSDK({
20
+ name: messageName.APP_TO_SDK,
21
+ instanceId: context.AMSSDK._instanceId,
22
+ context: {
23
+ event: EVENT.error.name,
24
+ data: error
25
+ }
26
+ });
27
+ return;
28
+ }
29
+ dorpinDom.innerHTML = '';
30
+ if (context.app) {
31
+ dorpinDom.appendChild(context.app);
32
+ }
33
+ resolve();
34
+ });
35
+ };
@@ -1,11 +1,4 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- /**
3
- * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
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
- /* eslint-disable @typescript-eslint/no-explicit-any */
9
2
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
3
  // @ts-nocheck
11
4
  var charCodeOfDot = '.'.charCodeAt(0);