@alipay/ams-checkout 0.0.1761220900-dev.1 → 0.0.1762138227-dev.1

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.
@@ -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.45.0";
10
- export declare const AMSAutoDebitAppVersion = "1.45.0";
11
- export declare const AMSEasyPayAppVersion = "1.45.0";
12
- export declare const AMSCashierPaymentAppVersion = "1.45.0";
13
- export declare const AMSVaultingAppVersion = "1.45.0";
14
- export declare const AMSPaymentElementAppVersion = "1.45.0";
15
- export declare const ADDRESSElementAppVersion = "1.45.0";
16
- export declare const AUTHElementAppVersion = "1.45.0";
9
+ export declare const AMSCheckoutAppVersion = "1.46.0";
10
+ export declare const AMSAutoDebitAppVersion = "1.46.0";
11
+ export declare const AMSEasyPayAppVersion = "1.46.0";
12
+ export declare const AMSCashierPaymentAppVersion = "1.46.0";
13
+ export declare const AMSVaultingAppVersion = "1.46.0";
14
+ export declare const AMSPaymentElementAppVersion = "1.46.0";
15
+ export declare const ADDRESSElementAppVersion = "1.46.0";
16
+ export declare const AUTHElementAppVersion = "1.46.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.45.0'; // 兜底版本号
40
- export var AMSAutoDebitAppVersion = '1.45.0'; // 代扣
41
- export var AMSEasyPayAppVersion = '1.45.0'; // easypay
42
- export var AMSCashierPaymentAppVersion = '1.45.0'; // 收银台(卡、apm)
43
- export var AMSVaultingAppVersion = '1.45.0'; // 绑卡
44
- export var AMSPaymentElementAppVersion = '1.45.0'; // payment element
45
- export var ADDRESSElementAppVersion = '1.45.0'; // address element
46
- export var AUTHElementAppVersion = '1.45.0'; // auth element
39
+ export var AMSCheckoutAppVersion = '1.46.0'; // 兜底版本号
40
+ export var AMSAutoDebitAppVersion = '1.46.0'; // 代扣
41
+ export var AMSEasyPayAppVersion = '1.46.0'; // easypay
42
+ export var AMSCashierPaymentAppVersion = '1.46.0'; // 收银台(卡、apm)
43
+ export var AMSVaultingAppVersion = '1.46.0'; // 绑卡
44
+ export var AMSPaymentElementAppVersion = '1.46.0'; // payment element
45
+ export var ADDRESSElementAppVersion = '1.46.0'; // address element
46
+ export var AUTHElementAppVersion = '1.46.0'; // auth element
@@ -98,7 +98,7 @@ export declare const ERRORMESSAGE: {
98
98
  code: string;
99
99
  message: string;
100
100
  };
