@alipay/ams-checkout 0.0.1762310209-dev.0 → 0.0.1762410565-dev.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 (30) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +8 -8
  3. package/esm/config/index.js +8 -8
  4. package/esm/core/component/ckp/index.d.ts +11 -2
  5. package/esm/core/component/ckp/index.js +22 -8
  6. package/esm/core/component/element/elementController/index.js +2 -1
  7. package/esm/core/component/element/elementProcessor/addressProcessor.js +4 -2
  8. package/esm/core/component/element/elementProcessor/authProcessor.js +4 -2
  9. package/esm/core/component/element/elementProcessor/paymentProcessor.js +4 -2
  10. package/esm/core/component/element/type.d.ts +4 -0
  11. package/esm/core/component/element/util.d.ts +9 -1
  12. package/esm/core/component/element/util.js +14 -5
  13. package/esm/foundation/core/index.js +2 -1
  14. package/esm/foundation/index.d.ts +8 -1
  15. package/esm/foundation/product-processor/autoDebit/index.d.ts +5 -1
  16. package/esm/foundation/product-processor/autoDebit/index.js +5 -2
  17. package/esm/foundation/product-processor/easysafepay/index.d.ts +4 -1
  18. package/esm/foundation/product-processor/easysafepay/index.js +25 -17
  19. package/esm/foundation/product-processor/element/index.d.ts +1 -1
  20. package/esm/foundation/product-processor/element/index.js +1 -1
  21. package/esm/foundation/utils/web_app_url_utils.d.ts +3 -0
  22. package/esm/foundation/utils/web_app_url_utils.js +15 -8
  23. package/esm/index.js +1 -0
  24. package/esm/plugin/component/cashierApp.d.ts +9 -1
  25. package/esm/plugin/component/cashierApp.js +19 -7
  26. package/esm/plugin/component/index.js +9 -2
  27. package/esm/types/index.d.ts +8 -0
  28. package/esm/util/index.d.ts +2 -1
  29. package/esm/util/index.js +21 -1
  30. package/package.json +3 -1
@@ -6,11 +6,11 @@ export declare const sdkVersion: string;
6
6
  * @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
7
7
  * TODO 这里考虑直接换成packagejson.version
8
8
  */
9
- export declare const AMSCheckoutAppVersion = "1.46.1";
10
- export declare const AMSAutoDebitAppVersion = "1.46.1";
11
- export declare const AMSEasyPayAppVersion = "1.46.1";
12
- export declare const AMSCashierPaymentAppVersion = "1.46.1";
13
- export declare const AMSVaultingAppVersion = "1.46.1";
14
- export declare const AMSPaymentElementAppVersion = "1.46.1";
15
- export declare const ADDRESSElementAppVersion = "1.46.1";
16
- export declare const AUTHElementAppVersion = "1.46.1";
9
+ export declare const AMSCheckoutAppVersion = "1.47.0";
10
+ export declare const AMSAutoDebitAppVersion = "1.47.0";
11
+ export declare const AMSEasyPayAppVersion = "1.47.0";
12
+ export declare const AMSCashierPaymentAppVersion = "1.47.0";
13
+ export declare const AMSVaultingAppVersion = "1.47.0";
14
+ export declare const AMSPaymentElementAppVersion = "1.47.0";
15
+ export declare const ADDRESSElementAppVersion = "1.47.0";
16
+ export declare const AUTHElementAppVersion = "1.47.0";
@@ -36,11 +36,11 @@ export var sdkVersion = json.version;
36
36
  * @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
37
37
  * TODO 这里考虑直接换成packagejson.version
38
38
  */
39
- export var AMSCheckoutAppVersion = '1.46.1'; // 兜底版本号
40
- export var AMSAutoDebitAppVersion = '1.46.1'; // 代扣
41
- export var AMSEasyPayAppVersion = '1.46.1'; // easypay
42
- export var AMSCashierPaymentAppVersion = '1.46.1'; // 收银台(卡、apm)
43
- export var AMSVaultingAppVersion = '1.46.1'; // 绑卡
44
- export var AMSPaymentElementAppVersion = '1.46.1'; // payment element
45
- export var ADDRESSElementAppVersion = '1.46.1'; // address element
46
- export var AUTHElementAppVersion = '1.46.1'; // auth element
39
+ export var AMSCheckoutAppVersion = '1.47.0'; // 兜底版本号
40
+ export var AMSAutoDebitAppVersion = '1.47.0'; // 代扣
41
+ export var AMSEasyPayAppVersion = '1.47.0'; // easypay
42
+ export var AMSCashierPaymentAppVersion = '1.47.0'; // 收银台(卡、apm)
43
+ export var AMSVaultingAppVersion = '1.47.0'; // 绑卡
44
+ export var AMSPaymentElementAppVersion = '1.47.0'; // payment element
45
+ export var ADDRESSElementAppVersion = '1.47.0'; // address element
46
+ export var AUTHElementAppVersion = '1.47.0'; // auth element
@@ -3,15 +3,24 @@ import { Logger } from '../../../util/logger';
3
3
  type LOCAL_URL = string;
