@alipay/ams-checkout 0.0.1754894468-dev.11 → 0.0.1754894468-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 (59) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/popupWindow.style.d.ts +18 -9
  3. package/esm/component/popupWindow.style.js +21 -11
  4. package/esm/config/index.d.ts +8 -7
  5. package/esm/config/index.js +8 -7
  6. package/esm/config/request.js +14 -2
  7. package/esm/constant/index.d.ts +58 -0
  8. package/esm/constant/index.js +64 -1
  9. package/esm/core/component/element/EventCenter/index.d.ts +31 -0
  10. package/esm/core/component/element/EventCenter/index.js +178 -0
  11. package/esm/core/component/element/elementContainerService/containerService.d.ts +1 -0
  12. package/esm/core/component/element/elementContainerService/containerService.js +8 -2
  13. package/esm/core/component/element/elementController/index.d.ts +24 -3
  14. package/esm/core/component/element/elementController/index.js +534 -189
  15. package/esm/core/component/element/elementProcessor/addressProcessor.js +5 -6
  16. package/esm/core/component/element/elementProcessor/authProcessor.js +2 -3
  17. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +2 -0
  18. package/esm/core/component/element/elementProcessor/paymentProcessor.js +55 -19
  19. package/esm/core/component/element/index.d.ts +6 -5
  20. package/esm/core/component/element/index.js +14 -3
  21. package/esm/core/component/element/mock.js +1 -0
  22. package/esm/core/component/element/type.d.ts +57 -4
  23. package/esm/core/component/element/type.js +63 -2
  24. package/esm/core/component/element/util.d.ts +20 -4
  25. package/esm/core/component/element/util.js +59 -7
  26. package/esm/foundation/core/index.js +27 -8
  27. package/esm/foundation/index.d.ts +1 -0
  28. package/esm/foundation/product-processor/easysafepay/index.js +4 -2
  29. package/esm/foundation/service/container/popup.d.ts +11 -0
  30. package/esm/foundation/service/container/popup.js +23 -2
  31. package/esm/foundation/service/log/keys.js +4 -0
  32. package/esm/foundation/service/requester/requester.js +2 -3
  33. package/esm/index.js +2 -1
  34. package/esm/plugin/applepay/index.d.ts +0 -4
  35. package/esm/plugin/applepay/index.js +10 -8
  36. package/esm/plugin/component/channel.js +20 -4
  37. package/esm/plugin/component/index.d.ts +1 -0
  38. package/esm/plugin/component/index.js +9 -5
  39. package/esm/plugin/drop-in/index.d.ts +2 -0
  40. package/esm/plugin/drop-in/index.js +2 -2
  41. package/esm/types/index.d.ts +22 -2
  42. package/esm/types/index.js +2 -1
  43. package/esm/util/spm-map.d.ts +24 -2
  44. package/esm/util/spm-map.js +14 -1
  45. package/package.json +1 -1
  46. package/esm/core/component/oldElement/components/address.d.ts +0 -19
  47. package/esm/core/component/oldElement/components/address.js +0 -68
  48. package/esm/core/component/oldElement/components/auth.d.ts +0 -17
  49. package/esm/core/component/oldElement/components/auth.js +0 -60
  50. package/esm/core/component/oldElement/components/payment.d.ts +0 -19
  51. package/esm/core/component/oldElement/components/payment.js +0 -74
  52. package/esm/core/component/oldElement/index.d.ts +0 -59
  53. package/esm/core/component/oldElement/index.js +0 -956
  54. package/esm/core/component/oldElement/mock.d.ts +0 -6
  55. package/esm/core/component/oldElement/mock.js +0 -567
  56. package/esm/core/component/oldElement/type.d.ts +0 -354
  57. package/esm/core/component/oldElement/type.js +0 -81
  58. package/esm/core/component/oldElement/utils.d.ts +0 -13
  59. package/esm/core/component/oldElement/utils.js +0 -6
@@ -25,20 +25,32 @@ export var formatElementOption = function formatElementOption(options) {
25
25
  });
26
26
  };
27
27
  export var validateElementOption = function validateElementOption(options) {
28
+ var errors = [];
28
29
  if (!options.sessionData) {
30
+ console.error('sessionData is empty, please check new AMSElement params.');
31
+ errors.push({
32
+ field: 'sessionData',
33
+ message: 'sessionData is empty'
34
+ });
35
+ }
36
+ if (errors.length > 0) {
29
37
  var _options$onEventCallb;
30
38
  options === null || options === void 0 || (_options$onEventCallb = options.onEventCallback) === null || _options$onEventCallb === void 0 || _options$onEventCallb.call(options, {
31
39
  code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
32
40
  message: 'sessionData is empty'
33
41
  });
34
- return false;
35
42
  }
36
- return true;
43
+ return {
44
+ isValid: errors.length === 0,
45
+ errors: errors
46
+ };
37
47
  };