101
- INITALIZE_TIMEOUT: {
101
+ INITIALIZE_TIMEOUT: {
102
102
  code: string;
103
103
  API: {
104
104
  code: string;
@@ -98,14 +98,14 @@ export var ERRORMESSAGE = {
98
98
  code: 'UI_STATE_ERROR',
99
99
  message: 'An error occurred. The transaction cannot be initiated.'
100
100
  },
101
- INITALIZE_TIMEOUT: {
102
- code: 'INITALIZE_TIMEOUT',
101
+ INITIALIZE_TIMEOUT: {
102
+ code: 'INITIALIZE_TIMEOUT',
103
103
  API: {
104
- code: 'INITALIZE_API_TIMEOUT',
104
+ code: 'INITIALIZE_API_TIMEOUT',
105
105
  message: 'An error occurred. The transaction cannot be initiated.'
106
106
  },
107
107
  WEB: {
108
- code: 'INITALIZE_WEB_TIMEOUT',
108
+ code: 'INITIALIZE_WEB_TIMEOUT',
109
109
  message: 'An error occurred; the transaction cannot be initiated.'
110
110
  }
111
111
  },
@@ -287,7 +287,7 @@ export var EVENT = {
287
287
  },
288
288
  // Element支付完成后事件
289
289
  submitPromiseCallback: {
290
- name: 'submitPromiseCallback'
290
+ name: 'onSubmitPayCallback'
291
291
  },
292
292
  validateFieldsResult: {
293
293
  name: 'validateFieldsResult',
@@ -195,7 +195,7 @@ var ElementController = /*#__PURE__*/function () {
195
195
  title: 'sdk_event_web_app_timeout'
196
196
  });
197
197
  resolve({
198
- error: ERRORMESSAGE.INITALIZE_TIMEOUT.WEB
198
+ error: ERRORMESSAGE.INITIALIZE_TIMEOUT.WEB
199
199
  });
200
200
  }, TIMEOUT_DURATION);
201
201
  }
@@ -642,7 +642,7 @@ var ElementController = /*#__PURE__*/function () {
642
642
  _context5.t0 = _context5["catch"](1);
643
643
  this.handleInitializationError();
644
644
  readyCallback({
645
- error: _objectSpread(_objectSpread({}, ERRORMESSAGE.INITALIZE_TIMEOUT.API), {}, {
645
+ error: _objectSpread(_objectSpread({}, ERRORMESSAGE.INITIALIZE_TIMEOUT.API), {}, {
646
646
  traceId: _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.traceId
647
647
  })
648
648
  });
@@ -269,7 +269,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
269
269
  value: function () {
270
270
  var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
271
271
  var _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3;
272
- var paymentSession, displayInfo, _convertPaymentSessio2, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload, eventCenter, data;
272
+ var paymentSession, displayInfo, _convertPaymentSessio2, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload, eventCenter, data, normalUrl;
273
273
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
274
274
  while (1) switch (_context4.prev = _context4.next) {
275
275
  case 0:
@@ -350,14 +350,18 @@ export var AntomSDKCore = /*#__PURE__*/function () {
350
350
  return _context4.abrupt("return");
351
351
  case 36:
352
352
  if (!(this.bizFlowStartBehavior.behaviorType === 'REDIRECT')) {
353
- _context4.next = 45;
353
+ _context4.next = 49;
354
354
  break;
355
355
  }
356
356
  payload = (_this$bizFlowStartBeh = this.bizFlowStartBehavior) === null || _this$bizFlowStartBeh === void 0 ? void 0 : _this$bizFlowStartBeh.payload;
357
- if (!options.isNativeAppWebview) {
358
- _context4.next = 43;
357
+ console.log('sdk 打印', payload);
358
+ console.log('sdk 触发', options);
359
+ //Sessiondata中authUrlInfo的openInApp为true,说明端内打开,不需要处理isNativeAppWebview的外跳事件逻辑
360
+ if (!(options.isNativeAppWebview && !!!payload.openInApp)) {
361
+ _context4.next = 46;
359
362
  break;
360
363
  }
364
+ console.log('sdk 打印跳转', options);
361
365
  eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
362
366
  data = {
363
367
  normalUrl: (payload === null || payload === void 0 ? void 0 : payload.url) || '',
@@ -371,10 +375,16 @@ export var AntomSDKCore = /*#__PURE__*/function () {
371
375
  }
372
376
  });
373
377
  return _context4.abrupt("return");
374
- case 43:
378
+ case 46:
379
+ if (payload.url && payload.openInApp && options.isNativeAppWebview) {
380
+ //Sessiondata中authUrlInfo的openInApp为true,normalUrl存在,isNativeAppWebview为true,拼接source=embedded
381
+ normalUrl = new URL(payload.url);
382
+ normalUrl.searchParams.set('source', 'embedded');
383
+ payload.url = normalUrl.toString();
384
+ }
375
385
  redirect(payload, this.instanceId);
376
386
  return _context4.abrupt("return");
377
- case 45:
387
+ case 49:
378
388
  case "end":
379
389
  return _context4.stop();
380
390
  }
@@ -62,6 +62,7 @@ export interface RedirectBehaviorPayload {
62
62
  browserLinkTarget?: TargetEnum;
63
63
  isCallApp?: boolean;
64
64
  callAppDetectSuccessDelay?: number;
65
+ openInApp?: boolean;
65
66
  }
66
67
  /**
67
68
  * Provide some capability, such as MonitorService, EventBusService, SecurityService
@@ -153,13 +153,15 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
153
153
  data = {
154
154
  url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
155
155
  schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
156
- applinkUrl: 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
157
158
  };
158
159
  } else {
159
160
  data = {
160
161
  url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.normalUrl,
161
162
  schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.schemeUrl,
162
- applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.applinkUrl
163
+ applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.applinkUrl,
164
+ openInApp: (authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.openInApp) || false
163
165
  };
164
166
  }
165
167
  var result = {
@@ -15,7 +15,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
15
15
  * Proxy代理层
16
16
  * **/
17
17
  import ProxyPolyfillBuilder from 'proxy-polyfill/src/proxy';
18
- import { instanceApiMap } from "./constant";
18
+ import { EConstructorName, instanceApiMap } from "./constant";
19
19
  import { supportsDefineProperty, supportsProxy } from "./utils/common";
20
20
  import { setDebugContext } from "./utils/debugger";
21
21
  import { loadSdk, newActualInstance } from "./utils/loadSDK";
@@ -29,6 +29,7 @@ import { consoleLogger, logger } from "./utils/logger";
29
29
 
30
30
  // eslint-disable-next-line
31
31
  export function createBaseProxy(constructorName) {
32
+ var _this = this;
32
33
  var _newProxyInstance = function _newProxyInstance(self) {
33
34
  return new Proxy(self, {
34
35
  get: function get(target, prop) {
@@ -49,6 +50,7 @@ export function createBaseProxy(constructorName) {
49
50
  } else {
50
51
  // SDK未加载,记录调用
51
52
  return new Promise(function (resolve, reject) {
53
+ consoleLogger.log("Cache API [".concat(constructorName, ".").concat(prop, "]"));
52
54
  self.pendingCalls.push({
53
55
  method: prop,
54
56
  args: args,
@@ -88,6 +90,7 @@ export function createBaseProxy(constructorName) {
88
90
  } else {
89
91
  // SDK未加载,记录调用
90
92
  return new Promise(function (resolve, reject) {
93
+ consoleLogger.log("Cache API [".concat(constructorName, ".").concat(prop, "]"));
91
94
  self.pendingCalls.push({
92
95
  method: prop,
93
96
  args: args,
@@ -123,6 +126,81 @@ export function createBaseProxy(constructorName) {
123
126
  });
124
127
  return instanceForError;
125
128
  };
129
+
130
+ // 使用Promise.then来抛出错误对象 构造一个虚拟错误对象来模拟产品实例,其中所有的API都会在.then中返回错误对象
131
+ var throwErrorWithPromise = function throwErrorWithPromise(errorObj) {
132
+ var message = errorObj.error.message;
133
+ var instanceForError = _newInstanceForError(errorObj);
134
+ _this.actualInstance = instanceForError;
135
+ _this.hasActualInstance = true;
136
+ _this.executePendingCalls();
137
+ logger.logError({
138
+ title: message
139
+ }, {
140
+ errorMessage: message,
141
+ constructorName: constructorName
142
+ });
143
+ consoleLogger.error(message);
144
+ };
145
+
146
+ // 使用onEventCallback向外抛出SDK内部错误
147
+ var throwErrorWithOnEventCallback = function throwErrorWithOnEventCallback(errorObj, newProps) {
148
+ var onEventCallbackFn = newProps === null || newProps === void 0 ? void 0 : newProps.onEventCallback;
149
+ var message = errorObj.message;
150
+ if (typeof onEventCallbackFn === 'function') {
151
+ onEventCallbackFn === null || onEventCallbackFn === void 0 || onEventCallbackFn.call(null, errorObj);
152
+ }
153
+ logger.logError({
154
+ title: message
155
+ }, {
156
+ errorMessage: message,
157
+ constructorName: constructorName
158
+ });
159
+ consoleLogger.error(message);
160
+ };
161
+ var onCreateInstanceError = function onCreateInstanceError(newProps) {
162
+ // 不同实例进行不同的错误处理方案
163
+ if (constructorName === EConstructorName.AMSElement) {
164
+ throwErrorWithPromise({
165
+ error: {
166
+ code: 'INTERNAL_ERROR',
167
+ message: 'create_actual_instance_error'
168
+ },
169
+ status: 'FAIL'
170
+ });
171
+ } else if (constructorName === EConstructorName.AMSEasyPay) {
172
+ throwErrorWithOnEventCallback({
173
+ code: 'SDK_INTERNAL_ERROR',
174
+ message: 'create_actual_instance_error'
175
+ }, newProps);
176
+ } else {
177
+ throwErrorWithOnEventCallback({
178
+ code: 'SDK_INTERNAL_ERROR',
179
+ message: 'create_actual_instance_error'
180
+ }, newProps);
181
+ }
182
+ };
183
+ var onLoadSDKError = function onLoadSDKError(newProps) {
184
+ if (constructorName === EConstructorName.AMSElement) {
185
+ throwErrorWithPromise({
186
+ error: {
187
+ code: 'INITIALIZE_WEB_TIMEOUT',
188
+ message: 'load_sdk_resource_error'
189
+ },
190
+ status: 'FAIL'
191
+ });
192
+ } else if (constructorName === EConstructorName.AMSEasyPay) {
193
+ throwErrorWithOnEventCallback({
194
+ code: 'SDK_INTERNAL_ERROR',
195
+ message: 'load_sdk_resource_error'
196
+ }, newProps);
197
+ } else {
198
+ throwErrorWithOnEventCallback({
199
+ code: 'SDK_INTERNAL_ERROR',
200
+ message: 'load_sdk_resource_error'
201
+ }, newProps);
202
+ }
203
+ };
126
204
  var BaseProxy = /*#__PURE__*/function () {
127
205
  // 返回代理实例对象
128
206
  function BaseProxy(newProps, debugProps) {
@@ -150,7 +228,7 @@ export function createBaseProxy(constructorName) {
150
228
  _createClass(BaseProxy, [{
151
229
  key: "loadSDKAndCreateInstance",
152
230
  value: function loadSDKAndCreateInstance(constructorName, newProps) {
153
- var _this = this;
231
+ var _this2 = this;
154
232
  loadSdk().then(function () {
155
233
  try {
156
234
  var actualInstance = newActualInstance(constructorName, newProps);
@@ -158,7 +236,7 @@ export function createBaseProxy(constructorName) {
158
236
  logger.logInfo({
159
237
  title: 'report_customized_performance_m5'
160
238
  }, {
161
- m5: Date.now() - _this.startTime
239
+ m5: Date.now() - _this2.startTime
162
240
  });
163
241
  logger.logInfo({
164
242
  title: 'create_actual_instance_success'
@@ -166,48 +244,14 @@ export function createBaseProxy(constructorName) {
166
244
  constructorName: constructorName
167
245
  });
168
246
  consoleLogger.log('create_actual_instance_success');
169
- _this.actualInstance = actualInstance;
170
- _this.hasActualInstance = true;
171
- _this.executePendingCalls();
247
+ _this2.actualInstance = actualInstance;
248
+ _this2.hasActualInstance = true;
249
+ _this2.executePendingCalls();
172
250
  } catch (error) {
173
- //创建实例失败时,构造一个虚拟错误对象来模拟产品实例,其中所有的API都会在.then中返回错误对象
174
- var instanceForError = _newInstanceForError({
175
- error: {
176
- code: 'INTERNAL_ERROR',
177
- message: 'create_actual_instance_error'
178
- },
179
- status: 'FAIL'
180
- });
181
- _this.actualInstance = instanceForError;
182
- _this.hasActualInstance = true;
183
- _this.executePendingCalls();
184
- logger.logError({
185
- title: 'create_actual_instance_error'
186
- }, {
187
- errorMessage: error,
188
- constructorName: constructorName
189
- });
190
- consoleLogger.error('create_actual_instance_error');
251
+ onCreateInstanceError(newProps);
191
252
  }
192
- }).catch(function (error) {
193
- //SDK加载失败时,构造一个虚拟错误对象来模拟产品实例,其中所有的API都会在.then中返回错误对象
194
- var instanceForError = _newInstanceForError({
195
- error: {
196
- code: 'INITIALIZE_WEB_TIMEOUT',
197
- message: 'load_sdk_resource_error'
198
- },
199
- status: 'FAIL'
200
- });
201
- _this.actualInstance = instanceForError;
202
- _this.hasActualInstance = true;
203
- _this.executePendingCalls();
204
- logger.logError({
205
- title: 'load_sdk_resource_error'
206
- }, {
207
- errorMessage: error,
208
- constructorName: constructorName
209
- });
210
- consoleLogger.error('load_sdk_resource_error');
253
+ }).catch(function () {
254
+ onLoadSDKError(newProps);
211
255
  });
212
256
  }
213
257
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1761220900-dev.1",
3
+ "version": "0.0.1762138227-dev.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",