4
4
  export type CKPEmbeddedAppEnv = 'dev' | 'sit' | 'pre' | 'prod';
5
5
  export type CKPEmbeddedEventType = 'SDK_PAYMENT_SUCCESSFUL' | 'SDK_PAYMENT_FAIL' | 'SDK_PAYMENT_CANCEL' | 'SDK_PAYMENT_CLICK_BACK_TO_MERCHANT';
6
- export declare const getCKPPageAddress: (env: IoptionsParams['environment'] | LOCAL_URL) => string;
6
+ export declare const getCKPPageAddress: (env: IoptionsParams['environment'] | LOCAL_URL, mockOptions?: {
7
+ useMock: boolean;
8
+ mockUserId?: any;
9
+ }) => string;
7
10
  export declare class AMSCheckoutPage {
8
11
  logger: Logger;
9
12
  private _instanceId;
10
13
  private iframe;
11
14
  private originOptions;
15
+ private mockOptions?;
12
16
  private readonly APP_IFRAME_ID;
13
17
  private eventListener?;
14
- constructor(options: Pick<IoptionsParams, 'environment' | 'locale' | 'onEventCallback'>);
18
+ constructor(options: Pick<IoptionsParams, 'environment' | 'locale' | 'onEventCallback'> & {
19
+ mockOptions?: {
20
+ useMock: boolean;
21
+ mockUserId?: any;
22
+ };
23
+ });
15
24
  private generateIframeSrc;
16
25
  private eventListenerWrapper;
17
26
  private addListener;
@@ -10,7 +10,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
10
10
  import { redirect } from "../../../util/redirect";
11
11
  import { v4 as uuid } from 'uuid';
12
12
  import { EnvironmentEnum, MessageName } from "../../../types";
13
- import { queryParse } from "../../../util";
13
+ import { genProxyUrl, queryParse } from "../../../util";
14
14
  import { LogConfig, Logger } from "../../../util/logger";
15
15
  var CKP_PAYMENT_PAGE_HOST = {
16
16
  DEV: 'https://dev.page.alipay.net',
@@ -23,22 +23,34 @@ var CKP_PAYMENT_PAGE_HOST = {
23
23
 
24
24
  var CKP_PAGE_ADDRESS = '/page/antom-web-checkout-v2/checkout-page/pages/payment/index.html';
25
25
  var CKP_PAGE_NEW_ADDRESS = '/checkout-page/pages/payment/index.html';
26
- export var getCKPPageAddress = function getCKPPageAddress(env) {
26
+ export var getCKPPageAddress = function getCKPPageAddress(env, mockOptions) {
27
+ var baseUrl;
27
28
  switch (env) {
28
29
  case 'dev':
29
- return "".concat(CKP_PAYMENT_PAGE_HOST.DEV).concat(CKP_PAGE_ADDRESS);
30
+ baseUrl = "".concat(CKP_PAYMENT_PAGE_HOST.DEV).concat(CKP_PAGE_ADDRESS);
31
+ break;
30
32
  case 'sit':
31
- return "".concat(CKP_PAYMENT_PAGE_HOST.TEST).concat(CKP_PAGE_ADDRESS);
33
+ baseUrl = "".concat(CKP_PAYMENT_PAGE_HOST.TEST).concat(CKP_PAGE_ADDRESS);
34
+ break;
32
35
  case 'pre':
33
- return "".concat(CKP_PAYMENT_PAGE_HOST.PRE).concat(CKP_PAGE_ADDRESS);
36
+ baseUrl = "".concat(CKP_PAYMENT_PAGE_HOST.PRE).concat(CKP_PAGE_ADDRESS);
37
+ break;
34
38
  case 'prod':
35
39
  case 'sandbox':
36
40
  case 'light_sandbox':
37
- return "".concat(CKP_PAYMENT_PAGE_HOST.PROD).concat(CKP_PAGE_NEW_ADDRESS);
41
+ baseUrl = "".concat(CKP_PAYMENT_PAGE_HOST.PROD).concat(CKP_PAGE_NEW_ADDRESS);
42
+ break;
38
43
  default:
39
44
  // for local development, e.g. http://localhost:5173/checkout-page/src/pages/payment/index.html
40
- return env;
45
+ baseUrl = env;
46
+ break;
41
47
  }
48
+
49
+ // 简化的Mock逻辑:直接使用genProxyUrl,内部会处理环境安全检查
50
+ if (mockOptions && mockOptions.useMock === true) {
51
+ baseUrl = genProxyUrl(baseUrl, env);
52
+ }
53
+ return baseUrl;
42
54
  };
43
55
  export var AMSCheckoutPage = /*#__PURE__*/function () {
44
56
  function AMSCheckoutPage(options) {
@@ -48,13 +60,14 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
48
60
  _defineProperty(this, "_instanceId", void 0);
49
61
  _defineProperty(this, "iframe", void 0);
50
62
  _defineProperty(this, "originOptions", void 0);
63
+ _defineProperty(this, "mockOptions", void 0);
51
64
  _defineProperty(this, "APP_IFRAME_ID", 'antom-checkout-page-sub-page-iframe');
52
65
  _defineProperty(this, "eventListener", void 0);
53
66
  _defineProperty(this, "generateIframeSrc", function (sessionData) {
54
67
  var env = _this.originOptions.environment || 'prod';
55
68
  var session = sessionData || '';
56
69
  var lang = _this.originOptions.locale || 'en_US';
57
- var ckpPageAddress = getCKPPageAddress(env);
70
+ var ckpPageAddress = getCKPPageAddress(env, _this.mockOptions);
58
71
  console.log('[antom-web-sdk] <antom-checkout-page> generateIframeSrc', _this.originOptions, env, session, lang, ckpPageAddress);
59
72
 
60
73
  // 先获取去除的 query 参数的 url
@@ -124,6 +137,7 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
124
137
  this._instanceId = uuid();
125
138
  this.iframe = null;
126
139
  this.originOptions = options;
140
+ this.mockOptions = options.mockOptions;
127
141
  this.eventListener = options.onEventCallback;
128
142
  this.logger = new Logger(LogConfig, ![EnvironmentEnum.prod, EnvironmentEnum.sandbox].includes(options === null || options === void 0 ? void 0 : options.environment));
129
143
  Logger.setInstance(this.logger);
@@ -270,7 +270,8 @@ var ElementController = /*#__PURE__*/function () {
270
270
  paymentSession: _this2.options.sessionData,
271
271
  displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
272
272
  appendAliasContainerId: true
273
- })
273
+ }),
274
+ mockOptions: _this2.options.mockOptions
274
275
  };
275
276
  _this2.setControllerStatusOrView(IElementStatus.IN_BIZ_FLOW);
276
277
  _this2.elementContainer.startBizFlow(startBizFlowData);
@@ -90,7 +90,8 @@ var AddressProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
90
90
  var _ref2 = this.elementContainer.getPaymentContext() || {},
91
91
  paymentSession = _ref2.paymentSession,
92
92
  paymentSessionObj = _ref2.paymentSessionObj,
93
- sdkMetaData = _ref2.sdkMetaData;
93
+ sdkMetaData = _ref2.sdkMetaData,
94
+ startBizFlowOptions = _ref2.startBizFlowOptions;
94
95
  var _this$options = this.options,
95
96
  environment = _this$options.env.environment,
96
97
  analytics = _this$options.analytics,
@@ -105,7 +106,8 @@ var AddressProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
105
106
  link: link,
106
107
  appVersion: sdkMetaData === null || sdkMetaData === void 0 ? void 0 : sdkMetaData.webAppVersion,
107
108
  pageUrl: pageUrl,
108
- instanceId: instanceId
109
+ instanceId: instanceId,
110
+ mockOptions: startBizFlowOptions === null || startBizFlowOptions === void 0 ? void 0 : startBizFlowOptions.mockOptions
109
111
  });
110
112
  }
111
113
  }, {
@@ -64,7 +64,8 @@ var AuthProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
64
64
  var _ref2 = this.elementContainer.getPaymentContext() || {},
65
65
  paymentSession = _ref2.paymentSession,
66
66
  paymentSessionObj = _ref2.paymentSessionObj,
67
- sdkMetaData = _ref2.sdkMetaData;
67
+ sdkMetaData = _ref2.sdkMetaData,
68
+ startBizFlowOptions = _ref2.startBizFlowOptions;
68
69
  var _this$options = this.options,
69
70
  environment = _this$options.env.environment,
70
71
  analytics = _this$options.analytics,
@@ -79,7 +80,8 @@ var AuthProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
79
80
  link: link,
80
81
  appVersion: sdkMetaData === null || sdkMetaData === void 0 ? void 0 : sdkMetaData.webAppVersion,
81
82
  pageUrl: pageUrl,
82
- instanceId: instanceId
83
+ instanceId: instanceId,
84
+ mockOptions: startBizFlowOptions === null || startBizFlowOptions === void 0 ? void 0 : startBizFlowOptions.mockOptions
83
85
  });
