@alipay/ams-checkout 1.20.1 → 1.22.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 (42) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +11 -0
  3. package/esm/config/index.js +20 -1
  4. package/esm/constant/index.d.ts +10 -0
  5. package/esm/constant/index.js +83 -1
  6. package/esm/core/component/address.d.ts +8 -0
  7. package/esm/core/component/address.js +72 -0
  8. package/esm/core/component/index.d.ts +5 -2
  9. package/esm/core/component/index.js +70 -55
  10. package/esm/core/instance/index.d.ts +1 -0
  11. package/esm/core/instance/index.js +13 -1
  12. package/esm/index.d.ts +8 -8
  13. package/esm/index.js +44 -8
  14. package/esm/plugin/applepay/component.js +1 -1
  15. package/esm/plugin/component/cashierApp.d.ts +3 -3
  16. package/esm/plugin/component/cashierApp.js +33 -3
  17. package/esm/plugin/component/channel.js +1 -0
  18. package/esm/plugin/component/component.inline.style.d.ts +8 -9
  19. package/esm/plugin/component/component.inline.style.js +87 -6
  20. package/esm/plugin/component/component.popup.style.d.ts +1 -0
  21. package/esm/plugin/component/component.popup.style.js +3 -0
  22. package/esm/plugin/component/index.d.ts +4 -1
  23. package/esm/plugin/component/index.js +175 -97
  24. package/esm/plugin/component/popupWindow.style.d.ts +5 -2
  25. package/esm/plugin/component/popupWindow.style.js +70 -14
  26. package/esm/plugin/payment-element/utils.d.ts +2 -0
  27. package/esm/plugin/payment-element/utils.js +6 -0
  28. package/esm/plugin/paypal/index.js +1 -0
  29. package/esm/plugin/type.d.ts +1 -0
  30. package/esm/types/index.d.ts +93 -4
  31. package/esm/types/index.js +14 -0
  32. package/esm/util/getBackScheme.d.ts +5 -0
  33. package/esm/util/getBackScheme.js +42 -0
  34. package/esm/util/security.d.ts +1 -0
  35. package/esm/util/security.js +1 -1
  36. package/esm/util/ua/index.d.ts +2 -0
  37. package/esm/util/ua/index.js +2 -0
  38. package/esm/util/ua/isAndroid.d.ts +4 -0
  39. package/esm/util/ua/isAndroid.js +7 -0
  40. package/esm/util/ua/isIOS.d.ts +4 -0
  41. package/esm/util/ua/isIOS.js +7 -0
  42. package/package.json +2 -1
@@ -1,8 +1,11 @@
1
+ export declare const createCustomSheet: (curTheme?: 'dark' | 'light') => void;
2
+ export declare const renderPopupLoading: (container: HTMLDivElement, curTheme: 'dark' | 'light') => void;
3
+ export declare const removePopupLoading: (isShowMockup?: boolean) => void;
1
4
  export declare const insertStyleSheet: () => void;
