@alipay/ams-checkout 0.0.1705989903-dev.0 → 0.0.1708315090-dev.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/core/component/index.d.ts +5 -0
- package/esm/core/component/index.js +63 -9
- package/esm/index.d.ts +10 -2
- package/esm/index.js +43 -8
- package/esm/plugin/component/cashierApp.d.ts +3 -0
- package/esm/plugin/component/cashierApp.js +23 -2
- package/esm/plugin/component/index.d.ts +4 -0
- package/esm/plugin/component/index.js +96 -41
- package/esm/types/index.d.ts +5 -2
- package/esm/util/createIframeNode.d.ts +1 -0
- package/esm/util/createIframeNode.js +6 -0
- package/package.json +1 -1
@@ -22,7 +22,7 @@ import { queryPaymentInfo, submitPayInfo } from "../../service";
|
|
22
22
|
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
|
23
23
|
import { getType, isJsonString, isPC } from "../../util";
|
24
24
|
import { isLocalMock } from "../../util/mock";
|
25
|
-
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
25
|
+
import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
26
26
|
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
27
27
|
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
28
28
|
import { createModal, destroyModal, insertStyleSheet } from "./popupWindow.style";
|
@@ -40,6 +40,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
40
40
|
_defineProperty(this, "popupApp", void 0);
|
41
41
|
_defineProperty(this, "appDomain", void 0);
|
42
42
|
_defineProperty(this, "createIframeNode", void 0);
|
43
|
+
_defineProperty(this, "createPreloadIframeNode", void 0);
|
43
44
|
_defineProperty(this, "_selector", void 0);
|
44
45
|
_defineProperty(this, "_appVersion", void 0);
|
45
46
|
_defineProperty(this, "_isRetention", void 0);
|
@@ -53,12 +54,15 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
53
54
|
_defineProperty(this, "_merchantAppointParam", void 0);
|
54
55
|
_defineProperty(this, "_webAppHeartBeatTimeoutId", void 0);
|
55
56
|
_defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
|
56
|
-
this._appVersion = '1.
|
57
|
+
this._appVersion = '1.10.1';
|
57
58
|
this._isInitComponent = false;
|
58
59
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
59
60
|
this.createIframeNode = function () {
|
60
61
|
return Promise.resolve();
|
61
62
|
};
|
63
|
+
this.createPreloadIframeNode = function () {
|
64
|
+
return Promise.resolve();
|
65
|
+
};
|
62
66
|
this.platform = isPC() ? platformEnum.desktop : platformEnum.mobile;
|
63
67
|
this._isRetention = true;
|
64
68
|
this._appLocationSearch = '';
|
@@ -119,6 +123,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
119
123
|
value: function setRender(renderFunc) {
|
120
124
|
this.createIframeNode = renderFunc;
|
121
125
|
}
|
126
|
+
}, {
|
127
|
+
key: "setPreloadRender",
|
128
|
+
value: function setPreloadRender(renderFunc) {
|
129
|
+
this.createPreloadIframeNode = renderFunc;
|
130
|
+
}
|
122
131
|
}, {
|
123
132
|
key: "initSecurity",
|
124
133
|
value: function initSecurity() {
|
@@ -280,6 +289,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
280
289
|
return Promise.reject(error);
|
281
290
|
});
|
282
291
|
}
|
292
|
+
}, {
|
293
|
+
key: "appendPreloadIframeNodes",
|
294
|
+
value: function appendPreloadIframeNodes(componentSign, productSceneVersion) {
|
295
|
+
var virtualPreloadIframe = this.createPreloadApp(componentSign, productSceneVersion);
|
296
|
+
this.createPreloadIframeNode(virtualPreloadIframe);
|
297
|
+
}
|
283
298
|
}, {
|
284
299
|
key: "setParameterDefaultValues",
|
285
300
|
value: function setParameterDefaultValues(componentSign, renderParams) {
|
@@ -315,9 +330,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
315
330
|
var _this4 = this;
|
316
331
|
return new Promise(function (resolve, reject) {
|
317
332
|
_this4._loadAppPromiseResolve = resolve;
|
318
|
-
_this4.AMSSDK.logger.logError({
|
319
|
-
title: 'sdk_event_webAppPreLoadStart'
|
320
|
-
});
|
321
333
|
setTimeout(function () {
|
322
334
|
reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
323
335
|
}, loadTimeLimit !== null && loadTimeLimit !== void 0 ? loadTimeLimit : LOADTIME_LIMIT);
|
@@ -345,8 +357,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
345
357
|
// eslint-disable-next-line no-async-promise-executor
|
346
358
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
347
359
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
348
|
-
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
|
349
|
-
var envInfo, params, _this5$
|
360
|
+
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5;
|
361
|
+
var envInfo, params, _this5$_renderParams$, extendInfo, enableVaultingApiOptimize, extendInfoData, _this5$_renderParams6, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams7, _action$web, _action$wap, action, signType;
|
350
362
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
351
363
|
while (1) switch (_context2.prev = _context2.next) {
|
352
364
|
case 0:
|
@@ -362,78 +374,95 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
362
374
|
/**
|
363
375
|
* @description Simulated or unnecessary scenarios
|
364
376
|
*/
|
365
|
-
|
366
|
-
|
377
|
+
_this5$_renderParams$ = (_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData, extendInfo = _this5$_renderParams$.extendInfo;
|
378
|
+
enableVaultingApiOptimize = false;
|
379
|
+
try {
|
380
|
+
extendInfoData = JSON.parse(extendInfo);
|
381
|
+
enableVaultingApiOptimize = extendInfoData.enableVaultingApiOptimize || false;
|
382
|
+
} catch (error) {
|
383
|
+
console.log(error);
|
384
|
+
}
|
385
|
+
if (!isLocalMock()) {
|
386
|
+
_context2.next = 7;
|
367
387
|
break;
|
368
388
|
}
|
369
389
|
return _context2.abrupt("return", resolve({
|
370
390
|
message: 'sdk no need to make query request',
|
371
391
|
success: true
|
372
392
|
}));
|
373
|
-
case
|
393
|
+
case 7:
|
394
|
+
if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign && (_this5$_renderParams5 = _this5._renderParams) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.action) !== null && _this5$_renderParams5 !== void 0 && _this5$_renderParams5.skipSdkQuery && !enableVaultingApiOptimize)) {
|
395
|
+
_context2.next = 9;
|
396
|
+
break;
|
397
|
+
}
|
398
|
+
return _context2.abrupt("return", resolve({
|
399
|
+
message: 'sdk no need to make query request',
|
400
|
+
success: true
|
401
|
+
}));
|
402
|
+
case 9:
|
374
403
|
if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
|
375
|
-
_context2.next =
|
404
|
+
_context2.next = 15;
|
376
405
|
break;
|
377
406
|
}
|
378
407
|
params.paymentMethodType = 'CARD';
|
379
|
-
_context2.next =
|
408
|
+
_context2.next = 13;
|
380
409
|
return _this5.getDeviceIdAndLog();
|
381
|
-
case
|
410
|
+
case 13:
|
382
411
|
envInfo.deviceId = _context2.sent;
|
383
412
|
if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
|
384
413
|
envInfo.extendInfo = {
|
385
414
|
WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
|
386
415
|
};
|
387
416
|
}
|
388
|
-
case
|
417
|
+
case 15:
|
389
418
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
390
|
-
_context2.next =
|
419
|
+
_context2.next = 23;
|
391
420
|
break;
|
392
421
|
}
|
393
422
|
_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;
|
394
|
-
_ref4 = ((_this5$
|
423
|
+
_ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.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;
|
395
424
|
if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
|
396
|
-
_context2.next =
|
425
|
+
_context2.next = 20;
|
397
426
|
break;
|
398
427
|
}
|
399
428
|
return _context2.abrupt("return", resolve({
|
400
429
|
message: 'sdk no need to make query request',
|
401
430
|
success: true
|
402
431
|
}));
|
403
|
-
case
|
404
|
-
_context2.next =
|
432
|
+
case 20:
|
433
|
+
_context2.next = 22;
|
405
434
|
return _this5.getDeviceIdAndLog();
|
406
|
-
case
|
435
|
+
case 22:
|
407
436
|
envInfo.deviceId = _context2.sent;
|
408
|
-
case
|
437
|
+
case 23:
|
409
438
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
410
|
-
_context2.next =
|
439
|
+
_context2.next = 33;
|
411
440
|
break;
|
412
441
|
}
|
413
|
-
action = ((_this5$
|
442
|
+
action = ((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 || (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.action) || {};
|
414
443
|
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;
|
415
444
|
if (!(signType === 'SMS')) {
|
416
|
-
_context2.next =
|
445
|
+
_context2.next = 28;
|
417
446
|
break;
|
418
447
|
}
|
419
448
|
return _context2.abrupt("return", resolve({
|
420
449
|
message: 'sdk no need to make query request',
|
421
450
|
success: true
|
422
451
|
}));
|
423
|
-
case
|
452
|
+
case 28:
|
424
453
|
if (!(!signType || signType !== 'REDIRECT')) {
|
425
|
-
_context2.next =
|
454
|
+
_context2.next = 30;
|
426
455
|
break;
|
427
456
|
}
|
428
457
|
return _context2.abrupt("return", resolve({
|
429
458
|
success: false
|
430
459
|
}));
|
431
|
-
case
|
432
|
-
_context2.next =
|
460
|
+
case 30:
|
461
|
+
_context2.next = 32;
|
433
462
|
return _this5.getDeviceIdAndLog();
|
434
|
-
case
|
463
|
+
case 32:
|
435
464
|
envInfo.deviceId = _context2.sent;
|
436
|
-
case
|
465
|
+
case 33:
|
437
466
|
_this5.AMSSDK.logger.logInfo({
|
438
467
|
title: 'sdk_event_sdkQuery'
|
439
468
|
}, {
|
@@ -447,11 +476,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
447
476
|
key: 'sdk_action_query_end',
|
448
477
|
value: Date.now()
|
449
478
|
});
|
450
|
-
|
451
|
-
resolve(res);
|
452
|
-
} else {
|
453
|
-
resolve(res);
|
454
|
-
}
|
479
|
+
resolve(res);
|
455
480
|
}).catch(function (err) {
|
456
481
|
if ([componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.VAULTING_CARD, componentSignEnum.CASHIER_PAYMENT_APM].includes(_this5._componentSign)) {
|
457
482
|
return resolve({
|
@@ -469,7 +494,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
469
494
|
paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
|
470
495
|
}).send();
|
471
496
|
});
|
472
|
-
case
|
497
|
+
case 35:
|
473
498
|
case "end":
|
474
499
|
return _context2.stop();
|
475
500
|
}
|
@@ -481,6 +506,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
481
506
|
}());
|
482
507
|
return this._actionQueryPromise;
|
483
508
|
}
|
509
|
+
|
510
|
+
// private create
|
484
511
|
}, {
|
485
512
|
key: "createSubmitPromise",
|
486
513
|
value: function createSubmitPromise() {
|
@@ -596,7 +623,33 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
596
623
|
console.error(error);
|
597
624
|
}
|
598
625
|
}
|
599
|
-
|
626
|
+
// 预加载iframe创建
|
627
|
+
}, {
|
628
|
+
key: "createPreloadApp",
|
629
|
+
value: function createPreloadApp(componentSign) {
|
630
|
+
var productSceneVersion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1.0';
|
631
|
+
var preloadIframe = createPreloadIframe(componentSign, productSceneVersion);
|
632
|
+
var _getIframeUrl = getIframeUrl({
|
633
|
+
renderDisplayType: renderDisplayTypeEnum.popup,
|
634
|
+
componentSign: componentSign,
|
635
|
+
analytics: {
|
636
|
+
enabled: false
|
637
|
+
},
|
638
|
+
productSceneVersion: productSceneVersion,
|
639
|
+
environment: this.AMSSDK.options.env.environment,
|
640
|
+
// TODO 确定一下这个参数是干啥的
|
641
|
+
appVersion: this._appVersion,
|
642
|
+
extendInfo: '',
|
643
|
+
locale: '',
|
644
|
+
instanceId: '',
|
645
|
+
isPreload: 'true'
|
646
|
+
}),
|
647
|
+
path = _getIframeUrl.path,
|
648
|
+
locationSearch = _getIframeUrl.locationSearch;
|
649
|
+
preloadIframe.src = "".concat(path, "?").concat(locationSearch);
|
650
|
+
console.log(preloadIframe.src, '--preloadIframe.src');
|
651
|
+
return preloadIframe;
|
652
|
+
}
|
600
653
|
/**
|
601
654
|
* @description Create app
|
602
655
|
*/
|
@@ -624,7 +677,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
624
677
|
extendInfo: extendInfo
|
625
678
|
});
|
626
679
|
this.app = createIframe(this.AMSSDK.options.mode, this.platform);
|
627
|
-
var
|
680
|
+
var hostSign = ((renderParams === null || renderParams === void 0 ? void 0 : renderParams.sessionData) || '').split('&&')[1] || '';
|
681
|
+
var _getIframeUrl2 = getIframeUrl({
|
628
682
|
renderDisplayType: renderParams.renderDisplayType,
|
629
683
|
componentSign: this._componentSign,
|
630
684
|
analytics: this.AMSSDK.options.analytics,
|
@@ -633,10 +687,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
633
687
|
appVersion: this._appVersion,
|
634
688
|
extendInfo: extendInfo,
|
635
689
|
locale: this.AMSSDK.options.locale,
|
636
|
-
instanceId: this.AMSSDK._instanceId
|
690
|
+
instanceId: this.AMSSDK._instanceId,
|
691
|
+
hostSign: hostSign
|
637
692
|
}),
|
638
|
-
path =
|
639
|
-
locationSearch =
|
693
|
+
path = _getIframeUrl2.path,
|
694
|
+
locationSearch = _getIframeUrl2.locationSearch;
|
640
695
|
this._appLocationSearch = locationSearch;
|
641
696
|
this.app.src = "".concat(path, "?").concat(locationSearch);
|
642
697
|
|
package/esm/types/index.d.ts
CHANGED
@@ -153,6 +153,9 @@ export interface IpaymentSessionMetaData {
|
|
153
153
|
paymentMethodInfo?: {
|
154
154
|
paymentMethodType?: string;
|
155
155
|
};
|
156
|
+
paymentMethodViewMetaData?: any;
|
157
|
+
paymentRequestId?: string;
|
158
|
+
supportedLanguages?: any;
|
156
159
|
};
|
157
160
|
}
|
158
161
|
export declare enum localeEnum {
|
@@ -375,8 +378,8 @@ export interface ApplePayPaymentSessionResult {
|
|
375
378
|
message?: string;
|
376
379
|
}
|
377
380
|
export declare enum redirectTypeEnum {
|
378
|
-
UNSAFE_BROWSER = "UNSAFE_BROWSER"
|
379
|
-
SAFETY_BROWSER = "SAFETY_BROWSER"
|
381
|
+
UNSAFE_BROWSER = "UNSAFE_BROWSER",// 非安全浏览器
|
382
|
+
SAFETY_BROWSER = "SAFETY_BROWSER",// 安全浏览器
|
380
383
|
INVOKE_SDK = "INVOKE_SDK"
|
381
384
|
}
|
382
385
|
export interface ActionForm {
|
@@ -3,3 +3,4 @@ import { Iselector, renderDisplayTypeEnum } from '../types';
|
|
3
3
|
* @description context中需要包含app节点,用于插入selector中
|
4
4
|
*/
|
5
5
|
export declare const createIframeNode: (context: any, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
|
6
|
+
export declare const createPreloadIframeNode: (virtualPreloadIframe: any) => void;
|
@@ -39,4 +39,10 @@ export var createIframeNode = function createIframeNode(context, selector, rende
|
|
39
39
|
}
|
40
40
|
resolve();
|
41
41
|
});
|
42
|
+
};
|
43
|
+
export var createPreloadIframeNode = function createPreloadIframeNode(virtualPreloadIframe) {
|
44
|
+
var body = document.body || null;
|
45
|
+
if (body) {
|
46
|
+
body.appendChild(virtualPreloadIframe);
|
47
|
+
}
|
42
48
|
};
|