84
86
  }
85
87
  }, {
@@ -216,7 +216,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
216
216
  var _ref2 = this.elementContainer.getPaymentContext() || {},
217
217
  paymentSession = _ref2.paymentSession,
218
218
  paymentSessionObj = _ref2.paymentSessionObj,
219
- sdkMetaData = _ref2.sdkMetaData;
219
+ sdkMetaData = _ref2.sdkMetaData,
220
+ startBizFlowOptions = _ref2.startBizFlowOptions;
220
221
  var _this$options = this.options,
221
222
  environment = _this$options.env.environment,
222
223
  analytics = _this$options.analytics,
@@ -240,7 +241,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
240
241
  link: link,
241
242
  appVersion: sdkMetaData === null || sdkMetaData === void 0 ? void 0 : sdkMetaData.webAppVersion,
242
243
  pageUrl: pageUrl,
243
- instanceId: instanceId
244
+ instanceId: instanceId,
245
+ mockOptions: startBizFlowOptions === null || startBizFlowOptions === void 0 ? void 0 : startBizFlowOptions.mockOptions
244
246
  });
245
247
  this.setElementUrl(url);
246
248
  return url;
@@ -391,6 +391,10 @@ export interface IElementOptions {
391
391
  onStartLoading: () => void;
392
392
  onEndLoading: () => void;
393
393
  };