38
48
 
39
49
  /**
40
50
  * 校验渲染条件
41
- * 校验当前sdkSelector结点是否存在
51
+ * 1.校验当前 sdkSelector 结点是否存在
52
+ * 2.校验当前 Element 的状态是否能够渲染
53
+ * 3.校验当前 type 类型 Elment 是否已经执行过 mount
42
54
  */
43
55
  export function checkCanMount(_ref) {
44
56
  var sdkSelector = _ref.sdkSelector,
@@ -50,13 +62,15 @@ export function checkCanMount(_ref) {
50
62
  console.error("Element with selector ".concat(sdkSelector, " not found."));
51
63
  return {
52
64
  success: false,
53
- errorMsg: "Element with selector ".concat(sdkSelector, " not found.")
65
+ errorMsg: "Element with selector ".concat(sdkSelector, " not found."),
66
+ error: ERRORMESSAGE.PARAM_INVALID
54
67
  };
55
68
  }
56
69
  if (status === IElementStatus.DESTROYED) {
57
70
  return {
58
71
  success: false,
59
- errorMsg: "Creating components in the destroyed state is forbidden."
72
+ errorMsg: "Creating components in the destroyed state is forbidden.",
73
+ error: ERRORMESSAGE.UI_STATE_ERROR
60
74
  };
61
75
  }
62
76
  if (status === IElementStatus.READY) {
@@ -67,7 +81,8 @@ export function checkCanMount(_ref) {
67
81
  if (containerService) {
68
82
  return {
69
83
  success: false,
70
- errorMsg: "SDK status error."
84
+ errorMsg: "SDK status error.",
85
+ error: ERRORMESSAGE.UI_STATE_ERROR
71
86
  };
72
87
  }
73
88
  return {
@@ -429,7 +444,7 @@ export function showToast() {
429
444
  textAlign: 'center',
430
445
  marginTop: '12px',
431
446
  lineHeight: '20px',
432
- fontFamily: "Noto Sans",
447
+ fontFamily: 'Noto Sans',
433
448
  fontWeight: 400,
434
449
  fontSize: '14px'
435
450
  }
@@ -474,4 +489,41 @@ export var isElementPad = function isElementPad() {
474
489
  };
475
490
  export var isElementPC = function isElementPC() {
476
491
  return !isElementMobile();
492
+ };
493
+
494
+ /**
495
+ * 判断是否需要加载错误页
496
+ * @param {CashierSdkActionQueryResult} params
497
+ * @returns {boolean} - 是否需要加载错误页
498
+ */
499
+ export var isLoadErrorPage = function isLoadErrorPage(params) {
500
+ var success = params.success,
501
+ paymentMethods = params.paymentMethods,
502
+ savedPaymentMethods = params.savedPaymentMethods,
503
+ orderAmountView = params.orderAmountView,
504
+ paymentAmountView = params.paymentAmountView;
505
+
506
+ // 校验是否存在支付方式
507
+ var hasValidPaymentMethods = paymentMethods && Array.isArray(paymentMethods) && paymentMethods.length > 0 || savedPaymentMethods && Array.isArray(savedPaymentMethods) && savedPaymentMethods.length > 0;
508
+
509
+ // 金额存在性校验
510
+ var hasAmountViews = !!orderAmountView && !!paymentAmountView;
511
+
512
+ // 错误条件判断(满足任意条件即需要展示错误页)
513
+ return !success ||
514
+ // 接口请求失败
515
+ !hasValidPaymentMethods ||
516
+ // 无有效支付方式
517
+ !hasAmountViews // 缺少金额展示
518
+ ;
519
+ };
520
+ export var safeStringify = function safeStringify(payload) {
521
+ var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
522
+ if (!payload) return defaultValue;
523
+ try {
524
+ return JSON.stringify(payload) || defaultValue;
525
+ } catch (e) {
526
+ console.error('JSON.stringify failed:', e);
527
+ return defaultValue;
528
+ }
477
529
  };
@@ -242,7 +242,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
242
242
  value: function () {
243
243
  var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
244
244
  var _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3;
245
- var paymentSession, displayInfo, _convertPaymentSessio2, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload;
245
+ var paymentSession, displayInfo, _convertPaymentSessio2, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload, eventCenter, data;
246
246
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
247
247
  while (1) switch (_context4.prev = _context4.next) {
248
248
  case 0:
@@ -252,9 +252,6 @@ export var AntomSDKCore = /*#__PURE__*/function () {
252
252
  }
253
253
  throw new Error('paymentSession is empty');
254
254
  case 2:
255
- this.logger.logInfo({
256
- title: 'sdk_event_createComponent'
257
- });
258
255
  this.setStatus(IElementStatus.IN_BIZ_FLOW);
259
256
  paymentSession = options.paymentSession, displayInfo = options.displayInfo;
260
257
  _convertPaymentSessio2 = convertPaymentSession(paymentSession), paymentSessionId = _convertPaymentSessio2.id, paymentSessionMetaData = _convertPaymentSessio2.data;
@@ -272,10 +269,14 @@ export var AntomSDKCore = /*#__PURE__*/function () {
272
269
  webAppMatchConfig = parseWebAppMatchConfig(this.paymentContext.paymentSessionObj.extendInfo);
273
270
  webAppVersion = getWebAppVersion(this.sdkMetaData, mid, webAppMatchConfig);
274
271
  this.sdkMetaData.webAppVersion = webAppVersion;
275
- saveWebAppVersion(webAppVersion, this.sdkMetaData);
276
-
277
272
  // Call service to update via payment context
278
273
  ServiceProvider.getInstance(this.instanceId).update(this.paymentContext);
274
+ // Element使用了新的埋点方案,后续ESP、VAULTING需要同步,将废弃sdk_event_createComponent
275
+ this.logger.logInfo({
276
+ title: 'sdk_event_createComponent'
277
+ });
278
+ // Storage operations are placed after logInfo
279
+ saveWebAppVersion(webAppVersion, this.sdkMetaData);
279
280
 
280
281
  // Invoke processor
281
282
  productScene = (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentSessionConfig) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.productScene;
@@ -322,13 +323,31 @@ export var AntomSDKCore = /*#__PURE__*/function () {
322
323
  return _context4.abrupt("return");
323
324
  case 36:
324
325
  if (!(this.bizFlowStartBehavior.behaviorType === 'REDIRECT')) {
325
- _context4.next = 40;
326
+ _context4.next = 45;
326
327
  break;
327
328
  }
328
329
  payload = (_this$bizFlowStartBeh = this.bizFlowStartBehavior) === null || _this$bizFlowStartBeh === void 0 ? void 0 : _this$bizFlowStartBeh.payload;
330
+ if (!options.isNativeAppWebview) {
331
+ _context4.next = 43;
332
+ break;
333
+ }
334
+ eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
335
+ data = {
336
+ normalUrl: (payload === null || payload === void 0 ? void 0 : payload.url) || '',
337
+ schemeUrl: (payload === null || payload === void 0 ? void 0 : payload.schemeUrl) || '',
338
+ applinkUrl: (payload === null || payload === void 0 ? void 0 : payload.applinkUrl) || ''
339
+ };
340
+ eventCenter.emit(EVENT.eventCallback.name, {
341
+ code: eventCodeEnum.SDK_REDIRECT,
342
+ result: {
343
+ redirectUrls: data
344
+ }
345
+ });
346
+ return _context4.abrupt("return");
347
+ case 43:
329
348
  redirect(payload, this.instanceId);
330
349
  return _context4.abrupt("return");
331
- case 40:
350
+ case 45:
332
351
  case "end":
333
352
  return _context4.stop();
334
353
  }
@@ -20,6 +20,7 @@ export interface StartBizFlowOptions {
20
20
  displayInfo?: Partial<DisplayInfo>;
21
21
  submitPayRequestExtra?: any;
22
22
  isAppWebview?: boolean;
23
+ isNativeAppWebview?: boolean;
23
24
  }
24
25
  export declare class DisplayInfo {
25
26
  type: DisplayTypeEnum;
@@ -208,6 +208,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
208
208
  appearance: (_this$paymentContext$ = _this.paymentContext.displayInfo) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.appearance,
209
209
  notRedirectAfterComplete: ((_this$paymentContext$2 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.notRedirectAfterComplete) === true,
210
210
  isAppWebview: _this.paymentContext.startBizFlowOptions.isAppWebview,
211
+ isNativeAppWebview: _this.paymentContext.startBizFlowOptions.isNativeAppWebview,
211
212
  merchantAppointParam: (_this$paymentContext$3 = _this.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.merchantAppointParam,
212
213
  allowSubmitPayCallAhead: _this.allowSubmitPayCallAhead,
213
214
  doubleFaUrl: getDoubleFaUrlFromSession((_this$paymentContext3 = _this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionObj, _this.initConfig.environment),
@@ -350,7 +351,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
350
351
  value: function () {
351
352
  var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
352
353
  var _this$paymentContext9, _this$paymentContext10, _this$paymentContext11, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$8, _this$paymentContext12;
353
- var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$7, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, _this$paymentContext$9, res;
354
+ var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$7, paymentMethodType, isAppWebview, isNativeAppWebview, backScheme, requestBizId, extParams, requester, _this$paymentContext$9, res;
354
355
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
355
356
  while (1) switch (_context3.prev = _context3.next) {
356
357
  case 0:
@@ -365,7 +366,8 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
365
366
  submitParams['signAgreement'] = enableSignAgreement;
366
367
  paymentMethodType = (_this$paymentContext$7 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$7 === void 0 || (_this$paymentContext$7 = _this$paymentContext$7.paymentMethodInfoView) === null || _this$paymentContext$7 === void 0 ? void 0 : _this$paymentContext$7.paymentMethodType;
367
368
  isAppWebview = this.paymentContext.startBizFlowOptions.isAppWebview;
368
- if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
369
+ isNativeAppWebview = this.paymentContext.startBizFlowOptions.isNativeAppWebview;
370
+ if (paymentMethodType === 'ALIPAY_CN' && (!isAppWebview || !isNativeAppWebview)) {
369
371
  backScheme = getBackScheme(undefined, this.logger);
370
372
  if (backScheme && backScheme !== 'https') {
371
373
  submitParams['h5FromApp'] = encodeURIComponent(backScheme);
@@ -6,6 +6,11 @@ export type IPopUpParams = {
6
6
  platform: PlatformEnum;
7
7
  showCloseOnLoading: boolean;
8
8
  onCloseOnLoading: () => void;
9
+ textDirection?: 'ltr' | 'rtl';
10
+ loadingConfig?: {
11
+ theme?: string;
12
+ backgroundPrimary?: string;
13
+ };
9
14
  };
10
15
  /**
11
16
  * @author 谦彧 <zhangmian.zm@alipay.com>
@@ -15,6 +20,12 @@ export declare class PopupManager {
15
20
  private popupUrlQuery;
16
21
  popupApp: HTMLIFrameElement;
17
22
  setPopupUrlQuery(queryParams: string): void;
23
+ /**
24
+ * 合并URL参数, 优先加载弹窗参数作为基准, 用baseUrl参数覆盖弹窗参数
25
+ * @param baseUrl 基础URL
26
+ * @returns 合并后的URL
27
+ */
28
+ private mergeUrlParams;
18
29
  popup(data: IPopUpParams): Promise<void>;
19
30
  pop(): void;
20
31
  }
@@ -25,6 +25,26 @@ export var PopupManager = /*#__PURE__*/function () {
25
25
  value: function setPopupUrlQuery(queryParams) {
26
26
  this.popupUrlQuery = queryParams;
27
27
  }
28
+ /**
29
+ * 合并URL参数, 优先加载弹窗参数作为基准, 用baseUrl参数覆盖弹窗参数
30
+ * @param baseUrl 基础URL
31
+ * @returns 合并后的URL
32
+ */
33
+ }, {
34
+ key: "mergeUrlParams",
35
+ value: function mergeUrlParams(baseUrl) {
36
+ var urlObj = new URL(baseUrl);
37
+ // 优先加载弹窗参数作为基准
38
+ var mergedParams = new URLSearchParams(this.popupUrlQuery.replace(/^(?:\?|%3F)/i, ''));
39
+ // 用baseUrl参数覆盖弹窗参数(set方法自动覆盖)
40
+ urlObj.searchParams.forEach(function (value, key) {
41
+ mergedParams.set(key, value);
42
+ });
43
+ // 将合并后的参数设置到URL对象中
44
+ urlObj.search = mergedParams.toString();
45
+ // 返回合并后的URL
46
+ return urlObj.toString();
47
+ }
28
48
  }, {
29
49
  key: "popup",
30
50
  value: function () {
@@ -45,7 +65,7 @@ export var PopupManager = /*#__PURE__*/function () {
45
65
  pageUrl = data.url;
46
66
  _context.prev = 6;
47
67
  if (this.popupUrlQuery) {
48
- pageUrl = data.url.includes('?') ? "".concat(data.url, "&").concat(this.popupUrlQuery) : "".concat(data.url, "?").concat(this.popupUrlQuery);
68
+ pageUrl = this.mergeUrlParams(data.url);
49
69
  }
50
70
  isLoad = false;
51
71
  _context.next = 11;
@@ -55,7 +75,8 @@ export var PopupManager = /*#__PURE__*/function () {
55
75
  url: pageUrl,
56
76
  loadingConfig: undefined,
57
77
  showCloseOnLoading: data.showCloseOnLoading,
58
- onCloseOnLoading: data.onCloseOnLoading
78
+ onCloseOnLoading: data.onCloseOnLoading,
79
+ textDirection: data === null || data === void 0 ? void 0 : data.textDirection
59
80
  });
60
81
  case 11:
61
82
  this.popupApp = _context.sent;
@@ -51,6 +51,8 @@ _defineProperty(LogComplianceExtendKeys, "complianceExtParams", {
51
51
  callbackData: 'C',
52
52
  callbackId: 'C',
53
53
  actionNames: 'C',
54
+ isValid: 'C',
55
+ needChangeSessionForRetry: 'C',
54
56
  // D 维度信息
55
57
  operationType: 'D',
56
58
  jsApi: 'D',
@@ -86,6 +88,8 @@ _defineProperty(LogComplianceExtendKeys, "complianceExtParams", {
86
88
  // 用来标记事件别名
87
89
  success: 'D',
88
90
  // 用来标记行为是否成功
91
+ startTime: 'D',
92
+ endTime: 'D',
89
93
  // M 数字类型
90
94
  timeCost: 'M',
91
95
  pageLoadProgress: 'M',
@@ -12,8 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
12
12
  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); }
13
13
  import axios from 'axios';
14
14
  import { ServiceProvider } from '..';
15
- import { errorEnum } from "./deps";
16
- import { appId, device, fomatGetwayError, get, hostSignMap, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
15
+ import { appId, device, errorEnum, fomatGetwayError, get, hostSignMap, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
17
16
 
18
17
  /**
19
18
  * @author congle.zzq <congle.zzq@alipay.com>
@@ -116,7 +115,7 @@ export var RequesterService = /*#__PURE__*/function () {
116
115
  errorMessage: _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message
117
116
  });
118
117
  timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
119
- _errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
118
+ _errorCode = timeoutCode || (_error === null || _error === void 0 ? void 0 : _error.errorCode);
120
119
  this.reportRequestTimeCost({
121
120
  title: 'a3753.b101271.c388193.d521387',
122
121
  name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
package/esm/index.js CHANGED
@@ -251,7 +251,8 @@ export var AMSEasyPay = /*#__PURE__*/function () {
251
251
  displayInfo: {
252
252
  type: DisplayTypeEnum.popup
253
253
  },
254
- isAppWebview: params.isAppWebview
254
+ isAppWebview: params.isAppWebview,
255
+ isNativeAppWebview: params.isNativeAppWebview
255
256
  });
256
257
  }
257
258
  }, {
@@ -1,9 +1,5 @@
1
1
  import type { Logger } from "../../util/logger";
2
2
  import { BusContext, BusMessage, BusSubscriber } from "../../core/bus";
3
- export declare class ApplePayInitMessage {
4
- private environment;
5
- private locale;
6
- }
7
3
  export declare class ApplePayBusSubscriber extends BusSubscriber {
8
4
  private applePay;
9
5
  logger: Logger;
@@ -1,6 +1,9 @@
1
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
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
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; }
4
7
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
5
8
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
6
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -8,9 +11,6 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
8
11
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9
12
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
13
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11
- 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); } }
12
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
14
  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; }
15
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
16
  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); }
@@ -18,11 +18,13 @@ import { BusManager, BusMessage, BusSubscriber } from "../../core/bus";
18
18
  import { ApplePayActionEnum, PaymentActionEnum, SDKCallbackActionEnum } from "../../core/bus/interface";
19
19
  import ApplePayComponent, { ApplePayComponentEvent } from "./component";
20
20
  import ApplePayService from "./service";
21
- export var ApplePayInitMessage = /*#__PURE__*/_createClass(function ApplePayInitMessage() {
22
- _classCallCheck(this, ApplePayInitMessage);
23
- _defineProperty(this, "environment", void 0);
24
- _defineProperty(this, "locale", void 0);
25
- });
21
+
22
+ // TODO 无意义代码
23
+ // export class ApplePayInitMessage {
24
+ // private environment:string;
25
+ // private locale:string;
26
+ // }
27
+
26
28
  export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
27
29
  _inherits(ApplePayBusSubscriber, _BusSubscriber);
28
30
  var _super = _createSuper(ApplePayBusSubscriber);
@@ -8,14 +8,14 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
8
8
  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; }
9
9
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
10
  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); }
11
+ import { MODE } from "../../constant/easysafepay";
11
12
  import { BusManager, BusMessage } from "../../core/bus";
12
13
  import { SecuritySDKActionEnum } from "../../core/bus/interface";
14
+ import { getDoubleFaUrlFromSession } from "../../foundation/utils/web_app_url_utils";
13
15
  import { getApplePayPaymentSession, submitPayInfo } from "../../service";
14
16
  import { EnvironmentEnum } from "../../types";
15
17
  import { device, isEmpty } from "../../util";
16
18
  import { APPLE_PAY_RECURRING_VERSION, APPLE_PAY_VERSION } from "../applepay/interface";
17
- import { getDoubleFaUrlFromSession } from "../../foundation/utils/web_app_url_utils";
18
- import { MODE } from "../../constant/easysafepay";
19
19
  var APPLEPAYERRORENUM = /*#__PURE__*/function (APPLEPAYERRORENUM) {
20
20
  APPLEPAYERRORENUM["APPLE_PAY_MISSING_DATA"] = "APPLE_PAY_MISSING_DATA";
21
21
  APPLEPAYERRORENUM["APPLE_PAY_NOT_SUPPORTED"] = "APPLE_PAY_NOT_SUPPORTED";
@@ -103,8 +103,21 @@ export var handleGooglePay = function handleGooglePay(data) {
103
103
  }
104
104
  }
105
105
  });
106
- // 获取到googlePay token后返回消息给app
107
- paymentsClient.loadPaymentData(paymentRequest).then(function (paymentData) {
106
+ // 使用GooglePay官方API判断设备是否支持,目前WebView场景有bug,不支持的WebView仍然显示支持
107
+ // UA判断方案和isReadyToPay方案PD决策使用【isReadyToPay方案】
108
+ // PD已反馈给Google,Google已确认bug待修复
109
+ paymentsClient.isReadyToPay(paymentRequest).then(function (response) {
110
+ if (response.result) {
111
+ // 设备支持 GooglePay,继续拉起
112
+ return paymentsClient.loadPaymentData(paymentRequest);
113
+ } else {
114
+ // 抛错给收银台,目前errorCode未消费
115
+ reject({
116
+ errorCode: 'GOOGLE_PAY_NOT_SUPPORTED'
117
+ });
118
+ }
119
+ }).then(function (paymentData) {
120
+ // 获取到googlePay token后返回消息给app
108
121
  if (paymentData) {
109
122
  resolve(paymentData);
110
123
  }
@@ -112,6 +125,9 @@ export var handleGooglePay = function handleGooglePay(data) {
112
125
  reject(err);
113
126
  });
114
127
  };
128
+ script.onerror = function (err) {
129
+ reject(err);
130
+ };
115
131
  });
116
132
  };
117
133
  export var ApplePaySdk = /*#__PURE__*/function () {
@@ -26,6 +26,7 @@ export default class ComponentApp {
26
26
  private _renderDisplayType;
27
27
  private _multipleCallbackEvents;
28
28
  private _isAppWebview;
29
+ private _isNativeAppWebview;
29
30
  _merchantAppointParam: IMerchantAppointParam;
30
31
  private _webAppHeartBeatTimeoutFn;
31
32
  private _hasRenderComponent;
@@ -17,13 +17,13 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
17
  * 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.
18
18
  */
19
19
  /* eslint-disable @typescript-eslint/no-explicit-any */
20
+ import { ElementPaymentMethod } from "../../core/component/element/type";
20
21
  import { v4 as uuid } from 'uuid';
21
22
  import { sdkVersion } from "../../config";
22
23
  import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID, POPUP_LOADTIME_LOG_LIMIT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../constant";
23
- import { ElementPaymentMethod } from "../../core/component/oldElement/type";
24
24
  import { queryPaymentInfo, submitPayInfo } from "../../service";
25
25
  import { ComponentSignEnum, DisplayTypeEnum, eventCodeEnum, MessageName, PlatformEnum, ProductSceneEnum, RedirectType, TargetEnum } from "../../types";
26
- import { getType, isJsonString, isPC, device } from "../../util";
26
+ import { device, getType, isJsonString, isPC } from "../../util";
27
27
  import { getBackScheme } from "../../util/getBackScheme";
28
28
  import { isLocalMock } from "../../util/mock";
29
29
  import { matchVersion } from "../../util/versionCompare";
@@ -60,6 +60,7 @@ var ComponentApp = /*#__PURE__*/function () {
60
60
  _defineProperty(this, "_renderDisplayType", DisplayTypeEnum.popup);
61
61
  _defineProperty(this, "_multipleCallbackEvents", void 0);
62
62
  _defineProperty(this, "_isAppWebview", void 0);
63
+ _defineProperty(this, "_isNativeAppWebview", void 0);
63
64
  _defineProperty(this, "_merchantAppointParam", void 0);
64
65
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
65
66
  _defineProperty(this, "_hasRenderComponent", false);
@@ -282,6 +283,7 @@ var ComponentApp = /*#__PURE__*/function () {
282
283
  var inlineId = "".concat(COMPONENT_CONTAINER_ID).concat(appendAliasContainerId);
283
284
  var insertedNode = (this === null || this === void 0 ? void 0 : this._renderDisplayType) === DisplayTypeEnum.inline ? "#".concat(inlineId) : this === null || this === void 0 ? void 0 : this._selector;
284
285
  this._isAppWebview = renderParams.isAppWebview;
286
+ this._isNativeAppWebview = renderParams.isNativeAppWebview;
285
287
  this.initLoggerMeta();
286
288
  this.initSecurity();
287
289
  this._performanceData.push({
@@ -739,7 +741,7 @@ var ComponentApp = /*#__PURE__*/function () {
739
741
  this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
740
742
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
741
743
  var _channelBehavior$buil, _this6$_renderParams$, _this6$_renderParams4;
742
- var shouldSkipSubmitPayInSDK, _this6$_renderParams, _this6$_renderParams2, _this6$_renderParams3, _ref10, _ref10$productSceneVe, productSceneVersion, _ref10$productScene, productScene, _ref11, _ref11$action, _ref11$action2, _ref11$action2$enable, enableSignAgreement, _ref11$action2$autoDe, autoDebitWithToken, _ref12, _ref12$paymentMethodI, _ref12$paymentMethodI2, _ref12$paymentMethodI3, paymentMethodType, isAppWebview, backScheme, extParams;
744
+ var shouldSkipSubmitPayInSDK, _this6$_renderParams, _this6$_renderParams2, _this6$_renderParams3, _ref10, _ref10$productSceneVe, productSceneVersion, _ref10$productScene, productScene, _ref11, _ref11$action, _ref11$action2, _ref11$action2$enable, enableSignAgreement, _ref11$action2$autoDe, autoDebitWithToken, _ref12, _ref12$paymentMethodI, _ref12$paymentMethodI2, _ref12$paymentMethodI3, paymentMethodType, isAppWebview, isNativeAppWebview, backScheme, extParams;
743
745
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
744
746
  while (1) switch (_context3.prev = _context3.next) {
745
747
  case 0:
@@ -764,9 +766,10 @@ var ComponentApp = /*#__PURE__*/function () {
764
766
  _ref11 = ((_this6$_renderParams2 = _this6._renderParams) === null || _this6$_renderParams2 === void 0 ? void 0 : _this6$_renderParams2.paymentSessionMetaData) || {}, _ref11$action = _ref11.action, _ref11$action2 = _ref11$action === void 0 ? {} : _ref11$action, _ref11$action2$enable = _ref11$action2.enableSignAgreement, enableSignAgreement = _ref11$action2$enable === void 0 ? false : _ref11$action2$enable, _ref11$action2$autoDe = _ref11$action2.autoDebitWithToken, autoDebitWithToken = _ref11$action2$autoDe === void 0 ? false : _ref11$action2$autoDe;
765
767
  _ref12 = ((_this6$_renderParams3 = _this6._renderParams) === null || _this6$_renderParams3 === void 0 ? void 0 : _this6$_renderParams3.paymentSessionMetaData) || {}, _ref12$paymentMethodI = _ref12.paymentMethodInfoView, _ref12$paymentMethodI2 = _ref12$paymentMethodI === void 0 ? {} : _ref12$paymentMethodI, _ref12$paymentMethodI3 = _ref12$paymentMethodI2.paymentMethodType, paymentMethodType = _ref12$paymentMethodI3 === void 0 ? '' : _ref12$paymentMethodI3;
766
768
  if (productScene === ProductSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
767
- isAppWebview = _this6._isAppWebview || false; ///EasyPay 2.0 首次传signAgreement字段
769
+ isAppWebview = _this6._isAppWebview || false;
770
+ isNativeAppWebview = _this6._isNativeAppWebview || false; ///EasyPay 2.0 首次传signAgreement字段
768
771
  params['signAgreement'] = enableSignAgreement;
769
- if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
772
+ if (paymentMethodType === 'ALIPAY_CN' && (!isAppWebview || !isNativeAppWebview)) {
770
773
  backScheme = getBackScheme(undefined, _this6.AMSSDK.logger);
771
774
  if (backScheme && backScheme !== 'https') {
772
775
  params['h5FromApp'] = encodeURIComponent(backScheme);
@@ -1869,6 +1872,7 @@ var ComponentApp = /*#__PURE__*/function () {
1869
1872
  appearance: (_this$_renderParams29 = this._renderParams) === null || _this$_renderParams29 === void 0 ? void 0 : _this$_renderParams29.appearance,
1870
1873
  notRedirectAfterComplete: ((_this$_renderParams30 = this._renderParams) === null || _this$_renderParams30 === void 0 ? void 0 : _this$_renderParams30.notRedirectAfterComplete) === true,
1871
1874
  isAppWebview: this._isAppWebview,
1875
+ isNativeAppWebview: this._isNativeAppWebview,
1872
1876
  merchantAppointParam: this._merchantAppointParam,
1873
1877
  allowSubmitPayCallAhead: this._allowSubmitPayCallAhead,
1874
1878
  /** 地址组件集成的参数 */
@@ -1,5 +1,7 @@
1
1
  import type AMSCheckout from '../../core/instance';
2
2
  import type { IcreatePaymentParams, EventPayload } from '../../types';
3
+ export declare const getServerPath: (_environment: string, version: string) => string;
4
+ export declare const getServerHost: (_environment: string, version: string) => string;
3
5
  export default class CheckoutApp {
4
6
  app: any;
5
7
  paymentMethodsResult: any;
@@ -15,7 +15,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
15
15
  import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
16
16
  import { MessageName } from "../../types";
17
17
  import { getOrigin, getType, getViewPort, isDom, isJsonString, serialize } from "../../util";
18
- var getServerPath = function getServerPath() {
18
+ export var getServerPath = function getServerPath() {
19
19
  var _environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
20
20
  var version = arguments.length > 1 ? arguments[1] : undefined;
21
21
  var host = '';
@@ -35,7 +35,7 @@ var getServerPath = function getServerPath() {
35
35
  }
36
36
  return host;
37
37
  };
38
- var getServerHost = function getServerHost(_environment, version) {
38
+ export var getServerHost = function getServerHost(_environment, version) {
39
39
  var reg = /^https?:\/\/([^/<>\s]+\.?)*/;
40
40
  var macth = reg.exec(getServerPath(_environment, version));
41
41
  return macth && macth[0] || '';
@@ -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;
@@ -594,6 +600,11 @@ export interface CashierSdkActionQueryResult {
594
600
  channelOrderId?: string;
595
601
  };
596
602
  errorActions?: Record<string, string>;
603
+ orderAmountView?: IAmountView;
604
+ paymentAmountView?: IAmountView;
605
+ paymentMethods?: IPaymentMethod[];
606
+ savedPaymentMethods?: IPaymentMethod[];
607
+ traceId?: string;
597
608
  }
598
609
  export interface CashierSdkActionQuerySessionResult extends IPaymentSessionMetaData {
599
610
  success: boolean;
@@ -674,7 +685,11 @@ export declare enum eventCodeEnum {
674
685
  SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING",
675
686
  SDK_PAYMENT_WARN = "SDK_PAYMENT_WARN",
676
687
  SDK_PAYMENT_SHIPPINGCHANGE = "SDK_PAYMENT_SHIPPINGCHANGE",
677
- 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"
678
693
  }
679
694
  export declare enum RedirectType {
680
695
  ApplinkUrl = "ApplinkUrl",
@@ -832,3 +847,8 @@ export declare enum EventLoggingEventId {
832
847
  LeaveAnyWay = "LeaveAnyWay",
833
848
  ContinuePaying = "ContinuePaying"
834
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) {