2
- export declare const createModal: ({ device, url, widthPadding, heightPadding }: {
5
+ export declare const createModal: ({ device, url, widthPadding, loadingConfig }: {
3
6
  device: any;
4
7
  url: any;
5
8
  widthPadding: any;
6
- heightPadding: any;
9
+ loadingConfig: any;
7
10
  }) => Promise<HTMLIFrameElement>;
8
11
  export declare const destroyModal: () => void;
@@ -1,41 +1,92 @@
1
- import { AMSPOPUP_PREFIX, ANIMATION_TIME } from "../../constant";
1
+ import { AMSPOPUP_PREFIX, ANIMATION_TIME, MOCKUP_ID, POPUPLOADING_ID } from "../../constant";
2
+ import { getDesignFontSize } from "../../util";
2
3
 
3
4
  // CSS样式字符串
4
- var modalStyles = "\n .".concat(AMSPOPUP_PREFIX, "modal {\n /* \u6DFB\u52A0\u5F39\u7A97\u6837\u5F0F */\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n\n .").concat(AMSPOPUP_PREFIX, "overlay {\n /* \u6DFB\u52A0\u8499\u5C42\u6837\u5F0F */\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: 999;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeIn {\n /* \u6DFB\u52A0\u6DE1\u5165\u52A8\u753B */\n animation: fadeIn ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeOut {\n /* \u6DFB\u52A0\u6DE1\u51FA\u52A8\u753B */\n animation: fadeOut ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n /* \u5B9A\u4E49\u6DE1\u5165\u52A8\u753B */\n @keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-webkit-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-moz-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u51FA\u52A8\u753B */\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-webkit-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-moz-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n");
5
-
5
+ var modalStyles = "\n .".concat(AMSPOPUP_PREFIX, "modal {\n /* \u6DFB\u52A0\u5F39\u7A97\u6837\u5F0F */\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n .").concat(AMSPOPUP_PREFIX, "modal-mobile{\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n bottom: 0;\n left: 0%;\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n\n .").concat(AMSPOPUP_PREFIX, "overlay {\n /* \u6DFB\u52A0\u8499\u5C42\u6837\u5F0F */\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: 999;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeIn {\n /* \u6DFB\u52A0\u6DE1\u5165\u52A8\u753B */\n animation: fadeIn ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeOut {\n /* \u6DFB\u52A0\u6DE1\u51FA\u52A8\u753B */\n animation: fadeOut ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "-drawer-enter {\n animation: slideIn ").concat(ANIMATION_TIME, "ms forwards;\n }\n \n @keyframes slideIn {\n from {\n transform: translateY(100%); /* \u6ED1\u5165\u65F6\u5728\u89C6\u53E3\u5E95\u90E8\u5916 */\n opacity: 0; /* \u521D\u59CB\u900F\u660E\u5EA6\u4E3A 0 */\n }\n to {\n transform: translateY(0); /* \u6ED1\u5165\u7ED3\u675F\u65F6\u5728\u539F\u4F4D\u7F6E */\n opacity: 1; /* \u7ED3\u675F\u65F6\u900F\u660E\u5EA6\u4E3A 1 */\n }\n }\n\n /* \u62BD\u5C49\u4ECE\u5E95\u90E8\u6ED1\u51FA */\n .").concat(AMSPOPUP_PREFIX, "-drawer-exit {\n animation: slideOut ").concat(ANIMATION_TIME, "ms forwards;\n }\n\n @keyframes slideOut {\n from {\n transform: translateY(0); /* \u6ED1\u51FA\u65F6\u4ECE\u5F53\u524D\u4F4D\u7F6E\u5F00\u59CB */\n opacity: 1; /* \u521D\u59CB\u900F\u660E\u5EA6\u4E3A 1 */\n }\n to {\n transform: translateY(100%); /* \u6ED1\u51FA\u7ED3\u675F\u65F6\u5728\u89C6\u53E3\u5E95\u90E8\u5916 */\n opacity: 0; /* \u7ED3\u675F\u65F6\u900F\u660E\u5EA6\u4E3A 0 */\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u5165\u52A8\u753B */\n @keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-webkit-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-moz-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u51FA\u52A8\u753B */\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-webkit-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-moz-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n\n.ams-component-popup-loading {\n width: 0.8em;\n height:0.8em;\n border-radius: 8px;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1001;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.ams-component-popup-loading .line {\n width: 40px;\n height: 40px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.ams-component-popup-loading .line div {\n position: absolute;\n left: 17.67px;\n top: 0;\n width: 5.33px;\n height: 40px;\n}\n\n.ams-component-popup-loading .line div:before,\n.ams-component-popup-loading .line div:after {\n content: '';\n display: block;\n height: 13.33px;\n background: black;\n border-radius: 5.3px;\n}\n.ams-component-popup-loading .line div:after {\n margin-top: 13.33px;\n}\n\n.ams-component-popup-loading .line div:nth-child(2) {\n -webkit-transform: rotate(45deg);\n}\n\n.ams-component-popup-loading .line div:nth-child(3) {\n -webkit-transform: rotate(90deg);\n}\n\n.ams-component-popup-loading .line div:nth-child(4) {\n -webkit-transform: rotate(135deg);\n}\n\n/** \u52A0\u8F7D\u52A8\u753B **/\n@-webkit-keyframes load {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n.ams-component-popup-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.875s infinite;\n}\n\n.ams-component-popup-loading-logo {\n width: 0.44em;\n height: 0.44em;\n -webkit-transform:rotate(360deg);\n transform:rotate(360deg);\n -webkit-transition:-webkit-transform 1s linear;\n transition:transform 1s linear;\n animation: ams-component-loading-logo 1s linear infinite;\n}\n");
6
+ var getCurrentTheme = function getCurrentTheme() {
7
+ var curTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
8
+ var theme = {
9
+ night: 'dark',
10
+ gamingPurple: 'dark',
11
+ agateGreen: 'dark',
12
+ default: 'light',
13
+ nostalgicGray: 'light',
14
+ cherryBlossomPink: 'light'
15
+ };
16
+ return theme[curTheme];
17
+ };
18
+ export var createCustomSheet = function createCustomSheet() {
19
+ var curTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'light';
20
+ var sheet = "\n .ams-component-popup-loading .line div:before,\n .ams-component-popup-loading .line div:after {\n background: ".concat(curTheme === 'light' ? '#000000' : '#ffffff', " !important;\n }");
21
+ var style = document.createElement('style');
22
+ style.innerHTML = sheet;
23
+ document.head.appendChild(style);
24
+ };
25
+ export var renderPopupLoading = function renderPopupLoading(container, curTheme) {
26
+ createCustomSheet(curTheme);
27
+ var loading = document.createElement('div');
28
+ loading === null || loading === void 0 || loading.classList.add(POPUPLOADING_ID);
29
+ loading.id = POPUPLOADING_ID;
30
+ loading.innerHTML = '<div class="line"><div></div><div></div><div></div><div></div></div>';
31
+ loading.style.fontSize = "".concat(getDesignFontSize(), "px");
32
+ container.appendChild(loading);
33
+ };
34
+ export var removePopupLoading = function removePopupLoading() {
35
+ var _document$getElementB;
36
+ var isShowMockup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
37
+ var mockup = document.getElementById(MOCKUP_ID);
38
+ if (mockup) {
39
+ mockup.style.background = 'rgb(0, 0, 0, 0.6)';
40
+ mockup.style.display = isShowMockup ? 'block' : 'none';
41
+ }
42
+ (_document$getElementB = document.getElementById(POPUPLOADING_ID)) === null || _document$getElementB === void 0 || _document$getElementB.remove();
43
+ };
6
44
  // 创建和插入样式表
7
45
  export var insertStyleSheet = function insertStyleSheet() {
8
46
  var style = document.createElement('style');
9
47
  style.innerHTML = modalStyles;
10
48
  document.head.appendChild(style);
11
49
  };
12
-
50
+ var modalDevice = 'desktop';
13
51
  // 插入弹窗
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
53
  export var createModal = function createModal(_ref) {
15
54
  var device = _ref.device,
16
55
  url = _ref.url,
17
56
  widthPadding = _ref.widthPadding,
18
- heightPadding = _ref.heightPadding;
57
+ loadingConfig = _ref.loadingConfig;
19
58
  return new Promise(function (resolve, reject) {
20
59
  try {
60
+ modalDevice = device;
21
61
  var overlay = document.createElement('div');
22
62
  overlay.classList.add("".concat(AMSPOPUP_PREFIX, "overlay"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
23
63
  var modal = document.createElement('div');
24
- modal.classList.add("".concat(AMSPOPUP_PREFIX, "modal"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
25
64
  if (device === 'desktop') {
26
- modal.style.width = '600px';
27
- modal.style.height = '464px';
65
+ modal.classList.add("".concat(AMSPOPUP_PREFIX, "modal"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
66
+ modal.style.width = '656px';
67
+ modal.style.height = '620px';
28
68
  modal.style.borderRadius = '12px';
29
69
  } else {
30
- modal.style.width = "calc(100% - ".concat(2 * widthPadding, "px)");
31
- modal.style.height = "calc(100% - ".concat(2 * heightPadding, "px)");
32
- modal.style.borderRadius = '8px';
70
+ modal.classList.add("".concat(AMSPOPUP_PREFIX, "modal-mobile"), "".concat(AMSPOPUP_PREFIX, "-drawer-enter"));
71
+ modal.style.width = '100%';
72
+ modal.style.height = '80vh';
73
+ modal.style.borderRadius = '12px 12px 0 0';
33
74
  }
34
75
  var iframe = document.createElement('iframe');
35
76
  iframe.src = url; // 替换为实际的 URL 地址
36
77
  iframe.style.border = 'none';
37
78
  iframe.style.width = '100%';
38
79
  iframe.style.height = '100%';
80
+ if (loadingConfig && Object.keys(loadingConfig).length) {
81
+ var _loadingConfig$theme = loadingConfig.theme,
82
+ theme = _loadingConfig$theme === void 0 ? 'default' : _loadingConfig$theme,
83
+ _loadingConfig$backgr = loadingConfig.backgroundPrimary,
84
+ backgroundPrimary = _loadingConfig$backgr === void 0 ? '#ffffff' : _loadingConfig$backgr;
85
+ var mode = getCurrentTheme(theme);
86
+ renderPopupLoading(modal, mode);
87
+ modal.style.backgroundColor = backgroundPrimary;
88
+ iframe.style.backgroundColor = backgroundPrimary;
89
+ }
39
90
  modal.appendChild(iframe);
40
91
  var body = document.getElementsByTagName('body')[0];
41
92
  body.appendChild(overlay);
@@ -53,11 +104,16 @@ export var createModal = function createModal(_ref) {
53
104
  // 销毁弹窗
54
105
  export var destroyModal = function destroyModal() {
55
106
  var overlay = document.querySelector(".".concat(AMSPOPUP_PREFIX, "overlay"));
56
- var modal = document.querySelector(".".concat(AMSPOPUP_PREFIX, "modal"));
107
+ var modal = modalDevice === 'desktop' ? document.querySelector(".".concat(AMSPOPUP_PREFIX, "modal")) : document.querySelector(".".concat(AMSPOPUP_PREFIX, "modal-mobile"));
57
108
  overlay.classList.remove("".concat(AMSPOPUP_PREFIX, "fadeIn"));
58
109
  overlay.classList.add("".concat(AMSPOPUP_PREFIX, "fadeOut"));
59
- modal.classList.remove("".concat(AMSPOPUP_PREFIX, "fadeIn"));
60
- modal.classList.add("".concat(AMSPOPUP_PREFIX, "fadeOut"));
110
+ if (modalDevice === 'desktop') {
111
+ modal.classList.remove("".concat(AMSPOPUP_PREFIX, "fadeIn"));
112
+ modal.classList.add("".concat(AMSPOPUP_PREFIX, "fadeOut"));
113
+ } else {
114
+ modal.classList.remove("".concat(AMSPOPUP_PREFIX, "-drawer-enter"));
115
+ modal.classList.add("".concat(AMSPOPUP_PREFIX, "-drawer-exit"));
116
+ }
61
117
  setTimeout(function () {
62
118
  overlay.parentNode.removeChild(overlay);
63
119
  modal.parentNode.removeChild(modal);
@@ -0,0 +1,2 @@
1
+ import type { IpaymentSessionConfig } from '../../types';
2
+ export declare const handlePaymentSessionConfig: (config: IpaymentSessionConfig) => Pick<IpaymentSessionConfig, 'productScene' | 'productSceneVersion'>;
@@ -0,0 +1,6 @@
1
+ export var handlePaymentSessionConfig = function handlePaymentSessionConfig(config) {
2
+ return {
3
+ productScene: config === null || config === void 0 ? void 0 : config.productScene,
4
+ productSceneVersion: config === null || config === void 0 ? void 0 : config.productSceneVersion
5
+ };
6
+ };
@@ -380,6 +380,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
380
380
  break;
381
381
  case PaypalActionEnum.destroyComponent:
382
382
  this.destroyComponent(context, message);
383
+ break;
383
384
  default:
384
385
  console.log('Unknown action: ' + message.getAction());
385
386
  }
@@ -8,6 +8,7 @@ export interface ComponentActionNamesType {
8
8
  mountComponent?: string;
9
9
  submit?: string;
10
10
  destroyComponent?: string;
11
+ getValue?: string;
11
12
  }
12
13
  export type IExtendPluginItem = {
13
14
  /**
@@ -5,6 +5,17 @@
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
+ export type onChange = () => onCnageResult;
9
+ interface onCnageResult {
10
+ complete: boolean;
11
+ addressValue: AddressItem[];
12
+ selectIndex: number | string;
13
+ }
14
+ export type getValue = (hasValidate: boolean) => Promise<AddressValueResult>;
15
+ interface AddressValueResult {
16
+ complete: boolean;
17
+ value: AddressItem;
18
+ }
8
19
  /**
9
20
  * SDK options
10
21
  */
@@ -17,6 +28,7 @@ export interface IoptionsParams {
17
28
  onLog?: callOnLog;
18
29
  onEventCallback?: callOnEventCallback;
19
30
  onClose?: callOnClose;
31
+ onChange?: onChange;
20
32
  networkMode?: string;
21
33
  mode?: string;
22
34
  analytics?: {
@@ -41,6 +53,10 @@ export interface IcreatePaymentParams {
41
53
  backgroundColor?: string;
42
54
  };
43
55
  }
56
+ export declare enum ComponentSignEnumV2 {
57
+ 'ELEMENT_PAYMENT' = "ELEMENT_PAYMENT_ALL",
58
+ 'ELEMENT_ADDRESS' = "ELEMENT_ADDRESS_ALL"
59
+ }
44
60
  export declare enum componentSignEnum {
45
61
  'EASY_PAY_WALLET' = "EASY_PAY_WALLET",
46
62
  'EASY_PAY_APM' = "EASY_PAY_APM",
@@ -51,6 +67,8 @@ export declare enum componentSignEnum {
51
67
  'AUTO_DEBIT_PAY_WALLET' = "AUTO_DEBIT_PAY_WALLET",
52
68
  'NONE' = "NONE",
53
69
  'VAULTING_CARD' = "VAULTING_CARD",
70
+ 'ELEMENT_PAYMENT' = "ELEMENT_PAYMENT_ALL",
71
+ 'ELEMENT_ADDRESS' = "ELEMENT_ADDRESS_ALL",
54
72
  'CHECKOUT_PAYMENT' = "CHECKOUT_PAYMENT"
55
73
  }
56
74
  export declare enum productSceneEnum {
@@ -61,13 +79,16 @@ export declare enum productSceneEnum {
61
79
  'VAULTING' = "VAULTING",
62
80
  'FLASH_BUY' = "FLASH_BUY",
63
81
  'CARD_APPLE_PAY' = "CARD_APPLE_PAY",
82
+ 'ELEMENT_PAYMENT' = "ELEMENT_PAYMENT",
83
+ 'ELEMENT_ADDRESS' = "ELEMENT_ADDRESS",
64
84
  'CHECKOUT_PAYMENT' = "CHECKOUT_PAYMENT"
65
85
  }
66
86
  export declare enum paymentMethodCategoryTypeEnum {
67
87
  'CARD' = "CARD",
68
88
  'WALLET' = "WALLET",
69
89
  'BANK' = "BANK",
70
- 'APM' = "APM"
90
+ 'APM' = "APM",
91
+ 'ALL' = "ALL"
71
92
  }
72
93
  export interface DeviceIdParameter {
73
94
  scene?: string;
@@ -80,7 +101,12 @@ export interface IcreateComponent {
80
101
  sessionData: string;
81
102
  paymentSessionData?: string;
82
103
  notRedirectAfterComplete?: boolean;
83
- appearance?: Record<string, any>;
104
+ appearance?: {
105
+ [x: string]: any;
106
+ themeType?: string;
107
+ accentColor?: string;
108
+ };
109
+ isAppWebview?: boolean;
84
110
  merchantAppointParam?: IMerchantAppointParam;
85
111
  }
86
112
  export interface IappendIframeNodesParams extends IcreateComponent {
@@ -88,7 +114,59 @@ export interface IappendIframeNodesParams extends IcreateComponent {
88
114
  renderDisplayType: renderDisplayTypeEnum;
89
115
  selector?: Iselector;
90
116
  paypalConfiguration?: IPaypalConfiguration;
91
- }
117
+ /** 将address-element参数定义合入原参数定义 */
118
+ configParams?: {
119
+ hideFields?: string[];
120
+ addressAutoSuggestDisabled?: addressAutoSuggestDisabledType;
121
+ };
122
+ prefillValue?: AddressItem[];
123
+ componentSession?: string;
124
+ loca?: string;
125
+ }
126
+ /** 表单地址数据 */
127
+ export interface AddressItem {
128
+ shippingName: {
129
+ firstName: string;
130
+ lastName: string;
131
+ };
132
+ /** 手机号 */
133
+ shippingPhoneNo: string;
134
+ /** 地址 */
135
+ shippingAddress: {
136
+ /** 国家 */
137
+ region: string;
138
+ /** 地址1 */
139
+ address1: string;
140
+ /** 地址2 */
141
+ address2: string;
142
+ /** 省份 */
143
+ province?: string;
144
+ /** 城市 */
145
+ city?: string;
146
+ /** 地址级联 四层 【province,city,district,subDistrict】 */
147
+ district?: string[];
148
+ /** 邮政编码 */
149
+ zipCode: string;
150
+ /** 对应地址级联数据对象 */
151
+ districtValues?: {
152
+ /** 城市 */
153
+ city?: string;
154
+ /** 区/县 */
155
+ district?: string;
156
+ /** 省份 */
157
+ province?: string;
158
+ /** 子区域 */
159
+ subDistrict?: string;
160
+ };
161
+ };
162
+ /** 备注 */
163
+ notes?: string;
164
+ open?: boolean;
165
+ /** 是否默认地址 */
166
+ prefer?: '1' | '0';
167
+ shippingId?: string;
168
+ }
169
+ type addressAutoSuggestDisabledType = 0 | 1;
92
170
  export interface IPaypalConfiguration {
93
171
  style?: object;
94
172
  blockPayPalCreditButton?: boolean;
@@ -120,7 +198,7 @@ export interface Isubmit {
120
198
  }
121
199
  export interface IpaymentSessionConfig {
122
200
  productScene: productSceneEnum;
123
- paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
201
+ paymentMethodCategoryType?: paymentMethodCategoryTypeEnum;
124
202
  productSceneVersion: string;
125
203
  }
126
204
  export interface IpaymentSecurityConfig {
@@ -572,3 +650,14 @@ export type IAppendParams = {
572
650
  componentSign: componentSignEnum;
573
651
  iframeNodesParams: IappendIframeNodesParams;
574
652
  };
653
+ export interface IoptionsAddressParams {
654
+ environment?: string;
655
+ locale?: string;
656
+ onSizeChanged?: callOnSizeChanged;
657
+ onChange?: onChange;
658
+ analytics?: {
659
+ enabled: boolean;
660
+ };
661
+ product?: string;
662
+ }
663
+ export {};
@@ -6,6 +6,7 @@
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
  /* eslint-disable @typescript-eslint/no-explicit-any */
9
+
9
10
  /**
10
11
  * SDK options
11
12
  */
@@ -15,6 +16,11 @@ export var renderDisplayTypeEnum = /*#__PURE__*/function (renderDisplayTypeEnum)
15
16
  renderDisplayTypeEnum["inline"] = "inline";
16
17
  return renderDisplayTypeEnum;
17
18
  }({});
19
+ export var ComponentSignEnumV2 = /*#__PURE__*/function (ComponentSignEnumV2) {
20
+ ComponentSignEnumV2["ELEMENT_PAYMENT"] = "ELEMENT_PAYMENT_ALL";
21
+ ComponentSignEnumV2["ELEMENT_ADDRESS"] = "ELEMENT_ADDRESS_ALL";
22
+ return ComponentSignEnumV2;
23
+ }({});
18
24
  export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {
19
25
  componentSignEnum["EASY_PAY_WALLET"] = "EASY_PAY_WALLET";
20
26
  componentSignEnum["EASY_PAY_APM"] = "EASY_PAY_APM";
@@ -25,6 +31,8 @@ export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {
25
31
  componentSignEnum["AUTO_DEBIT_PAY_WALLET"] = "AUTO_DEBIT_PAY_WALLET";
26
32
  componentSignEnum["NONE"] = "NONE";
27
33
  componentSignEnum["VAULTING_CARD"] = "VAULTING_CARD";
34
+ componentSignEnum["ELEMENT_PAYMENT"] = "ELEMENT_PAYMENT_ALL";
35
+ componentSignEnum["ELEMENT_ADDRESS"] = "ELEMENT_ADDRESS_ALL";
28
36
  componentSignEnum["CHECKOUT_PAYMENT"] = "CHECKOUT_PAYMENT";
29
37
  return componentSignEnum;
30
38
  }({});
@@ -36,6 +44,8 @@ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
36
44
  productSceneEnum["VAULTING"] = "VAULTING";
37
45
  productSceneEnum["FLASH_BUY"] = "FLASH_BUY";
38
46
  productSceneEnum["CARD_APPLE_PAY"] = "CARD_APPLE_PAY";
47
+ productSceneEnum["ELEMENT_PAYMENT"] = "ELEMENT_PAYMENT";
48
+ productSceneEnum["ELEMENT_ADDRESS"] = "ELEMENT_ADDRESS";
39
49
  productSceneEnum["CHECKOUT_PAYMENT"] = "CHECKOUT_PAYMENT";
40
50
  return productSceneEnum;
41
51
  }({});
@@ -44,8 +54,12 @@ export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodC
44
54
  paymentMethodCategoryTypeEnum["WALLET"] = "WALLET";
45
55
  paymentMethodCategoryTypeEnum["BANK"] = "BANK";
46
56
  paymentMethodCategoryTypeEnum["APM"] = "APM";
57
+ paymentMethodCategoryTypeEnum["ALL"] = "ALL";
47
58
  return paymentMethodCategoryTypeEnum;
48
59
  }({});
60
+
61
+ /** 表单地址数据 */
62
+
49
63
  export var payPalConfigurationIntentEnum = /*#__PURE__*/function (payPalConfigurationIntentEnum) {
50
64
  payPalConfigurationIntentEnum["intent"] = "intent";
51
65
  payPalConfigurationIntentEnum["capture"] = "capture";
@@ -0,0 +1,5 @@
1
+ import { Logger } from './logger';
2
+ /**
3
+ * 通过配置规则检测 UA 和获得回跳 scheme
4
+ */
5
+ export declare function getBackScheme(mockUa?: string, logger?: Logger): any;
@@ -0,0 +1,42 @@
1
+ import { isAndroid, isIOS } from "./ua";
2
+ import { RULES } from "../constant/index";
3
+ /**
4
+ * 通过配置规则检测 UA 和获得回跳 scheme
5
+ */
6
+ export function getBackScheme(mockUa, logger) {
7
+ var ua = mockUa || window.navigator.userAgent || '';
8
+ // 获取规则
9
+ var uaMatchedRule = RULES;
10
+ var matchedRule;
11
+ var matched = null;
12
+ for (var i = 0; i < uaMatchedRule.length; i++) {
13
+ var rule = uaMatchedRule[i];
14
+ matched = ua.match(rule.matchRule);
15
+ if (matched) {
16
+ matchedRule = rule;
17
+ break;
18
+ }
19
+ }
20
+ if (!matchedRule) {
21
+ logBackScheme(logger, ua, '');
22
+ return;
23
+ }
24
+ if (isAndroid(ua)) {
25
+ logBackScheme(logger, ua, matchedRule.andScheme);
26
+ return matchedRule.andScheme;
27
+ }
28
+ if (isIOS(ua)) {
29
+ logBackScheme(logger, ua, matchedRule.iosScheme);
30
+ return matchedRule.iosScheme;
31
+ }
32
+ }
33
+ function logBackScheme(logger, userAgent, scheme) {
34
+ if (logger) {
35
+ logger.logInfo({
36
+ title: 'a3753.b101271.c377460'
37
+ }, {
38
+ userAgent: userAgent,
39
+ backScheme: scheme
40
+ });
41
+ }
42
+ }
@@ -18,6 +18,7 @@ export declare const sceneMap: {
18
18
  EASYPAY: string;
19
19
  EASY_PAY: string;
20
20
  FLASH_BUY: string;
21
+ ELEMENT_PAYMENT: string;
21
22
  };
22
23
  export declare const getSecurityHost: (region: string) => string;
23
24
  export declare const getSecurityScene: (product: string) => string;
@@ -24,7 +24,7 @@ export var securityHost = {
24
24
  US: 'https://open-na-global.alipay.com/api/open/risk_client',
25
25
  DE: 'https://open-de-global.alipay.com/api/open/risk_client'
26
26
  };
27
- export var sceneMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, productSceneEnum.CASHIER_PAYMENT, 'Acquirer'), productSceneEnum.AUTO_DEBIT, 'Acquirer'), productSceneEnum.VAULTING, 'Acquirer'), productSceneEnum.CARD_APPLE_PAY, 'Acquirer'), "EASYPAY", 'EasyPay'), productSceneEnum.EASY_PAY, 'EasyPay'), productSceneEnum.FLASH_BUY, 'OneAccount');
27
+ export var sceneMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, productSceneEnum.CASHIER_PAYMENT, 'Acquirer'), productSceneEnum.AUTO_DEBIT, 'Acquirer'), productSceneEnum.VAULTING, 'Acquirer'), productSceneEnum.CARD_APPLE_PAY, 'Acquirer'), "EASYPAY", 'EasyPay'), productSceneEnum.EASY_PAY, 'EasyPay'), productSceneEnum.FLASH_BUY, 'OneAccount'), productSceneEnum.ELEMENT_PAYMENT, 'Acquirer');
28
28
  export var getSecurityHost = function getSecurityHost(region) {
29
29
  return securityHost[region] || securityHost[SecurityRegionEnum.SG];
30
30
  };
@@ -0,0 +1,2 @@
1
+ export * from './isAndroid';
2
+ export * from './isIOS';
@@ -0,0 +1,2 @@
1
+ export * from "./isAndroid";
2
+ export * from "./isIOS";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 当前运行环境是否 Android
3
+ */
4
+ export declare function isAndroid(mockUA?: string): boolean;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 当前运行环境是否 Android
3
+ */
4
+ export function isAndroid(mockUA) {
5
+ var ua = (mockUA || navigator.userAgent).toLowerCase();
6
+ return /android|adr|linux/.test(ua);
7
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 当前运行环境是否 IOS
3
+ */
4
+ export declare function isIOS(mockUA?: string): boolean;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 当前运行环境是否 IOS
3
+ */
4
+ export function isIOS(mockUA) {
5
+ var ua = (mockUA || navigator.userAgent).toLowerCase();
6
+ return /iphone|ipad|ipod|ios|macintosh/.test(ua);
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "1.20.1",
3
+ "version": "1.22.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",
@@ -15,6 +15,7 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "build": "father build",
18
+ "dev": "father dev",
18
19
  "ci": "npm run lint",
19
20
  "cov": "jest --coverage",
20
21
  "format": "prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"",