394
+ mockOptions?: {
395
+ useMock: boolean;
396
+ mockUserId?: any;
397
+ };
394
398
  }
395
399
  export interface IElementProcessors {
396
400
  [ElementType.auth]: AuthProcessor;
@@ -19,6 +19,10 @@ export declare const formatElementOption: (options: IElementOptions) => {
19
19
  onStartLoading: () => void;
20
20
  onEndLoading: () => void;
21
21
  };
22
+ mockOptions?: {
23
+ useMock: boolean;
24
+ mockUserId?: any;
25
+ };
22
26
  };
23
27
  export declare const validateElementOption: (options: IElementOptions) => {
24
28
  isValid: boolean;
@@ -48,7 +52,7 @@ export declare function checkCanUpdate({ status, paymentContainerService, newPay
48
52
  newPaymentSessionData: string;
49
53
  oldPaymentSessionData: string;
50
54
  }): boolean;
51
- export declare function generateIframeSrc({ paymentSessionObj, paymentSession, instanceId, environment, appVersion, analytics, locale, pageUrl, link, }: {
55
+ export declare function generateIframeSrc({ paymentSessionObj, paymentSession, instanceId, environment, appVersion, analytics, locale, pageUrl, link, mockOptions, }: {
52
56
  paymentSessionObj: IPaymentSessionMetaData;
53
57
  paymentSession: string;
54
58
  environment: string;
@@ -58,6 +62,10 @@ export declare function generateIframeSrc({ paymentSessionObj, paymentSession, i
58
62
  pageUrl: string;
59
63
  appVersion: string;
60
64
  link?: string;
65
+ mockOptions?: {
66
+ useMock: boolean;
67
+ mockUserId?: any;
68
+ };
61
69
  }): string;
62
70
  export declare function handleRedirect(data: any, fromFastSdk: boolean, eventCallback: ({ code, message }: {
63
71
  code: any;
@@ -14,7 +14,7 @@ import { ERRORMESSAGE } from "../../../constant";
14
14
  import { IElementStatus } from "../../../foundation";
15
15
  import { getIframeUrl } from "../../../plugin/component/cashierApp";
16
16
  import { DisplayTypeEnum, eventCodeEnum, RedirectType, TargetEnum, terminalTypeEnum } from "../../../types";
17
- import { device } from "../../../util/index";
17
+ import { device, genProxyUrl } from "../../../util/index";
18
18
  import CallApp from "../../../util/intl-callapp/es/main";
19
19
  import { getComponentSign, parseSessionData } from "../index";
20
20
  import { ELEMENT_ENVIRONMENT, EventCallbackCode } from "./type";
@@ -129,7 +129,8 @@ export function generateIframeSrc(_ref3) {
129
129
  analytics = _ref3.analytics,
130
130
  locale = _ref3.locale,
131
131
  pageUrl = _ref3.pageUrl,
132
- link = _ref3.link;
132
+ link = _ref3.link,
133
+ mockOptions = _ref3.mockOptions;
133
134
  var componentSign = getComponentSign(paymentSessionObj);
134
135
  var productSceneVersion = (paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productSceneVersion) || '';
135
136
  var productScene = (paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$pa2 = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa2 === void 0 ? void 0 : _paymentSessionObj$pa2.productScene) || '';
@@ -154,12 +155,20 @@ export function generateIframeSrc(_ref3) {
154
155
  instanceId: instanceId,
155
156
  hostSign: hostSign,
156
157
  mid: mid,
157
- elementLink: link // TODO Connect本地调试link
158
+ elementLink: link,
159
+ // TODO Connect本地调试link
160
+ mockOptions: mockOptions
158
161
  }),
159
162
  path = _getIframeUrl.path,
160
163
  locationSearch = _getIframeUrl.locationSearch;
161
- console.log('[debug] generateIframeSrc', path, locationSearch);
162
- return "".concat(path, "?").concat(locationSearch);
164
+
165
+ // 简化的Mock逻辑:直接使用genProxyUrl,内部会处理环境安全检查
166
+ var finalPath = path;
167
+ if (mockOptions && mockOptions.useMock === true) {
168
+ finalPath = genProxyUrl(path, environment);
169
+ }
170
+ console.log('[debug] generateIframeSrc', finalPath, locationSearch);
171
+ return "".concat(finalPath, "?").concat(locationSearch);
163
172
  }
164
173
  export function handleRedirect(data) {
165
174
  var _data$isDestroy, _data$isCallApp, _data$callAppDetectSu;
@@ -22,6 +22,7 @@ import { getGrayscaleId } from "../utils/gray_scale_utils";
22
22
  import { convertPaymentSession, getWebAppVersion, saveWebAppVersion } from "../utils/payment_context_utils";
23
23
  import { redirect } from "../utils/redirect_utils";
24
24
  import { parseWebAppMatchConfig } from "../utils/web_app_url_utils";
25
+
25
26
  /**
26
27
  * @author 谦彧 <zhangmian.zm@alipay.com>
27
28
  * @date 2024/9/17
@@ -234,7 +235,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
234
235
 
235
236
  // execute additional logic from specified product
236
237
  if (this.productProcessors[sdkMetaData.productScene]) {
237
- this.productProcessors[sdkMetaData.productScene].init(options, this.instanceId, sdkMetaData);
238
+ this.productProcessors[sdkMetaData.productScene].init(options, this.instanceId, sdkMetaData, options.mockOptions);
238
239
  }
239
240
  }
240
241
  }, {
@@ -20,6 +20,10 @@ export interface StartBizFlowOptions {
20
20
  displayInfo?: Partial<DisplayInfo>;
21
21
  submitPayRequestExtra?: any;
22
22
  isAppWebview?: boolean;
23
+ mockOptions?: {
24
+ useMock: boolean;
25
+ mockUserId?: any;
26
+ };
23
27
  isNativeAppWebview?: boolean;
24
28
  }
25
29
  export declare class DisplayInfo {
@@ -43,7 +47,10 @@ export declare class DisplayInfo {
43
47
  * Such as: EasySafePay, PayPal in Cashier
44
48
  */
45
49
  export interface ProductProcessor {
46
- init(config: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): any;
50
+ init(config: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData, mockOptions?: {
51
+ useMock?: boolean;
52
+ mockUserId?: any;
53
+ }): any;
47
54
  startBizFlow(paymentContext: PaymentContext): Promise<BizFlowStartBehavior>;
48
55
  }
49
56
  export interface BizFlowStartBehavior {
@@ -10,7 +10,11 @@ export declare class AutoDebitProcessor implements ProductProcessor {
10
10
  private hostSign;
11
11
  private _performanceData;
12
12
  private SECURITY_SDK_INIT_TIMEOUT;
13
- init(config: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
13
+ private mockOptions?;
14
+ init(config: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData, mockOptions?: {
15
+ useMock?: boolean;
16
+ mockUserId?: any;
17
+ }): void;
14
18
  startBizFlow(paymentContext: PaymentContext): Promise<BizFlowStartBehavior>;
15
19
  private acquireApdidToken;
16
20
  /**
@@ -36,12 +36,14 @@ export var AutoDebitProcessor = /*#__PURE__*/function () {
36
36
  _defineProperty(this, "_performanceData", []);
37
37
  // 安全SDK初始化超时时间
38
38
  _defineProperty(this, "SECURITY_SDK_INIT_TIMEOUT", 1500);
39
+ _defineProperty(this, "mockOptions", void 0);
39
40
  }
40
41
  _createClass(AutoDebitProcessor, [{
41
42
  key: "init",
42
- value: function init(config, instanceId, sdkMetaData) {
43
+ value: function init(config, instanceId, sdkMetaData, mockOptions) {
43
44
  this.initConfig = config;
44
45
  this.instanceId = instanceId;
46
+ this.mockOptions = mockOptions;
45
47
  this.logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
46
48
  this.eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
47
49
  this.securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
@@ -391,7 +393,8 @@ export var AutoDebitProcessor = /*#__PURE__*/function () {
391
393
  hostSign: hostSign
392
394
  },
393
395
  mid: mid,
394
- extendInfo: extendInfo
396
+ extendInfo: extendInfo,
397
+ mockOptions: this.mockOptions
395
398
  });
396
399
  return webAppUrl;
397
400
  // // 调试地址
@@ -13,7 +13,10 @@ export declare class EasySafePayProcessor implements ProductProcessor {
13
13
  private SECURITY_SDK_INIT_TIMEOUT;
14
14
  private SDK_REQUEST_TIMEOUT;
15
15
  private LOAD_APP_RESOURCES_TIMEOUT;
16
- init(config: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
16
+ init(config: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData, mockOptions?: {
17
+ useMock?: boolean;
18
+ mockUserId?: any;
19
+ }): void;
17
20
  startBizFlow(paymentContext: PaymentContext): Promise<BizFlowStartBehavior>;
18
21
  private buildWebAppUrl;
19
22
  private buildRedirectResult;
@@ -16,10 +16,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
16
16
  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; }
17
17
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
18
  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); }
19
+ import { getDoubleFaUrlFromSession } from "../../utils/web_app_url_utils";
19
20
  import PreloadHelper from "../../../foundation/utils/preload_helper";
20
- import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, PaymentMethodCategoryTypeEnum, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil, EVENT, eventCodeEnum } from "./deps";
21
21
  import { isEmpty } from "../../../util";
22
- import { getDoubleFaUrlFromSession } from "../../utils/web_app_url_utils";
22
+ import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, PaymentMethodCategoryTypeEnum, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil } from "./deps";
23
23
  export var EasySafePayProcessor = /*#__PURE__*/function () {
24
24
  function EasySafePayProcessor() {
25
25
  _classCallCheck(this, EasySafePayProcessor);
@@ -41,7 +41,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
41
41
  }
42
42
  _createClass(EasySafePayProcessor, [{
43
43
  key: "init",
44
- value: function init(config, instanceId, sdkMetaData) {
44
+ value: function init(config, instanceId, sdkMetaData, mockOptions) {
45
45
  this.initConfig = config;
46
46
  this.instanceId = instanceId;
47
47
  this.logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
@@ -88,6 +88,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
88
88
  case 12:
89
89
  // 下面的场景是需要渲染UI的渠道, 打开WebUrl
90
90
  webAppUrl = this.buildWebAppUrl();
91
+ console.log('object>>>>webAppUrl', webAppUrl);
91
92
  resultPayload = {
92
93
  url: webAppUrl,
93
94
  allowClickPopupOutsideClose: (_this$channelBehavior = this.channelBehavior) === null || _this$channelBehavior === void 0 ? void 0 : _this$channelBehavior.allowClickOutsideClose
@@ -104,7 +105,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
104
105
  behaviorType: 'RENDER',
105
106
  payload: resultPayload
106
107
  });
107
- case 17:
108
+ case 18:
108
109
  case "end":
109
110
  return _context.stop();
110
111
  }
@@ -118,7 +119,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
118
119
  }, {
119
120
  key: "buildWebAppUrl",
120
121
  value: function buildWebAppUrl() {
121
- var _paymentContext$payme3, _paymentContext$payme4, _paymentContext$payme5, _this$initConfig$anal;
122
+ var _paymentContext$payme3, _paymentContext$payme4, _paymentContext$payme5, _paymentContext$start2, _this$initConfig$anal;
122
123
  var paymentContext = this.paymentContext;
123
124
  var paymentMethodCategoryType = (_paymentContext$payme3 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme3 === void 0 ? void 0 : _paymentContext$payme3.paymentMethodCategoryType;
124
125
  var productScene = (_paymentContext$payme4 = paymentContext.paymentSessionObj.paymentSessionConfig) === null || _paymentContext$payme4 === void 0 ? void 0 : _paymentContext$payme4.productScene;
@@ -126,6 +127,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
126
127
  var hostSign = this.hostSign;
127
128
  var mid = paymentContext.paymentSessionObj.clientId;
128
129
  var extendInfo = paymentContext.paymentSessionObj.extendInfo;
130
+ var mockOptions = (_paymentContext$start2 = paymentContext.startBizFlowOptions) === null || _paymentContext$start2 === void 0 ? void 0 : _paymentContext$start2.mockOptions;
129
131
  var webAppUrl = WebAppUrlUtil.getWebAppV2Url({
130
132
  environment: this.initConfig.environment,
131
133
  paymentMethodCategoryType: paymentMethodCategoryType,
@@ -141,7 +143,8 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
141
143
  hostSign: hostSign
142
144
  },
143
145
  mid: mid,
144
- extendInfo: extendInfo
146
+ extendInfo: extendInfo,
147
+ mockOptions: mockOptions
145
148
  });
146
149
  return webAppUrl;
147
150
  }
@@ -153,15 +156,13 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
153
156
  data = {
154
157
  url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
155
158
  schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
156
- applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
157
- openInApp: (authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.openInApp) || false
159
+ applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl
158
160
  };
159
161
  } else {
160
162
  data = {
161
163
  url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.normalUrl,
162
164
  schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.schemeUrl,
163
- applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.applinkUrl,
164
- openInApp: (authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.openInApp) || false
165
+ applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.applinkUrl
165
166
  };
166
167
  }
167
168
  var result = {
@@ -233,19 +234,26 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
233
234
  if (queryRes) {
234
235
  data.queryResult = queryRes;
235
236
  }
237
+ _this.logger.logInfo({
238
+ title: 'sdk_event_renderComponent'
239
+ });
236
240
  _this.eventCenter.dispatchToApp({
237
241
  event: 'renderComponent',
238
242
  data: data
239
243
  });
240
- _this.logger.logInfo({
241
- title: 'sdk_event_renderComponent'
242
- });
243
244
  }).catch(function (error) {
244
- _this.eventCenter.emit(EVENT.destroy.name, {});
245
- _this.eventCenter.emit(EVENT.eventCallback.name, {
246
- code: eventCodeEnum.SDK_INTERNAL_ERROR,
245
+ var _this$logger$logError, _this$logger;
246
+ var message = error instanceof Error ? error.message : String(error);
247
+ (_this$logger$logError = (_this$logger = _this.logger).logError) === null || _this$logger$logError === void 0 || _this$logger$logError.call(_this$logger, {
248
+ title: 'sdk_event_webAppOnLaunch_failed'
249
+ }, {
250
+ errorMessage: message
251
+ });
252
+ _this.eventCenter.emit('onDestroy', {});
253
+ _this.eventCenter.emit('onEventCallback', {
254
+ code: 'SDK_INTERNAL_ERROR',
247
255
  result: {
248
- message: error === null || error === void 0 ? void 0 : error.message
256
+ message: message
249
257
  }
250
258
  });
251
259
  });
@@ -1,7 +1,7 @@
1
1
  import { BizFlowStartBehavior, ProductProcessor } from "../..";
2
2
  declare class ElementProcessor implements ProductProcessor {
3
3
  constructor();
4
- init(config: any, instanceId: string): any;
4
+ init(config: any, instanceId: string, sdkMetaData?: any, mockOptions?: any): any;
5
5
  startBizFlow(): Promise<BizFlowStartBehavior>;
6
6
  }
7
7
  export { ElementProcessor };
@@ -10,7 +10,7 @@ var ElementProcessor = /*#__PURE__*/function () {
10
10
  }
11
11
  _createClass(ElementProcessor, [{
12
12
  key: "init",
13
- value: function init(config, instanceId) {
13
+ value: function init(config, instanceId, sdkMetaData, mockOptions) {
14
14
  return null;
15
15
  }
16
16
  // TODO 定义返回类型和实际类型不一致
@@ -58,6 +58,9 @@ export declare const getWebAppV2Url: (params: {
58
58
  query: QueryParams;
59
59
  mid?: string;
60
60
  extendInfo?: string;
61
+ mockOptions?: {
62
+ [key: string]: any;
63
+ };
61
64
  }) => string;
62
65
  export declare const getWebAppUrl: (params: {
63
66
  environment: string;
@@ -7,7 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
7
7
  import { marmotMap, sdkVersion, v2AppMarmotMap } from "../../config";
8
8
  import { ESP_PAGE_NAME } from "../../constant/easysafepay";
9
9
  import { ComponentSignEnum, ProductSceneEnum } from "../../types";
10
- import { queryParse, serialize } from "../../util";
10
+ import { genProxyUrl, queryParse, serialize } from "../../util";
11
11
  import { isDebugLog } from "../../util/debug";
12
12
  import { compareVersion } from "../../util/versionCompare";
13
13
 
@@ -39,10 +39,11 @@ export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
39
39
  _queryParse$groupId = _queryParse.groupId,
40
40
  groupId = _queryParse$groupId === void 0 ? '' : _queryParse$groupId,
41
41
  LOCAL_MOCK = _queryParse.LOCAL_MOCK,
42
- _displayType = _queryParse._displayType;
42
+ _displayType = _queryParse._displayType,
43
+ __DEBUG_TOKEN__ = _queryParse.__DEBUG_TOKEN__;
43
44
  var urlParams = {};
44
- for (var key in query) {
45
- urlParams[key] = '' + query[key];
45
+ for (var _key in query) {
46
+ urlParams[_key] = '' + query[_key];
46
47
  }
47
48
  // 如果是preload模式,添加一个preload的query参数
48
49
  if (isPreload) {
@@ -58,6 +59,7 @@ export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
58
59
  if (environment === 'light_sandbox' || _light_sandbox === 'true') urlParams.sandbox = 'true';
59
60
  if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
60
61
  if (_displayType) urlParams.displayType = _displayType;
62
+ if (__DEBUG_TOKEN__) urlParams.__DEBUG_TOKEN__ = __DEBUG_TOKEN__;
61
63
  var locationSearch = serialize(urlParams);
62
64
  if (isDebugLog()) {
63
65
  console.log('appUpgrade#getIframeUrl#appMatched', urlParams.appMatched);
@@ -73,7 +75,8 @@ export var getWebAppV2Url = function getWebAppV2Url(params) {
73
75
  isPreload = params.isPreload,
74
76
  mid = params.mid,
75
77
  extendInfo = params.extendInfo,
76
- environment = params.environment;
78
+ environment = params.environment,
79
+ mockOptions = params.mockOptions;
77
80
  var webAppUrlMatchConfig = parseWebAppUrlMatchConfig(extendInfo);
78
81
  var v2Url = isPreload ? getLocalCheckoutUrl(productScene, environment) : getMatchedWebAppV2Url(productScene, mid, webAppUrlMatchConfig, environment);
79
82
  var info = getWebAppUrlInfo(_objectSpread(_objectSpread({}, params), {}, {
@@ -84,10 +87,14 @@ export var getWebAppV2Url = function getWebAppV2Url(params) {
84
87
  saveLocalCheckoutUrl(productScene, info.path);
85
88
  }
86
89
  var webAppUrl;
87
- if (info.path.indexOf('?') !== -1) {
88
- webAppUrl = "".concat(info.path, "&").concat(info.locationSearch);
90
+ var path = info.path;
91
+ if (mockOptions && mockOptions.useMock === true) {
92
+ path = genProxyUrl(info.path, environment);
93
+ }
94
+ if (path.indexOf('?') !== -1) {
95
+ webAppUrl = "".concat(path, "&").concat(info.locationSearch);
89
96
  } else {
90
- webAppUrl = "".concat(info.path, "?").concat(info.locationSearch);
97
+ webAppUrl = "".concat(path, "?").concat(info.locationSearch);
91
98
  }
92
99
  console.log('[web-sdk] web app, url: ', webAppUrl);
93
100
  return webAppUrl;
package/esm/index.js CHANGED
@@ -252,6 +252,7 @@ export var AMSEasyPay = /*#__PURE__*/function () {
252
252
  type: DisplayTypeEnum.popup
253
253
  },
254
254
  isAppWebview: params.isAppWebview,
255
+ mockOptions: params.mockOptions,
255
256
  isNativeAppWebview: params.isNativeAppWebview
256
257
  });
257
258
  }