@alipay/ams-checkout 0.0.1758783821-dev.4 → 0.0.1758783821-dev.7
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 +99 -89
- package/esm/constant/index.js +27 -14
- package/esm/core/component/element/elementController/index.d.ts +3 -8
- package/esm/core/component/element/elementController/index.js +54 -36
- package/esm/core/component/element/index.d.ts +3 -10
- package/esm/core/component/element/index.js +4 -1
- package/esm/core/component/element/mock.js +1 -0
- package/esm/core/component/element/type.d.ts +23 -4
- package/esm/core/component/element/type.js +16 -0
- package/esm/core/component/element/util.d.ts +1 -1
- package/esm/plugin/component/index.js +2 -2
- package/esm/types/index.d.ts +2 -2
- package/esm/types/index.js +1 -1
- package/package.json +1 -1
- package/esm/core/component/oldElement/components/address.d.ts +0 -19
- package/esm/core/component/oldElement/components/address.js +0 -68
- package/esm/core/component/oldElement/components/auth.d.ts +0 -17
- package/esm/core/component/oldElement/components/auth.js +0 -60
- package/esm/core/component/oldElement/components/payment.d.ts +0 -19
- package/esm/core/component/oldElement/components/payment.js +0 -74
- package/esm/core/component/oldElement/index.d.ts +0 -59
- package/esm/core/component/oldElement/index.js +0 -956
- package/esm/core/component/oldElement/mock.d.ts +0 -6
- package/esm/core/component/oldElement/mock.js +0 -567
- package/esm/core/component/oldElement/type.d.ts +0 -354
- package/esm/core/component/oldElement/type.js +0 -81
- package/esm/core/component/oldElement/utils.d.ts +0 -13
- package/esm/core/component/oldElement/utils.js +0 -6
package/esm/constant/index.d.ts
CHANGED
|
@@ -6,117 +6,113 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { eventCodeEnum } from '../types';
|
|
8
8
|
export declare const ERRORMESSAGE: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
DOMAIN_NOT_IN_WHITE_LIST: {
|
|
10
|
+
code: eventCodeEnum;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
NOT_JSON_FORMAT: {
|
|
14
|
+
code: eventCodeEnum;
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
SDK_COMPATIBILITY_ISSUES: {
|
|
18
|
+
code: eventCodeEnum;
|
|
19
|
+
BROWSER_NOT_SUPPORT_POSTMESSAGE: {
|
|
20
|
+
code: eventCodeEnum;
|
|
21
|
+
message: string;
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
FAILED_TO_CREATE_IFRAME: {
|
|
24
|
+
code: eventCodeEnum;
|
|
25
|
+
message: string;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
INIT_PARAMETER_ERROR: {
|
|
29
|
+
code: eventCodeEnum;
|
|
30
|
+
UI_MODE_NOT_SUPPORTED: {
|
|
31
|
+
code: eventCodeEnum;
|
|
32
|
+
message: string;
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
ENVIRONMENT_ERROR: {
|
|
35
|
+
code: eventCodeEnum;
|
|
36
|
+
message: string;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
MODE_ERROR: {
|
|
39
|
+
code: eventCodeEnum;
|
|
40
|
+
message: string;
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
LOCALE_ERROR: {
|
|
43
|
+
code: eventCodeEnum;
|
|
44
|
+
message: string;
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
NET_MODE_NOT_SUPPORT: {
|
|
47
|
+
code: eventCodeEnum;
|
|
48
|
+
message: string;
|
|
49
49
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
EVENT_ERROR: {
|
|
51
|
+
code: eventCodeEnum;
|
|
52
|
+
message: string;
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
CREATEPAYMENT_PARAMETER_ERROR: {
|
|
56
|
+
code: eventCodeEnum;
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
CREATECOMPONENT_ERROR: {
|
|
59
|
+
code: eventCodeEnum;
|
|
60
|
+
message: string;
|
|
61
|
+
SINGLETON_COMPONENT_ERROR: {
|
|
62
|
+
code: eventCodeEnum;
|
|
63
|
+
message: string;
|
|
64
64
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
LOAD_APP_TIMEOUT: {
|
|
66
|
+
code: eventCodeEnum;
|
|
67
|
+
message: string;
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
NETWORK_REQUEST_ERROR: {
|
|
70
|
+
code: eventCodeEnum;
|
|
71
|
+
message: string;
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
SDK_LAUNCH_PAYMENT_APP_ERROR: {
|
|
75
|
+
code: eventCodeEnum;
|
|
76
|
+
CALL_APP_URL_ERROR: {
|
|
77
|
+
code: eventCodeEnum;
|
|
78
|
+
message: string;
|
|
79
79
|
};
|
|
80
80
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
SDK_SUBMIT_ERROR: {
|
|
82
|
+
code: eventCodeEnum;
|
|
83
|
+
message: string;
|
|
84
84
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
PARAM_INVALID: {
|
|
86
|
+
code: string;
|
|
87
|
+
message: string;
|
|
88
88
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
UI_STATE_ERROR: {
|
|
90
|
+
code: string;
|
|
91
|
+
message: string;
|
|
92
92
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
readonly code: "INITALIZE_TIMEOUT";
|
|
99
|
-
readonly API: {
|
|
100
|
-
readonly code: "INITALIZE_API_TIMEOUT";
|
|
101
|
-
readonly message: "The request is abnormal and the transaction cannot be initiated.";
|
|
93
|
+
INITALIZE_TIMEOUT: {
|
|
94
|
+
code: string;
|
|
95
|
+
API: {
|
|
96
|
+
code: string;
|
|
97
|
+
message: string;
|
|
102
98
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
WEB: {
|
|
100
|
+
code: string;
|
|
101
|
+
message: string;
|
|
106
102
|
};
|
|
107
103
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
ERR_DATA_STRUCT_UNRECOGNIZED: {
|
|
105
|
+
code: string;
|
|
106
|
+
message: string;
|
|
111
107
|
};
|
|
112
108
|
/**
|
|
113
109
|
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
|
114
110
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
SDK_CALL_URL_ERROR: {
|
|
112
|
+
code: eventCodeEnum;
|
|
113
|
+
REDIRECT_ERROR: {
|
|
114
|
+
code: eventCodeEnum;
|
|
115
|
+
message: string;
|
|
120
116
|
};
|
|
121
117
|
};
|
|
122
118
|
};
|
|
@@ -315,9 +311,23 @@ export declare const LOADINGIMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA
|
|
|
315
311
|
* @description Promise回调code映射
|
|
316
312
|
*/
|
|
317
313
|
export declare const PROMISE_CALLBACK_CODE: {
|
|
318
|
-
SUCCESS:
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
314
|
+
SUCCESS: {
|
|
315
|
+
code: string;
|
|
316
|
+
};
|
|
317
|
+
UNKNOWN_EXCEPTION: {
|
|
318
|
+
code: string;
|
|
319
|
+
message: string;
|
|
320
|
+
};
|
|
321
|
+
REPEAT_REQ_REJECT: {
|
|
322
|
+
code: string;
|
|
323
|
+
message: string;
|
|
324
|
+
};
|
|
325
|
+
PROCESS_FAIL: {
|
|
326
|
+
code: string;
|
|
327
|
+
message: string;
|
|
328
|
+
};
|
|
329
|
+
INQUIRY_PAYMENT_SESSION_FAILED: {
|
|
330
|
+
code: string;
|
|
331
|
+
message: string;
|
|
332
|
+
};
|
|
323
333
|
};
|
package/esm/constant/index.js
CHANGED
|
@@ -84,30 +84,26 @@ export var ERRORMESSAGE = {
|
|
|
84
84
|
},
|
|
85
85
|
PARAM_INVALID: {
|
|
86
86
|
code: 'PARAM_INVALID',
|
|
87
|
-
message: '
|
|
87
|
+
message: 'An error occurred. The transaction cannot be initiated.'
|
|
88
88
|
},
|
|
89
89
|
UI_STATE_ERROR: {
|
|
90
90
|
code: 'UI_STATE_ERROR',
|
|
91
|
-
message: '
|
|
92
|
-
},
|
|
93
|
-
CONTAINER_NOT_LOADED: {
|
|
94
|
-
code: 'CONTAINER_NOT_LOADED',
|
|
95
|
-
message: 'The request is abnormal and the transaction cannot be initiated.'
|
|
91
|
+
message: 'An error occurred. The transaction cannot be initiated.'
|
|
96
92
|
},
|
|
97
93
|
INITALIZE_TIMEOUT: {
|
|
98
94
|
code: 'INITALIZE_TIMEOUT',
|
|
99
95
|
API: {
|
|
100
96
|
code: 'INITALIZE_API_TIMEOUT',
|
|
101
|
-
message: '
|
|
97
|
+
message: 'An error occurred. The transaction cannot be initiated.'
|
|
102
98
|
},
|
|
103
99
|
WEB: {
|
|
104
100
|
code: 'INITALIZE_WEB_TIMEOUT',
|
|
105
|
-
message: '
|
|
101
|
+
message: 'An error occurred; the transaction cannot be initiated.'
|
|
106
102
|
}
|
|
107
103
|
},
|
|
108
104
|
ERR_DATA_STRUCT_UNRECOGNIZED: {
|
|
109
105
|
code: 'ERR_DATA_STRUCT_UNRECOGNIZED',
|
|
110
|
-
|
|
106
|
+
message: 'An error occurred. The transaction cannot be initiated.'
|
|
111
107
|
},
|
|
112
108
|
/**
|
|
113
109
|
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
|
@@ -120,6 +116,9 @@ export var ERRORMESSAGE = {
|
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
118
|
};
|
|
119
|
+
|
|
120
|
+
// as const satisfies Record<string, ErrorMessage>;
|
|
121
|
+
|
|
123
122
|
export var BASEPLUGINID = 'CHECKOUT';
|
|
124
123
|
export var COMPONENTPLUGINID = 'COMPONENT';
|
|
125
124
|
export var EVENT = {
|
|
@@ -321,9 +320,23 @@ export var LOADINGIMG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACEB
|
|
|
321
320
|
* @description Promise回调code映射
|
|
322
321
|
*/
|
|
323
322
|
export var PROMISE_CALLBACK_CODE = {
|
|
324
|
-
SUCCESS:
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
323
|
+
SUCCESS: {
|
|
324
|
+
code: 'SUCCESS'
|
|
325
|
+
},
|
|
326
|
+
UNKNOWN_EXCEPTION: {
|
|
327
|
+
code: 'UNKNOWN_EXCEPTION',
|
|
328
|
+
message: 'Unknown exception. Please check the payment status and contact the merchant.'
|
|
329
|
+
},
|
|
330
|
+
REPEAT_REQ_REJECT: {
|
|
331
|
+
code: 'REPEAT_REQ_REJECT',
|
|
332
|
+
message: 'The order status is abnormal. Please check the payment status and contact the merchant.'
|
|
333
|
+
},
|
|
334
|
+
PROCESS_FAIL: {
|
|
335
|
+
code: 'PROCESS_FAIL',
|
|
336
|
+
message: 'Unknown exception. Please check the payment status and contact the merchant.'
|
|
337
|
+
},
|
|
338
|
+
INQUIRY_PAYMENT_SESSION_FAILED: {
|
|
339
|
+
code: 'INQUIRY_PAYMENT_SESSION_FAILED',
|
|
340
|
+
message: 'The order status is abnormal. Please check the payment status and contact the merchant.'
|
|
341
|
+
}
|
|
329
342
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddressMountOptions, IElementOptions,
|
|
1
|
+
import { AddressMountOptions, ICommonApiResponse, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions } from '../type';
|
|
2
2
|
declare class ElementController {
|
|
3
3
|
private options;
|
|
4
4
|
private elementContainer;
|
|
@@ -23,7 +23,7 @@ declare class ElementController {
|
|
|
23
23
|
private setInitTimeout;
|
|
24
24
|
private initializeAndMountProcessor;
|
|
25
25
|
private handleStartBizFlowError;
|
|
26
|
-
mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string):
|
|
26
|
+
mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string): Promise<ICommonApiResponse>;
|
|
27
27
|
private onValidateFunc;
|
|
28
28
|
private onValidateAndSubmitPay;
|
|
29
29
|
/**
|
|
@@ -33,12 +33,7 @@ declare class ElementController {
|
|
|
33
33
|
validateFields(): Promise<{
|
|
34
34
|
isValid: boolean;
|
|
35
35
|
}>;
|
|
36
|
-
submitPayment(): Promise<
|
|
37
|
-
error: {
|
|
38
|
-
readonly code: "CONTAINER_NOT_LOADED";
|
|
39
|
-
readonly message: "The request is abnormal and the transaction cannot be initiated.";
|
|
40
|
-
};
|
|
41
|
-
}>;
|
|
36
|
+
submitPayment(): Promise<IPaymentApiResponse>;
|
|
42
37
|
private changeLoading;
|
|
43
38
|
private addEventListener;
|
|
44
39
|
private sendRequestAndWaitWebLaunch;
|
|
@@ -38,7 +38,7 @@ import { ElementContainerService } from "../elementContainerService"; // 引入
|
|
|
38
38
|
import { IContainerStatus } from "../elementContainerService/containerService";
|
|
39
39
|
import { EventCenter as ElementEventCenter } from "../EventCenter/index";
|
|
40
40
|
import { oneAccountUpdate, sdkActionUpdate } from "../mock";
|
|
41
|
-
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType } from "../type";
|
|
41
|
+
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType, PaymentStatus } from "../type";
|
|
42
42
|
import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, showToast } from "../util";
|
|
43
43
|
var TIMEOUT_DURATION = 10000;
|
|
44
44
|
var ElementController = /*#__PURE__*/function () {
|
|
@@ -232,7 +232,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
232
232
|
});
|
|
233
233
|
var readyCallback = function readyCallback(payload) {
|
|
234
234
|
_this2.elementEventCenter.endEvent(startEventId, payload);
|
|
235
|
-
resolve(payload)
|
|
235
|
+
resolve(_objectSpread(_objectSpread({}, payload || {}), {}, {
|
|
236
|
+
needChangeSessionForRetry: false
|
|
237
|
+
}));
|
|
236
238
|
};
|
|
237
239
|
if (!checkMountResult.success) {
|
|
238
240
|
_this2.handleMountError({
|
|
@@ -327,7 +329,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
327
329
|
break;
|
|
328
330
|
}
|
|
329
331
|
res = {
|
|
330
|
-
error: ERRORMESSAGE.
|
|
332
|
+
error: ERRORMESSAGE.UI_STATE_ERROR,
|
|
333
|
+
status: PaymentStatus.FAIL,
|
|
334
|
+
needChangeSessionForRetry: false
|
|
331
335
|
};
|
|
332
336
|
this.elementEventCenter.endEvent(startEventId, res);
|
|
333
337
|
return _context4.abrupt("return", Promise.resolve(res));
|
|
@@ -338,12 +342,22 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
338
342
|
_context4.next = 10;
|
|
339
343
|
return new Promise( /*#__PURE__*/function () {
|
|
340
344
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
341
|
-
var params, processStep, _yield$_this3$onValid2, data, errorResult;
|
|
345
|
+
var that, recordResultCallback, params, processStep, _yield$_this3$onValid2, data, errorResult;
|
|
342
346
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
343
347
|
while (1) switch (_context3.prev = _context3.next) {
|
|
344
348
|
case 0:
|
|
345
|
-
|
|
346
|
-
|
|
349
|
+
recordResultCallback = function _recordResultCallback(result) {
|
|
350
|
+
if (result instanceof Object) {
|
|
351
|
+
var _that$elementProcesso;
|
|
352
|
+
var needChangeSessionForRetry = typeof (result === null || result === void 0 ? void 0 : result.needChangeSessionForRetry) === 'undefined' ? (_that$elementProcesso = that.elementProcessors[ElementType.payment]) === null || _that$elementProcesso === void 0 || (_that$elementProcesso = _that$elementProcesso.obtainDataRes) === null || _that$elementProcesso === void 0 || (_that$elementProcesso = _that$elementProcesso.originActionQueryResult) === null || _that$elementProcesso === void 0 ? void 0 : _that$elementProcesso.notSupportRetryPayForSameSession : result === null || result === void 0 ? void 0 : result.needChangeSessionForRetry;
|
|
353
|
+
result.needChangeSessionForRetry = needChangeSessionForRetry || false;
|
|
354
|
+
}
|
|
355
|
+
recordResult = result;
|
|
356
|
+
resolve(recordResult);
|
|
357
|
+
};
|
|
358
|
+
that = _this3;
|
|
359
|
+
_context3.prev = 2;
|
|
360
|
+
_this3.submitPayPromise = recordResultCallback;
|
|
347
361
|
params = {}; // 统一处理逻辑
|
|
348
362
|
processStep = /*#__PURE__*/function () {
|
|
349
363
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(elementType, method) {
|
|
@@ -367,8 +381,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
367
381
|
_context2.next = 11;
|
|
368
382
|
break;
|
|
369
383
|
}
|
|
384
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
370
385
|
recordResult = data;
|
|
371
|
-
|
|
386
|
+
recordResultCallback(recordResult);
|
|
372
387
|
return _context2.abrupt("return", false);
|
|
373
388
|
case 11:
|
|
374
389
|
return _context2.abrupt("return", true);
|
|
@@ -382,47 +397,49 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
382
397
|
return _ref4.apply(this, arguments);
|
|
383
398
|
};
|
|
384
399
|
}(); // 按顺序处理步骤
|
|
385
|
-
_context3.next =
|
|
400
|
+
_context3.next = 8;
|
|
386
401
|
return processStep(ElementType.auth, ElementPaymentMethod.AUTH_ELEMENT);
|
|
387
|
-
case
|
|
402
|
+
case 8:
|
|
388
403
|
if (_context3.sent) {
|
|
389
|
-
_context3.next =
|
|
404
|
+
_context3.next = 10;
|
|
390
405
|
break;
|
|
391
406
|
}
|
|
392
407
|
return _context3.abrupt("return");
|
|
393
|
-
case 8:
|
|
394
|
-
_context3.next = 10;
|
|
395
|
-
return processStep(ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT);
|
|
396
408
|
case 10:
|
|
409
|
+
_context3.next = 12;
|
|
410
|
+
return processStep(ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT);
|
|
411
|
+
case 12:
|
|
397
412
|
if (_context3.sent) {
|
|
398
|
-
_context3.next =
|
|
413
|
+
_context3.next = 14;
|
|
399
414
|
break;
|
|
400
415
|
}
|
|
401
416
|
return _context3.abrupt("return");
|
|
402
|
-
case
|
|
417
|
+
case 14:
|
|
403
418
|
if (!_this3.elementProcessors[ElementType.payment]) {
|
|
404
|
-
_context3.next =
|
|
419
|
+
_context3.next = 22;
|
|
405
420
|
break;
|
|
406
421
|
}
|
|
407
|
-
_context3.next =
|
|
422
|
+
_context3.next = 17;
|
|
408
423
|
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
|
409
|
-
case
|
|
424
|
+
case 17:
|
|
410
425
|
_yield$_this3$onValid2 = _context3.sent;
|
|
411
426
|
data = _yield$_this3$onValid2.data;
|
|
427
|
+
console.log('[test] data-----', data);
|
|
428
|
+
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
429
|
+
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
|
412
430
|
recordResult = data;
|
|
413
|
-
|
|
414
|
-
case
|
|
415
|
-
_context3.next =
|
|
431
|
+
recordResultCallback(recordResult);
|
|
432
|
+
case 22:
|
|
433
|
+
_context3.next = 30;
|
|
416
434
|
break;
|
|
417
|
-
case
|
|
418
|
-
_context3.prev =
|
|
419
|
-
_context3.t0 = _context3["catch"](
|
|
435
|
+
case 24:
|
|
436
|
+
_context3.prev = 24;
|
|
437
|
+
_context3.t0 = _context3["catch"](2);
|
|
420
438
|
errorResult = {
|
|
421
|
-
error: {
|
|
422
|
-
code: ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED.code,
|
|
439
|
+
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
|
|
423
440
|
context: JSON.stringify(_context3.t0)
|
|
424
|
-
},
|
|
425
|
-
status:
|
|
441
|
+
}),
|
|
442
|
+
status: PaymentStatus.FAIL
|
|
426
443
|
};
|
|
427
444
|
_this3.serviceMap.Log.logError({
|
|
428
445
|
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
@@ -430,12 +447,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
430
447
|
msg: JSON.stringify(errorResult)
|
|
431
448
|
});
|
|
432
449
|
recordResult = errorResult;
|
|
433
|
-
|
|
434
|
-
case
|
|
450
|
+
recordResultCallback(errorResult);
|
|
451
|
+
case 30:
|
|
435
452
|
case "end":
|
|
436
453
|
return _context3.stop();
|
|
437
454
|
}
|
|
438
|
-
}, _callee3, null, [[
|
|
455
|
+
}, _callee3, null, [[2, 24]]);
|
|
439
456
|
}));
|
|
440
457
|
return function (_x) {
|
|
441
458
|
return _ref3.apply(this, arguments);
|
|
@@ -608,12 +625,13 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
608
625
|
traceId = _response$originActio.traceId,
|
|
609
626
|
errorCode = _response$originActio.errorCode,
|
|
610
627
|
errorMessage = _response$originActio.errorMessage;
|
|
611
|
-
var error = {
|
|
612
|
-
code: ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED.code
|
|
613
|
-
};
|
|
628
|
+
var error = _objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED);
|
|
614
629
|
if (PROMISE_CALLBACK_CODE[errorCode]) {
|
|
615
|
-
|
|
616
|
-
error
|
|
630
|
+
var _PROMISE_CALLBACK_COD;
|
|
631
|
+
error = {
|
|
632
|
+
code: PROMISE_CALLBACK_CODE[errorCode].code,
|
|
633
|
+
message: ((_PROMISE_CALLBACK_COD = PROMISE_CALLBACK_CODE[errorCode]) === null || _PROMISE_CALLBACK_COD === void 0 ? void 0 : _PROMISE_CALLBACK_COD.message) || errorMessage
|
|
634
|
+
};
|
|
617
635
|
} else {
|
|
618
636
|
this.serviceMap.Log.logError({
|
|
619
637
|
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IElementOptions, PaymentMountOptions } from './type';
|
|
2
2
|
export declare class ElementComponent {
|
|
3
3
|
private options;
|
|
4
4
|
private controller;
|
|
5
5
|
constructor(options: IElementOptions);
|
|
6
6
|
updatePayment(paymentSessionData: any): Promise<unknown>;
|
|
7
|
-
mount(renderOptions:
|
|
8
|
-
mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
|
9
|
-
mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
|
|
7
|
+
mount(renderOptions: PaymentMountOptions, sdkSelector: string): Promise<import("./type").ICommonApiResponse>;
|
|
10
8
|
validateFields(): Promise<{
|
|
11
9
|
isValid: boolean;
|
|
12
10
|
}>;
|
|
13
|
-
submitPayment(): Promise<import("./type").
|
|
14
|
-
error: {
|
|
15
|
-
readonly code: "CONTAINER_NOT_LOADED";
|
|
16
|
-
readonly message: "The request is abnormal and the transaction cannot be initiated.";
|
|
17
|
-
};
|
|
18
|
-
}>;
|
|
11
|
+
submitPayment(): Promise<import("./type").IPaymentApiResponse>;
|
|
19
12
|
destroy(): void;
|
|
20
13
|
}
|
|
@@ -43,7 +43,10 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
43
43
|
return _updatePayment.apply(this, arguments);
|
|
44
44
|
}
|
|
45
45
|
return updatePayment;
|
|
46
|
-
}()
|
|
46
|
+
}() // 暂不透出 link 和 address element
|
|
47
|
+
// mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
|
|
48
|
+
// mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
|
49
|
+
// mount(renderOptions: PaymentMountOptions, sdkSelector: string);
|
|
47
50
|
}, {
|
|
48
51
|
key: "mount",
|
|
49
52
|
value: function mount(renderOptions, sdkSelector) {
|
|
@@ -36,6 +36,20 @@ export declare enum ElementType {
|
|
|
36
36
|
address = "address",
|
|
37
37
|
payment = "payment"
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* TODO 替换外外网链接
|
|
41
|
+
* 支付状态参考: https://yuque.antfin.com/antom_ka_team/yg9y7x/fe8xxqgbivnx5fd2#rGgE
|
|
42
|
+
*/
|
|
43
|
+
export declare enum PaymentStatus {
|
|
44
|
+
SUCCESS = "SUCCESS",
|
|
45
|
+
PROCESSING = "PROCESSING",
|
|
46
|
+
CANCELLED = "CANCELLED",
|
|
47
|
+
PENDING = "PENDING",
|
|
48
|
+
S = "SUCCESS",
|
|
49
|
+
F = "FAIL",
|
|
50
|
+
U = "PROCESSING",
|
|
51
|
+
FAIL = "FAIL"
|
|
52
|
+
}
|
|
39
53
|
export declare const MountElementType: {
|
|
40
54
|
auth: ElementPaymentMethod;
|
|
41
55
|
address: ElementPaymentMethod;
|
|
@@ -194,6 +208,8 @@ export interface ValidateResult<T = {}> {
|
|
|
194
208
|
success: boolean;
|
|
195
209
|
data: {
|
|
196
210
|
success: boolean;
|
|
211
|
+
status: PaymentStatus;
|
|
212
|
+
message?: string;
|
|
197
213
|
data: T;
|
|
198
214
|
};
|
|
199
215
|
}
|
|
@@ -393,15 +409,18 @@ export interface IToastOptions {
|
|
|
393
409
|
icon?: 'SUCCESS' | 'FAIL';
|
|
394
410
|
spin?: boolean;
|
|
395
411
|
}
|
|
396
|
-
export interface
|
|
397
|
-
success?: boolean;
|
|
412
|
+
export interface ICommonApiResponse {
|
|
398
413
|
error?: {
|
|
399
414
|
code: string;
|
|
400
|
-
message
|
|
415
|
+
message: string;
|
|
401
416
|
traceId?: string;
|
|
402
417
|
context?: any;
|
|
403
418
|
};
|
|
404
|
-
|
|
419
|
+
needChangeSessionForRetry?: boolean;
|
|
420
|
+
}
|
|
421
|
+
export interface IPaymentApiResponse extends ICommonApiResponse {
|
|
422
|
+
status: keyof typeof PaymentStatus;
|
|
423
|
+
userCanceled3D?: boolean;
|
|
405
424
|
}
|
|
406
425
|
export declare class InvalidElementConfigError extends Error {
|
|
407
426
|
errors: Array<{
|
|
@@ -49,6 +49,22 @@ export var ElementType = /*#__PURE__*/function (ElementType) {
|
|
|
49
49
|
ElementType["payment"] = "payment";
|
|
50
50
|
return ElementType;
|
|
51
51
|
}({});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* TODO 替换外外网链接
|
|
55
|
+
* 支付状态参考: https://yuque.antfin.com/antom_ka_team/yg9y7x/fe8xxqgbivnx5fd2#rGgE
|
|
56
|
+
*/
|
|
57
|
+
export var PaymentStatus = /*#__PURE__*/function (PaymentStatus) {
|
|
58
|
+
PaymentStatus["SUCCESS"] = "SUCCESS";
|
|
59
|
+
PaymentStatus["PROCESSING"] = "PROCESSING";
|
|
60
|
+
PaymentStatus["CANCELLED"] = "CANCELLED";
|
|
61
|
+
PaymentStatus["PENDING"] = "PENDING";
|
|
62
|
+
PaymentStatus["S"] = "SUCCESS";
|
|
63
|
+
PaymentStatus["F"] = "FAIL";
|
|
64
|
+
PaymentStatus["U"] = "PROCESSING";
|
|
65
|
+
PaymentStatus["FAIL"] = "FAIL";
|
|
66
|
+
return PaymentStatus;
|
|
67
|
+
}({});
|
|
52
68
|
export var MountElementType = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ElementType.auth, ElementPaymentMethod.AUTH_ELEMENT), ElementType.address, ElementPaymentMethod.ADDRESS_ELEMENT), ElementType.payment, ElementPaymentMethod.PAYMENT_ELEMENT), ElementPaymentMethod.AUTH_ELEMENT, ElementType.auth), ElementPaymentMethod.ADDRESS_ELEMENT, ElementType.address), ElementPaymentMethod.PAYMENT_ELEMENT, ElementType.payment);
|
|
53
69
|
export var ThemeType = /*#__PURE__*/function (ThemeType) {
|
|
54
70
|
ThemeType["NostalgicGray"] = "nostalgicGray";
|
|
@@ -39,7 +39,7 @@ export declare function checkCanMount({ sdkSelector, containerService, status, }
|
|
|
39
39
|
errorMsg?: string;
|
|
40
40
|
error?: {
|
|
41
41
|
code: string;
|
|
42
|
-
message
|
|
42
|
+
message: string;
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
45
|
export declare function checkCanUpdate({ status, paymentContainerService, newPaymentSessionData, oldPaymentSessionData, }: {
|
|
@@ -17,13 +17,13 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
17
17
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
|
18
18
|
*/
|
|
19
19
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
|
+
import { ElementPaymentMethod } from "../../core/component/element/type";
|
|
20
21
|
import { v4 as uuid } from 'uuid';
|
|
21
22
|
import { sdkVersion } from "../../config";
|
|
22
23
|
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID, POPUP_LOADTIME_LOG_LIMIT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../constant";
|
|
23
|
-
import { ElementPaymentMethod } from "../../core/component/oldElement/type";
|
|
24
24
|
import { queryPaymentInfo, submitPayInfo } from "../../service";
|
|
25
25
|
import { ComponentSignEnum, DisplayTypeEnum, eventCodeEnum, MessageName, PlatformEnum, ProductSceneEnum, RedirectType, TargetEnum } from "../../types";
|
|
26
|
-
import { getType, isJsonString, isPC
|
|
26
|
+
import { device, getType, isJsonString, isPC } from "../../util";
|
|
27
27
|
import { getBackScheme } from "../../util/getBackScheme";
|
|
28
28
|
import { isLocalMock } from "../../util/mock";
|
|
29
29
|
import { matchVersion } from "../../util/versionCompare";
|