@alipay/ams-checkout 0.0.1758783821-dev.1 → 0.0.1758783821-dev.13

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 (60) hide show
  1. package/README.md +17 -1
  2. package/dist/umd/ams-checkout.min.js +1 -1
  3. package/esm/component/popupWindow.style.d.ts +1 -0
  4. package/esm/component/popupWindow.style.js +5 -2
  5. package/esm/config/index.d.ts +1 -0
  6. package/esm/config/index.js +2 -1
  7. package/esm/config/request.js +14 -2
  8. package/esm/constant/index.d.ts +33 -12
  9. package/esm/constant/index.js +43 -18
  10. package/esm/core/component/element/EventCenter/index.d.ts +3 -1
  11. package/esm/core/component/element/EventCenter/index.js +48 -11
  12. package/esm/core/component/element/elementContainerService/containerService.d.ts +1 -0
  13. package/esm/core/component/element/elementContainerService/containerService.js +5 -0
  14. package/esm/core/component/element/elementController/index.d.ts +3 -8
  15. package/esm/core/component/element/elementController/index.js +152 -66
  16. package/esm/core/component/element/elementProcessor/addressProcessor.js +2 -3
  17. package/esm/core/component/element/elementProcessor/authProcessor.js +2 -3
  18. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +2 -0
  19. package/esm/core/component/element/elementProcessor/paymentProcessor.js +36 -6
  20. package/esm/core/component/element/index.d.ts +3 -10
  21. package/esm/core/component/element/index.js +4 -1
  22. package/esm/core/component/element/mock.js +1 -0
  23. package/esm/core/component/element/type.d.ts +26 -6
  24. package/esm/core/component/element/type.js +18 -0
  25. package/esm/core/component/element/util.d.ts +6 -3
  26. package/esm/core/component/element/util.js +15 -2
  27. package/esm/foundation/core/index.js +28 -8
  28. package/esm/foundation/index.d.ts +1 -0
  29. package/esm/foundation/product-processor/easysafepay/index.js +4 -2
  30. package/esm/foundation/product-processor/element/index.js +1 -0
  31. package/esm/foundation/service/log/keys.js +2 -0
  32. package/esm/foundation/utils/payment_context_utils.js +1 -0
  33. package/esm/index.js +2 -1
  34. package/esm/plugin/component/cashierApp.d.ts +2 -0
  35. package/esm/plugin/component/cashierApp.js +2 -2
  36. package/esm/plugin/component/channel.js +20 -5
  37. package/esm/plugin/component/component.popup.style.d.ts +1 -0
  38. package/esm/plugin/component/component.popup.style.js +1 -1
  39. package/esm/plugin/component/index.d.ts +1 -0
  40. package/esm/plugin/component/index.js +9 -5
  41. package/esm/types/index.d.ts +18 -2
  42. package/esm/types/index.js +2 -1
  43. package/esm/util/index.js +4 -1
  44. package/esm/util/spm-map.d.ts +22 -2
  45. package/esm/util/spm-map.js +13 -1
  46. package/package.json +12 -7
  47. package/esm/core/component/oldElement/components/address.d.ts +0 -19
  48. package/esm/core/component/oldElement/components/address.js +0 -68
  49. package/esm/core/component/oldElement/components/auth.d.ts +0 -17
  50. package/esm/core/component/oldElement/components/auth.js +0 -60
  51. package/esm/core/component/oldElement/components/payment.d.ts +0 -19
  52. package/esm/core/component/oldElement/components/payment.js +0 -74
  53. package/esm/core/component/oldElement/index.d.ts +0 -59
  54. package/esm/core/component/oldElement/index.js +0 -956
  55. package/esm/core/component/oldElement/mock.d.ts +0 -6
  56. package/esm/core/component/oldElement/mock.js +0 -567
  57. package/esm/core/component/oldElement/type.d.ts +0 -354
  58. package/esm/core/component/oldElement/type.js +0 -81
  59. package/esm/core/component/oldElement/utils.d.ts +0 -13
  60. package/esm/core/component/oldElement/utils.js +0 -6
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { IApplePayContactField } from '../plugin/applepay/interface';
9
9
  export type onChange = () => onCnageResult;
