@alipay/ams-checkout 0.0.1766664288-dev.2 → 0.0.1766729653-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ams-checkout.js +3 -3
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/core/component/element/elementController/index.d.ts +2 -4
- package/esm/core/component/element/elementController/index.js +21 -45
- package/esm/core/component/element/index.d.ts +2 -3
- package/esm/core/component/element/index.js +2 -7
- package/esm/core/component/element/type.d.ts +3 -21
- package/esm/core/component/element/type.js +1 -7
- package/esm/core/component/element/util.d.ts +0 -1
- package/esm/core/component/element/util.js +12 -13
- package/esm/foundation/service/log/index.d.ts +1 -0
- package/esm/foundation/service/log/index.js +40 -3
- package/esm/main.d.ts +10 -1
- package/esm/main.js +17 -2
- package/esm/util/logger.d.ts +1 -0
- package/esm/util/logger.js +40 -3
- package/package.json +1 -1
- package/esm/core/component/element/config.d.ts +0 -10
- package/esm/core/component/element/config.js +0 -17
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddressMountOptions,
|
|
1
|
+
import { AddressMountOptions, ICommonApiResponse, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions } from '../type';
|
|
2
2
|
declare class ElementController {
|
|
3
3
|
private options;
|
|
4
4
|
private elementContainer;
|
|
@@ -33,7 +33,7 @@ declare class ElementController {
|
|
|
33
33
|
validateFields(): Promise<{
|
|
34
34
|
isValid: boolean;
|
|
35
35
|
}>;
|
|
36
|
-
submitPayment(
|
|
36
|
+
submitPayment(): Promise<IPaymentApiResponse>;
|
|
37
37
|
private changeLoading;
|
|
38
38
|
private addEventListener;
|
|
39
39
|
private sendRequestAndWaitWebLaunch;
|
|
@@ -44,7 +44,5 @@ declare class ElementController {
|
|
|
44
44
|
private destroyHandle;
|
|
45
45
|
destroy(): void;
|
|
46
46
|
private setControllerStatusOrView;
|
|
47
|
-
on<T extends EVENTNAME>(event: T, callback: (data: EventDataMap[T]) => void): void;
|
|
48
|
-
private isEventAllowed;
|
|
49
47
|
}
|
|
50
48
|
export default ElementController;
|
|
@@ -40,9 +40,8 @@ import { IContainerStatus } from "../elementContainerService/containerService";
|
|
|
40
40
|
import { EventCenter as ElementEventCenter } from "../EventCenter/index";
|
|
41
41
|
import { oneAccountUpdate, sdkActionUpdate } from "../mock";
|
|
42
42
|
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType, PaymentStatus } from "../type";
|
|
43
|
-
import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage,
|
|
43
|
+
import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, safeStringify, showToast } from "../util";
|
|
44
44
|
import { convertPaymentSession } from "../../../../foundation/utils/payment_context_utils";
|
|
45
|
-
import { productEventScenarios, ProductScene } from "../config";
|
|
46
45
|
var TIMEOUT_DURATION = 10000;
|
|
47
46
|
var ElementController = /*#__PURE__*/function () {
|
|
48
47
|
function ElementController(options) {
|
|
@@ -338,7 +337,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
338
337
|
}, {
|
|
339
338
|
key: "submitPayment",
|
|
340
339
|
value: function () {
|
|
341
|
-
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(
|
|
340
|
+
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
342
341
|
var _this3 = this;
|
|
343
342
|
var startEventId, res, logParams, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
|
344
343
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
@@ -370,7 +369,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
370
369
|
_context4.next = 11;
|
|
371
370
|
return new Promise( /*#__PURE__*/function () {
|
|
372
371
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
373
|
-
var that, recordResultCallback, params, processStep,
|
|
372
|
+
var that, recordResultCallback, params, processStep, _yield$_this3$onValid2, data, errorString, errorResult;
|
|
374
373
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
375
374
|
while (1) switch (_context3.prev = _context3.next) {
|
|
376
375
|
case 0:
|
|
@@ -423,7 +422,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
423
422
|
}
|
|
424
423
|
}, _callee2);
|
|
425
424
|
}));
|
|
426
|
-
return function processStep(
|
|
425
|
+
return function processStep(_x2, _x3) {
|
|
427
426
|
return _ref4.apply(this, arguments);
|
|
428
427
|
};
|
|
429
428
|
}(); // 按顺序处理步骤
|
|
@@ -446,28 +445,29 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
446
445
|
return _context3.abrupt("return");
|
|
447
446
|
case 14:
|
|
448
447
|
if (!_this3.elementProcessors[ElementType.payment]) {
|
|
449
|
-
_context3.next =
|
|
448
|
+
_context3.next = 21;
|
|
450
449
|
break;
|
|
451
450
|
}
|
|
452
|
-
|
|
453
|
-
_context3.next = 18;
|
|
451
|
+
_context3.next = 17;
|
|
454
452
|
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
|
455
|
-
case
|
|
453
|
+
case 17:
|
|
456
454
|
_yield$_this3$onValid2 = _context3.sent;
|
|
457
|
-
|
|
455
|
+
data = _yield$_this3$onValid2.data;
|
|
458
456
|
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
459
457
|
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
|
460
|
-
recordResult =
|
|
458
|
+
recordResult = data;
|
|
461
459
|
recordResultCallback(recordResult);
|
|
462
|
-
case
|
|
460
|
+
case 21:
|
|
463
461
|
_context3.next = 30;
|
|
464
462
|
break;
|
|
465
|
-
case
|
|
466
|
-
_context3.prev =
|
|
463
|
+
case 23:
|
|
464
|
+
_context3.prev = 23;
|
|
467
465
|
_context3.t0 = _context3["catch"](2);
|
|
466
|
+
// 修复error为{}空对象的问题,上报stack&message
|
|
467
|
+
errorString = JSON.stringify(_context3.t0, Object.getOwnPropertyNames(_context3.t0));
|
|
468
468
|
errorResult = {
|
|
469
469
|
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
|
|
470
|
-
context:
|
|
470
|
+
context: errorString
|
|
471
471
|
}),
|
|
472
472
|
status: PaymentStatus.FAIL
|
|
473
473
|
};
|
|
@@ -482,9 +482,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
482
482
|
case "end":
|
|
483
483
|
return _context3.stop();
|
|
484
484
|
}
|
|
485
|
-
}, _callee3, null, [[2,
|
|
485
|
+
}, _callee3, null, [[2, 23]]);
|
|
486
486
|
}));
|
|
487
|
-
return function (
|
|
487
|
+
return function (_x) {
|
|
488
488
|
return _ref3.apply(this, arguments);
|
|
489
489
|
};
|
|
490
490
|
}());
|
|
@@ -509,7 +509,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
509
509
|
}
|
|
510
510
|
}, _callee4, this, [[8,, 12, 17]]);
|
|
511
511
|
}));
|
|
512
|
-
function submitPayment(
|
|
512
|
+
function submitPayment() {
|
|
513
513
|
return _submitPayment.apply(this, arguments);
|
|
514
514
|
}
|
|
515
515
|
return submitPayment;
|
|
@@ -654,7 +654,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
654
654
|
}
|
|
655
655
|
}, _callee5, this, [[1, 20]]);
|
|
656
656
|
}));
|
|
657
|
-
function sendRequestAndWaitWebLaunch(
|
|
657
|
+
function sendRequestAndWaitWebLaunch(_x4, _x5) {
|
|
658
658
|
return _sendRequestAndWaitWebLaunch.apply(this, arguments);
|
|
659
659
|
}
|
|
660
660
|
return sendRequestAndWaitWebLaunch;
|
|
@@ -787,7 +787,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
787
787
|
}
|
|
788
788
|
}, _callee6);
|
|
789
789
|
}));
|
|
790
|
-
return function (
|
|
790
|
+
return function (_x7) {
|
|
791
791
|
return _ref5.apply(this, arguments);
|
|
792
792
|
};
|
|
793
793
|
}()));
|
|
@@ -797,7 +797,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
797
797
|
}
|
|
798
798
|
}, _callee7);
|
|
799
799
|
}));
|
|
800
|
-
function updatePayment(
|
|
800
|
+
function updatePayment(_x6) {
|
|
801
801
|
return _updatePayment.apply(this, arguments);
|
|
802
802
|
}
|
|
803
803
|
return updatePayment;
|
|
@@ -834,30 +834,6 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
834
834
|
(_this$onStatusChangeC = this.onStatusChangeCallback) === null || _this$onStatusChangeC === void 0 || _this$onStatusChangeC.call(this, "\u72B6\u6001\u7531 ".concat(_status, " \u53D8\u66F4\u4E3A ").concat(status));
|
|
835
835
|
this.elementContainer.setStatus(status);
|
|
836
836
|
}
|
|
837
|
-
}, {
|
|
838
|
-
key: "on",
|
|
839
|
-
value: function on(event, callback) {
|
|
840
|
-
if (!this.isEventAllowed(event)) {
|
|
841
|
-
return console.error("Event \"".concat(event, "\" is not allowed."));
|
|
842
|
-
}
|
|
843
|
-
this.serviceMap.EventCenter.listen(event, function (data) {
|
|
844
|
-
callback === null || callback === void 0 || callback(data);
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
}, {
|
|
848
|
-
key: "isEventAllowed",
|
|
849
|
-
value: function isEventAllowed(event) {
|
|
850
|
-
var _safeParse, _this$elementContaine;
|
|
851
|
-
// 获取当前场景
|
|
852
|
-
var isExpressCheckout = (_safeParse = safeParse((_this$elementContaine = this.elementContainer.getPaymentContext()) === null || _this$elementContaine === void 0 || (_this$elementContaine = _this$elementContaine.paymentSessionObj) === null || _this$elementContaine === void 0 ? void 0 : _this$elementContaine.extendInfo)) === null || _safeParse === void 0 ? void 0 : _safeParse.expressCheckout;
|
|
853
|
-
var productScene = isExpressCheckout ? ProductScene.EXPRESS_CHECKOUT : ProductScene.ELEMENT_PAYMENT;
|
|
854
|
-
// 查找对应的产品场景
|
|
855
|
-
var scenario = productEventScenarios.find(function (s) {
|
|
856
|
-
return s.eventName === productScene;
|
|
857
|
-
});
|
|
858
|
-
// 检查场景存在且事件名称在支持的事件列表中
|
|
859
|
-
return scenario !== undefined && scenario.supportedEvents.includes(event);
|
|
860
|
-
}
|
|
861
837
|
}]);
|
|
862
838
|
return ElementController;
|
|
863
839
|
}();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IElementOptions, PaymentMountOptions } from './type';
|
|
2
2
|
export declare class ElementComponent {
|
|
3
3
|
private options;
|
|
4
4
|
private controller;
|
|
@@ -8,7 +8,6 @@ export declare class ElementComponent {
|
|
|
8
8
|
validateFields(): Promise<{
|
|
9
9
|
isValid: boolean;
|
|
10
10
|
}>;
|
|
11
|
-
submitPayment(
|
|
11
|
+
submitPayment(): Promise<import("./type").IPaymentApiResponse>;
|
|
12
12
|
destroy(): void;
|
|
13
|
-
on<T extends EVENTNAME>(event: T, callback: (data: EventDataMap[T]) => void): void;
|
|
14
13
|
}
|
|
@@ -62,19 +62,14 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
62
62
|
}
|
|
63
63
|
}, {
|
|
64
64
|
key: "submitPayment",
|
|
65
|
-
value: function submitPayment(
|
|
66
|
-
return this.controller.submitPayment(
|
|
65
|
+
value: function submitPayment() {
|
|
66
|
+
return this.controller.submitPayment();
|
|
67
67
|
}
|
|
68
68
|
}, {
|
|
69
69
|
key: "destroy",
|
|
70
70
|
value: function destroy() {
|
|
71
71
|
this.controller.destroy();
|
|
72
72
|
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "on",
|
|
75
|
-
value: function on(event, callback) {
|
|
76
|
-
this.controller.on(event, callback);
|
|
77
|
-
}
|
|
78
73
|
}]);
|
|
79
74
|
return ElementComponent;
|
|
80
75
|
}();
|
|
@@ -183,6 +183,9 @@ export interface PaymentMountOptions extends BaseMountOptions {
|
|
|
183
183
|
card?: {
|
|
184
184
|
showBrandIcon?: boolean;
|
|
185
185
|
};
|
|
186
|
+
accordion?: {
|
|
187
|
+
showRadio?: boolean;
|
|
188
|
+
};
|
|
186
189
|
};
|
|
187
190
|
notRedirectAfterComplete?: boolean;
|
|
188
191
|
merchantAppointParam?: IMerchantAppointParam;
|
|
@@ -261,20 +264,9 @@ export interface AddressSubmitData {
|
|
|
261
264
|
shippingId: string;
|
|
262
265
|
actionFlag?: 'I' | 'U' | 'D';
|
|
263
266
|
}
|
|
264
|
-
export interface HandleAction {
|
|
265
|
-
threeD?: boolean;
|
|
266
|
-
callApp?: boolean;
|
|
267
|
-
pageRedirect?: boolean;
|
|
268
|
-
qrCode?: boolean;
|
|
269
|
-
}
|
|
270
|
-
export type HandleActionType = boolean | HandleAction;
|
|
271
|
-
export interface SubmitFuncParams {
|
|
272
|
-
handleAction?: HandleActionType;
|
|
273
|
-
}
|
|
274
267
|
export interface SubmitServiceParams extends PaymentSubmitData {
|
|
275
268
|
accountInfo: AuthSubmitData['accountInfo'];
|
|
276
269
|
shipping?: AddressSubmitData;
|
|
277
|
-
handleAction?: HandleActionType;
|
|
278
270
|
}
|
|
279
271
|
interface SubmitResultActionForm extends ActionForm {
|
|
280
272
|
paymentCodeExpireTime: string;
|
|
@@ -454,14 +446,4 @@ export declare enum EXPOSURE_API_EVENT {
|
|
|
454
446
|
VALIDATAFIELDS = "validateFields",
|
|
455
447
|
UPDATEPAYMENT = "updatePayment"
|
|
456
448
|
}
|
|
457
|
-
export declare enum EVENTNAME {
|
|
458
|
-
PAYMENTMETHODCHANGED = "paymentMethodChanged"
|
|
459
|
-
}
|
|
460
|
-
interface PaymentMethodChangedData {
|
|
461
|
-
type: string;
|
|
462
|
-
name: string;
|
|
463
|
-
}
|
|
464
|
-
export interface EventDataMap {
|
|
465
|
-
[EVENTNAME.PAYMENTMETHODCHANGED]: PaymentMethodChangedData;
|
|
466
|
-
}
|
|
467
449
|
export {};
|
|
@@ -147,10 +147,4 @@ export var EXPOSURE_API_EVENT = /*#__PURE__*/function (EXPOSURE_API_EVENT) {
|
|
|
147
147
|
EXPOSURE_API_EVENT["VALIDATAFIELDS"] = "validateFields";
|
|
148
148
|
EXPOSURE_API_EVENT["UPDATEPAYMENT"] = "updatePayment";
|
|
149
149
|
return EXPOSURE_API_EVENT;
|
|
150
|
-
}({});
|
|
151
|
-
export var EVENTNAME = /*#__PURE__*/function (EVENTNAME) {
|
|
152
|
-
EVENTNAME["PAYMENTMETHODCHANGED"] = "paymentMethodChanged";
|
|
153
|
-
return EVENTNAME;
|
|
154
|
-
}({});
|
|
155
|
-
|
|
156
|
-
// 支付方式改变的回调函数的数据结构
|
|
150
|
+
}({});
|
|
@@ -83,4 +83,3 @@ export declare const isElementPC: () => boolean;
|
|
|
83
83
|
*/
|
|
84
84
|
export declare const isLoadErrorPage: (params: CashierSdkActionQueryResult) => boolean;
|
|
85
85
|
export declare const safeStringify: (payload: any, defaultValue?: string) => string;
|
|
86
|
-
export declare const safeParse: (payload: any, defaultValue?: Record<string, any>) => Record<string, any>;
|
|
@@ -63,14 +63,20 @@ export function checkCanMount(_ref) {
|
|
|
63
63
|
return {
|
|
64
64
|
success: false,
|
|
65
65
|
errorMsg: "Element with selector ".concat(sdkSelector, " not found."),
|
|
66
|
-
error:
|
|
66
|
+
error: {
|
|
67
|
+
code: ERRORMESSAGE.PARAM_INVALID.code,
|
|
68
|
+
message: "Element with selector ".concat(sdkSelector, " not found.")
|
|
69
|
+
}
|
|
67
70
|
};
|
|
68
71
|
}
|
|
69
72
|
if (status === IElementStatus.DESTROYED) {
|
|
70
73
|
return {
|
|
71
74
|
success: false,
|
|
72
75
|
errorMsg: "Creating components in the destroyed state is forbidden.",
|
|
73
|
-
error:
|
|
76
|
+
error: {
|
|
77
|
+
code: ERRORMESSAGE.UI_STATE_ERROR.code,
|
|
78
|
+
message: "Creating components in the destroyed state is forbidden."
|
|
79
|
+
}
|
|
74
80
|
};
|
|
75
81
|
}
|
|
76
82
|
if (status === IElementStatus.READY) {
|
|
@@ -82,7 +88,10 @@ export function checkCanMount(_ref) {
|
|
|
82
88
|
return {
|
|
83
89
|
success: false,
|
|
84
90
|
errorMsg: "SDK status error.",
|
|
85
|
-
error:
|
|
91
|
+
error: {
|
|
92
|
+
code: ERRORMESSAGE.UI_STATE_ERROR.code,
|
|
93
|
+
message: "SDK status error."
|
|
94
|
+
}
|
|
86
95
|
};
|
|
87
96
|
}
|
|
88
97
|
return {
|
|
@@ -526,14 +535,4 @@ export var safeStringify = function safeStringify(payload) {
|
|
|
526
535
|
console.error('JSON.stringify failed:', e);
|
|
527
536
|
return defaultValue;
|
|
528
537
|
}
|
|
529
|
-
};
|
|
530
|
-
export var safeParse = function safeParse(payload) {
|
|
531
|
-
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
532
|
-
if (!payload) return defaultValue;
|
|
533
|
-
try {
|
|
534
|
-
return JSON.parse(payload) || defaultValue;
|
|
535
|
-
} catch (e) {
|
|
536
|
-
console.error('JSON.parse failed:', e);
|
|
537
|
-
return defaultValue;
|
|
538
|
-
}
|
|
539
538
|
};
|
|
@@ -35,6 +35,7 @@ export declare class LogService implements Service {
|
|
|
35
35
|
log(type: string, payload: LogPayload, extra?: LogExtra, enableExtractCompliance?: boolean): LogService;
|
|
36
36
|
private reportLogs;
|
|
37
37
|
private loadScript;
|
|
38
|
+
private fallbackLoadScript;
|
|
38
39
|
private initTracker;
|
|
39
40
|
send(): void;
|
|
40
41
|
setComponentStartTime(val: number): void;
|
|
@@ -183,6 +183,43 @@ export var LogService = /*#__PURE__*/function () {
|
|
|
183
183
|
}, {
|
|
184
184
|
key: "loadScript",
|
|
185
185
|
value: function loadScript(url, callback) {
|
|
186
|
+
var _this3 = this;
|
|
187
|
+
/*
|
|
188
|
+
* 如果宿主环境存在AMD加载器,通过直接创建script标签的方式加载会造成宿主环境报错:
|
|
189
|
+
* Message: Mismatched anonymous define() module
|
|
190
|
+
* 原因是直接通过script标签加载的模块如果没有定义模块名,会被AMD加载器认为是匿名模块,
|
|
191
|
+
* 而宿主环境中已经存在匿名模块,导致报错。
|
|
192
|
+
*
|
|
193
|
+
* TODO: 所有通过window.iTracker调用的方法都需要判断
|
|
194
|
+
* 是否是AMD环境,如果是,需要通过require加载获取iTracker实例
|
|
195
|
+
* */
|
|
196
|
+
if (typeof window.define === 'function' && window.define.amd && typeof window.require === 'function') {
|
|
197
|
+
var moduleId = 'antom_iTracker';
|
|
198
|
+
try {
|
|
199
|
+
var _specified, _ref;
|
|
200
|
+
// 避免重复 config
|
|
201
|
+
if (!((_specified = (_ref = window.require).specified) !== null && _specified !== void 0 && _specified.call(_ref, moduleId))) {
|
|
202
|
+
// @ts-expect-error amd
|
|
203
|
+
window.require.config({
|
|
204
|
+
paths: _defineProperty({}, moduleId, url.replace(/\.js$/, ''))
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// @ts-expect-error amd
|
|
209
|
+
window.require([moduleId], callback, function (err) {
|
|
210
|
+
console.error('AMD load failed, falling back to script tag', err);
|
|
211
|
+
_this3.fallbackLoadScript(url, callback);
|
|
212
|
+
});
|
|
213
|
+
return;
|
|
214
|
+
} catch (e) {
|
|
215
|
+
console.warn('require not available, using script tag', e);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
this.fallbackLoadScript(url, callback);
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "fallbackLoadScript",
|
|
222
|
+
value: function fallbackLoadScript(url, callback) {
|
|
186
223
|
var script = document.createElement('script');
|
|
187
224
|
script.type = 'text/javascript';
|
|
188
225
|
script.src = url;
|
|
@@ -195,16 +232,16 @@ export var LogService = /*#__PURE__*/function () {
|
|
|
195
232
|
}, {
|
|
196
233
|
key: "initTracker",
|
|
197
234
|
value: function initTracker() {
|
|
198
|
-
var
|
|
235
|
+
var _this4 = this;
|
|
199
236
|
if (this.isLoaded) return;
|
|
200
237
|
this.isLoaded = true;
|
|
201
238
|
try {
|
|
202
239
|
if (typeof localStorage !== 'undefined') {
|
|
203
240
|
this.loadScript(this.config.scriptUrl, function () {
|
|
204
241
|
var _window4;
|
|
205
|
-
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(
|
|
242
|
+
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(_this4.config);
|
|
206
243
|
setTimeout(function () {
|
|
207
|
-
|
|
244
|
+
_this4.reportLogs();
|
|
208
245
|
}, 80);
|
|
209
246
|
});
|
|
210
247
|
}
|
package/esm/main.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AddressComponent } from './core/component/address';
|
|
2
2
|
import { ElementComponent } from './core/component/element';
|
|
3
3
|
import { AMSComponent } from './core/component/index';
|
|
4
|
-
import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions } from './types';
|
|
4
|
+
import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions, ValidationResult } from './types';
|
|
5
5
|
export { AMSCheckoutPage } from './core/component/ckp';
|
|
6
6
|
export * from './types';
|
|
7
7
|
export declare class AMSCheckout extends AMSComponent {
|
|
@@ -14,6 +14,15 @@ export declare class AMSAutoDebitPay extends AMSCheckout {
|
|
|
14
14
|
export declare class AMSCashierPayment extends AMSCheckout {
|
|
15
15
|
constructor(options: IoptionsParams);
|
|
16
16
|
static preload(options?: IPreloadOptions): void;
|
|
17
|
+
/**
|
|
18
|
+
* Form validation function
|
|
19
|
+
* If the form is currently displayed:
|
|
20
|
+
* - Successful validation: isValid is true
|
|
21
|
+
* - Failed validation: isValid is false, and error messages are displayed on the form page
|
|
22
|
+
* If not on the form display page, isValid returns false
|
|
23
|
+
* @returns {Promise<ValidationResult>} Returns a Promise containing the validation result
|
|
24
|
+
*/
|
|
25
|
+
validateFields(): Promise<ValidationResult>;
|
|
17
26
|
}
|
|
18
27
|
export declare class AMSVaulting extends AMSCheckout {
|
|
19
28
|
constructor(options: IoptionsParams);
|
package/esm/main.js
CHANGED
|
@@ -112,7 +112,21 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout2) {
|
|
|
112
112
|
}
|
|
113
113
|
return _super3.call(this, _options, currentChannelType);
|
|
114
114
|
}
|
|
115
|
-
_createClass(AMSCashierPayment,
|
|
115
|
+
_createClass(AMSCashierPayment, [{
|
|
116
|
+
key: "validateFields",
|
|
117
|
+
value:
|
|
118
|
+
/**
|
|
119
|
+
* Form validation function
|
|
120
|
+
* If the form is currently displayed:
|
|
121
|
+
* - Successful validation: isValid is true
|
|
122
|
+
* - Failed validation: isValid is false, and error messages are displayed on the form page
|
|
123
|
+
* If not on the form display page, isValid returns false
|
|
124
|
+
* @returns {Promise<ValidationResult>} Returns a Promise containing the validation result
|
|
125
|
+
*/
|
|
126
|
+
function validateFields() {
|
|
127
|
+
return this._validateFields();
|
|
128
|
+
}
|
|
129
|
+
}], [{
|
|
116
130
|
key: "preload",
|
|
117
131
|
value: function preload() {
|
|
118
132
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
@@ -238,7 +252,8 @@ export var AMSEasyPay = /*#__PURE__*/function () {
|
|
|
238
252
|
displayInfo: {
|
|
239
253
|
type: DisplayTypeEnum.popup
|
|
240
254
|
},
|
|
241
|
-
isAppWebview: params.isAppWebview
|
|
255
|
+
isAppWebview: params.isAppWebview,
|
|
256
|
+
isNativeAppWebview: params.isNativeAppWebview
|
|
242
257
|
});
|
|
243
258
|
}
|
|
244
259
|
}, {
|
package/esm/util/logger.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export declare class Logger {
|
|
|
56
56
|
reportRPC(rpcData: LogPayload, extra?: Extra): Logger;
|
|
57
57
|
reportLogs(): void;
|
|
58
58
|
loadScript(url: string, callback: () => void): void;
|
|
59
|
+
private fallbackLoadScript;
|
|
59
60
|
initTracker(): void;
|
|
60
61
|
send(): void;
|
|
61
62
|
setComponentStartTime(val: number): void;
|
package/esm/util/logger.js
CHANGED
|
@@ -176,6 +176,43 @@ export var Logger = /*#__PURE__*/function () {
|
|
|
176
176
|
}, {
|
|
177
177
|
key: "loadScript",
|
|
178
178
|
value: function loadScript(url, callback) {
|
|
179
|
+
var _this5 = this;
|
|
180
|
+
/*
|
|
181
|
+
* 如果宿主环境存在AMD加载器,通过直接创建script标签的方式加载会造成宿主环境报错:
|
|
182
|
+
* Message: Mismatched anonymous define() module
|
|
183
|
+
* 原因是直接通过script标签加载的模块如果没有定义模块名,会被AMD加载器认为是匿名模块,
|
|
184
|
+
* 而宿主环境中已经存在匿名模块,导致报错。
|
|
185
|
+
*
|
|
186
|
+
* TODO: 所有通过window.iTracker调用的方法都需要判断
|
|
187
|
+
* 是否是AMD环境,如果是,需要通过require加载获取iTracker实例
|
|
188
|
+
* */
|
|
189
|
+
if (typeof window.define === 'function' && window.define.amd && typeof window.require === 'function') {
|
|
190
|
+
var moduleId = 'antom_iTracker';
|
|
191
|
+
try {
|
|
192
|
+
var _specified, _ref;
|
|
193
|
+
// 避免重复 config
|
|
194
|
+
if (!((_specified = (_ref = window.require).specified) !== null && _specified !== void 0 && _specified.call(_ref, moduleId))) {
|
|
195
|
+
// @ts-expect-error amd
|
|
196
|
+
window.require.config({
|
|
197
|
+
paths: _defineProperty({}, moduleId, url.replace(/\.js$/, ''))
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// @ts-expect-error amd
|
|
202
|
+
window.require([moduleId], callback, function (err) {
|
|
203
|
+
console.error('AMD load failed, falling back to script tag', err);
|
|
204
|
+
_this5.fallbackLoadScript(url, callback);
|
|
205
|
+
});
|
|
206
|
+
return;
|
|
207
|
+
} catch (e) {
|
|
208
|
+
console.warn('require not available, using script tag', e);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
this.fallbackLoadScript(url, callback);
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "fallbackLoadScript",
|
|
215
|
+
value: function fallbackLoadScript(url, callback) {
|
|
179
216
|
var script = document.createElement('script');
|
|
180
217
|
script.type = 'text/javascript';
|
|
181
218
|
script.src = url;
|
|
@@ -188,16 +225,16 @@ export var Logger = /*#__PURE__*/function () {
|
|
|
188
225
|
}, {
|
|
189
226
|
key: "initTracker",
|
|
190
227
|
value: function initTracker() {
|
|
191
|
-
var
|
|
228
|
+
var _this6 = this;
|
|
192
229
|
if (this.isLoaded) return;
|
|
193
230
|
this.isLoaded = true;
|
|
194
231
|
try {
|
|
195
232
|
if (typeof localStorage !== 'undefined') {
|
|
196
233
|
this.loadScript(this.config.scriptUrl, function () {
|
|
197
234
|
var _window4;
|
|
198
|
-
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(
|
|
235
|
+
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(_this6.config);
|
|
199
236
|
setTimeout(function () {
|
|
200
|
-
|
|
237
|
+
_this6.reportLogs();
|
|
201
238
|
}, 80);
|
|
202
239
|
});
|
|
203
240
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare enum ProductScene {
|
|
2
|
-
EXPRESS_CHECKOUT = "EXPRESS_CHECKOUT",
|
|
3
|
-
ELEMENT_PAYMENT = "ELEMENT_PAYMENT"
|
|
4
|
-
}
|
|
5
|
-
interface EventScenario {
|
|
6
|
-
eventName: ProductScene;
|
|
7
|
-
supportedEvents: string[];
|
|
8
|
-
}
|
|
9
|
-
export declare const productEventScenarios: EventScenario[];
|
|
10
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// 定义产品场景的枚举
|
|
2
|
-
export var ProductScene = /*#__PURE__*/function (ProductScene) {
|
|
3
|
-
ProductScene["EXPRESS_CHECKOUT"] = "EXPRESS_CHECKOUT";
|
|
4
|
-
ProductScene["ELEMENT_PAYMENT"] = "ELEMENT_PAYMENT";
|
|
5
|
-
return ProductScene;
|
|
6
|
-
}({});
|
|
7
|
-
|
|
8
|
-
// 定义一个事件场景的接口
|
|
9
|
-
|
|
10
|
-
// 存储产品场景及支持的事件名
|
|
11
|
-
export var productEventScenarios = [{
|
|
12
|
-
eventName: ProductScene.EXPRESS_CHECKOUT,
|
|
13
|
-
supportedEvents: [] // 没有支持的事件
|
|
14
|
-
}, {
|
|
15
|
-
eventName: ProductScene.ELEMENT_PAYMENT,
|
|
16
|
-
supportedEvents: ['paymentMethodChanged'] // 支持的事件
|
|
17
|
-
}];
|