@alipay/ams-checkout 0.0.1699863258-dev.1 → 0.0.1699863258-dev.3
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/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/plugin/component/index.d.ts +4 -0
- package/esm/plugin/component/index.js +212 -81
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +1 -1
- package/esm/service/index.d.ts +4 -3
- package/esm/service/index.js +23 -0
- package/esm/types/index.d.ts +61 -2
- package/esm/types/index.js +6 -0
- package/esm/util/index.js +11 -6
- package/package.json +1 -1
package/esm/constant/index.d.ts
CHANGED
@@ -152,6 +152,9 @@ export declare const EVENT: {
|
|
152
152
|
getDeviceId: {
|
153
153
|
name: string;
|
154
154
|
};
|
155
|
+
declareEventCallbackInfo: {
|
156
|
+
name: string;
|
157
|
+
};
|
155
158
|
};
|
156
159
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
157
160
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
package/esm/constant/index.js
CHANGED
@@ -17,10 +17,12 @@ export default class ComponentApp {
|
|
17
17
|
private _appVersion;
|
18
18
|
private _isRetention;
|
19
19
|
private _actionQueryPromise;
|
20
|
+
private _actionSubmitPromise;
|
20
21
|
private _renderParams;
|
21
22
|
private _componentSign;
|
22
23
|
private _appLocationSearch;
|
23
24
|
private _renderDisplayType;
|
25
|
+
private _multipleCallbackEvents;
|
24
26
|
constructor();
|
25
27
|
/**
|
26
28
|
* @description Cancel listening and destroy the dom
|
@@ -49,6 +51,7 @@ export default class ComponentApp {
|
|
49
51
|
* @description Interface request
|
50
52
|
*/
|
51
53
|
private createActionQueryPromise;
|
54
|
+
private createSubmitPromise;
|
52
55
|
private cleanElement;
|
53
56
|
/**
|
54
57
|
* @description Create app
|
@@ -70,6 +73,7 @@ export default class ComponentApp {
|
|
70
73
|
private handleSizeChanged;
|
71
74
|
private handleRedirect;
|
72
75
|
private handleDeclareInfo;
|
76
|
+
private handleDeclarePopWindowCallback;
|
73
77
|
private handleCloseBtnShow;
|
74
78
|
/**
|
75
79
|
* @description Send message to SDK
|
@@ -17,7 +17,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
18
|
import { marmotMap } from "../../config/index";
|
19
19
|
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
|
20
|
-
import { queryPaymentInfo } from "../../service";
|
20
|
+
import { queryPaymentInfo, submitPayInfo } from "../../service";
|
21
21
|
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
|
22
22
|
import { getType, isJsonString, isPC } from "../../util";
|
23
23
|
import { isLocalMock } from "../../util/mock";
|
@@ -43,11 +43,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
43
43
|
_defineProperty(this, "_appVersion", void 0);
|
44
44
|
_defineProperty(this, "_isRetention", void 0);
|
45
45
|
_defineProperty(this, "_actionQueryPromise", null);
|
46
|
+
_defineProperty(this, "_actionSubmitPromise", null);
|
46
47
|
_defineProperty(this, "_renderParams", null);
|
47
48
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
48
49
|
_defineProperty(this, "_appLocationSearch", void 0);
|
49
50
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
50
|
-
this
|
51
|
+
_defineProperty(this, "_multipleCallbackEvents", void 0);
|
52
|
+
this._appVersion = '1.6.1';
|
51
53
|
this._isInitComponent = false;
|
52
54
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
53
55
|
this.createIframeNode = function () {
|
@@ -257,12 +259,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
257
259
|
this.renderPopupLoading(renderParams);
|
258
260
|
}
|
259
261
|
this.createApp(renderParams);
|
260
|
-
return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
|
261
|
-
_this3.AMSSDK.logger.logInfo({
|
262
|
-
title: 'sdk_event_successfully_created_app_process'
|
263
|
-
}).send();
|
262
|
+
return Promise.all([this.createActionQueryPromise(), this.createSubmitPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
|
264
263
|
return Promise.resolve();
|
265
264
|
}).catch(function (error) {
|
265
|
+
_this3.AMSSDK.logger.logError({
|
266
|
+
title: 'sdk_error_created_app_process_failed'
|
267
|
+
}).send();
|
266
268
|
_this3._isInitComponent = false;
|
267
269
|
_this3.cleanContainer();
|
268
270
|
return Promise.reject(error);
|
@@ -323,8 +325,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
323
325
|
// eslint-disable-next-line no-async-promise-executor
|
324
326
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
325
327
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
326
|
-
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3;
|
327
|
-
var envInfo, params, _this5$
|
328
|
+
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
|
329
|
+
var envInfo, params, _this5$_renderParams5, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams6, _action$web, _action$wap, action, signType;
|
328
330
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
329
331
|
while (1) switch (_context2.prev = _context2.next) {
|
330
332
|
case 0:
|
@@ -337,70 +339,80 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
337
339
|
notRedirectAfterComplete: ((_this5$_renderParams3 = _this5._renderParams) === null || _this5$_renderParams3 === void 0 ? void 0 : _this5$_renderParams3.notRedirectAfterComplete) === true
|
338
340
|
};
|
339
341
|
/**
|
340
|
-
* @description
|
342
|
+
* @description Simulated or unnecessary scenarios
|
341
343
|
*/
|
344
|
+
if (!(isLocalMock() || (_this5$_renderParams4 = _this5._renderParams) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.action) !== null && _this5$_renderParams4 !== void 0 && _this5$_renderParams4.skipSdkQuery)) {
|
345
|
+
_context2.next = 4;
|
346
|
+
break;
|
347
|
+
}
|
348
|
+
return _context2.abrupt("return", resolve({
|
349
|
+
message: 'sdk no need to make query request',
|
350
|
+
success: true
|
351
|
+
}));
|
352
|
+
case 4:
|
342
353
|
if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
|
343
|
-
_context2.next =
|
354
|
+
_context2.next = 9;
|
344
355
|
break;
|
345
356
|
}
|
346
357
|
params.paymentMethodType = 'CARD';
|
347
|
-
_context2.next =
|
358
|
+
_context2.next = 8;
|
348
359
|
return _this5.getDeviceIdAndLog();
|
349
|
-
case
|
360
|
+
case 8:
|
350
361
|
envInfo.deviceId = _context2.sent;
|
351
|
-
case
|
362
|
+
case 9:
|
352
363
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
353
|
-
_context2.next =
|
364
|
+
_context2.next = 17;
|
354
365
|
break;
|
355
366
|
}
|
356
367
|
_ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
|
357
|
-
_ref4 = ((_this5$
|
368
|
+
_ref4 = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
|
358
369
|
if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
|
359
|
-
_context2.next =
|
370
|
+
_context2.next = 14;
|
360
371
|
break;
|
361
372
|
}
|
362
373
|
return _context2.abrupt("return", resolve({
|
363
374
|
message: 'sdk no need to make query request',
|
364
375
|
success: true
|
365
376
|
}));
|
366
|
-
case 12:
|
367
|
-
_context2.next = 14;
|
368
|
-
return _this5.getDeviceIdAndLog();
|
369
377
|
case 14:
|
378
|
+
_context2.next = 16;
|
379
|
+
return _this5.getDeviceIdAndLog();
|
380
|
+
case 16:
|
370
381
|
envInfo.deviceId = _context2.sent;
|
371
|
-
case
|
382
|
+
case 17:
|
372
383
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
373
|
-
_context2.next =
|
384
|
+
_context2.next = 27;
|
374
385
|
break;
|
375
386
|
}
|
376
|
-
action = ((_this5$
|
387
|
+
action = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 || (_this5$_renderParams6 = _this5$_renderParams6.paymentSessionMetaData) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.action) || {};
|
377
388
|
signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
378
389
|
if (!(signType === 'SMS')) {
|
379
|
-
_context2.next =
|
390
|
+
_context2.next = 22;
|
380
391
|
break;
|
381
392
|
}
|
382
393
|
return _context2.abrupt("return", resolve({
|
383
394
|
message: 'sdk no need to make query request',
|
384
395
|
success: true
|
385
396
|
}));
|
386
|
-
case 20:
|
387
|
-
if (!(!signType || signType !== 'REDIRECT')) {
|
388
|
-
_context2.next = 22;
|
389
|
-
break;
|
390
|
-
}
|
391
|
-
return _context2.abrupt("return", resolve({
|
392
|
-
success: false
|
393
|
-
}));
|
394
397
|
case 22:
|
395
|
-
if (!
|
398
|
+
if (!(!signType || signType !== 'REDIRECT')) {
|
396
399
|
_context2.next = 24;
|
397
400
|
break;
|
398
401
|
}
|
399
402
|
return _context2.abrupt("return", resolve({
|
400
|
-
|
401
|
-
success: true
|
403
|
+
success: false
|
402
404
|
}));
|
403
405
|
case 24:
|
406
|
+
_context2.next = 26;
|
407
|
+
return _this5.getDeviceIdAndLog();
|
408
|
+
case 26:
|
409
|
+
envInfo.deviceId = _context2.sent;
|
410
|
+
case 27:
|
411
|
+
_this5.AMSSDK.logger.logInfo({
|
412
|
+
title: 'sdk_event_sdkQuery'
|
413
|
+
}, {
|
414
|
+
paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
|
415
|
+
}).send();
|
404
416
|
queryPaymentInfo(params, {
|
405
417
|
env: _this5.AMSSDK.options.env.environment,
|
406
418
|
envInfo: envInfo
|
@@ -424,8 +436,14 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
424
436
|
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
|
425
437
|
});
|
426
438
|
reject(err);
|
439
|
+
}).finally(function () {
|
440
|
+
_this5.AMSSDK.logger.logInfo({
|
441
|
+
title: 'sdk_event_sdkQueryEnd'
|
442
|
+
}, {
|
443
|
+
paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
|
444
|
+
}).send();
|
427
445
|
});
|
428
|
-
case
|
446
|
+
case 29:
|
429
447
|
case "end":
|
430
448
|
return _context2.stop();
|
431
449
|
}
|
@@ -437,6 +455,90 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
437
455
|
}());
|
438
456
|
return this._actionQueryPromise;
|
439
457
|
}
|
458
|
+
}, {
|
459
|
+
key: "createSubmitPromise",
|
460
|
+
value: function createSubmitPromise() {
|
461
|
+
var _this$_renderParams3,
|
462
|
+
_this$_renderParams4,
|
463
|
+
_this6 = this;
|
464
|
+
this._performanceData.push({
|
465
|
+
key: 'sdk_submit_start',
|
466
|
+
value: Date.now()
|
467
|
+
});
|
468
|
+
var params = {
|
469
|
+
paymentSessionData: this._renderParams && ((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData) || '',
|
470
|
+
paymentSessionConfig: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionMetaData) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionConfig
|
471
|
+
};
|
472
|
+
|
473
|
+
// eslint-disable-next-line no-async-promise-executor
|
474
|
+
this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
|
475
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
476
|
+
var _this6$_renderParams;
|
477
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
478
|
+
while (1) switch (_context3.prev = _context3.next) {
|
479
|
+
case 0:
|
480
|
+
if (!(!((_this6$_renderParams = _this6._renderParams) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.paymentSessionMetaData) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.action) !== null && _this6$_renderParams !== void 0 && _this6$_renderParams.skipSdkQuery) || componentSignEnum.EASY_PAY_WALLET !== _this6._componentSign)) {
|
481
|
+
_context3.next = 2;
|
482
|
+
break;
|
483
|
+
}
|
484
|
+
return _context3.abrupt("return", resolve({
|
485
|
+
message: 'sdk no need to make submitPay request',
|
486
|
+
success: true
|
487
|
+
}));
|
488
|
+
case 2:
|
489
|
+
_this6.AMSSDK.logger.logInfo({
|
490
|
+
title: 'sdk_event_submitPay'
|
491
|
+
}, {
|
492
|
+
paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
|
493
|
+
}).send();
|
494
|
+
_context3.t0 = submitPayInfo;
|
495
|
+
_context3.t1 = params;
|
496
|
+
_context3.t2 = _this6.AMSSDK.options.env.environment;
|
497
|
+
_context3.next = 8;
|
498
|
+
return _this6.getDeviceIdAndLog();
|
499
|
+
case 8:
|
500
|
+
_context3.t3 = _context3.sent;
|
501
|
+
_context3.t4 = {
|
502
|
+
deviceId: _context3.t3
|
503
|
+
};
|
504
|
+
_context3.t5 = {
|
505
|
+
env: _context3.t2,
|
506
|
+
timeout: 15000,
|
507
|
+
envInfo: _context3.t4
|
508
|
+
};
|
509
|
+
_context3.t6 = _this6.AMSSDK.logger;
|
510
|
+
(0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6).then(function (res) {
|
511
|
+
_this6._performanceData.push({
|
512
|
+
key: 'sdk_submit_end',
|
513
|
+
value: Date.now()
|
514
|
+
});
|
515
|
+
if (res !== null && res !== void 0 && res.success) {
|
516
|
+
resolve(res);
|
517
|
+
} else {
|
518
|
+
resolve(res);
|
519
|
+
}
|
520
|
+
}).catch(function () {
|
521
|
+
resolve({
|
522
|
+
success: false
|
523
|
+
});
|
524
|
+
}).finally(function () {
|
525
|
+
_this6.AMSSDK.logger.logInfo({
|
526
|
+
title: 'sdk_event_submitPayEnd'
|
527
|
+
}, {
|
528
|
+
paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
|
529
|
+
}).send();
|
530
|
+
});
|
531
|
+
case 13:
|
532
|
+
case "end":
|
533
|
+
return _context3.stop();
|
534
|
+
}
|
535
|
+
}, _callee3);
|
536
|
+
}));
|
537
|
+
return function (_x3) {
|
538
|
+
return _ref5.apply(this, arguments);
|
539
|
+
};
|
540
|
+
}());
|
541
|
+
}
|
440
542
|
}, {
|
441
543
|
key: "cleanElement",
|
442
544
|
value: function cleanElement() {
|
@@ -553,9 +655,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
553
655
|
}, {
|
554
656
|
key: "createPopupWindow",
|
555
657
|
value: function createPopupWindow(data) {
|
556
|
-
var _this$
|
658
|
+
var _this$_renderParams5;
|
557
659
|
this._threedData = data;
|
558
|
-
var sessionData = encodeURIComponent((_this$
|
660
|
+
var sessionData = encodeURIComponent((_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData);
|
559
661
|
var threedPageUrl = "".concat(marmotMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&").concat(this._appLocationSearch);
|
560
662
|
this.popupWindow = createModal({
|
561
663
|
device: this.platform,
|
@@ -565,19 +667,19 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
565
667
|
}, {
|
566
668
|
key: "getDeviceIdAndCallback",
|
567
669
|
value: function () {
|
568
|
-
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
670
|
+
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(eventContext) {
|
569
671
|
var deviceId;
|
570
|
-
return _regeneratorRuntime().wrap(function
|
571
|
-
while (1) switch (
|
672
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
673
|
+
while (1) switch (_context4.prev = _context4.next) {
|
572
674
|
case 0:
|
573
675
|
if (!(eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId)) {
|
574
|
-
|
676
|
+
_context4.next = 5;
|
575
677
|
break;
|
576
678
|
}
|
577
|
-
|
679
|
+
_context4.next = 3;
|
578
680
|
return this.getDeviceIdAndLog(eventContext === null || eventContext === void 0 ? void 0 : eventContext.data, true);
|
579
681
|
case 3:
|
580
|
-
deviceId =
|
682
|
+
deviceId = _context4.sent;
|
581
683
|
this.dispatchToApp({
|
582
684
|
context: {
|
583
685
|
event: 'appEventCallback',
|
@@ -589,11 +691,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
589
691
|
});
|
590
692
|
case 5:
|
591
693
|
case "end":
|
592
|
-
return
|
694
|
+
return _context4.stop();
|
593
695
|
}
|
594
|
-
},
|
696
|
+
}, _callee4, this);
|
595
697
|
}));
|
596
|
-
function getDeviceIdAndCallback(
|
698
|
+
function getDeviceIdAndCallback(_x4) {
|
597
699
|
return _getDeviceIdAndCallback.apply(this, arguments);
|
598
700
|
}
|
599
701
|
return getDeviceIdAndCallback;
|
@@ -623,7 +725,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
623
725
|
}, {
|
624
726
|
key: "_handleAppMessage",
|
625
727
|
value: function _handleAppMessage(data) {
|
626
|
-
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name, EVENT.popupWindow.name, EVENT.threedReady.name, EVENT.closePopup.name, EVENT.getDeviceId.name];
|
728
|
+
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name, EVENT.popupWindow.name, EVENT.threedReady.name, EVENT.closePopup.name, EVENT.getDeviceId.name, EVENT.declareEventCallbackInfo.name];
|
627
729
|
if (!eventKeyMap.includes(data.context.event)) {
|
628
730
|
return;
|
629
731
|
}
|
@@ -696,6 +798,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
696
798
|
this.handleDeclareInfo(data.context.data);
|
697
799
|
return;
|
698
800
|
}
|
801
|
+
if (data.context.event === EVENT.declareEventCallbackInfo.name) {
|
802
|
+
this._multipleCallbackEvents = data.context.data;
|
803
|
+
return;
|
804
|
+
}
|
699
805
|
if (data.context.event === EVENT.eventCallback.name) {
|
700
806
|
this.AMSSDK.logger.logInfo({
|
701
807
|
title: 'sdk_event_event_callback'
|
@@ -758,7 +864,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
758
864
|
}, {
|
759
865
|
key: "handleRedirect",
|
760
866
|
value: function handleRedirect(data) {
|
761
|
-
var
|
867
|
+
var _this7 = this;
|
762
868
|
var _data = typeof data === 'string' ? {
|
763
869
|
normalUrl: data
|
764
870
|
} : {
|
@@ -773,11 +879,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
773
879
|
redirectInfo: JSON.stringify(_data)
|
774
880
|
}).send();
|
775
881
|
var successCallback = function successCallback(type, url) {
|
776
|
-
|
882
|
+
_this7.dispatchToSDK(EVENT.eventCallback.name, {
|
777
883
|
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
778
884
|
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
779
885
|
});
|
780
|
-
|
886
|
+
_this7.AMSSDK.logger.logInfo({
|
781
887
|
title: 'sdk_event_call_url_success'
|
782
888
|
}, {
|
783
889
|
redirectInfo: JSON.stringify(_data),
|
@@ -786,11 +892,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
786
892
|
}).send();
|
787
893
|
};
|
788
894
|
var failCallback = function failCallback(type, url) {
|
789
|
-
|
895
|
+
_this7.dispatchToSDK(EVENT.eventCallback.name, {
|
790
896
|
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
791
897
|
message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
|
792
898
|
});
|
793
|
-
|
899
|
+
_this7.AMSSDK.logger.logInfo({
|
794
900
|
title: 'sdk_error_call_url_failed'
|
795
901
|
}, {
|
796
902
|
redirectInfo: JSON.stringify(_data),
|
@@ -813,14 +919,14 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
813
919
|
successCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
814
920
|
}).catch(function () {
|
815
921
|
failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
816
|
-
return
|
922
|
+
return _this7.AMSSDK._redirect({
|
817
923
|
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
818
924
|
});
|
819
925
|
}).then(function () {
|
820
926
|
successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
821
927
|
}).catch(function () {
|
822
928
|
failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
823
|
-
return
|
929
|
+
return _this7.AMSSDK._redirect({
|
824
930
|
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
825
931
|
});
|
826
932
|
}).then(function () {
|
@@ -831,13 +937,31 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
831
937
|
}
|
832
938
|
}, {
|
833
939
|
key: "handleDeclareInfo",
|
834
|
-
value: function handleDeclareInfo(
|
835
|
-
var
|
836
|
-
closeDialogData =
|
940
|
+
value: function handleDeclareInfo(_ref6) {
|
941
|
+
var _ref6$closeDialogData = _ref6.closeDialogData,
|
942
|
+
closeDialogData = _ref6$closeDialogData === void 0 ? {} : _ref6$closeDialogData;
|
837
943
|
_handleDeclareInfo({
|
838
944
|
closeDialogData: closeDialogData
|
839
945
|
});
|
840
946
|
}
|
947
|
+
}, {
|
948
|
+
key: "handleDeclarePopWindowCallback",
|
949
|
+
value: function handleDeclarePopWindowCallback() {
|
950
|
+
var eventInfoName = 'popWindowEventInfo';
|
951
|
+
if (this._multipleCallbackEvents && eventInfoName in this._multipleCallbackEvents) {
|
952
|
+
var eventInfo = this._multipleCallbackEvents[eventInfoName];
|
953
|
+
if (eventInfo.enableCallback) {
|
954
|
+
this.dispatchToSDK(EVENT.eventCallback.name, {
|
955
|
+
code: eventInfo.eventName,
|
956
|
+
result: {
|
957
|
+
result: eventInfo.eventResult
|
958
|
+
}
|
959
|
+
});
|
960
|
+
}
|
961
|
+
} else {
|
962
|
+
console.log("not valid ".concat(eventInfoName, " in "), this._multipleCallbackEvents);
|
963
|
+
}
|
964
|
+
}
|
841
965
|
}, {
|
842
966
|
key: "handleCloseBtnShow",
|
843
967
|
value: function handleCloseBtnShow(showClose) {
|
@@ -907,22 +1031,26 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
907
1031
|
}, {
|
908
1032
|
key: "sendRenderEvent",
|
909
1033
|
value: function () {
|
910
|
-
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
911
|
-
var _this$
|
912
|
-
return _regeneratorRuntime().wrap(function
|
913
|
-
while (1) switch (
|
1034
|
+
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
1035
|
+
var _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, res, submitRes;
|
1036
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
1037
|
+
while (1) switch (_context5.prev = _context5.next) {
|
914
1038
|
case 0:
|
915
|
-
|
916
|
-
if (this._actionQueryPromise) {
|
917
|
-
|
1039
|
+
_context5.prev = 0;
|
1040
|
+
if (!(!this._actionQueryPromise || !this._actionSubmitPromise)) {
|
1041
|
+
_context5.next = 3;
|
918
1042
|
break;
|
919
1043
|
}
|
920
|
-
return
|
1044
|
+
return _context5.abrupt("return");
|
921
1045
|
case 3:
|
922
|
-
|
1046
|
+
_context5.next = 5;
|
923
1047
|
return this._actionQueryPromise;
|
924
1048
|
case 5:
|
925
|
-
res =
|
1049
|
+
res = _context5.sent;
|
1050
|
+
_context5.next = 8;
|
1051
|
+
return this._actionSubmitPromise;
|
1052
|
+
case 8:
|
1053
|
+
submitRes = _context5.sent;
|
926
1054
|
this._performanceData.push({
|
927
1055
|
key: 'sdk_render_component',
|
928
1056
|
value: Date.now()
|
@@ -932,12 +1060,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
932
1060
|
event: 'renderComponent',
|
933
1061
|
data: {
|
934
1062
|
queryResult: res,
|
935
|
-
|
936
|
-
|
1063
|
+
submitResult: submitRes,
|
1064
|
+
sessionResult: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentSessionMetaData,
|
1065
|
+
paymentSessionData: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.sessionData,
|
937
1066
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
938
|
-
renderDisplayType: (_this$
|
939
|
-
appearance: (_this$
|
940
|
-
notRedirectAfterComplete: ((_this$
|
1067
|
+
renderDisplayType: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.renderDisplayType,
|
1068
|
+
appearance: (_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.appearance,
|
1069
|
+
notRedirectAfterComplete: ((_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.notRedirectAfterComplete) === true,
|
941
1070
|
envInfo: {
|
942
1071
|
screenHeight: screen.height,
|
943
1072
|
screenWidth: screen.width
|
@@ -954,16 +1083,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
954
1083
|
}
|
955
1084
|
});
|
956
1085
|
// eslint-disable-next-line no-empty
|
957
|
-
|
1086
|
+
_context5.next = 16;
|
958
1087
|
break;
|
959
|
-
case
|
960
|
-
|
961
|
-
|
962
|
-
case
|
1088
|
+
case 14:
|
1089
|
+
_context5.prev = 14;
|
1090
|
+
_context5.t0 = _context5["catch"](0);
|
1091
|
+
case 16:
|
963
1092
|
case "end":
|
964
|
-
return
|
1093
|
+
return _context5.stop();
|
965
1094
|
}
|
966
|
-
},
|
1095
|
+
}, _callee5, this, [[0, 14]]);
|
967
1096
|
}));
|
968
1097
|
function sendRenderEvent() {
|
969
1098
|
return _sendRenderEvent.apply(this, arguments);
|
@@ -977,7 +1106,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
977
1106
|
key: "cleanContainer",
|
978
1107
|
value: function cleanContainer() {
|
979
1108
|
var _document$getElementB4,
|
980
|
-
|
1109
|
+
_this8 = this;
|
981
1110
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
982
1111
|
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
983
1112
|
this._performanceData = [];
|
@@ -989,7 +1118,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
989
1118
|
mockup === null || mockup === void 0 || mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
|
990
1119
|
if (immediately) this.cleanElement();else {
|
991
1120
|
setTimeout(function () {
|
992
|
-
|
1121
|
+
_this8.cleanElement();
|
993
1122
|
}, 300);
|
994
1123
|
}
|
995
1124
|
}
|
@@ -1012,6 +1141,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1012
1141
|
if (this._isRetention) this.showRetentionPopup();else {
|
1013
1142
|
this.cleanContainer();
|
1014
1143
|
this.dispatchToSDK(EVENT.close.name, {});
|
1144
|
+
this.handleDeclarePopWindowCallback();
|
1015
1145
|
}
|
1016
1146
|
}
|
1017
1147
|
}, {
|
@@ -1020,6 +1150,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1020
1150
|
this.dispatchToSDK(EVENT.close.name, {});
|
1021
1151
|
this.hideRetentionPopupFunc();
|
1022
1152
|
this.cleanContainer();
|
1153
|
+
this.handleDeclarePopWindowCallback();
|
1023
1154
|
}
|
1024
1155
|
}, {
|
1025
1156
|
key: "removeRetentionPopup",
|
package/esm/request/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { RequestConfig } from '../types';
|
2
2
|
import { Logger } from '../util/logger';
|
3
3
|
/**
|
4
4
|
*
|
@@ -6,4 +6,4 @@ import { Logger } from '../util/logger';
|
|
6
6
|
* @param options 请求配置
|
7
7
|
* @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
|
8
8
|
*/
|
9
|
-
export declare function request<T>(requestData: Record<string, any> | undefined, options:
|
9
|
+
export declare function request<T>(requestData: Record<string, any> | undefined, options: RequestConfig, logger: Logger): Promise<T>;
|
package/esm/request/index.js
CHANGED
@@ -19,8 +19,8 @@ import axios from 'axios';
|
|
19
19
|
import { sdkVersion } from "../config/index";
|
20
20
|
import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
|
21
21
|
import { errorEnum } from "../types";
|
22
|
-
import { device, isPC, queryParse, safeJson } from "../util";
|
23
22
|
import { get } from "../util/get";
|
23
|
+
import { device, isPC, queryParse, safeJson } from "../util";
|
24
24
|
import { fomatGetwayError } from "./utils";
|
25
25
|
var _queryParse = queryParse(),
|
26
26
|
_sandbox = _queryParse._sandbox;
|
package/esm/service/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult,
|
1
|
+
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
|
2
2
|
import { Logger } from '../util/logger';
|
3
|
-
export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options:
|
4
|
-
export declare function antomConfig(options:
|
3
|
+
export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
|
4
|
+
export declare function antomConfig(options: RequestConfig, logger: Logger): Promise<any>;
|
5
|
+
export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
|
package/esm/service/index.js
CHANGED
@@ -74,4 +74,27 @@ function _antomConfig() {
|
|
74
74
|
}, _callee2, null, [[0, 11]]);
|
75
75
|
}));
|
76
76
|
return _antomConfig.apply(this, arguments);
|
77
|
+
}
|
78
|
+
export function submitPayInfo(_x6, _x7, _x8) {
|
79
|
+
return _submitPayInfo.apply(this, arguments);
|
80
|
+
}
|
81
|
+
function _submitPayInfo() {
|
82
|
+
_submitPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params, options, logger) {
|
83
|
+
var hostSign;
|
84
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
85
|
+
while (1) switch (_context3.prev = _context3.next) {
|
86
|
+
case 0:
|
87
|
+
hostSign = ((params === null || params === void 0 ? void 0 : params.paymentSessionData) || '').split('&&')[1] || '';
|
88
|
+
return _context3.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
|
89
|
+
hostSign: hostSign,
|
90
|
+
needEnvInfo: true,
|
91
|
+
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
92
|
+
}), logger));
|
93
|
+
case 2:
|
94
|
+
case "end":
|
95
|
+
return _context3.stop();
|
96
|
+
}
|
97
|
+
}, _callee3);
|
98
|
+
}));
|
99
|
+
return _submitPayInfo.apply(this, arguments);
|
77
100
|
}
|