@alipay/ams-checkout 1.29.0 → 1.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/core/component/element/components/address.d.ts +1 -1
- package/esm/core/component/element/components/address.js +2 -2
- package/esm/core/component/element/components/payment.d.ts +1 -1
- package/esm/core/component/element/components/payment.js +2 -2
- package/esm/core/component/element/index.d.ts +9 -6
- package/esm/core/component/element/index.js +361 -230
- package/esm/core/component/element/type.d.ts +171 -12
- package/esm/core/component/element/type.js +48 -3
- package/esm/core/component/index.js +5 -0
- package/esm/core/instance/index.js +12 -1
- package/esm/foundation/index.d.ts +1 -1
- package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -2
- package/esm/foundation/product-processor/easysafepay/index.js +29 -73
- package/esm/foundation/service/container/index.d.ts +0 -2
- package/esm/foundation/service/container/index.js +20 -47
- package/esm/foundation/utils/payment_product_utils.d.ts +1 -1
- package/esm/foundation/utils/payment_product_utils.js +2 -2
- package/esm/foundation/utils/preload_helper.d.ts +21 -0
- package/esm/foundation/utils/preload_helper.js +143 -0
- package/esm/index.d.ts +7 -2
- package/esm/index.js +94 -7
- package/esm/plugin/component/channel.d.ts +20 -26
- package/esm/plugin/component/channel.js +392 -428
- package/esm/plugin/component/index.d.ts +1 -0
- package/esm/plugin/component/index.js +51 -20
- package/esm/plugin/const.js +1 -1
- package/esm/service/index.d.ts +0 -1
- package/esm/service/index.js +0 -2
- package/esm/types/index.d.ts +11 -116
- package/esm/types/index.js +3 -33
- package/esm/util/index.d.ts +2 -1
- package/esm/util/index.js +16 -1
- package/esm/util/security.d.ts +1 -0
- package/esm/util/security.js +3 -1
- package/esm/util/spm-map.d.ts +3 -0
- package/esm/util/spm-map.js +3 -0
- package/esm/util/versionCompare.d.ts +1 -1
- package/package.json +1 -1
- package/esm/service/element.d.ts +0 -4
- package/esm/service/element.js +0 -51
@@ -18,16 +18,19 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
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 PackageJson from "../../../../package.json";
|
20
20
|
import { AntomSDKCore } from "../../../foundation/core";
|
21
|
+
import { ServiceProvider } from "../../../foundation/service";
|
21
22
|
import { EVENT as ConstantEvent } from "../../../constant";
|
22
|
-
import {
|
23
|
+
import { ProductSceneEnum } from "../../../types";
|
23
24
|
import { parseSessionData } from "../index";
|
24
25
|
import { ElementAddressComponent } from "./components/address";
|
25
26
|
import { ElementAuthComponent } from "./components/auth";
|
26
27
|
import { ElementPaymentComponent } from "./components/payment";
|
27
28
|
// import { oneAccount, sdkAction, submitResult } from './mock';
|
29
|
+
import { ApplePaySdk, isSkipRenderPaymentMethod } from "../../../plugin/component/channel";
|
28
30
|
import { v4 as uuid } from 'uuid';
|
29
|
-
import {
|
31
|
+
import { destroyModal } from "../../../plugin/component/popupWindow.style";
|
30
32
|
import { LogConfig, Logger } from "../../../util/logger";
|
33
|
+
import { addressTheme, ElementPaymentEvent, ElementPaymentMethod, ElementType, ELEMENT_ENVIRONMENT, EventCallbackCode, MountElementType, ThemeType } from "./type";
|
31
34
|
var logger = new Logger(LogConfig, true);
|
32
35
|
var ElementProcessor = /*#__PURE__*/function () {
|
33
36
|
function ElementProcessor(options) {
|
@@ -39,12 +42,8 @@ var ElementProcessor = /*#__PURE__*/function () {
|
|
39
42
|
}
|
40
43
|
_createClass(ElementProcessor, [{
|
41
44
|
key: "init",
|
42
|
-
value: function init() {
|
43
|
-
|
44
|
-
elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', undefined);
|
45
|
-
elementContainer.init({}, ProductSceneEnum.ELEMENT_PAYMENT);
|
46
|
-
var serviceProvider = elementContainer.getServiceProvider();
|
47
|
-
this.requestService = serviceProvider.getService('Requester');
|
45
|
+
value: function init(config, instanceId) {
|
46
|
+
this.requestService = ServiceProvider.getInstance(instanceId).getService('Requester');
|
48
47
|
}
|
49
48
|
}, {
|
50
49
|
key: "sdkActionQuery",
|
@@ -149,15 +148,13 @@ var ElementProcessor = /*#__PURE__*/function () {
|
|
149
148
|
return ElementProcessor;
|
150
149
|
}();
|
151
150
|
export var ElementComponent = /*#__PURE__*/function () {
|
152
|
-
// address事件回调
|
153
|
-
|
154
151
|
function ElementComponent(options) {
|
155
152
|
var _this4 = this;
|
156
153
|
_classCallCheck(this, ElementComponent);
|
157
154
|
_defineProperty(this, "parseData", void 0);
|
158
155
|
// sessionData 解析出来的数据
|
159
156
|
_defineProperty(this, "loading", void 0);
|
160
|
-
//
|
157
|
+
// element loading
|
161
158
|
_defineProperty(this, "sessionData", void 0);
|
162
159
|
// sessionData 解析出来的数据
|
163
160
|
_defineProperty(this, "elementContainer", void 0);
|
@@ -172,14 +169,15 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
172
169
|
// element 入参
|
173
170
|
_defineProperty(this, "eventService", void 0);
|
174
171
|
// 消息服务
|
175
|
-
|
176
|
-
// 接口服务
|
172
|
+
// private requestService: RequesterService; // 接口服务 一期connect功能,目前已都放入到应用层
|
177
173
|
_defineProperty(this, "sdkActionRes", void 0);
|
178
174
|
// sdk aciton接口返回
|
179
175
|
_defineProperty(this, "oneAccountRes", void 0);
|
180
176
|
// one account接口返回
|
181
177
|
_defineProperty(this, "launchSource", void 0);
|
182
178
|
// launch 来源记录
|
179
|
+
_defineProperty(this, "initCompleted", void 0);
|
180
|
+
// init完成
|
183
181
|
_defineProperty(this, "isConnect", void 0);
|
184
182
|
// 当前sessionData是否connect模式
|
185
183
|
_defineProperty(this, "iframeSrc", void 0);
|
@@ -188,9 +186,14 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
188
186
|
// 组件mount配置记录
|
189
187
|
_defineProperty(this, "iframes", void 0);
|
190
188
|
// iframs合集
|
189
|
+
_defineProperty(this, "loadingElement", []);
|
190
|
+
// 当前加载中的element
|
191
191
|
_defineProperty(this, "componentsCount", void 0);
|
192
192
|
// mount 渲染了多少个element
|
193
193
|
_defineProperty(this, "eventCallback", void 0);
|
194
|
+
// address事件回调
|
195
|
+
// apple pay
|
196
|
+
_defineProperty(this, "ApplePayService", void 0);
|
194
197
|
// 渲染地址组件
|
195
198
|
_defineProperty(this, "mountAddress", function (renderOptions, sdkSelector) {
|
196
199
|
var _renderOptions$appear, _this4$_options;
|
@@ -207,9 +210,10 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
207
210
|
prefillValue: renderOptions.prefillValue
|
208
211
|
};
|
209
212
|
_this4.mountOptions[ElementPaymentMethod.ADDRESS_ELEMENT] = _mountParams;
|
210
|
-
_this4.addressBase.mount(
|
213
|
+
_this4.addressBase.mount(_objectSpread({
|
211
214
|
selector: sdkSelector,
|
212
|
-
elementProps: renderOptions.elementProps
|
215
|
+
elementProps: renderOptions.elementProps,
|
216
|
+
sessionData: renderOptions.sessionData
|
213
217
|
}, _mountParams)).then(function (result) {
|
214
218
|
if (!result) {
|
215
219
|
return _this4.mountErrorHandle();
|
@@ -232,8 +236,10 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
232
236
|
}
|
233
237
|
};
|
234
238
|
_this4.mountOptions[ElementPaymentMethod.PAYMENT_ELEMENT] = _mountParams;
|
235
|
-
_this4.
|
239
|
+
_this4.initApplePaySdk();
|
240
|
+
_this4.paymentBase.mount(_objectSpread({
|
236
241
|
selector: sdkSelector,
|
242
|
+
sessionData: renderOptions.sessionData,
|
237
243
|
elementProps: renderOptions.elementProps
|
238
244
|
}, _mountParams)).then(function (result) {
|
239
245
|
if (!result) {
|
@@ -244,7 +250,7 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
244
250
|
});
|
245
251
|
return {};
|
246
252
|
});
|
247
|
-
// submit提交非RISK_REJECT错误
|
253
|
+
// submit提交非RISK_REJECT错误 一期connect功能,目前已都放入到应用层
|
248
254
|
_defineProperty(this, "onAfterSubmitFunc", function (target, params) {
|
249
255
|
_this4.eventService.emitAndListen({
|
250
256
|
event: ElementPaymentEvent.AFTER_SUBMIT,
|
@@ -255,65 +261,76 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
255
261
|
}
|
256
262
|
}, function () {});
|
257
263
|
});
|
258
|
-
// submit提交 失败,清空组件数据
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
}
|
269
|
-
//
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
264
|
+
// submit提交 失败,清空组件数据 一期connect功能,目前已都放入到应用层
|
265
|
+
// private onSubmitRiskFunc = (target: ElementPaymentMethod) => {
|
266
|
+
// this.eventService.emitAndListen(
|
267
|
+
// {
|
268
|
+
// event: ElementPaymentEvent.SUBMIT_RISK,
|
269
|
+
// data: {
|
270
|
+
// target,
|
271
|
+
// source: ElementPaymentMethod.CONTAINER_ELEMENT,
|
272
|
+
// params: {},
|
273
|
+
// },
|
274
|
+
// },
|
275
|
+
// () => {},
|
276
|
+
// );
|
277
|
+
// };
|
278
|
+
// 发起支付 一期connect功能,目前已都放入到应用层
|
279
|
+
// private onSubmit = (params: SubmitServiceParams): Promise<SubmitFuncResult> => {
|
280
|
+
// return new Promise((resolve) => {
|
281
|
+
// const { paymentSessionConfig } = this.parseData;
|
282
|
+
// console.log('element submit params ------', {
|
283
|
+
// paymentSessionConfig,
|
284
|
+
// paymentSessionData: this.sessionData,
|
285
|
+
// ...params,
|
286
|
+
// });
|
287
|
+
// this.requestService
|
288
|
+
// .request<SubmitServiceResult>(
|
289
|
+
// {
|
290
|
+
// paymentSessionConfig,
|
291
|
+
// paymentSessionData: this.sessionData,
|
292
|
+
// ...params,
|
293
|
+
// },
|
294
|
+
// {
|
295
|
+
// env: this._options.environment,
|
296
|
+
// envInfo: {
|
297
|
+
// locale: this._options.locale,
|
298
|
+
// },
|
299
|
+
// timeout: 300000, // TODO dev环境submit提交接口超时
|
300
|
+
// 'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession',
|
301
|
+
// },
|
302
|
+
// )
|
303
|
+
// .then(
|
304
|
+
// (result) => {
|
305
|
+
// if (
|
306
|
+
// result?.codeFormViews &&
|
307
|
+
// result?.codeFormViews?.[0]?.codeExpireTime &&
|
308
|
+
// result?.actionForm &&
|
309
|
+
// !result?.actionForm?.paymentCodeExpireTime
|
310
|
+
// ) {
|
311
|
+
// result.actionForm.paymentCodeExpireTime = result?.codeFormViews?.[0]?.codeExpireTime;
|
312
|
+
// }
|
313
|
+
// if (result.errorCode === ConnectErrorCode.RISK_REJECT) {
|
314
|
+
// this.onSubmitRiskFunc(ElementPaymentMethod.ADDRESS_ELEMENT);
|
315
|
+
// this.onSubmitRiskFunc(ElementPaymentMethod.AUTH_ELEMENT);
|
316
|
+
// this.onSubmitRiskFunc(ElementPaymentMethod.PAYMENT_ELEMENT);
|
317
|
+
// } else {
|
318
|
+
// this.onAfterSubmitFunc(ElementPaymentMethod.PAYMENT_ELEMENT, result);
|
319
|
+
// }
|
320
|
+
// resolve({
|
321
|
+
// success: result.success,
|
322
|
+
// msg: result.errorMessage,
|
323
|
+
// });
|
324
|
+
// },
|
325
|
+
// () => {
|
326
|
+
// resolve({
|
327
|
+
// success: false,
|
328
|
+
// msg: 'submitPayByPaymentSession api error',
|
329
|
+
// });
|
330
|
+
// },
|
331
|
+
// );
|
332
|
+
// });
|
333
|
+
// };
|
317
334
|
// 发送validate消息
|
318
335
|
_defineProperty(this, "onValidateFunc", function (target, params) {
|
319
336
|
return new Promise(function (resolve) {
|
@@ -341,70 +358,65 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
341
358
|
case 0:
|
342
359
|
params = {};
|
343
360
|
if (!_this4.launchSource.includes(ElementPaymentMethod.AUTH_ELEMENT)) {
|
344
|
-
_context.next =
|
361
|
+
_context.next = 8;
|
345
362
|
break;
|
346
363
|
}
|
347
364
|
_context.next = 4;
|
348
365
|
return _this4.onValidateFunc(ElementPaymentMethod.AUTH_ELEMENT);
|
349
366
|
case 4:
|
350
367
|
result = _context.sent;
|
351
|
-
console.log('element submit validate auth---------', result);
|
352
368
|
params.accountInfo = (_result$data = result.data) === null || _result$data === void 0 || (_result$data = _result$data.data) === null || _result$data === void 0 ? void 0 : _result$data.accountInfo;
|
353
369
|
if (result !== null && result !== void 0 && (_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.success) {
|
354
|
-
_context.next =
|
370
|
+
_context.next = 8;
|
355
371
|
break;
|
356
372
|
}
|
357
373
|
return _context.abrupt("return", resolve(undefined));
|
358
|
-
case
|
374
|
+
case 8:
|
359
375
|
if (!_this4.launchSource.includes(ElementPaymentMethod.ADDRESS_ELEMENT)) {
|
360
|
-
_context.next =
|
376
|
+
_context.next = 15;
|
361
377
|
break;
|
362
378
|
}
|
363
|
-
_context.next =
|
379
|
+
_context.next = 11;
|
364
380
|
return _this4.onValidateFunc(ElementPaymentMethod.ADDRESS_ELEMENT);
|
365
|
-
case
|
381
|
+
case 11:
|
366
382
|
_result = _context.sent;
|
367
|
-
console.log('element submit validate address---------', _result);
|
368
383
|
params.shipping = (_result$data3 = _result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.data;
|
369
384
|
if (_result !== null && _result !== void 0 && (_result$data4 = _result.data) !== null && _result$data4 !== void 0 && _result$data4.success) {
|
370
|
-
_context.next =
|
385
|
+
_context.next = 15;
|
371
386
|
break;
|
372
387
|
}
|
373
388
|
return _context.abrupt("return", resolve(undefined));
|
374
|
-
case
|
389
|
+
case 15:
|
375
390
|
if (!(_this4.launchSource.includes(ElementPaymentMethod.PAYMENT_ELEMENT) || !_this4.isConnect)) {
|
376
|
-
_context.next =
|
391
|
+
_context.next = 27;
|
377
392
|
break;
|
378
393
|
}
|
379
|
-
_context.prev =
|
380
|
-
_context.next =
|
394
|
+
_context.prev = 16;
|
395
|
+
_context.next = 19;
|
381
396
|
return _this4.onValidateFunc(ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
382
|
-
case
|
397
|
+
case 19:
|
383
398
|
_result2 = _context.sent;
|
384
|
-
console.log('element submit validate payment---------', _result2, _this4.isConnect);
|
385
|
-
// params.paymentFactors = result.data?.data?.paymentFactors;
|
386
|
-
// params.paymentMethod = result.data?.data?.paymentMethod;
|
387
399
|
if (_result2 !== null && _result2 !== void 0 && (_result2$data = _result2.data) !== null && _result2$data !== void 0 && _result2$data.success) {
|
388
|
-
_context.next =
|
400
|
+
_context.next = 22;
|
389
401
|
break;
|
390
402
|
}
|
391
403
|
return _context.abrupt("return", resolve(undefined));
|
392
|
-
case
|
393
|
-
_context.next =
|
404
|
+
case 22:
|
405
|
+
_context.next = 27;
|
394
406
|
break;
|
395
|
-
case
|
396
|
-
_context.prev =
|
397
|
-
_context.t0 = _context["catch"](
|
407
|
+
case 24:
|
408
|
+
_context.prev = 24;
|
409
|
+
_context.t0 = _context["catch"](16);
|
398
410
|
return _context.abrupt("return", resolve(undefined));
|
399
|
-
case
|
411
|
+
case 27:
|
400
412
|
// params.paymentFactors = paymentResult.data?.data.paymentFactors;
|
401
413
|
// params.paymentMethod = paymentResult.data?.data.paymentMethod;
|
402
414
|
resolve(params);
|
403
|
-
case
|
415
|
+
case 28:
|
404
416
|
case "end":
|
405
417
|
return _context.stop();
|
406
418
|
}
|
407
|
-
}, _callee, null, [[
|
419
|
+
}, _callee, null, [[16, 24]]);
|
408
420
|
}));
|
409
421
|
return function (_x) {
|
410
422
|
return _ref.apply(this, arguments);
|
@@ -415,14 +427,6 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
415
427
|
this._options = _objectSpread(_objectSpread({}, options), {}, {
|
416
428
|
environment: env.toLocaleLowerCase()
|
417
429
|
});
|
418
|
-
this.eventCallback = _defineProperty(_defineProperty(_defineProperty({}, ElementPaymentMethod.ADDRESS_ELEMENT, {}), ElementPaymentMethod.AUTH_ELEMENT, {}), ElementPaymentMethod.PAYMENT_ELEMENT, {});
|
419
|
-
this.launchSource = [];
|
420
|
-
this.componentsCount = 0;
|
421
|
-
this.iframes = {};
|
422
|
-
this.mountOptions = {};
|
423
|
-
logger.logInfo({
|
424
|
-
title: 'a3753.b101271.c386688'
|
425
|
-
});
|
426
430
|
this.createElement();
|
427
431
|
}
|
428
432
|
|
@@ -430,17 +434,32 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
430
434
|
_createClass(ElementComponent, [{
|
431
435
|
key: "createElement",
|
432
436
|
value: function createElement() {
|
437
|
+
this.eventCallback = _defineProperty(_defineProperty(_defineProperty({}, ElementPaymentMethod.ADDRESS_ELEMENT, {}), ElementPaymentMethod.AUTH_ELEMENT, {}), ElementPaymentMethod.PAYMENT_ELEMENT, {});
|
438
|
+
this.launchSource = [];
|
439
|
+
this.componentsCount = 0;
|
440
|
+
this.iframes = {};
|
441
|
+
this.mountOptions = {};
|
442
|
+
logger.logInfo({
|
443
|
+
title: 'sdk_element_create'
|
444
|
+
});
|
445
|
+
this.elementContainer = new AntomSDKCore();
|
446
|
+
this.iframeSrc = this.createIframeSrc(this._options.environment, this._options.version);
|
447
|
+
}
|
448
|
+
}, {
|
449
|
+
key: "beforeMount",
|
450
|
+
value: function beforeMount(mountSessionData) {
|
433
451
|
var _parseData$connectFac,
|
434
452
|
_parseData$paymentSes,
|
435
453
|
_this5 = this;
|
436
|
-
|
454
|
+
if (this.initCompleted) return;
|
455
|
+
this.initCompleted = true;
|
456
|
+
var _parseSessionData = parseSessionData(mountSessionData),
|
437
457
|
_parseSessionData2 = _slicedToArray(_parseSessionData, 2),
|
438
458
|
parseData = _parseSessionData2[0],
|
439
459
|
sessionData = _parseSessionData2[1];
|
440
460
|
this.parseData = parseData;
|
441
461
|
this.sessionData = sessionData;
|
442
462
|
this.isConnect = (parseData === null || parseData === void 0 || (_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;
|
443
|
-
this.elementContainer = new AntomSDKCore();
|
444
463
|
this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor({
|
445
464
|
paymentSessionConfig: parseData === null || parseData === void 0 ? void 0 : parseData.paymentSessionConfig,
|
446
465
|
sessionData: sessionData,
|
@@ -449,72 +468,83 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
449
468
|
isConnect: this.isConnect
|
450
469
|
}));
|
451
470
|
this.elementContainer.init({}, ProductSceneEnum.ELEMENT_PAYMENT);
|
452
|
-
this.elementContainer.startBizFlow({
|
453
|
-
paymentSession: this._options.sessionData
|
454
|
-
}).then(function () {
|
455
|
-
var _bizFlowBehavior$data;
|
456
|
-
if (!_this5.isConnect) return;
|
457
|
-
var bizFlowBehavior = _this5.elementContainer.getBizFlowBehavior();
|
458
|
-
if (!(bizFlowBehavior !== null && bizFlowBehavior !== void 0 && (_bizFlowBehavior$data = bizFlowBehavior.data) !== null && _bizFlowBehavior$data !== void 0 && _bizFlowBehavior$data.success)) {
|
459
|
-
var _this5$_options, _this5$_options$onEve;
|
460
|
-
console.log('demo event callback----', {
|
461
|
-
code: EventCallbackCode.FAILED,
|
462
|
-
message: 'INTERNAL_FAILED'
|
463
|
-
});
|
464
|
-
_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, {
|
465
|
-
code: EventCallbackCode.FAILED,
|
466
|
-
message: 'INTERNAL_FAILED'
|
467
|
-
});
|
468
|
-
} else {
|
469
|
-
var _bizFlowBehavior$data2, _bizFlowBehavior$data3;
|
470
|
-
_this5.oneAccountRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data2 = bizFlowBehavior.data) === null || _bizFlowBehavior$data2 === void 0 ? void 0 : _bizFlowBehavior$data2.oneAccountRes;
|
471
|
-
_this5.sdkActionRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data3 = bizFlowBehavior.data) === null || _bizFlowBehavior$data3 === void 0 ? void 0 : _bizFlowBehavior$data3.sdkActionRes;
|
472
|
-
_this5.afterInit();
|
473
|
-
}
|
474
|
-
});
|
475
|
-
this.iframeSrc = this.createIframeSrc(this._options.environment, this._options.version);
|
476
471
|
try {
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
472
|
+
this.elementContainer.startBizFlow({
|
473
|
+
paymentSession: mountSessionData
|
474
|
+
}).then(function () {
|
475
|
+
var _bizFlowBehavior$data;
|
476
|
+
if (!_this5.isConnect) return;
|
477
|
+
var bizFlowBehavior = _this5.elementContainer.getBizFlowBehavior();
|
478
|
+
if (!(bizFlowBehavior !== null && bizFlowBehavior !== void 0 && (_bizFlowBehavior$data = bizFlowBehavior.data) !== null && _bizFlowBehavior$data !== void 0 && _bizFlowBehavior$data.success)) {
|
479
|
+
var _this5$_options, _this5$_options$onEve;
|
480
|
+
_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, {
|
481
|
+
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
482
|
+
message: 'Component initialization exception.'
|
483
|
+
});
|
484
|
+
_this5.closeLoading();
|
485
|
+
} else {
|
486
|
+
var _bizFlowBehavior$data2, _bizFlowBehavior$data3;
|
487
|
+
_this5.oneAccountRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data2 = bizFlowBehavior.data) === null || _bizFlowBehavior$data2 === void 0 ? void 0 : _bizFlowBehavior$data2.oneAccountRes;
|
488
|
+
_this5.sdkActionRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data3 = bizFlowBehavior.data) === null || _bizFlowBehavior$data3 === void 0 ? void 0 : _bizFlowBehavior$data3.sdkActionRes;
|
489
|
+
_this5.afterInit();
|
490
|
+
}
|
482
491
|
});
|
483
|
-
var serviceProvider = this.elementContainer.getServiceProvider();
|
484
|
-
this.eventService = serviceProvider.getService('EventCenter');
|
485
|
-
this.requestService = serviceProvider.getService('Requester');
|
486
|
-
// 注册 payment 卡支付模块
|
487
|
-
this.paymentBase = new ElementPaymentComponent();
|
488
|
-
this.paymentBase.create({
|
489
|
-
environment: this._options.environment,
|
490
|
-
locale: this._options.locale,
|
491
|
-
appVersion: this._options.version || ''
|
492
|
-
}, this.isConnect);
|
493
|
-
|
494
|
-
// 注册 address 地址模块
|
495
|
-
this.addressBase = new ElementAddressComponent();
|
496
|
-
this.addressBase.create({
|
497
|
-
environment: this._options.environment,
|
498
|
-
locale: this._options.locale,
|
499
|
-
appVersion: this._options.version || ''
|
500
|
-
}, this.isConnect);
|
501
492
|
} catch (error) {
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
message: 'INTERNAL_FAILED'
|
506
|
-
});
|
507
|
-
(_this$_options$onEven = (_this$_options = this._options).onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options, {
|
508
|
-
code: EventCallbackCode.FAILED,
|
509
|
-
message: 'INTERNAL_FAILED'
|
510
|
-
// message: 'create sdk fail',
|
493
|
+
this._options.onEventCallback({
|
494
|
+
code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
|
495
|
+
message: 'Initialization parameter exception.'
|
511
496
|
});
|
497
|
+
this.closeLoading();
|
512
498
|
}
|
513
|
-
|
499
|
+
var serviceProvider = this.elementContainer.getServiceProvider();
|
500
|
+
// 注册事件服务
|
501
|
+
this.eventService = serviceProvider.getService('EventCenter');
|
502
|
+
// 注册请求服务服务 一期connect功能,目前已都放入到应用层
|
503
|
+
// this.requestService = serviceProvider.getService<RequesterService>('Requester');
|
514
504
|
// 注册监听消息
|
515
505
|
this.addListener();
|
516
506
|
}
|
517
507
|
|
508
|
+
// 创建
|
509
|
+
}, {
|
510
|
+
key: "createComponentSdk",
|
511
|
+
value: function createComponentSdk(type) {
|
512
|
+
try {
|
513
|
+
// 注册 auth 邮箱模块
|
514
|
+
if (type === ElementType.auth) {
|
515
|
+
this.authBase = new ElementAuthComponent();
|
516
|
+
this.authBase.create({
|
517
|
+
environment: this._options.environment,
|
518
|
+
locale: this._options.locale
|
519
|
+
});
|
520
|
+
} else if (type === ElementType.address) {
|
521
|
+
this.addressBase = new ElementAddressComponent();
|
522
|
+
this.addressBase.create({
|
523
|
+
environment: this._options.environment,
|
524
|
+
locale: this._options.locale,
|
525
|
+
appVersion: this._options.version || ''
|
526
|
+
}, this.isConnect);
|
527
|
+
} else if (type === ElementType.payment) {
|
528
|
+
// 注册 payment 卡支付模块
|
529
|
+
this.paymentBase = new ElementPaymentComponent();
|
530
|
+
this.paymentBase.create({
|
531
|
+
environment: this._options.environment,
|
532
|
+
locale: this._options.locale,
|
533
|
+
appVersion: this._options.version || ''
|
534
|
+
}, this.isConnect);
|
535
|
+
} else {
|
536
|
+
throw Error("The provided 'type' value is invalid");
|
537
|
+
}
|
538
|
+
} catch (error) {
|
539
|
+
var _this$_options, _this$_options$onEven;
|
540
|
+
this === null || this === void 0 || (_this$_options = this._options) === null || _this$_options === void 0 || (_this$_options$onEven = _this$_options.onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options, {
|
541
|
+
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
542
|
+
message: 'Component initialization exception.'
|
543
|
+
});
|
544
|
+
this.closeLoading();
|
545
|
+
}
|
546
|
+
}
|
547
|
+
|
518
548
|
// iframe src生成方法
|
519
549
|
}, {
|
520
550
|
key: "createIframeSrc",
|
@@ -536,6 +566,16 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
536
566
|
payment: payment
|
537
567
|
};
|
538
568
|
}
|
569
|
+
}, {
|
570
|
+
key: "closeLoading",
|
571
|
+
value: function closeLoading() {
|
572
|
+
var _this$_options$loadin;
|
573
|
+
if (this.loading && (_this$_options$loadin = this._options.loading) !== null && _this$_options$loadin !== void 0 && _this$_options$loadin.onEndLoading) {
|
574
|
+
var _this$_options$loadin2, _this$_options$loadin3;
|
575
|
+
(_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);
|
576
|
+
}
|
577
|
+
this.loading = false;
|
578
|
+
}
|
539
579
|
|
540
580
|
// 循环给所有iframe发同一个消息
|
541
581
|
// private postCommonMessage<T>(event: ElementPaymentEvent, params: T) {
|
@@ -570,12 +610,10 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
570
610
|
});
|
571
611
|
this.eventService.listen(ElementPaymentEvent.SEND_MUITI_APP_EVENT_TO_SDK, function (result) {
|
572
612
|
var _this6$_options$onEve, _this6$_options;
|
573
|
-
console.log('demo event callback----', result.data);
|
574
613
|
(_this6$_options$onEve = (_this6$_options = _this6._options).onEventCallback) === null || _this6$_options$onEve === void 0 || _this6$_options$onEve.call(_this6$_options, result.data);
|
575
614
|
});
|
576
615
|
this.eventService.listen(ElementPaymentEvent.CALLBACK, function (result) {
|
577
616
|
var _this6$eventCallback;
|
578
|
-
console.log('antom sdk 组件事件回调');
|
579
617
|
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]) {
|
580
618
|
var _this6$eventCallback$, _this6$eventCallback$2;
|
581
619
|
(_this6$eventCallback$ = (_this6$eventCallback$2 = _this6.eventCallback[result.source])[result.event]) === null || _this6$eventCallback$ === void 0 || _this6$eventCallback$.call(_this6$eventCallback$2, result.data);
|
@@ -587,8 +625,30 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
587
625
|
this.eventService.listen(ConstantEvent.redirect.name, function (data, res) {
|
588
626
|
data.isDestroy && _this6.unmount();
|
589
627
|
});
|
590
|
-
this.eventService.listen(
|
591
|
-
|
628
|
+
this.eventService.listen(ConstantEvent.appHeartBeat.name, function (result) {
|
629
|
+
_this6.closeLoading();
|
630
|
+
});
|
631
|
+
|
632
|
+
// this.eventService.listen(ElementPaymentEvent.LOG, (result: EventCallbackData) => {
|
633
|
+
// console.log('antom sdk 组件日志回调');
|
634
|
+
// });
|
635
|
+
|
636
|
+
this.eventService.listen(ElementPaymentEvent.HANDLE_PAYMENT, function (result) {
|
637
|
+
if ((result === null || result === void 0 ? void 0 : result.paymentMethodType) === 'APPLEPAY') {
|
638
|
+
_this6.ApplePayService.begin().then(function (res) {
|
639
|
+
_this6.onAfterSubmitFunc(ElementPaymentMethod.PAYMENT_ELEMENT, {
|
640
|
+
submitPayData: res
|
641
|
+
});
|
642
|
+
}).catch(function (e) {
|
643
|
+
_this6.onAfterSubmitFunc(ElementPaymentMethod.PAYMENT_ELEMENT, {
|
644
|
+
submitPayData: {},
|
645
|
+
errorInfo: {
|
646
|
+
hasError: true,
|
647
|
+
errorCode: e === null || e === void 0 ? void 0 : e.errorCode
|
648
|
+
}
|
649
|
+
});
|
650
|
+
});
|
651
|
+
}
|
592
652
|
});
|
593
653
|
}
|
594
654
|
|
@@ -612,15 +672,10 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
612
672
|
}, {
|
613
673
|
key: "showIframe",
|
614
674
|
value: function showIframe() {
|
615
|
-
var _this$paymentBase, _this$addressBase, _this$authBase
|
616
|
-
this.loading = false;
|
675
|
+
var _this$paymentBase, _this$addressBase, _this$authBase;
|
617
676
|
(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());
|
618
677
|
(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());
|
619
678
|
(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());
|
620
|
-
if ((_this$_options$loadin = this._options.loading) !== null && _this$_options$loadin !== void 0 && _this$_options$loadin.onEndLoading) {
|
621
|
-
var _this$_options$loadin2, _this$_options$loadin3;
|
622
|
-
(_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);
|
623
|
-
}
|
624
679
|
}
|
625
680
|
}, {
|
626
681
|
key: "afterInit",
|
@@ -639,7 +694,7 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
639
694
|
var baseData = {
|
640
695
|
originActionQueryResult: this.sdkActionRes,
|
641
696
|
originOneAccountQueryResult: this.oneAccountRes,
|
642
|
-
paymentSessionData: this.
|
697
|
+
paymentSessionData: this.sessionData,
|
643
698
|
sessionResult: this.parseData || {}
|
644
699
|
};
|
645
700
|
this.launchSource.forEach(function (target) {
|
@@ -669,6 +724,11 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
669
724
|
this.eventService.unlisten(ElementPaymentEvent.CAPTURE_ASSET);
|
670
725
|
this.eventService.unlisten(ElementPaymentEvent.LAUNCH);
|
671
726
|
this.eventService.unlisten(ElementPaymentEvent.SIZE_CHANGE);
|
727
|
+
this.eventService.unlisten(ElementPaymentEvent.CALLBACK);
|
728
|
+
this.eventService.unlisten(ConstantEvent.close.name);
|
729
|
+
this.eventService.unlisten(ConstantEvent.redirect.name);
|
730
|
+
this.eventService.unlisten(ConstantEvent.appHeartBeat.name);
|
731
|
+
this.eventService.unlisten(ElementPaymentEvent.HANDLE_PAYMENT);
|
672
732
|
}
|
673
733
|
|
674
734
|
// 注册组件事件监听
|
@@ -697,6 +757,7 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
697
757
|
var url = link.indexOf('?') === -1 ? "".concat(link, "?").concat(params) : link;
|
698
758
|
this.authBase.mount({
|
699
759
|
selector: sdkSelector,
|
760
|
+
sessionData: renderOptions.sessionData,
|
700
761
|
url: url
|
701
762
|
}).then(function (result) {
|
702
763
|
if (!result) {
|
@@ -707,51 +768,103 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
707
768
|
});
|
708
769
|
return {};
|
709
770
|
}
|
771
|
+
}, {
|
772
|
+
key: "initApplePaySdk",
|
773
|
+
value: function () {
|
774
|
+
var _initApplePaySdk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
775
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
776
|
+
while (1) switch (_context2.prev = _context2.next) {
|
777
|
+
case 0:
|
778
|
+
if (!isSkipRenderPaymentMethod(this.parseData)) {
|
779
|
+
_context2.next = 12;
|
780
|
+
break;
|
781
|
+
}
|
782
|
+
this.ApplePayService = new ApplePaySdk({
|
783
|
+
paymentSessionData: this.sessionData,
|
784
|
+
parseData: this.parseData,
|
785
|
+
logger: logger
|
786
|
+
});
|
787
|
+
_context2.prev = 2;
|
788
|
+
logger.logInfo({
|
789
|
+
title: 'a3753.b107385.c398110'
|
790
|
+
});
|
791
|
+
_context2.next = 6;
|
792
|
+
return this.ApplePayService.initApplePaySession();
|
793
|
+
case 6:
|
794
|
+
logger.logInfo({
|
795
|
+
title: 'a3753.b107385.c398112'
|
796
|
+
});
|
797
|
+
_context2.next = 12;
|
798
|
+
break;
|
799
|
+
case 9:
|
800
|
+
_context2.prev = 9;
|
801
|
+
_context2.t0 = _context2["catch"](2);
|
802
|
+
logger.logError({
|
803
|
+
title: 'a3753.b107385.c398111'
|
804
|
+
});
|
805
|
+
case 12:
|
806
|
+
case "end":
|
807
|
+
return _context2.stop();
|
808
|
+
}
|
809
|
+
}, _callee2, this, [[2, 9]]);
|
810
|
+
}));
|
811
|
+
function initApplePaySdk() {
|
812
|
+
return _initApplePaySdk.apply(this, arguments);
|
813
|
+
}
|
814
|
+
return initApplePaySdk;
|
815
|
+
}()
|
710
816
|
}, {
|
711
817
|
key: "mountErrorHandle",
|
712
818
|
value: function mountErrorHandle() {
|
713
|
-
var _this$
|
714
|
-
|
715
|
-
code: EventCallbackCode.
|
716
|
-
message: '
|
717
|
-
});
|
718
|
-
(_this$_options$onEven2 = (_this$_options3 = this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options3, {
|
719
|
-
code: EventCallbackCode.FAILED,
|
720
|
-
message: 'INTERNAL_FAILED'
|
819
|
+
var _this$_options3, _this$_options3$onEve;
|
820
|
+
this === null || this === void 0 || (_this$_options3 = this._options) === null || _this$_options3 === void 0 || (_this$_options3$onEve = _this$_options3.onEventCallback) === null || _this$_options3$onEve === void 0 || _this$_options3$onEve.call(_this$_options3, {
|
821
|
+
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
822
|
+
message: 'Component initialization exception.'
|
721
823
|
});
|
824
|
+
this.closeLoading();
|
722
825
|
logger.logError({
|
723
|
-
title: '
|
826
|
+
title: 'sdk_element_mount_fail'
|
724
827
|
});
|
828
|
+
this.resetState();
|
725
829
|
}
|
726
830
|
}, {
|
727
831
|
key: "mount",
|
728
832
|
value: function mount(renderOptions, sdkSelector) {
|
729
|
-
|
730
|
-
|
731
|
-
|
833
|
+
// 当前type element已加载 / 加载中
|
834
|
+
if (this.iframes[MountElementType[renderOptions === null || renderOptions === void 0 ? void 0 : renderOptions.type]] || this.loadingElement.includes(renderOptions === null || renderOptions === void 0 ? void 0 : renderOptions.type)) {
|
835
|
+
throw Error('The component has been mounted, please do not execute it again.');
|
836
|
+
}
|
732
837
|
if (typeof sdkSelector === 'string') {
|
733
838
|
var _this$_options$loadin4, _renderOptions$debugP, _renderOptions$debugP2;
|
734
839
|
var element = document.querySelector(sdkSelector);
|
840
|
+
// 容器是否存在
|
735
841
|
if (!element) {
|
736
|
-
|
842
|
+
throw Error('Loading failed, you need to check if the element exists.');
|
737
843
|
}
|
738
|
-
|
739
|
-
|
844
|
+
// 生成sdk,同时判断 type 是否合规,不合规会直接报错
|
845
|
+
this.createComponentSdk(renderOptions.type);
|
846
|
+
this.beforeMount(renderOptions.sessionData);
|
847
|
+
this.loadingElement.push(renderOptions === null || renderOptions === void 0 ? void 0 : renderOptions.type);
|
848
|
+
logger.logInfo({
|
849
|
+
title: 'sdk_element_mount_start'
|
850
|
+
});
|
851
|
+
if (!this.loading && (_this$_options$loadin4 = this._options.loading) !== null && _this$_options$loadin4 !== void 0 && _this$_options$loadin4.onStartLoading) {
|
740
852
|
var _this$_options$loadin5, _this$_options$loadin6;
|
741
853
|
(_this$_options$loadin5 = this._options.loading) === null || _this$_options$loadin5 === void 0 || (_this$_options$loadin6 = _this$_options$loadin5.onStartLoading) === null || _this$_options$loadin6 === void 0 || _this$_options$loadin6.call(_this$_options$loadin5);
|
742
854
|
}
|
855
|
+
this.loading = true;
|
856
|
+
this.componentsCount = this.componentsCount + 1;
|
743
857
|
var elementLink = renderOptions !== null && renderOptions !== void 0 && (_renderOptions$debugP = renderOptions.debugProps) !== null && _renderOptions$debugP !== void 0 && _renderOptions$debugP.localLink ? renderOptions === null || renderOptions === void 0 || (_renderOptions$debugP2 = renderOptions.debugProps) === null || _renderOptions$debugP2 === void 0 ? void 0 : _renderOptions$debugP2.localLink : this.iframeSrc[renderOptions.type];
|
744
858
|
renderOptions.elementProps = {
|
745
859
|
elementLink: elementLink
|
746
860
|
};
|
747
|
-
|
748
|
-
if (renderOptions.type === 'auth') {
|
861
|
+
if (renderOptions.type === ElementType.auth) {
|
749
862
|
return this.mountAuth(renderOptions, sdkSelector);
|
750
863
|
}
|
751
|
-
if (renderOptions.type ===
|
864
|
+
if (renderOptions.type === ElementType.address) {
|
752
865
|
return this.mountAddress(renderOptions, sdkSelector);
|
753
866
|
}
|
754
|
-
if (renderOptions.type ===
|
867
|
+
if (renderOptions.type === ElementType.payment) {
|
755
868
|
return this.mountPayment(renderOptions, sdkSelector);
|
756
869
|
}
|
757
870
|
} else {
|
@@ -760,60 +873,78 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
760
873
|
}
|
761
874
|
|
762
875
|
// 注销单个iframe,暂时没有用到
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
return source !== sdk;
|
771
|
-
});
|
772
|
-
this.componentsCount = this.componentsCount - 1;
|
773
|
-
this.eventService.removeIFrame(this.iframes[sdk]);
|
774
|
-
}
|
775
|
-
}
|
876
|
+
// private removeIframe(sdk: ElementPaymentMethod) {
|
877
|
+
// if (sdk && this.launchSource.some((source) => source === sdk)) {
|
878
|
+
// this.launchSource = this.launchSource.filter((source) => source !== sdk);
|
879
|
+
// this.componentsCount = this.componentsCount - 1;
|
880
|
+
// this.eventService.removeIFrame(this.iframes[sdk]);
|
881
|
+
// }
|
882
|
+
// }
|
776
883
|
|
777
884
|
// 暴露出去的注销组件方法
|
778
885
|
}, {
|
779
|
-
key: "
|
780
|
-
value: function
|
886
|
+
key: "resetState",
|
887
|
+
value: function resetState() {
|
781
888
|
var _this$authBase2, _this$authBase2$unmou, _this$addressBase2, _this$addressBase2$un, _this$paymentBase2, _this$paymentBase2$un;
|
782
889
|
(_this$authBase2 = this.authBase) === null || _this$authBase2 === void 0 || (_this$authBase2$unmou = _this$authBase2.unmount) === null || _this$authBase2$unmou === void 0 || _this$authBase2$unmou.call(_this$authBase2);
|
783
890
|
(_this$addressBase2 = this.addressBase) === null || _this$addressBase2 === void 0 || (_this$addressBase2$un = _this$addressBase2.unmount) === null || _this$addressBase2$un === void 0 || _this$addressBase2$un.call(_this$addressBase2);
|
784
891
|
(_this$paymentBase2 = this.paymentBase) === null || _this$paymentBase2 === void 0 || (_this$paymentBase2$un = _this$paymentBase2.unmount) === null || _this$paymentBase2$un === void 0 || _this$paymentBase2$un.call(_this$paymentBase2);
|
785
892
|
this.launchSource = [];
|
893
|
+
this.iframes = {};
|
786
894
|
this.componentsCount = 0;
|
787
895
|
this.eventService.destroy();
|
788
896
|
this.removeListener();
|
897
|
+
this.loadingElement = [];
|
898
|
+
this.initCompleted = false;
|
899
|
+
}
|
900
|
+
}, {
|
901
|
+
key: "unmount",
|
902
|
+
value: function unmount() {
|
903
|
+
if (!this.iframes.PAYMENT_ELEMENT) {
|
904
|
+
throw Error('Component is not mounted. You need to check if the mount method has been successfully called to mount the component.');
|
905
|
+
}
|
906
|
+
// popup未注册会报错,但element不需要感知popup是否被注册
|
907
|
+
try {
|
908
|
+
destroyModal(); // 关闭popup弹窗
|
909
|
+
} catch (error) {}
|
910
|
+
this.resetState();
|
789
911
|
}
|
790
912
|
}, {
|
791
913
|
key: "submitPayment",
|
792
914
|
value: // 暴露出去的submit方法
|
793
915
|
function () {
|
794
|
-
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
795
|
-
var _this$_options$loadin7
|
796
|
-
var _this$_options$loadin8, _this$_options$loadin9
|
797
|
-
return _regeneratorRuntime().wrap(function
|
798
|
-
while (1) switch (
|
916
|
+
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
917
|
+
var _this$_options$loadin7;
|
918
|
+
var _this$_options$loadin8, _this$_options$loadin9;
|
919
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
920
|
+
while (1) switch (_context3.prev = _context3.next) {
|
799
921
|
case 0:
|
800
|
-
|
801
|
-
|
922
|
+
if (this.iframes.PAYMENT_ELEMENT) {
|
923
|
+
_context3.next = 2;
|
924
|
+
break;
|
925
|
+
}
|
926
|
+
throw Error('Component is not mounted. You need to check if the mount method has been successfully called to mount the component.');
|
927
|
+
case 2:
|
928
|
+
if (!this.loading) {
|
929
|
+
_context3.next = 4;
|
930
|
+
break;
|
931
|
+
}
|
932
|
+
throw Error('The form is submitted repeatedly. without the need to click submit repeatedly.');
|
933
|
+
case 4:
|
802
934
|
if ((_this$_options$loadin7 = this._options.loading) !== null && _this$_options$loadin7 !== void 0 && _this$_options$loadin7.onStartLoading) {
|
803
935
|
(_this$_options$loadin8 = this._options.loading) === null || _this$_options$loadin8 === void 0 || (_this$_options$loadin9 = _this$_options$loadin8.onStartLoading) === null || _this$_options$loadin9 === void 0 || _this$_options$loadin9.call(_this$_options$loadin8);
|
804
936
|
}
|
805
|
-
|
937
|
+
this.loading = true;
|
938
|
+
_context3.next = 8;
|
806
939
|
return this.validatePromiseFuncs();
|
807
|
-
case
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
return _context2.abrupt("return");
|
812
|
-
case 5:
|
940
|
+
case 8:
|
941
|
+
this.closeLoading();
|
942
|
+
return _context3.abrupt("return");
|
943
|
+
case 10:
|
813
944
|
case "end":
|
814
|
-
return
|
945
|
+
return _context3.stop();
|
815
946
|
}
|
816
|
-
},
|
947
|
+
}, _callee3, this);
|
817
948
|
}));
|
818
949
|
function submitPayment() {
|
819
950
|
return _submitPayment.apply(this, arguments);
|