@alipay/ams-checkout 0.0.1757298389-dev.2 → 0.0.1757298389-dev.21
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/README.md +17 -1
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/component.popup.style.d.ts +1 -0
- package/esm/component/component.popup.style.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +60 -0
- package/esm/constant/index.js +68 -1
- package/esm/core/component/element/EventCenter/index.d.ts +29 -0
- package/esm/core/component/element/EventCenter/index.js +155 -0
- package/esm/core/component/element/elementContainerService/containerService.js +3 -2
- package/esm/core/component/element/elementController/index.d.ts +16 -4
- package/esm/core/component/element/elementController/index.js +497 -280
- package/esm/core/component/element/elementProcessor/addressProcessor.js +3 -3
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +20 -14
- package/esm/core/component/element/index.d.ts +3 -5
- package/esm/core/component/element/index.js +9 -3
- package/esm/core/component/element/mock.js +1 -0
- package/esm/core/component/element/type.d.ts +55 -5
- package/esm/core/component/element/type.js +59 -2
- package/esm/core/component/element/util.d.ts +20 -5
- package/esm/core/component/element/util.js +49 -7
- package/esm/core/component/index.d.ts +4 -1
- package/esm/core/component/index.js +105 -2
- package/esm/foundation/service/log/keys.js +2 -0
- package/esm/foundation/service/requester/requester.js +2 -3
- package/esm/index.d.ts +10 -1
- package/esm/index.js +15 -1
- package/esm/plugin/component/channel.js +5 -3
- package/esm/plugin/component/index.d.ts +2 -0
- package/esm/plugin/component/index.js +24 -8
- package/esm/plugin/paypal/index.js +5 -2
- package/esm/types/index.d.ts +13 -1
- package/esm/types/index.js +1 -1
- package/esm/util/spm-map.d.ts +8 -0
- package/esm/util/spm-map.js +5 -1
- package/package.json +13 -8
- 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
|
@@ -20,9 +20,9 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
20
20
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
21
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
22
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
-
import { ProductSceneEnum } from "../../../../types";
|
|
24
23
|
import { parseSessionData } from "../..";
|
|
25
24
|
import PackageJson from "../../../../../package.json";
|
|
25
|
+
import { ProductSceneEnum } from "../../../../types";
|
|
26
26
|
import { generateIframeSrc as _generateIframeSrc } from "../util";
|
|
27
27
|
import BaseElementProcessor from "./baseElementProcessor";
|
|
28
28
|
var AddressProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
@@ -35,12 +35,12 @@ var AddressProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
35
35
|
_createClass(AddressProcessor, [{
|
|
36
36
|
key: "onReady",
|
|
37
37
|
value: function onReady(extraParam) {
|
|
38
|
-
var _paymentSessionObj$pa, _extraParam$originOne;
|
|
38
|
+
var _paymentSessionObj$co, _paymentSessionObj$pa, _extraParam$originOne;
|
|
39
39
|
var paymentContext = this.elementContainer.getPaymentContext();
|
|
40
40
|
var paymentSessionObj = paymentContext.paymentSessionObj,
|
|
41
41
|
paymentSessionId = paymentContext.paymentSessionId,
|
|
42
42
|
displayInfo = paymentContext.displayInfo;
|
|
43
|
-
var isConnect = paymentSessionObj.connectFactor.enableConnect && ((_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
|
|
43
|
+
var isConnect = ((_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect) && ((_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
|
|
44
44
|
this.eventCenter.dispatchToApp({
|
|
45
45
|
event: 'renderComponent',
|
|
46
46
|
data: {
|
|
@@ -27,11 +27,11 @@ import PackageJson from "../../../../../package.json";
|
|
|
27
27
|
import { EVENT } from "../../../../constant";
|
|
28
28
|
import { ServiceProvider } from "../../../../foundation/service";
|
|
29
29
|
import { ApplePaySdk, handleGooglePay, isSkipRenderPaymentMethod } from "../../../../plugin/component/channel";
|
|
30
|
-
import { LogConfig, Logger } from "../../../../util/logger";
|
|
31
30
|
import { queryParse } from "../../../../util";
|
|
31
|
+
import { LogConfig, Logger } from "../../../../util/logger";
|
|
32
32
|
import { parseSessionData } from "../../index";
|
|
33
33
|
import { oneAccount, sdkAction } from "../mock";
|
|
34
|
-
import { generateIframeSrc as _generateIframeSrc,
|
|
34
|
+
import { generateIframeSrc as _generateIframeSrc, isElementPad, isElementPC } from "../util";
|
|
35
35
|
import BaseElementProcessor from "./baseElementProcessor";
|
|
36
36
|
var logger = new Logger(LogConfig, true);
|
|
37
37
|
var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
@@ -58,7 +58,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
58
58
|
event: 'renderComponent',
|
|
59
59
|
data: {
|
|
60
60
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
|
61
|
-
|
|
61
|
+
// 极简架构需要全量sessionData, 服务端与谦评估没得影响
|
|
62
|
+
paymentSessionData: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSession,
|
|
62
63
|
queryResult: extraParam === null || extraParam === void 0 ? void 0 : extraParam.originActionQueryResult,
|
|
63
64
|
envInfo: {
|
|
64
65
|
screenHeight: screen.height,
|
|
@@ -242,18 +243,19 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
242
243
|
value: function () {
|
|
243
244
|
var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
244
245
|
var _paymentSessionObj$co;
|
|
245
|
-
var requestService, _this$elementContaine8, paymentSession, paymentSessionObj, displayInfo,
|
|
246
|
+
var requestService, _this$elementContaine8, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options2, environment, locale, _ref4, paymentSessionConfig, hostSign, isConnect, LOCAL_MOCK, _queryParse, appType, terminalType, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
|
|
246
247
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
247
248
|
while (1) switch (_context2.prev = _context2.next) {
|
|
248
249
|
case 0:
|
|
249
250
|
requestService = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
|
250
251
|
_this$elementContaine8 = this.elementContainer.getPaymentContext(), paymentSession = _this$elementContaine8.paymentSession, paymentSessionObj = _this$elementContaine8.paymentSessionObj, displayInfo = _this$elementContaine8.displayInfo;
|
|
251
|
-
|
|
252
|
+
_displayInfo = displayInfo;
|
|
253
|
+
debugProps = _displayInfo.debugProps;
|
|
252
254
|
_this$options2 = this.options, environment = _this$options2.env.environment, locale = _this$options2.locale;
|
|
253
255
|
_ref4 = paymentSessionObj || {}, paymentSessionConfig = _ref4.paymentSessionConfig;
|
|
254
256
|
hostSign = paymentSession.split('&&')[1] || '';
|
|
255
257
|
isConnect = paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect;
|
|
256
|
-
LOCAL_MOCK =
|
|
258
|
+
LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock);
|
|
257
259
|
_queryParse = queryParse(this.getElementUrl()), appType = _queryParse.appType;
|
|
258
260
|
terminalType = isElementPad() ? 'WEB' : appType ? 'APP' : isElementPC() ? 'WEB' : 'WAP';
|
|
259
261
|
generateActionQueryPromise = function generateActionQueryPromise() {
|
|
@@ -267,7 +269,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
267
269
|
}
|
|
268
270
|
var sdkRequestData = {
|
|
269
271
|
paymentSessionConfig: paymentSessionConfig,
|
|
270
|
-
paymentSessionData: paymentSession
|
|
272
|
+
paymentSessionData: paymentSession,
|
|
273
|
+
extParams: {
|
|
274
|
+
// 必传,服务端用于根据前端传入locale判断是否使用用户偏好语言
|
|
275
|
+
isUserPreferredLocale: true
|
|
276
|
+
}
|
|
271
277
|
};
|
|
272
278
|
if (displayInfo !== null && displayInfo !== void 0 && (_displayInfo$merchant = displayInfo.merchantAppointParam) !== null && _displayInfo$merchant !== void 0 && _displayInfo$merchant.storedCard) {
|
|
273
279
|
sdkRequestData.merchantAppointParam = displayInfo.merchantAppointParam;
|
|
@@ -287,8 +293,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
287
293
|
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
|
288
294
|
}).then(function (result) {
|
|
289
295
|
resolve(result);
|
|
290
|
-
}, function () {
|
|
291
|
-
reject(
|
|
296
|
+
}, function (e) {
|
|
297
|
+
reject(e);
|
|
292
298
|
});
|
|
293
299
|
});
|
|
294
300
|
};
|
|
@@ -317,14 +323,14 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
317
323
|
'Operation-Type': 'com.ipay.iexpfront.one.account.query'
|
|
318
324
|
}).then(function (result) {
|
|
319
325
|
resolve(result);
|
|
320
|
-
}, function () {
|
|
321
|
-
reject(
|
|
326
|
+
}, function (e) {
|
|
327
|
+
reject(e);
|
|
322
328
|
});
|
|
323
329
|
});
|
|
324
330
|
};
|
|
325
|
-
_context2.next =
|
|
331
|
+
_context2.next = 15;
|
|
326
332
|
return Promise.all(isConnect ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
|
|
327
|
-
case
|
|
333
|
+
case 15:
|
|
328
334
|
_yield$Promise$all = _context2.sent;
|
|
329
335
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
330
336
|
originActionQueryResult = _yield$Promise$all2[0];
|
|
@@ -337,7 +343,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
337
343
|
originActionQueryResult: originActionQueryResult,
|
|
338
344
|
originOneAccountQueryResult: originOneAccountQueryResult
|
|
339
345
|
});
|
|
340
|
-
case
|
|
346
|
+
case 21:
|
|
341
347
|
case "end":
|
|
342
348
|
return _context2.stop();
|
|
343
349
|
}
|
|
@@ -1,15 +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():
|
|
11
|
+
submitPayment(): Promise<import("./type").IPaymentApiResponse>;
|
|
14
12
|
destroy(): void;
|
|
15
13
|
}
|
|
@@ -11,6 +11,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
11
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
13
|
import ElementController from "./elementController";
|
|
14
|
+
import { InvalidElementConfigError } from "./type";
|
|
14
15
|
import { formatElementOption, validateElementOption } from "./util";
|
|
15
16
|
export var ElementComponent = /*#__PURE__*/function () {
|
|
16
17
|
function ElementComponent(options) {
|
|
@@ -18,7 +19,9 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
18
19
|
_defineProperty(this, "options", void 0);
|
|
19
20
|
_defineProperty(this, "controller", void 0);
|
|
20
21
|
var validate = validateElementOption(options);
|
|
21
|
-
if (!validate)
|
|
22
|
+
if (!validate.isValid) {
|
|
23
|
+
throw new InvalidElementConfigError(validate.errors);
|
|
24
|
+
}
|
|
22
25
|
this.options = formatElementOption(options);
|
|
23
26
|
this.controller = new ElementController(options);
|
|
24
27
|
}
|
|
@@ -40,7 +43,10 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
40
43
|
return _updatePayment.apply(this, arguments);
|
|
41
44
|
}
|
|
42
45
|
return updatePayment;
|
|
43
|
-
}()
|
|
46
|
+
}() // 暂不透出 link 和 address element
|
|
47
|
+
// mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
|
|
48
|
+
// mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
|
49
|
+
// mount(renderOptions: PaymentMountOptions, sdkSelector: string);
|
|
44
50
|
}, {
|
|
45
51
|
key: "mount",
|
|
46
52
|
value: function mount(renderOptions, sdkSelector) {
|
|
@@ -57,7 +63,7 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
57
63
|
}, {
|
|
58
64
|
key: "submitPayment",
|
|
59
65
|
value: function submitPayment() {
|
|
60
|
-
this.controller.submitPayment();
|
|
66
|
+
return this.controller.submitPayment();
|
|
61
67
|
}
|
|
62
68
|
}, {
|
|
63
69
|
key: "destroy",
|
|
@@ -23,8 +23,7 @@ export declare enum ElementPaymentEvent {
|
|
|
23
23
|
SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
|
|
24
24
|
LOG = "log",
|
|
25
25
|
HANDLE_PAYMENT = "handlePayment",
|
|
26
|
-
ON_EVENT_CALLBACK = "onEventCallback"
|
|
27
|
-
ON_PAY_STATUS_CHANGE = "onPayStatusChange"
|
|
26
|
+
ON_EVENT_CALLBACK = "onEventCallback"
|
|
28
27
|
}
|
|
29
28
|
export declare enum ElementPaymentMethod {
|
|
30
29
|
CONTAINER_ELEMENT = "CONTAINER_ELEMENT",
|
|
@@ -37,6 +36,20 @@ export declare enum ElementType {
|
|
|
37
36
|
address = "address",
|
|
38
37
|
payment = "payment"
|
|
39
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
|
+
}
|
|
40
53
|
export declare const MountElementType: {
|
|
41
54
|
auth: ElementPaymentMethod;
|
|
42
55
|
address: ElementPaymentMethod;
|
|
@@ -128,6 +141,10 @@ export interface LinkAuthMountOptions extends BaseMountOptions {
|
|
|
128
141
|
theme?: ThemeType;
|
|
129
142
|
};
|
|
130
143
|
}
|
|
144
|
+
type ToCamelCase<S extends string> = S extends `${infer First}-${infer Rest}` ? `${First}${Capitalize<ToCamelCase<Rest>>}` : S;
|
|
145
|
+
type CompatibleVariables<T extends Record<string, string>> = {
|
|
146
|
+
[K in keyof T as K | ToCamelCase<K & string>]: string;
|
|
147
|
+
};
|
|
131
148
|
export interface PaymentMountOptions extends BaseMountOptions {
|
|
132
149
|
type: ElementType.payment;
|
|
133
150
|
appearance?: {
|
|
@@ -135,7 +152,7 @@ export interface PaymentMountOptions extends BaseMountOptions {
|
|
|
135
152
|
layout?: {
|
|
136
153
|
type: PaymentElementLayout;
|
|
137
154
|
};
|
|
138
|
-
variables?: {
|
|
155
|
+
variables?: Partial<CompatibleVariables<{
|
|
139
156
|
'content-primary': string;
|
|
140
157
|
'content-secondary': string;
|
|
141
158
|
'content-tertiary': string;
|
|
@@ -160,7 +177,8 @@ export interface PaymentMountOptions extends BaseMountOptions {
|
|
|
160
177
|
'radius-module': string;
|
|
161
178
|
'radius-component': string;
|
|
162
179
|
'radius-button': string;
|
|
163
|
-
|
|
180
|
+
'warpper-padding': string;
|
|
181
|
+
}>>;
|
|
164
182
|
};
|
|
165
183
|
notRedirectAfterComplete?: boolean;
|
|
166
184
|
merchantAppointParam?: IMerchantAppointParam;
|
|
@@ -190,6 +208,8 @@ export interface ValidateResult<T = {}> {
|
|
|
190
208
|
success: boolean;
|
|
191
209
|
data: {
|
|
192
210
|
success: boolean;
|
|
211
|
+
status: PaymentStatus;
|
|
212
|
+
message?: string;
|
|
193
213
|
data: T;
|
|
194
214
|
};
|
|
195
215
|
}
|
|
@@ -361,7 +381,7 @@ export interface IElementOptions {
|
|
|
361
381
|
appearance?: {
|
|
362
382
|
theme: ThemeType.Default | ThemeType.Night;
|
|
363
383
|
};
|
|
364
|
-
onEventCallback?: ({ code, message, result }: {
|
|
384
|
+
onEventCallback?: ({ code, message, result, }: {
|
|
365
385
|
code: EventCallbackCode;
|
|
366
386
|
message: string;
|
|
367
387
|
result?: any;
|
|
@@ -389,4 +409,34 @@ export interface IToastOptions {
|
|
|
389
409
|
icon?: 'SUCCESS' | 'FAIL';
|
|
390
410
|
spin?: boolean;
|
|
391
411
|
}
|
|
412
|
+
export interface ICommonApiResponse {
|
|
413
|
+
error?: {
|
|
414
|
+
code: string;
|
|
415
|
+
message: string;
|
|
416
|
+
traceId?: string;
|
|
417
|
+
context?: any;
|
|
418
|
+
};
|
|
419
|
+
needChangeSessionForRetry?: boolean;
|
|
420
|
+
}
|
|
421
|
+
export interface IPaymentApiResponse extends ICommonApiResponse {
|
|
422
|
+
status: keyof typeof PaymentStatus;
|
|
423
|
+
userCanceled3D?: boolean;
|
|
424
|
+
}
|
|
425
|
+
export declare class InvalidElementConfigError extends Error {
|
|
426
|
+
errors: Array<{
|
|
427
|
+
field: keyof IElementOptions;
|
|
428
|
+
message: string;
|
|
429
|
+
}>;
|
|
430
|
+
constructor(errors: Array<{
|
|
431
|
+
field: keyof IElementOptions;
|
|
432
|
+
message: string;
|
|
433
|
+
}>);
|
|
434
|
+
}
|
|
435
|
+
export declare enum EXPOSURE_API_EVENT {
|
|
436
|
+
DESTORY = "destroy",
|
|
437
|
+
MOUNT = "mount",
|
|
438
|
+
SUBMITPAYMENT = "submitPayment",
|
|
439
|
+
VALIDATAFIELDS = "validateFields",
|
|
440
|
+
UPDATEPAYMENT = "updatePayment"
|
|
441
|
+
}
|
|
392
442
|
export {};
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
6
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
8
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
9
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
10
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
11
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
+
function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
2
15
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
16
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -21,7 +34,6 @@ export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
|
|
|
21
34
|
ElementPaymentEvent["LOG"] = "log";
|
|
22
35
|
ElementPaymentEvent["HANDLE_PAYMENT"] = "handlePayment";
|
|
23
36
|
ElementPaymentEvent["ON_EVENT_CALLBACK"] = "onEventCallback";
|
|
24
|
-
ElementPaymentEvent["ON_PAY_STATUS_CHANGE"] = "onPayStatusChange";
|
|
25
37
|
return ElementPaymentEvent;
|
|
26
38
|
}({});
|
|
27
39
|
export var ElementPaymentMethod = /*#__PURE__*/function (ElementPaymentMethod) {
|
|
@@ -37,6 +49,22 @@ export var ElementType = /*#__PURE__*/function (ElementType) {
|
|
|
37
49
|
ElementType["payment"] = "payment";
|
|
38
50
|
return ElementType;
|
|
39
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
|
+
}({});
|
|
40
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);
|
|
41
69
|
export var ThemeType = /*#__PURE__*/function (ThemeType) {
|
|
42
70
|
ThemeType["NostalgicGray"] = "nostalgicGray";
|
|
@@ -72,6 +100,11 @@ export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
|
|
|
72
100
|
ELEMENT_ENVIRONMENT["SANDBOX"] = "SANDBOX";
|
|
73
101
|
return ELEMENT_ENVIRONMENT;
|
|
74
102
|
}({});
|
|
103
|
+
|
|
104
|
+
// 将短横线命名转为小驼峰
|
|
105
|
+
|
|
106
|
+
// 同时兼容短横线和小驼峰两种键名
|
|
107
|
+
|
|
75
108
|
// export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
|
|
76
109
|
|
|
77
110
|
export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbackName) {
|
|
@@ -88,4 +121,28 @@ var AccountStatusEnum = /*#__PURE__*/function (AccountStatusEnum) {
|
|
|
88
121
|
AccountStatusEnum["EFFECTIVE"] = "EFFECTIVE";
|
|
89
122
|
AccountStatusEnum["UNREGISTERED"] = "UNREGISTERED";
|
|
90
123
|
return AccountStatusEnum;
|
|
91
|
-
}(AccountStatusEnum || {}); // element 接口start
|
|
124
|
+
}(AccountStatusEnum || {}); // element 接口start
|
|
125
|
+
export var InvalidElementConfigError = /*#__PURE__*/function (_Error) {
|
|
126
|
+
_inherits(InvalidElementConfigError, _Error);
|
|
127
|
+
var _super = _createSuper(InvalidElementConfigError);
|
|
128
|
+
function InvalidElementConfigError(errors) {
|
|
129
|
+
var _this;
|
|
130
|
+
_classCallCheck(this, InvalidElementConfigError);
|
|
131
|
+
var errorMessages = errors.map(function (e) {
|
|
132
|
+
return "".concat(e.field, ": ").concat(e.message);
|
|
133
|
+
});
|
|
134
|
+
_this = _super.call(this, "Invalid config:\n".concat(errorMessages.join('\n')));
|
|
135
|
+
_this.errors = errors;
|
|
136
|
+
_this.name = 'InvalidElementConfigError';
|
|
137
|
+
return _this;
|
|
138
|
+
}
|
|
139
|
+
return _createClass(InvalidElementConfigError);
|
|
140
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
141
|
+
export var EXPOSURE_API_EVENT = /*#__PURE__*/function (EXPOSURE_API_EVENT) {
|
|
142
|
+
EXPOSURE_API_EVENT["DESTORY"] = "destroy";
|
|
143
|
+
EXPOSURE_API_EVENT["MOUNT"] = "mount";
|
|
144
|
+
EXPOSURE_API_EVENT["SUBMITPAYMENT"] = "submitPayment";
|
|
145
|
+
EXPOSURE_API_EVENT["VALIDATAFIELDS"] = "validateFields";
|
|
146
|
+
EXPOSURE_API_EVENT["UPDATEPAYMENT"] = "updatePayment";
|
|
147
|
+
return EXPOSURE_API_EVENT;
|
|
148
|
+
}({});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IElementStatus } from '../../../foundation';
|
|
2
|
-
import { Ianalytics, IPaymentSessionMetaData } from '../../../types';
|
|
2
|
+
import { CashierSdkActionQueryResult, Ianalytics, IPaymentSessionMetaData } from '../../../types';
|
|
3
3
|
import { ContainerController } from './elementContainerService/containerService';
|
|
4
|
-
import { ELEMENT_ENVIRONMENT_TYPE, IElementOptions, IToastOptions
|
|
4
|
+
import { ELEMENT_ENVIRONMENT_TYPE, EventCallbackCode, IElementOptions, IToastOptions } from './type';
|
|
5
5
|
export declare const formatElementOption: (options: IElementOptions) => {
|
|
6
6
|
environment: ELEMENT_ENVIRONMENT_TYPE;
|
|
7
7
|
sessionData: string;
|
|
@@ -10,7 +10,7 @@ export declare const formatElementOption: (options: IElementOptions) => {
|
|
|
10
10
|
appearance?: {
|
|
11
11
|
theme: import("./type").ThemeType.Default | import("./type").ThemeType.Night;
|
|
12
12
|
};
|
|
13
|
-
onEventCallback?: ({ code, message, result }: {
|
|
13
|
+
onEventCallback?: ({ code, message, result, }: {
|
|
14
14
|
code: EventCallbackCode;
|
|
15
15
|
message: string;
|
|
16
16
|
result?: any;
|
|
@@ -20,10 +20,15 @@ export declare const formatElementOption: (options: IElementOptions) => {
|
|
|
20
20
|
onEndLoading: () => void;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
export declare const validateElementOption: (options: IElementOptions) =>
|
|
23
|
+
export declare const validateElementOption: (options: IElementOptions) => {
|
|
24
|
+
isValid: boolean;
|
|
25
|
+
errors: any[];
|
|
26
|
+
};
|
|
24
27
|
/**
|
|
25
28
|
* 校验渲染条件
|
|
26
|
-
*
|
|
29
|
+
* 1.校验当前 sdkSelector 结点是否存在
|
|
30
|
+
* 2.校验当前 Element 的状态是否能够渲染
|
|
31
|
+
* 3.校验当前 type 类型 Elment 是否已经执行过 mount
|
|
27
32
|
*/
|
|
28
33
|
export declare function checkCanMount({ sdkSelector, containerService, status, }: {
|
|
29
34
|
sdkSelector: string;
|
|
@@ -32,6 +37,10 @@ export declare function checkCanMount({ sdkSelector, containerService, status, }
|
|
|
32
37
|
}): {
|
|
33
38
|
success: boolean;
|
|
34
39
|
errorMsg?: string;
|
|
40
|
+
error?: {
|
|
41
|
+
code: string;
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
35
44
|
};
|
|
36
45
|
export declare function checkCanUpdate({ status, paymentContainerService, newPaymentSessionData, oldPaymentSessionData, }: {
|
|
37
46
|
status: IElementStatus;
|
|
@@ -67,3 +76,9 @@ export declare const isElementMobile: () => boolean;
|
|
|
67
76
|
*/
|
|
68
77
|
export declare const isElementPad: () => boolean;
|
|
69
78
|
export declare const isElementPC: () => boolean;
|
|
79
|
+
/**
|
|
80
|
+
* 判断是否需要加载错误页
|
|
81
|
+
* @param {CashierSdkActionQueryResult} params
|
|
82
|
+
* @returns {boolean} - 是否需要加载错误页
|
|
83
|
+
*/
|
|
84
|
+
export declare const isLoadErrorPage: (params: CashierSdkActionQueryResult) => boolean;
|
|
@@ -25,20 +25,32 @@ export var formatElementOption = function formatElementOption(options) {
|
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
export var validateElementOption = function validateElementOption(options) {
|
|
28
|
+
var errors = [];
|
|
28
29
|
if (!options.sessionData) {
|
|
30
|
+
console.error('sessionData is empty, please check new AMSElement params.');
|
|
31
|
+
errors.push({
|
|
32
|
+
field: 'sessionData',
|
|
33
|
+
message: 'sessionData is empty'
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (errors.length > 0) {
|
|
29
37
|
var _options$onEventCallb;
|
|
30
38
|
options === null || options === void 0 || (_options$onEventCallb = options.onEventCallback) === null || _options$onEventCallb === void 0 || _options$onEventCallb.call(options, {
|
|
31
39
|
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
|
32
40
|
message: 'sessionData is empty'
|
|
33
41
|
});
|
|
34
|
-
return false;
|
|
35
42
|
}
|
|
36
|
-
return
|
|
43
|
+
return {
|
|
44
|
+
isValid: errors.length === 0,
|
|
45
|
+
errors: errors
|
|
46
|
+
};
|
|
37
47
|
};
|
|
38
48
|
|
|
39
49
|
/**
|
|
40
50
|
* 校验渲染条件
|
|
41
|
-
*
|
|
51
|
+
* 1.校验当前 sdkSelector 结点是否存在
|
|
52
|
+
* 2.校验当前 Element 的状态是否能够渲染
|
|
53
|
+
* 3.校验当前 type 类型 Elment 是否已经执行过 mount
|
|
42
54
|
*/
|
|
43
55
|
export function checkCanMount(_ref) {
|
|
44
56
|
var sdkSelector = _ref.sdkSelector,
|
|
@@ -50,13 +62,15 @@ export function checkCanMount(_ref) {
|
|
|
50
62
|
console.error("Element with selector ".concat(sdkSelector, " not found."));
|
|
51
63
|
return {
|
|
52
64
|
success: false,
|
|
53
|
-
errorMsg: "Element with selector ".concat(sdkSelector, " not found.")
|
|
65
|
+
errorMsg: "Element with selector ".concat(sdkSelector, " not found."),
|
|
66
|
+
error: ERRORMESSAGE.PARAM_INVALID
|
|
54
67
|
};
|
|
55
68
|
}
|
|
56
69
|
if (status === IElementStatus.DESTROYED) {
|
|
57
70
|
return {
|
|
58
71
|
success: false,
|
|
59
|
-
errorMsg: "Creating components in the destroyed state is forbidden."
|
|
72
|
+
errorMsg: "Creating components in the destroyed state is forbidden.",
|
|
73
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
60
74
|
};
|
|
61
75
|
}
|
|
62
76
|
if (status === IElementStatus.READY) {
|
|
@@ -67,7 +81,8 @@ export function checkCanMount(_ref) {
|
|
|
67
81
|
if (containerService) {
|
|
68
82
|
return {
|
|
69
83
|
success: false,
|
|
70
|
-
errorMsg: "SDK status error."
|
|
84
|
+
errorMsg: "SDK status error.",
|
|
85
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
71
86
|
};
|
|
72
87
|
}
|
|
73
88
|
return {
|
|
@@ -429,7 +444,7 @@ export function showToast() {
|
|
|
429
444
|
textAlign: 'center',
|
|
430
445
|
marginTop: '12px',
|
|
431
446
|
lineHeight: '20px',
|
|
432
|
-
fontFamily:
|
|
447
|
+
fontFamily: 'Noto Sans',
|
|
433
448
|
fontWeight: 400,
|
|
434
449
|
fontSize: '14px'
|
|
435
450
|
}
|
|
@@ -474,4 +489,31 @@ export var isElementPad = function isElementPad() {
|
|
|
474
489
|
};
|
|
475
490
|
export var isElementPC = function isElementPC() {
|
|
476
491
|
return !isElementMobile();
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* 判断是否需要加载错误页
|
|
496
|
+
* @param {CashierSdkActionQueryResult} params
|
|
497
|
+
* @returns {boolean} - 是否需要加载错误页
|
|
498
|
+
*/
|
|
499
|
+
export var isLoadErrorPage = function isLoadErrorPage(params) {
|
|
500
|
+
var success = params.success,
|
|
501
|
+
paymentMethods = params.paymentMethods,
|
|
502
|
+
savedPaymentMethods = params.savedPaymentMethods,
|
|
503
|
+
orderAmountView = params.orderAmountView,
|
|
504
|
+
paymentAmountView = params.paymentAmountView;
|
|
505
|
+
|
|
506
|
+
// 校验是否存在支付方式
|
|
507
|
+
var hasValidPaymentMethods = paymentMethods && Array.isArray(paymentMethods) && paymentMethods.length > 0 || savedPaymentMethods && Array.isArray(savedPaymentMethods) && savedPaymentMethods.length > 0;
|
|
508
|
+
|
|
509
|
+
// 金额存在性校验
|
|
510
|
+
var hasAmountViews = !!orderAmountView && !!paymentAmountView;
|
|
511
|
+
|
|
512
|
+
// 错误条件判断(满足任意条件即需要展示错误页)
|
|
513
|
+
return !success ||
|
|
514
|
+
// 接口请求失败
|
|
515
|
+
!hasValidPaymentMethods ||
|
|
516
|
+
// 无有效支付方式
|
|
517
|
+
!hasAmountViews // 缺少金额展示
|
|
518
|
+
;
|
|
477
519
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ComponentApp from '../../plugin/component';
|
|
2
|
-
import { ComponentSignEnum, IappendIframeNodesParams, IcreateComponent, IoptionsParams, IPaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
|
|
2
|
+
import { ComponentSignEnum, EventPayloadContext, IappendIframeNodesParams, IcreateComponent, IoptionsParams, IPaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum, ValidationResult } from '../../types';
|
|
3
3
|
import CoreInstance from '../instance/index';
|
|
4
4
|
export declare const getComponentSign: (params: IPaymentSessionMetaData) => ComponentSignEnum;
|
|
5
5
|
export declare const parseSessionData: (sessionData: string) => [IPaymentSessionMetaData, string];
|
|
@@ -15,6 +15,7 @@ export declare class AMSComponent extends CoreInstance {
|
|
|
15
15
|
channelType: ComponentSignEnum[];
|
|
16
16
|
productSceneVersion: string;
|
|
17
17
|
timer: any;
|
|
18
|
+
private _validateResolveMap;
|
|
18
19
|
constructor(options: IAMSComponentOptions);
|
|
19
20
|
private parameterInitAndCheck;
|
|
20
21
|
private pluginAppendIframe;
|
|
@@ -52,4 +53,6 @@ export declare class AMSComponent extends CoreInstance {
|
|
|
52
53
|
* @param data - Transfer information in the submission interface according to your requirements (optional)
|
|
53
54
|
*/
|
|
54
55
|
submit(data?: Isubmit): Promise<unknown>;
|
|
56
|
+
protected _validateFields(): Promise<ValidationResult>;
|
|
57
|
+
protected _sendMessageToAPP(eventContext: EventPayloadContext): void;
|
|
55
58
|
}
|