10
- export { ElementType, PaymentElementLayout, ThemeType, type IElementOptions, } from '../core/component/oldElement/type';
10
+ export { type IElementOptions, ElementType, PaymentElementLayout, ThemeType } from '../core/component/element/type';
11
11
  interface onCnageResult {
12
12
  complete: boolean;
13
13
  addressValue: AddressItem[];
@@ -123,6 +123,7 @@ export interface IcreateComponent {
123
123
  };
124
124
  isAppWebview?: boolean;
125
125
  merchantAppointParam?: IMerchantAppointParam;
126
+ isNativeAppWebview?: boolean;
126
127
  }
127
128
  export interface IappendIframeNodesParams extends IcreateComponent {
128
129
  paymentSessionMetaData: IPaymentSessionMetaData;
@@ -425,6 +426,11 @@ export type EventCallbackResult = {
425
426
  resultStatus: string;
426
427
  resultMessage: string;
427
428
  };
429
+ redirectUrls?: {
430
+ applinkUrl?: string;
431
+ schemeUrl?: string;
432
+ normalUrl?: string;
433
+ };
428
434
  paymentResultCode?: string;
429
435
  paymentResultMessage?: string;
430
436
  paymentStatus?: string;
@@ -598,6 +604,7 @@ export interface CashierSdkActionQueryResult {
598
604
  paymentAmountView?: IAmountView;
599
605
  paymentMethods?: IPaymentMethod[];
600
606
  savedPaymentMethods?: IPaymentMethod[];
607
+ traceId?: string;
601
608
  }
602
609
  export interface CashierSdkActionQuerySessionResult extends IPaymentSessionMetaData {
603
610
  success: boolean;
@@ -678,7 +685,11 @@ export declare enum eventCodeEnum {
678
685
  SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING",
679
686
  SDK_PAYMENT_WARN = "SDK_PAYMENT_WARN",
680
687
  SDK_PAYMENT_SHIPPINGCHANGE = "SDK_PAYMENT_SHIPPINGCHANGE",
681
- SDK_PAYMENT_APPROVE = "SDK_PAYMENT_APPROVE"
688
+ SDK_PAYMENT_APPROVE = "SDK_PAYMENT_APPROVE",
689
+ /**
690
+ * ESP createComponent时传参isNativeAppWebview:true,ESP外跳授权时透传此SDK给商户
691
+ */
692
+ SDK_REDIRECT = "SDK_REDIRECT"
682
693
  }
683
694
  export declare enum RedirectType {
684
695
  ApplinkUrl = "ApplinkUrl",
@@ -836,3 +847,8 @@ export declare enum EventLoggingEventId {
836
847
  LeaveAnyWay = "LeaveAnyWay",
837
848
  ContinuePaying = "ContinuePaying"
838
849
  }
850
+ export interface ErrorMessage {
851
+ code: string;
852
+ message: string;
853
+ [key: string]: ErrorMessage | string;
854
+ }
@@ -8,7 +8,7 @@
8
8
 
9
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
10
10
 
11
- export { ElementType, PaymentElementLayout, ThemeType } from "../core/component/oldElement/type";
11
+ export { ElementType, PaymentElementLayout, ThemeType } from "../core/component/element/type";
12
12
 
13
13
  /**
14
14
  * SDK options
@@ -194,6 +194,7 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
194
194
  eventCodeEnum["SDK_PAYMENT_WARN"] = "SDK_PAYMENT_WARN";
195
195
  eventCodeEnum["SDK_PAYMENT_SHIPPINGCHANGE"] = "SDK_PAYMENT_SHIPPINGCHANGE";
196
196
  eventCodeEnum["SDK_PAYMENT_APPROVE"] = "SDK_PAYMENT_APPROVE";
197
+ eventCodeEnum["SDK_REDIRECT"] = "SDK_REDIRECT";
197
198
  return eventCodeEnum;
198
199
  }({});
199
200
  export var RedirectType = /*#__PURE__*/function (RedirectType) {
package/esm/util/index.js CHANGED
@@ -90,7 +90,7 @@ var EventCenter = /*#__PURE__*/function () {
90
90
  }
91
91
  }]);
92
92
  return EventCenter;
93
- }();
93
+ }(); // TODO 直接访问 meta.viewPort 可能不正确,标准的meta viewport应该通过name属性查找
94
94
  var getViewPort = function getViewPort(key) {
95
95
  var meta = document.getElementsByTagName('meta');
96
96
  // HTMLMetaElement
@@ -150,6 +150,7 @@ var isWindowsNT = /Windows NT/.test(UA);
150
150
  var isMobile = function isMobile() {
151
151
  return /Android|iPhone|iPad|iPod|Mobile/.test(UA) || isOpenHarmonyMobile();
152
152
  };
153
+ // TODO 未导出
153
154
  var isOpenHarmony = function isOpenHarmony() {
154
155
  // 检查是否为鸿蒙操作系统
155
156
  return /OpenHarmony/i.test(navigator.userAgent);
@@ -164,6 +165,7 @@ var isOpenHarmonyMobile = function isOpenHarmonyMobile() {
164
165
  // 返回是否为鸿蒙手机或平板
165
166
  return isHarmonyOS && (isPhone || isTablet);
166
167
  };
168
+ // TODO 未导出
167
169
  var isOpenHarmonyPC = function isOpenHarmonyPC() {
168
170
  // 检查是否为鸿蒙操作系统
169
171
  return /OpenHarmony/i.test(navigator.userAgent) && /PC/i.test(navigator.userAgent);
@@ -332,6 +334,7 @@ function loadSDKScript(_ref, logger) {
332
334
  reject(false);
333
335
  };
334
336
  timer = setTimeout(function () {
337
+ // TODO 直接使用 logger 参数,而不是 this.logger
335
338
  _this2.logger.logError({
336
339
  title: 'load_item_sdk_timeout'
337
340
  }, {
@@ -8,6 +8,17 @@ export declare const ELEMENT_SPM_MAP: {
8
8
  auto_apple_pay_failed: string;
9
9
  auto_apple_pay_success: string;
10
10
  sdk_element_handleHeartBeat: string;
11
+ sdk_element_handleInterAction: string;
12
+ sdk_element_callback_error: string;
13
+ sdk_element_missKeyData: string;
14
+ sdk_event_mount: string;
15
+ sdk_event_mount_end: string;
16
+ sdk_event_submitPay: string;
17
+ sdk_event_payment_end: string;
18
+ sdk_event_validateFields: string;
19
+ sdk_event_validateFields_end: string;
20
+ sdk_event_apiOnDestroy: string;
21
+ sdk_event_apiOnDestroy_end: string;
11
22
  };
12
23
  export declare const SPM_MAP: {
13
24
  sdk_event_mount_element: string;
@@ -19,6 +30,17 @@ export declare const SPM_MAP: {
19
30
  auto_apple_pay_failed: string;
20
31
  auto_apple_pay_success: string;
21
32
  sdk_element_handleHeartBeat: string;
33
+ sdk_element_handleInterAction: string;
34
+ sdk_element_callback_error: string;
35
+ sdk_element_missKeyData: string;
36
+ sdk_event_mount: string;
37
+ sdk_event_mount_end: string;
38
+ sdk_event_submitPay: string;
39
+ sdk_event_payment_end: string;
40
+ sdk_event_validateFields: string;
41
+ sdk_event_validateFields_end: string;
42
+ sdk_event_apiOnDestroy: string;
43
+ sdk_event_apiOnDestroy_end: string;
22
44
  sdk_error_runtime_error: string;
23
45
  sdk_event_sdkQuery_failed: string;
24
46
  container_error_error_insert_js: string;
@@ -65,7 +87,6 @@ export declare const SPM_MAP: {
65
87
  container_event_webViewOnPageFinished: string;
66
88
  container_event_page_load_success: string;
67
89
  sdk_event_pre_init: string;
68
- sdk_event_submitPay: string;
69
90
  sdk_event_submitPayEnd: string;
70
91
  container_stop_event_loop: string;
71
92
  iap_net_start: string;
@@ -89,7 +110,6 @@ export declare const SPM_MAP: {
89
110
  sdk_event_api_onDestroy: string;
90
111
  container_load_failed: string;
91
112
  sdk_event_kycAppPreLoadStart: string;
92
- sdk_event_apiOnDestroy: string;
93
113
  sdk_event_getRemoteConfigResult: string;
94
114
  iap_net_result: string;
95
115
  sdk_event_popupWindowCloseButtonClick: string;
@@ -15,7 +15,19 @@ export var ELEMENT_SPM_MAP = {
15
15
  auto_apple_pay_start: 'a3753.b107385.c398110',
16
16
  auto_apple_pay_failed: 'a3753.b107385.c398111',
17
17
  auto_apple_pay_success: 'a3753.b107385.c398112',
18
- sdk_element_handleHeartBeat: 'a3753.b101271.c388217.d624449'
18
+ sdk_element_handleHeartBeat: 'a3753.b101271.c388217.d624449',
19
+ sdk_element_handleInterAction: 'a3753.b101271.c388217.d630402',
20
+ sdk_element_callback_error: 'a3753.b101271.c388217.d630403',
21
+ sdk_element_missKeyData: 'a3753.b101271.c388217.d630404',
22
+ // 后续移除SPM,SDK埋点没有享受到SPM收益
23
+ sdk_event_mount: 'a3753.b101271.c388217.d640404',
24
+ sdk_event_mount_end: 'a3753.b101271.c388217.d640405',
25
+ sdk_event_submitPay: 'a3753.b101271.c388193.d512422',
26
+ sdk_event_payment_end: 'a3753.b101271.c388217.d640409',
27
+ sdk_event_validateFields: 'a3753.b101271.c388217.d640406',
28
+ sdk_event_validateFields_end: 'a3753.b101271.c388217.d640407',
29
+ sdk_event_apiOnDestroy: 'a3753.b101271.c388193.d512442',
30
+ sdk_event_apiOnDestroy_end: 'a3753.b101271.c388217.d640408'
19
31
  };
20
32
  export var SPM_MAP = _objectSpread({
21
33
  sdk_error_runtime_error: 'a3753.b101271.c388188.d512342',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1758783821-dev.1",
3
+ "version": "0.0.1758783821-dev.13",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",
@@ -16,8 +16,8 @@
16
16
  "scripts": {
17
17
  "build": "father build",
18
18
  "build:w": "father dev",
19
- "ci": "npm run lint",
20
- "cov": "jest --coverage",
19
+ "ci": "tnpm run cov",
20
+ "cov": "jest --coverage --silent",
21
21
  "dev": "father dev",
22
22
  "format": "prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"",
23
23
  "lint": "eslint ./src",
@@ -47,6 +47,7 @@
47
47
  "uuid": "^9.0.0"
48
48
  },
49
49
  "devDependencies": {
50
+ "@ali/ci": "^4.72.0",
50
51
  "@babel/core": "^7.20.7",
51
52
  "@babel/preset-env": "^7.20.2",
52
53
  "@commitlint/cli": "^17.3.0",
@@ -55,13 +56,13 @@
55
56
  "@testing-library/react": "^9.5.0",
56
57
  "@types/jest": "^29.2.4",
57
58
  "@types/uuid": "^9.0.0",
58
- "@typescript-eslint/eslint-plugin": "latest",
59
- "@typescript-eslint/parser": "^5.60.0",
59
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
60
+ "@typescript-eslint/parser": "^6.21.0",
60
61
  "babel-jest": "^29.3.1",
61
62
  "babel-loader": "^9.1.0",
62
63
  "babel-plugin-import": "^1.13.0",
63
- "eslint": "^8.36.0",
64
- "eslint-plugin-prettier": "latest",
64
+ "eslint": "^8.56.0",
65
+ "eslint-plugin-prettier": "^5.1.3",
65
66
  "father": "^4.2.3",
66
67
  "jest": "^29.5.0",
67
68
  "jest-environment-jsdom": "^29.3.1",
@@ -77,5 +78,9 @@
77
78
  },
78
79
  "publishConfig": {
79
80
  "access": "public"
81
+ },
82
+ "ci": {
83
+ "resourceClass": "L",
84
+ "type": "aci"
80
85
  }
81
86
  }
@@ -1,19 +0,0 @@
1
- import { AddressMountComponentsParams } from '../type';
2
- interface ElementAddressMountOptions extends Omit<AddressMountComponentsParams, 'type'> {
3
- selector: string;
4
- }
5
- export declare class ElementAddressComponent {
6
- private sdk;
7
- private elementContainer;
8
- private isConnect;
9
- constructor();
10
- create(options: {
11
- environment: string;
12
- locale: string;
13
- appVersion: string;
14
- }, isConnect: boolean): void;
15
- mount(options: ElementAddressMountOptions): Promise<HTMLIFrameElement | undefined>;
16
- update(): void;
17
- unmount(): void;
18
- }
19
- export {};
@@ -1,68 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- import { AddressComponent } from "../../address";
9
- export var ElementAddressComponent = /*#__PURE__*/function () {
10
- function ElementAddressComponent() {
11
- _classCallCheck(this, ElementAddressComponent);
12
- _defineProperty(this, "sdk", void 0);
13
- _defineProperty(this, "elementContainer", void 0);
14
- _defineProperty(this, "isConnect", void 0);
15
- }
16
- _createClass(ElementAddressComponent, [{
17
- key: "create",
18
- value: function create(options, isConnect) {
19
- this.isConnect = isConnect;
20
- this.sdk = new AddressComponent(options);
21
- }
22
- }, {
23
- key: "mount",
24
- value: function mount(options) {
25
- var _this = this;
26
- var elementContainer = document.querySelector(options.selector);
27
- if (this.isConnect) {
28
- elementContainer.style.display = 'none';
29
- }
30
- return new Promise(function (resolve) {
31
- _this.sdk.mountComponent({
32
- sessionData: options.sessionData,
33
- elementProps: options.elementProps,
34
- configParams: options.configParams,
35
- appearance: options.appearance,
36
- prefillValue: options.prefillValue,
37
- appendAliasContainerId: true
38
- }, options.selector).then(function () {
39
- var _elementContainer$get;
40
- _this.elementContainer = elementContainer;
41
- var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
42
- resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
43
- }, function () {
44
- resolve(undefined);
45
- });
46
- });
47
- }
48
- }, {
49
- key: "update",
50
- value: function update() {
51
- if (this.elementContainer && this.isConnect) {
52
- this.elementContainer.style.display = '';
53
- }
54
- // 下发数据
55
- }
56
- }, {
57
- key: "unmount",
58
- value: function unmount() {
59
- var _this$elementContaine, _this$elementContaine2;
60
- var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
61
- if (containers !== null && containers !== void 0 && containers[0]) {
62
- var _containers$, _containers$$remove;
63
- (_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
64
- }
65
- }
66
- }]);
67
- return ElementAddressComponent;
68
- }();
@@ -1,17 +0,0 @@
1
- import { LinkAuthMountOptions } from '../type';
2
- interface ElementAuthMountOptions extends Omit<LinkAuthMountOptions, 'type' | 'elementProps'> {
3
- selector: string;
4
- url: string;
5
- }
6
- export declare class ElementAuthComponent {
7
- private elementContainer;
8
- constructor();
9
- create(options: {
10
- environment: string;
11
- locale: string;
12
- }): void;
13
- mount(options: ElementAuthMountOptions): Promise<HTMLIFrameElement | undefined>;
14
- update(height?: number): void;
15
- unmount(): void;
16
- }
17
- export {};
@@ -1,60 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- import { createIframe } from "../../../../foundation/service/container/utils";
9
- import { createInlineBaseElement } from "../../../../plugin/component/component.inline.style";
10
- export var ElementAuthComponent = /*#__PURE__*/function () {
11
- function ElementAuthComponent() {
12
- _classCallCheck(this, ElementAuthComponent);
13
- _defineProperty(this, "elementContainer", void 0);
14
- }
15
- _createClass(ElementAuthComponent, [{
16
- key: "create",
17
- value: function create(options) {}
18
- }, {
19
- key: "mount",
20
- value: function mount(options) {
21
- var _this = this;
22
- return new Promise(function (resolve) {
23
- try {
24
- var selector = options.selector,
25
- url = options.url;
26
- var containerId = (selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1);
27
- var containerSelector = "antom-sdk-web-app-".concat(containerId);
28
- var container = createInlineBaseElement(selector);
29
- var webApp = createIframe(containerSelector);
30
- webApp.src = url;
31
- container.appendChild(webApp);
32
- _this.elementContainer = container;
33
- resolve(webApp);
34
- } catch (error) {
35
- resolve(undefined);
36
- }
37
- });
38
- }
39
- }, {
40
- key: "update",
41
- value: function update() {
42
- var _this$elementContaine, _this$elementContaine2;
43
- var height = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
44
- var iframes = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'iframe');
45
- if (iframes !== null && iframes !== void 0 && iframes[0]) {
46
- var iframe = iframes[0];
47
- iframe.style.opacity = '1';
48
- iframe.style.overflow = 'visible';
49
- iframe.style.height = "".concat(height, "px");
50
- }
51
- }
52
- }, {
53
- key: "unmount",
54
- value: function unmount() {
55
- var _this$elementContaine3, _this$elementContaine4;
56
- (_this$elementContaine3 = this.elementContainer) === null || _this$elementContaine3 === void 0 || (_this$elementContaine4 = _this$elementContaine3.remove) === null || _this$elementContaine4 === void 0 || _this$elementContaine4.call(_this$elementContaine3);
57
- }
58
- }]);
59
- return ElementAuthComponent;
60
- }();
@@ -1,19 +0,0 @@
1
- import { PaymentMountOptions } from '../type';
2
- interface ElementPaymentMountOptions extends Omit<PaymentMountOptions, 'type'> {
3
- selector: string;
4
- }
5
- export declare class ElementPaymentComponent {
6
- private sdk;
7
- private elementContainer;
8
- private isConnect;
9
- constructor();
10
- create(options: {
11
- environment: string;
12
- locale: string;
13
- appVersion: string;
14
- }, isConnect: boolean): void;
15
- mount(options: ElementPaymentMountOptions): Promise<HTMLIFrameElement | undefined>;
16
- update(): void;
17
- unmount(): void;
18
- }
19
- export {};
@@ -1,74 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
- import AMSPaymentElement from "../../../../index";
11
- export var ElementPaymentComponent = /*#__PURE__*/function () {
12
- function ElementPaymentComponent() {
13
- _classCallCheck(this, ElementPaymentComponent);
14
- _defineProperty(this, "sdk", void 0);
15
- _defineProperty(this, "elementContainer", void 0);
16
- _defineProperty(this, "isConnect", void 0);
17
- }
18
- _createClass(ElementPaymentComponent, [{
19
- key: "create",
20
- value: function create(options, isConnect) {
21
- this.isConnect = isConnect;
22
- this.sdk = new AMSPaymentElement(_objectSpread(_objectSpread({}, options), {}, {
23
- analytics: {
24
- enabled: true
25
- },
26
- onEventCallback: function onEventCallback(state) {}
27
- }));
28
- }
29
- }, {
30
- key: "mount",
31
- value: function mount(options) {
32
- var _this = this;
33
- var elementContainer = document.querySelector(options.selector);
34
- if (this.isConnect) {
35
- elementContainer.style.display = 'none';
36
- }
37
- return new Promise(function (resolve) {
38
- _this.sdk.mountComponent({
39
- sessionData: options.sessionData,
40
- appearance: options.appearance,
41
- elementProps: options.elementProps,
42
- notRedirectAfterComplete: true,
43
- appendAliasContainerId: true
44
- }, options.selector).then(function () {
45
- var _elementContainer$get;
46
- _this.elementContainer = elementContainer;
47
- var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
48
- resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
49
- }, function () {
50
- resolve(undefined);
51
- });
52
- });
53
- }
54
- }, {
55
- key: "update",
56
- value: function update() {
57
- if (this.elementContainer && this.isConnect) {
58
- this.elementContainer.style.display = 'initial';
59
- }
60
- // 下发数据
61
- }
62
- }, {
63
- key: "unmount",
64
- value: function unmount() {
65
- var _this$elementContaine, _this$elementContaine2;
66
- var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
67
- if (containers !== null && containers !== void 0 && containers[0]) {
68
- var _containers$, _containers$$remove;
69
- (_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
70
- }
71
- }
72
- }]);
73
- return ElementPaymentComponent;
74
- }();
@@ -1,59 +0,0 @@
1
- import { IPaymentSessionMetaData } from '../../../types';
2
- import type { AddressMountOptions, AddressMountResult, IElementOptions, LinkAuthMountOptions, LinkAuthMountResult, PaymentMountOptions, PaymentMountResult } from './type';
3
- export interface IElementProcessorOptions {
4
- paymentSessionConfig: IPaymentSessionMetaData['paymentSessionConfig'];
5
- sessionData: string;
6
- environment: string;
7
- locale: string;
8
- isConnect: boolean;
9
- }
10
- export declare class ElementComponent {
11
- private parseData;
12
- private loading;
13
- private sessionData;
14
- private elementContainer;
15
- private authBase;
16
- private addressBase;
17
- private paymentBase;
18
- private _options;
19
- private eventService;
20
- private sdkActionRes;
21
- private oneAccountRes;
22
- private launchSource;
23
- private initCompleted;
24
- private isConnect;
25
- private iframeSrc;
26
- private mountOptions;
27
- private iframes;
28
- private loadingElement;
29
- private componentsCount;
30
- private eventCallback;
31
- private ApplePayService;
32
- constructor(options: IElementOptions);
33
- private createElement;
34
- private beforeMount;
35
- private createComponentSdk;
36
- private createIframeSrc;
37
- private closeLoading;
38
- private addListener;
39
- private launchFunc;
40
- private showIframe;
41
- private afterInit;
42
- private sendRenderData;
43
- private removeListener;
44
- private registerEventListener;
45
- private mountAuth;
46
- private mountAddress;
47
- private mountPayment;
48
- private initApplePaySdk;
49
- mountErrorHandle(): void;
50
- mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
51
- mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
52
- mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
53
- private resetState;
54
- unmount(): void;
55
- private onAfterSubmitFunc;
56
- private onValidateFunc;
57
- private validatePromiseFuncs;
58
- submitPayment(): Promise<void>;
59
- }