@alipay/ams-checkout 0.0.1726046231-dev.13 → 0.0.1726046231-dev.19

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.
@@ -1,3 +1,4 @@
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); }
1
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
4
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -9,11 +10,10 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
9
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
11
  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; }
11
12
  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; }
12
- 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; }
13
- 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); }
14
13
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
14
  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); } }
16
15
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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
19
  import { AntomSDKCore } from "../../../foundation/core";
@@ -26,21 +26,119 @@ import { ElementPaymentComponent } from "./components/payment";
26
26
 
27
27
  import { addressTheme, ELEMENT_ENVIRONMENT, ThemeType } from "./type";
28
28
  var ElementProcessor = /*#__PURE__*/function () {
29
- function ElementProcessor() {
29
+ function ElementProcessor(options) {
30
30
  _classCallCheck(this, ElementProcessor);
31
+ _defineProperty(this, "requestService", void 0);
32
+ // 接口服务
33
+ _defineProperty(this, "_options", void 0);
34
+ this._options = options;
31
35
  }
32
36
  _createClass(ElementProcessor, [{
33
37
  key: "init",
34
- value: function init() {}
38
+ value: function init() {
39
+ var elementContainer = new AntomSDKCore();
40
+ elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', undefined);
41
+ elementContainer.init({}, ProductSceneEnum.ELEMENT_PAYMENT);
42
+ var serviceProvider = elementContainer.getServiceProvider();
43
+ this.requestService = serviceProvider.getService('Requester');
44
+ }
45
+ }, {
46
+ key: "sdkActionQuery",
47
+ value: function sdkActionQuery() {
48
+ var _this = this;
49
+ return new Promise(function (resolve, reject) {
50
+ // setTimeout(() => {
51
+ // resolve(sdkAction)
52
+ // }, 2000);
53
+ // return;
54
+ var hostSign = _this._options.sessionData.split('&&')[1] || '';
55
+ _this.requestService.request({
56
+ paymentSessionConfig: _this._options.paymentSessionConfig,
57
+ paymentSessionData: _this._options.sessionData
58
+ }, {
59
+ env: _this._options.environment,
60
+ envInfo: {
61
+ locale: _this._options.locale
62
+ },
63
+ hostSign: hostSign,
64
+ timeout: 300000,
65
+ // TODO dev环境接口超时
66
+ 'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
67
+ }).then(function (result) {
68
+ if (!result.success) {
69
+ reject('sdk.action.query Request Error');
70
+ }
71
+ resolve(result);
72
+ }, function () {
73
+ reject('sdk.action.query Request Error');
74
+ });
75
+ });
76
+ }
77
+ }, {
78
+ key: "oneAccountQuery",
79
+ value: function oneAccountQuery() {
80
+ var _this2 = this;
81
+ return new Promise(function (resolve, reject) {
82
+ // setTimeout(() => {
83
+ // resolve(oneAccount)
84
+ // }, 2000);
85
+ // return;
86
+ _this2.requestService.request({
87
+ paymentSessionConfig: _this2._options.paymentSessionConfig,
88
+ paymentSessionData: _this2._options.sessionData,
89
+ accountInfo: {
90
+ email: ''
91
+ }
92
+ }, {
93
+ env: _this2._options.environment,
94
+ envInfo: {
95
+ locale: _this2._options.locale
96
+ },
97
+ timeout: 300000,
98
+ // TODO dev环境接口超时
99
+ 'Operation-Type': 'com.ipay.iexpfront.one.account.query'
100
+ }).then(function (result) {
101
+ resolve(result);
102
+ }, function () {
103
+ reject('one.account.query Request Error');
104
+ });
105
+ });
106
+ }
35
107
  }, {
36
108
  key: "startBizFlow",
37
109
  value: function startBizFlow() {
38
- // action.query + one.account.query
110
+ var _this3 = this;
39
111
  return new Promise(function (resolve) {
40
- resolve({
41
- behaviorType: 'NONE',
42
- payload: {}
43
- });
112
+ if (_this3._options.isConnect) {
113
+ Promise.all([_this3.oneAccountQuery(), _this3.sdkActionQuery()]).then(function (result) {
114
+ resolve({
115
+ behaviorType: 'NONE',
116
+ payload: {},
117
+ data: {
118
+ success: true,
119
+ oneAccountRes: result[0],
120
+ sdkActionRes: result[1]
121
+ }
122
+ });
123
+ }, function (error) {
124
+ resolve({
125
+ behaviorType: 'NONE',
126
+ payload: {},
127
+ data: {
128
+ success: false,
129
+ errorMsg: error
130
+ }
131
+ });
132
+ });
133
+ } else {
134
+ resolve({
135
+ behaviorType: 'NONE',
136
+ payload: {},
137
+ data: {
138
+ success: true
139
+ }
140
+ });
141
+ }
44
142
  });
45
143
  }
46
144
  }]);
@@ -50,7 +148,7 @@ export var ElementComponent = /*#__PURE__*/function () {
50
148
  // address事件回调
51
149
 
52
150
  function ElementComponent(options) {
53
- var _this = this;
151
+ var _this4 = this;
54
152
  _classCallCheck(this, ElementComponent);
55
153
  _defineProperty(this, "parseData", void 0);
56
154
  // sessionData 解析出来的数据
@@ -91,70 +189,70 @@ export var ElementComponent = /*#__PURE__*/function () {
91
189
  _defineProperty(this, "eventCallback", void 0);
92
190
  // 渲染地址组件
93
191
  _defineProperty(this, "mountAddress", function (renderOptions, sdkSelector) {
94
- var _renderOptions$appear, _this$_options;
192
+ var _renderOptions$appear, _this4$_options;
95
193
  var _mountParams = {
96
194
  appearance: {
97
- themeType: addressTheme[(renderOptions === null || renderOptions === void 0 || (_renderOptions$appear = renderOptions.appearance) === null || _renderOptions$appear === void 0 ? void 0 : _renderOptions$appear.theme) || ((_this$_options = _this._options) === null || _this$_options === void 0 || (_this$_options = _this$_options.appearance) === null || _this$_options === void 0 ? void 0 : _this$_options.theme) || ThemeType.Default]
195
+ themeType: addressTheme[(renderOptions === null || renderOptions === void 0 || (_renderOptions$appear = renderOptions.appearance) === null || _renderOptions$appear === void 0 ? void 0 : _renderOptions$appear.theme) || ((_this4$_options = _this4._options) === null || _this4$_options === void 0 || (_this4$_options = _this4$_options.appearance) === null || _this4$_options === void 0 ? void 0 : _this4$_options.theme) || ThemeType.Default]
98
196
  },
99
197
  configParams: _objectSpread({
100
- needEditBackBtn: _this.isConnect,
101
- autoSaveAsDefaultAddress: _this.isConnect,
102
- editingNeedShippingQuery: _this.isConnect,
103
- showTitle: _this.isConnect
198
+ needEditBackBtn: _this4.isConnect,
199
+ autoSaveAsDefaultAddress: _this4.isConnect,
200
+ editingNeedShippingQuery: _this4.isConnect,
201
+ showTitle: _this4.isConnect
104
202
  }, renderOptions.configParams),
105
203
  prefillValue: renderOptions.prefillValue
106
204
  };
107
- _this.mountOptions[ElementPaymentMethod.ADDRESS_ELEMENT] = _mountParams;
108
- _this.addressBase.mount(_this._options.sessionData, _objectSpread({
205
+ _this4.mountOptions[ElementPaymentMethod.ADDRESS_ELEMENT] = _mountParams;
206
+ _this4.addressBase.mount(_this4._options.sessionData, _objectSpread({
109
207
  selector: sdkSelector,
110
208
  debugProps: renderOptions.debugProps
111
209
  }, _mountParams)).then(function (result) {
112
210
  if (!result) {
113
- var _this$_options$onEven, _this$_options2;
114
- (_this$_options$onEven = (_this$_options2 = _this._options).onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options2, {
211
+ var _this4$_options$onEve, _this4$_options2;
212
+ (_this4$_options$onEve = (_this4$_options2 = _this4._options).onEventCallback) === null || _this4$_options$onEve === void 0 || _this4$_options$onEve.call(_this4$_options2, {
115
213
  code: EventCallbackCode.Failed,
116
- message: 'Component loading failed'
214
+ message: 'Address Component loading failed'
117
215
  });
118
216
  return undefined;
119
217
  }
120
- _this.eventService.addIFrame(result);
121
- _this.iframes[ElementPaymentMethod.ADDRESS_ELEMENT] = result;
218
+ _this4.eventService.addIFrame(result);
219
+ _this4.iframes[ElementPaymentMethod.ADDRESS_ELEMENT] = result;
122
220
  });
123
221
  return {
124
222
  on: function on(event, callback) {
125
- _this.registerEventListener(ElementPaymentMethod.ADDRESS_ELEMENT, event, callback);
223
+ _this4.registerEventListener(ElementPaymentMethod.ADDRESS_ELEMENT, event, callback);
126
224
  }
127
225
  };
128
226
  });
129
227
  // 渲染卡支付组件
130
228
  _defineProperty(this, "mountPayment", function (renderOptions, sdkSelector) {
131
- var _this$_options3;
229
+ var _this4$_options3;
132
230
  var _mountParams = {
133
- appearance: renderOptions.appearance || ((_this$_options3 = _this._options) === null || _this$_options3 === void 0 ? void 0 : _this$_options3.appearance) || {
231
+ appearance: renderOptions.appearance || ((_this4$_options3 = _this4._options) === null || _this4$_options3 === void 0 ? void 0 : _this4$_options3.appearance) || {
134
232
  theme: ThemeType.Default
135
233
  }
136
234
  };
137
- _this.mountOptions[ElementPaymentMethod.PAYMENT_ELEMENT] = _mountParams;
138
- _this.paymentBase.mount(_this._options.sessionData, _objectSpread({
235
+ _this4.mountOptions[ElementPaymentMethod.PAYMENT_ELEMENT] = _mountParams;
236
+ _this4.paymentBase.mount(_this4._options.sessionData, _objectSpread({
139
237
  selector: sdkSelector,
140
238
  debugProps: renderOptions.debugProps
141
239
  }, _mountParams)).then(function (result) {
142
240
  if (!result) {
143
- var _this$_options$onEven2, _this$_options4;
144
- (_this$_options$onEven2 = (_this$_options4 = _this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options4, {
241
+ var _this4$_options$onEve2, _this4$_options4;
242
+ (_this4$_options$onEve2 = (_this4$_options4 = _this4._options).onEventCallback) === null || _this4$_options$onEve2 === void 0 || _this4$_options$onEve2.call(_this4$_options4, {
145
243
  code: EventCallbackCode.Failed,
146
- message: 'Component loading failed'
244
+ message: 'Payment Component loading failed'
147
245
  });
148
246
  return undefined;
149
247
  }
150
- _this.eventService.addIFrame(result);
151
- _this.iframes[ElementPaymentMethod.PAYMENT_ELEMENT] = result;
248
+ _this4.eventService.addIFrame(result);
249
+ _this4.iframes[ElementPaymentMethod.PAYMENT_ELEMENT] = result;
152
250
  });
153
251
  return {};
154
252
  });
155
253
  // submit提交非RISK_REJECT错误
156
254
  _defineProperty(this, "onAfterSubmitFunc", function (target, params) {
157
- _this.eventService.emitAndListen({
255
+ _this4.eventService.emitAndListen({
158
256
  event: ElementPaymentEvent.AFTER_SUBMIT,
159
257
  data: {
160
258
  target: target,
@@ -165,7 +263,7 @@ export var ElementComponent = /*#__PURE__*/function () {
165
263
  });
166
264
  // submit提交 失败,清空组件数据
167
265
  _defineProperty(this, "onSubmitRiskFunc", function (target) {
168
- _this.eventService.emitAndListen({
266
+ _this4.eventService.emitAndListen({
169
267
  event: ElementPaymentEvent.SUBMIT_RISK,
170
268
  data: {
171
269
  target: target,
@@ -177,18 +275,18 @@ export var ElementComponent = /*#__PURE__*/function () {
177
275
  // 发起支付
178
276
  _defineProperty(this, "onSubmit", function (params) {
179
277
  return new Promise(function (resolve) {
180
- var paymentSessionConfig = _this.parseData.paymentSessionConfig;
278
+ var paymentSessionConfig = _this4.parseData.paymentSessionConfig;
181
279
  console.log('element submit params ------', _objectSpread({
182
280
  paymentSessionConfig: paymentSessionConfig,
183
- paymentSessionData: _this.sessionData
281
+ paymentSessionData: _this4.sessionData
184
282
  }, params));
185
- _this.requestService.request(_objectSpread({
283
+ _this4.requestService.request(_objectSpread({
186
284
  paymentSessionConfig: paymentSessionConfig,
187
- paymentSessionData: _this.sessionData
285
+ paymentSessionData: _this4.sessionData
188
286
  }, params), {
189
- env: _this._options.environment,
287
+ env: _this4._options.environment,
190
288
  envInfo: {
191
- locale: _this._options.locale
289
+ locale: _this4._options.locale
192
290
  },
193
291
  timeout: 300000,
194
292
  // TODO dev环境submit提交接口超时
@@ -196,11 +294,11 @@ export var ElementComponent = /*#__PURE__*/function () {
196
294
  }).then(function (result) {
197
295
  console.log('element submit result ------', result);
198
296
  if (result.errorCode === ConnectErrorCode.RISK_REJECT) {
199
- _this.onSubmitRiskFunc(ElementPaymentMethod.ADDRESS_ELEMENT);
200
- _this.onSubmitRiskFunc(ElementPaymentMethod.AUTH_ELEMENT);
201
- _this.onSubmitRiskFunc(ElementPaymentMethod.PAYMENT_ELEMENT);
297
+ _this4.onSubmitRiskFunc(ElementPaymentMethod.ADDRESS_ELEMENT);
298
+ _this4.onSubmitRiskFunc(ElementPaymentMethod.AUTH_ELEMENT);
299
+ _this4.onSubmitRiskFunc(ElementPaymentMethod.PAYMENT_ELEMENT);
202
300
  } else {
203
- _this.onAfterSubmitFunc(ElementPaymentMethod.PAYMENT_ELEMENT, result);
301
+ _this4.onAfterSubmitFunc(ElementPaymentMethod.PAYMENT_ELEMENT, result);
204
302
  }
205
303
  resolve({
206
304
  success: result.success,
@@ -212,7 +310,7 @@ export var ElementComponent = /*#__PURE__*/function () {
212
310
  // 发送validate消息
213
311
  _defineProperty(this, "onValidateFunc", function (target) {
214
312
  return new Promise(function (resolve) {
215
- _this.eventService.emitAndListen({
313
+ _this4.eventService.emitAndListen({
216
314
  event: ElementPaymentEvent.VALIDATE,
217
315
  data: {
218
316
  target: target,
@@ -233,12 +331,12 @@ export var ElementComponent = /*#__PURE__*/function () {
233
331
  while (1) switch (_context.prev = _context.next) {
234
332
  case 0:
235
333
  params = {};
236
- if (!_this.launchSource.includes(ElementPaymentMethod.AUTH_ELEMENT)) {
334
+ if (!_this4.launchSource.includes(ElementPaymentMethod.AUTH_ELEMENT)) {
237
335
  _context.next = 9;
238
336
  break;
239
337
  }
240
338
  _context.next = 4;
241
- return _this.onValidateFunc(ElementPaymentMethod.AUTH_ELEMENT);
339
+ return _this4.onValidateFunc(ElementPaymentMethod.AUTH_ELEMENT);
242
340
  case 4:
243
341
  result = _context.sent;
244
342
  console.log('element submit validate auth---------', result);
@@ -249,12 +347,12 @@ export var ElementComponent = /*#__PURE__*/function () {
249
347
  }
250
348
  return _context.abrupt("return", resolve(undefined));
251
349
  case 9:
252
- if (!_this.launchSource.includes(ElementPaymentMethod.ADDRESS_ELEMENT)) {
350
+ if (!_this4.launchSource.includes(ElementPaymentMethod.ADDRESS_ELEMENT)) {
253
351
  _context.next = 17;
254
352
  break;
255
353
  }
256
354
  _context.next = 12;
257
- return _this.onValidateFunc(ElementPaymentMethod.ADDRESS_ELEMENT);
355
+ return _this4.onValidateFunc(ElementPaymentMethod.ADDRESS_ELEMENT);
258
356
  case 12:
259
357
  _result = _context.sent;
260
358
  console.log('element submit validate address---------', _result);
@@ -265,12 +363,12 @@ export var ElementComponent = /*#__PURE__*/function () {
265
363
  }
266
364
  return _context.abrupt("return", resolve(undefined));
267
365
  case 17:
268
- if (!_this.launchSource.includes(ElementPaymentMethod.PAYMENT_ELEMENT)) {
366
+ if (!_this4.launchSource.includes(ElementPaymentMethod.PAYMENT_ELEMENT)) {
269
367
  _context.next = 26;
270
368
  break;
271
369
  }
272
370
  _context.next = 20;
273
- return _this.onValidateFunc(ElementPaymentMethod.PAYMENT_ELEMENT);
371
+ return _this4.onValidateFunc(ElementPaymentMethod.PAYMENT_ELEMENT);
274
372
  case 20:
275
373
  _result2 = _context.sent;
276
374
  console.log('element submit validate payment---------', _result2);
@@ -309,42 +407,42 @@ export var ElementComponent = /*#__PURE__*/function () {
309
407
  _createClass(ElementComponent, [{
310
408
  key: "createElement",
311
409
  value: function createElement() {
312
- var _parseData$paymentSes,
313
- _this2 = this;
410
+ var _parseData$connectFac,
411
+ _parseData$paymentSes,
412
+ _this5 = this;
314
413
  var _parseSessionData = parseSessionData(this._options.sessionData),
315
414
  _parseSessionData2 = _slicedToArray(_parseSessionData, 2),
316
415
  parseData = _parseSessionData2[0],
317
416
  sessionData = _parseSessionData2[1];
318
417
  this.parseData = parseData;
319
418
  this.sessionData = sessionData;
419
+ this.isConnect = ((_parseData$connectFac = parseData.connectFactor) === null || _parseData$connectFac === void 0 ? void 0 : _parseData$connectFac.enableConnect) && (parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionConfig) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
320
420
  this.elementContainer = new AntomSDKCore();
321
- this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor());
421
+ this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor({
422
+ paymentSessionConfig: parseData.paymentSessionConfig,
423
+ sessionData: sessionData,
424
+ environment: this._options.environment,
425
+ locale: this._options.locale,
426
+ isConnect: this.isConnect
427
+ }));
322
428
  this.elementContainer.init({}, ProductSceneEnum.ELEMENT_PAYMENT);
323
- this.isConnect = parseData.connectFactor.enableConnect && (parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionConfig) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.productScene) === window.ProductSceneEnum.ELEMENT_PAYMENT;
324
429
  this.elementContainer.startBizFlow({
325
430
  paymentSession: this._options.sessionData
326
- }).then(function (res) {
327
- // console.log('antom sdk start-----', res, this.elementContainer.getBizFlowResult());
328
- if (_this2.isConnect) {
329
- // 请求消息
330
- Promise.all([_this2.oneAccountQuery(), _this2.sdkActionQuery()]).then(function (result) {
331
- _this2.oneAccountRes = result[0];
332
- _this2.sdkActionRes = result[1];
333
- _this2.sendRenderData();
431
+ }).then(function () {
432
+ var _bizFlowResult$data;
433
+ if (!_this5.isConnect) return;
434
+ var bizFlowResult = _this5.elementContainer.getBizFlowResult();
435
+ if (!(bizFlowResult !== null && bizFlowResult !== void 0 && (_bizFlowResult$data = bizFlowResult.data) !== null && _bizFlowResult$data !== void 0 && _bizFlowResult$data.success)) {
436
+ var _this5$_options, _this5$_options$onEve, _bizFlowResult$data2;
437
+ _this5 === null || _this5 === void 0 || (_this5$_options = _this5._options) === null || _this5$_options === void 0 || (_this5$_options$onEve = _this5$_options.onEventCallback) === null || _this5$_options$onEve === void 0 || _this5$_options$onEve.call(_this5$_options, {
438
+ code: EventCallbackCode.Failed,
439
+ message: (bizFlowResult === null || bizFlowResult === void 0 || (_bizFlowResult$data2 = bizFlowResult.data) === null || _bizFlowResult$data2 === void 0 ? void 0 : _bizFlowResult$data2.errorMsg) || 'start biz flow fail, please retry.'
334
440
  });
335
- // 本地mock测试数据
336
- // setTimeout(() => {
337
- // this.oneAccountRes = oneAccount;
338
- // this.sdkActionRes = sdkAction;
339
- // this.sendRenderData();
340
- // }, 500);
341
- // 本地mock测试报错页
342
- // setTimeout(() => {
343
- // this._options?.onEventCallback?.({
344
- // code: EventCallbackCode.Failed,
345
- // message: 'sdkAction.query Request Error',
346
- // });
347
- // }, 2000)
441
+ } else {
442
+ var _bizFlowResult$data3, _bizFlowResult$data4;
443
+ _this5.oneAccountRes = bizFlowResult === null || bizFlowResult === void 0 || (_bizFlowResult$data3 = bizFlowResult.data) === null || _bizFlowResult$data3 === void 0 ? void 0 : _bizFlowResult$data3.oneAccountRes;
444
+ _this5.sdkActionRes = bizFlowResult === null || bizFlowResult === void 0 || (_bizFlowResult$data4 = bizFlowResult.data) === null || _bizFlowResult$data4 === void 0 ? void 0 : _bizFlowResult$data4.sdkActionRes;
445
+ _this5.afterInit();
348
446
  }
349
447
  });
350
448
  this.iframeSrc = this.createIframeSrc(this._options.environment, this._options.version);
@@ -374,8 +472,8 @@ export var ElementComponent = /*#__PURE__*/function () {
374
472
  appVersion: this._options.version || ''
375
473
  }, this.isConnect);
376
474
  } catch (error) {
377
- var _this$_options$onEven3, _this$_options5;
378
- (_this$_options$onEven3 = (_this$_options5 = this._options).onEventCallback) === null || _this$_options$onEven3 === void 0 || _this$_options$onEven3.call(_this$_options5, {
475
+ var _this$_options$onEven, _this$_options;
476
+ (_this$_options$onEven = (_this$_options = this._options).onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options, {
379
477
  code: EventCallbackCode.Failed,
380
478
  message: 'create sdk fail'
381
479
  });
@@ -390,7 +488,7 @@ export var ElementComponent = /*#__PURE__*/function () {
390
488
  key: "createIframeSrc",
391
489
  value: function createIframeSrc() {
392
490
  var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ELEMENT_ENVIRONMENT.DEV;
393
- var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1.23.0';
491
+ var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1.24.0';
394
492
  var baseUrl = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ELEMENT_ENVIRONMENT.DEV, 'http://dev.page.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.TEST, 'http://page.test.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PRE, 'https://cdn-pre.marmot-cloud.com/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PROD, 'https://checkout.antom.com');
395
493
  var _env = (env === null || env === void 0 ? void 0 : env.toLocaleUpperCase()) || ELEMENT_ENVIRONMENT.DEV;
396
494
  return {
@@ -399,76 +497,6 @@ export var ElementComponent = /*#__PURE__*/function () {
399
497
  payment: "".concat(baseUrl[_env], "/elements/").concat(version, "/pages/element_payment/index.html")
400
498
  };
401
499
  }
402
- }, {
403
- key: "sdkActionQuery",
404
- value: function sdkActionQuery() {
405
- var _this3 = this;
406
- return new Promise(function (resolve, reject) {
407
- var paymentSessionConfig = _this3.parseData.paymentSessionConfig;
408
- var hostSign = _this3.sessionData.split('&&')[1] || '';
409
- _this3.requestService.request({
410
- paymentSessionConfig: paymentSessionConfig,
411
- paymentSessionData: _this3.sessionData
412
- }, {
413
- env: _this3._options.environment,
414
- envInfo: {
415
- locale: _this3._options.locale
416
- },
417
- hostSign: hostSign,
418
- timeout: 300000,
419
- // TODO dev环境接口超时
420
- 'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
421
- }).then(function (result) {
422
- if (!result.success) {
423
- var _this3$_options, _this3$_options$onEve;
424
- (_this3$_options = _this3._options) === null || _this3$_options === void 0 || (_this3$_options$onEve = _this3$_options.onEventCallback) === null || _this3$_options$onEve === void 0 || _this3$_options$onEve.call(_this3$_options, {
425
- code: EventCallbackCode.Failed,
426
- message: 'sdkAction.query Request Error'
427
- });
428
- reject(result);
429
- }
430
- resolve(result);
431
- }, function () {
432
- var _this3$_options2, _this3$_options2$onEv;
433
- _this3 === null || _this3 === void 0 || (_this3$_options2 = _this3._options) === null || _this3$_options2 === void 0 || (_this3$_options2$onEv = _this3$_options2.onEventCallback) === null || _this3$_options2$onEv === void 0 || _this3$_options2$onEv.call(_this3$_options2, {
434
- code: EventCallbackCode.Failed,
435
- message: 'sdk.action.query Request Error'
436
- });
437
- });
438
- });
439
- }
440
- }, {
441
- key: "oneAccountQuery",
442
- value: function oneAccountQuery() {
443
- var _this4 = this;
444
- return new Promise(function (resolve) {
445
- var paymentSessionConfig = _this4.parseData.paymentSessionConfig;
446
- _this4.requestService.request({
447
- paymentSessionConfig: paymentSessionConfig,
448
- paymentSessionData: _this4.sessionData,
449
- accountInfo: {
450
- email: ''
451
- }
452
- // oneAccountId: '',
453
- }, {
454
- env: _this4._options.environment,
455
- envInfo: {
456
- locale: _this4._options.locale
457
- },
458
- timeout: 300000,
459
- // TODO dev环境接口超时
460
- 'Operation-Type': 'com.ipay.iexpfront.one.account.query'
461
- }).then(function (result) {
462
- resolve(result);
463
- }, function () {
464
- var _this4$_options, _this4$_options$onEve;
465
- _this4 === null || _this4 === void 0 || (_this4$_options = _this4._options) === null || _this4$_options === void 0 || (_this4$_options$onEve = _this4$_options.onEventCallback) === null || _this4$_options$onEve === void 0 || _this4$_options$onEve.call(_this4$_options, {
466
- code: EventCallbackCode.Failed,
467
- message: 'one.account.query Request Error'
468
- });
469
- });
470
- });
471
- }
472
500
 
473
501
  // 循环给所有iframe发同一个消息
474
502
  // private postCommonMessage<T>(event: ElementPaymentEvent, params: T) {
@@ -491,22 +519,22 @@ export var ElementComponent = /*#__PURE__*/function () {
491
519
  }, {
492
520
  key: "addListener",
493
521
  value: function addListener() {
494
- var _this5 = this;
522
+ var _this6 = this;
495
523
  this.eventService.listen(ElementPaymentEvent.LAUNCH, function (result) {
496
- _this5.launchFunc(result);
524
+ _this6.launchFunc(result);
497
525
  });
498
526
  this.eventService.listen(ElementPaymentEvent.SIZE_CHANGE, function (result) {
499
527
  if (result.target === ElementPaymentMethod.CONTAINER_ELEMENT && result.source === ElementPaymentMethod.AUTH_ELEMENT) {
500
- var _this5$authBase;
501
- (_this5 === null || _this5 === void 0 ? void 0 : _this5.authBase) && (_this5 === null || _this5 === void 0 || (_this5$authBase = _this5.authBase) === null || _this5$authBase === void 0 ? void 0 : _this5$authBase.update(result.data.height));
528
+ var _this6$authBase;
529
+ (_this6 === null || _this6 === void 0 ? void 0 : _this6.authBase) && (_this6 === null || _this6 === void 0 || (_this6$authBase = _this6.authBase) === null || _this6$authBase === void 0 ? void 0 : _this6$authBase.update(result.data.height));
502
530
  }
503
531
  });
504
532
  this.eventService.listen(ElementPaymentEvent.CALLBACK, function (result) {
505
- var _this5$eventCallback;
533
+ var _this6$eventCallback;
506
534
  console.log('antom sdk 组件事件回调');
507
- if ((_this5$eventCallback = _this5.eventCallback) !== null && _this5$eventCallback !== void 0 && (_this5$eventCallback = _this5$eventCallback[result.source]) !== null && _this5$eventCallback !== void 0 && _this5$eventCallback[result.event]) {
508
- var _this5$eventCallback$, _this5$eventCallback$2;
509
- (_this5$eventCallback$ = (_this5$eventCallback$2 = _this5.eventCallback[result.source])[result.event]) === null || _this5$eventCallback$ === void 0 || _this5$eventCallback$.call(_this5$eventCallback$2, result.data);
535
+ if ((_this6$eventCallback = _this6.eventCallback) !== null && _this6$eventCallback !== void 0 && (_this6$eventCallback = _this6$eventCallback[result.source]) !== null && _this6$eventCallback !== void 0 && _this6$eventCallback[result.event]) {
536
+ var _this6$eventCallback$, _this6$eventCallback$2;
537
+ (_this6$eventCallback$ = (_this6$eventCallback$2 = _this6.eventCallback[result.source])[result.event]) === null || _this6$eventCallback$ === void 0 || _this6$eventCallback$.call(_this6$eventCallback$2, result.data);
510
538
  }
511
539
  });
512
540
  this.eventService.listen(ElementPaymentEvent.LOG, function (result) {
@@ -527,56 +555,60 @@ export var ElementComponent = /*#__PURE__*/function () {
527
555
  return item !== source;
528
556
  })) {
529
557
  this.launchSource.push(source);
530
- this.sendRenderData();
558
+ this.afterInit();
531
559
  }
532
560
  }
533
561
  }
534
562
  }, {
535
563
  key: "showIframe",
536
564
  value: function showIframe() {
537
- var _this$paymentBase, _this$addressBase, _this$authBase;
565
+ var _this$paymentBase, _this$addressBase, _this$authBase, _this$_options$loadin;
566
+ this.loading = false;
538
567
  (this === null || this === void 0 ? void 0 : this.paymentBase) && (this === null || this === void 0 || (_this$paymentBase = this.paymentBase) === null || _this$paymentBase === void 0 ? void 0 : _this$paymentBase.update());
539
568
  (this === null || this === void 0 ? void 0 : this.addressBase) && (this === null || this === void 0 || (_this$addressBase = this.addressBase) === null || _this$addressBase === void 0 ? void 0 : _this$addressBase.update());
540
569
  (this === null || this === void 0 ? void 0 : this.authBase) && (this === null || this === void 0 || (_this$authBase = this.authBase) === null || _this$authBase === void 0 ? void 0 : _this$authBase.update());
570
+ if ((_this$_options$loadin = this._options.loading) !== null && _this$_options$loadin !== void 0 && _this$_options$loadin.onEndLoading) {
571
+ var _this$_options$loadin2, _this$_options$loadin3;
572
+ (_this$_options$loadin2 = this._options.loading) === null || _this$_options$loadin2 === void 0 || (_this$_options$loadin3 = _this$_options$loadin2.onEndLoading) === null || _this$_options$loadin3 === void 0 || _this$_options$loadin3.call(_this$_options$loadin2);
573
+ }
574
+ }
575
+ }, {
576
+ key: "afterInit",
577
+ value: function afterInit() {
578
+ if (this.launchSource.length === this.componentsCount && this.sdkActionRes && this.oneAccountRes && this.isConnect) {
579
+ this.sendRenderData();
580
+ this.showIframe();
581
+ }
541
582
  }
542
583
 
543
584
  // 发送初始化数据
544
585
  }, {
545
586
  key: "sendRenderData",
546
587
  value: function sendRenderData() {
547
- var _this6 = this;
548
- if (this.launchSource.length === this.componentsCount && this.sdkActionRes && this.oneAccountRes) {
549
- var _this$_options$loadin;
550
- var baseData = {
551
- originActionQueryResult: this.sdkActionRes,
552
- originOneAccountQueryResult: this.oneAccountRes,
553
- paymentSessionData: this._options.sessionData,
554
- sessionResult: this.parseData || {}
555
- };
556
- this.loading = false;
557
- this.launchSource.forEach(function (target) {
558
- var _this6$mountOptions;
559
- var params = _objectSpread(_objectSpread({}, (_this6$mountOptions = _this6.mountOptions) === null || _this6$mountOptions === void 0 ? void 0 : _this6$mountOptions[target]), baseData);
560
- if (target === ElementPaymentMethod.ADDRESS_ELEMENT) {
561
- params.prefillValue = _this6.oneAccountRes.shippings || [];
562
- } else if (target === ElementPaymentMethod.PAYMENT_ELEMENT) {
563
- params.queryResult = _this6.sdkActionRes;
564
- }
565
- _this6.eventService.emitAndListen({
566
- event: ElementPaymentEvent.INITIAL_DATA_READY,
567
- data: {
568
- target: target,
569
- source: ElementPaymentMethod.CONTAINER_ELEMENT,
570
- params: params
571
- }
572
- }, function () {});
573
- });
574
- this.showIframe();
575
- if ((_this$_options$loadin = this._options.loading) !== null && _this$_options$loadin !== void 0 && _this$_options$loadin.onEndLoading) {
576
- var _this$_options$loadin2, _this$_options$loadin3;
577
- (_this$_options$loadin2 = this._options.loading) === null || _this$_options$loadin2 === void 0 || (_this$_options$loadin3 = _this$_options$loadin2.onEndLoading) === null || _this$_options$loadin3 === void 0 || _this$_options$loadin3.call(_this$_options$loadin2);
588
+ var _this7 = this;
589
+ var baseData = {
590
+ originActionQueryResult: this.sdkActionRes,
591
+ originOneAccountQueryResult: this.oneAccountRes,
592
+ paymentSessionData: this._options.sessionData,
593
+ sessionResult: this.parseData || {}
594
+ };
595
+ this.launchSource.forEach(function (target) {
596
+ var _this7$mountOptions;
597
+ var params = _objectSpread(_objectSpread({}, (_this7$mountOptions = _this7.mountOptions) === null || _this7$mountOptions === void 0 ? void 0 : _this7$mountOptions[target]), baseData);
598
+ if (target === ElementPaymentMethod.ADDRESS_ELEMENT) {
599
+ params.prefillValue = _this7.oneAccountRes.shippings || [];
600
+ } else if (target === ElementPaymentMethod.PAYMENT_ELEMENT) {
601
+ params.queryResult = _this7.sdkActionRes;
578
602
  }
579
- }
603
+ _this7.eventService.emitAndListen({
604
+ event: ElementPaymentEvent.INITIAL_DATA_READY,
605
+ data: {
606
+ target: target,
607
+ source: ElementPaymentMethod.CONTAINER_ELEMENT,
608
+ params: params
609
+ }
610
+ }, function () {});
611
+ });
580
612
  }
581
613
 
582
614
  // 注销所有消息监听,这里需要和addListener里面监听的事件对应
@@ -600,33 +632,32 @@ export var ElementComponent = /*#__PURE__*/function () {
600
632
  }, {
601
633
  key: "mountAuth",
602
634
  value: function mountAuth(renderOptions, sdkSelector) {
603
- var _this$_options6,
635
+ var _this$_options2,
604
636
  _renderOptions$debugP,
605
- _this7 = this;
637
+ _this8 = this;
606
638
  var _mountParams = {
607
- appearance: renderOptions.appearance || ((_this$_options6 = this._options) === null || _this$_options6 === void 0 ? void 0 : _this$_options6.appearance) || {
639
+ appearance: renderOptions.appearance || ((_this$_options2 = this._options) === null || _this$_options2 === void 0 ? void 0 : _this$_options2.appearance) || {
608
640
  theme: ThemeType.Default
609
641
  }
610
642
  };
611
643
  this.mountOptions[ElementPaymentMethod.AUTH_ELEMENT] = _mountParams;
612
- var _selector = sdkSelector.indexOf('#') === 0 ? sdkSelector.slice(1) : sdkSelector;
613
644
  var link = renderOptions === null || renderOptions === void 0 || (_renderOptions$debugP = renderOptions.debugProps) === null || _renderOptions$debugP === void 0 ? void 0 : _renderOptions$debugP.localLink;
614
645
  var params = window.location.href.split('?')[1];
615
646
  var url = link.indexOf('?') === -1 ? "".concat(link, "?").concat(params) : link;
616
647
  this.authBase.mount({
617
- selector: _selector,
648
+ selector: sdkSelector,
618
649
  url: url
619
650
  }).then(function (result) {
620
651
  if (!result) {
621
- var _this7$_options$onEve, _this7$_options;
622
- (_this7$_options$onEve = (_this7$_options = _this7._options).onEventCallback) === null || _this7$_options$onEve === void 0 || _this7$_options$onEve.call(_this7$_options, {
652
+ var _this8$_options$onEve, _this8$_options;
653
+ (_this8$_options$onEve = (_this8$_options = _this8._options).onEventCallback) === null || _this8$_options$onEve === void 0 || _this8$_options$onEve.call(_this8$_options, {
623
654
  code: EventCallbackCode.Failed,
624
- message: 'Component loading failed'
655
+ message: 'Auth Component loading failed'
625
656
  });
626
657
  return undefined;
627
658
  }
628
- _this7.eventService.addIFrame(result);
629
- _this7.iframes[ElementPaymentMethod.AUTH_ELEMENT] = result;
659
+ _this8.eventService.addIFrame(result);
660
+ _this8.iframes[ElementPaymentMethod.AUTH_ELEMENT] = result;
630
661
  });
631
662
  return {};
632
663
  }
@@ -637,8 +668,8 @@ export var ElementComponent = /*#__PURE__*/function () {
637
668
  var _this$_options$loadin4, _renderOptions$debugP2;
638
669
  var element = document.querySelector(sdkSelector);
639
670
  if (!element) {
640
- var _this$_options$onEven4, _this$_options7;
641
- (_this$_options$onEven4 = (_this$_options7 = this._options).onEventCallback) === null || _this$_options$onEven4 === void 0 || _this$_options$onEven4.call(_this$_options7, {
671
+ var _this$_options$onEven2, _this$_options3;
672
+ (_this$_options$onEven2 = (_this$_options3 = this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options3, {
642
673
  code: EventCallbackCode.Failed,
643
674
  message: 'Unable to obtain selector'
644
675
  });