@alipay/ams-checkout 0.0.1759909830-dev.1 → 0.0.1760520369-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/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/popupWindow.style.d.ts +19 -9
- package/esm/component/popupWindow.style.js +26 -13
- package/esm/config/index.d.ts +8 -7
- package/esm/config/index.js +8 -7
- package/esm/constant/index.d.ts +58 -0
- package/esm/constant/index.js +64 -1
- package/esm/core/component/element/EventCenter/index.d.ts +31 -0
- package/esm/core/component/element/EventCenter/index.js +178 -0
- package/esm/core/component/element/elementContainerService/containerService.d.ts +1 -0
- package/esm/core/component/element/elementContainerService/containerService.js +8 -2
- package/esm/core/component/element/elementController/index.d.ts +24 -3
- package/esm/core/component/element/elementController/index.js +533 -189
- package/esm/core/component/element/elementProcessor/addressProcessor.js +5 -6
- package/esm/core/component/element/elementProcessor/authProcessor.js +2 -3
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +2 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +55 -19
- package/esm/core/component/element/index.d.ts +6 -5
- package/esm/core/component/element/index.js +14 -3
- package/esm/core/component/element/mock.js +1 -0
- package/esm/core/component/element/type.d.ts +56 -4
- package/esm/core/component/element/type.js +61 -2
- package/esm/core/component/element/util.d.ts +21 -5
- package/esm/core/component/element/util.js +59 -7
- package/esm/foundation/core/index.js +27 -8
- package/esm/foundation/index.d.ts +1 -0
- package/esm/foundation/product-processor/easysafepay/index.js +4 -2
- package/esm/foundation/product-processor/element/index.js +1 -0
- package/esm/foundation/service/container/popup.d.ts +11 -0
- package/esm/foundation/service/container/popup.js +23 -2
- package/esm/foundation/service/log/keys.js +4 -0
- package/esm/foundation/service/requester/requester.js +2 -3
- package/esm/foundation/utils/payment_context_utils.js +1 -0
- package/esm/index.js +2 -1
- package/esm/plugin/component/cashierApp.d.ts +2 -0
- package/esm/plugin/component/cashierApp.js +2 -2
- package/esm/plugin/component/channel.js +20 -4
- package/esm/plugin/component/component.popup.style.d.ts +1 -0
- package/esm/plugin/component/component.popup.style.js +1 -1
- package/esm/plugin/component/index.d.ts +1 -0
- package/esm/plugin/component/index.js +9 -5
- package/esm/types/index.d.ts +22 -2
- package/esm/types/index.js +2 -1
- package/esm/util/index.js +4 -1
- package/esm/util/spm-map.d.ts +24 -2
- package/esm/util/spm-map.js +14 -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
@@ -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
|
-
import
|
24
|
+
import { ADDRESSElementAppVersion } from "../../../../config";
|
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: {
|
@@ -95,8 +95,7 @@ var AddressProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
95
95
|
environment = _this$options.env.environment,
|
96
96
|
analytics = _this$options.analytics,
|
97
97
|
locale = _this$options.locale;
|
98
|
-
var
|
99
|
-
var pageUrl = "/element-address/".concat(version, "/pages/address/index.html");
|
98
|
+
var pageUrl = "/element-address/".concat(ADDRESSElementAppVersion, "/pages/address/index.html");
|
100
99
|
return _generateIframeSrc({
|
101
100
|
paymentSession: paymentSession,
|
102
101
|
paymentSessionObj: paymentSessionObj,
|
@@ -17,8 +17,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
17
17
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
18
18
|
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; } }
|
19
19
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
20
|
+
import { AUTHElementAppVersion } from "../../../../config";
|
20
21
|
import { parseSessionData } from "../../index";
|
21
|
-
import PackageJson from "../../../../../package.json";
|
22
22
|
import { generateIframeSrc as _generateIframeSrc } from "../util";
|
23
23
|
import BaseElementProcessor from "./baseElementProcessor";
|
24
24
|
var AuthProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
@@ -69,8 +69,7 @@ var AuthProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
69
69
|
environment = _this$options.env.environment,
|
70
70
|
analytics = _this$options.analytics,
|
71
71
|
locale = _this$options.locale;
|
72
|
-
var
|
73
|
-
var pageUrl = "/auth-element/".concat(version, "/pages/element_auth/index.html");
|
72
|
+
var pageUrl = "/auth-element/".concat(AUTHElementAppVersion, "/pages/element_auth/index.html");
|
74
73
|
return _generateIframeSrc({
|
75
74
|
paymentSession: paymentSession,
|
76
75
|
paymentSessionObj: paymentSessionObj,
|
@@ -1,7 +1,9 @@
|
|
1
|
+
import { LogService } from "../../../../foundation/service/log";
|
1
2
|
import BaseElementProcessor from './baseElementProcessor';
|
2
3
|
declare class PaymentProcessor extends BaseElementProcessor {
|
3
4
|
private ApplePayService;
|
4
5
|
onReady(extraParam: any): void;
|
6
|
+
getLogger(): LogService;
|
5
7
|
private addEventListener;
|
6
8
|
private initApplePaySdk;
|
7
9
|
beforeMount(): void;
|
@@ -23,16 +23,16 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
23
23
|
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; }
|
24
24
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
25
25
|
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); }
|
26
|
-
import PackageJson from "../../../../../package.json";
|
27
26
|
import { EVENT } from "../../../../constant";
|
28
27
|
import { ServiceProvider } from "../../../../foundation/service";
|
29
28
|
import { ApplePaySdk, handleGooglePay, isSkipRenderPaymentMethod } from "../../../../plugin/component/channel";
|
30
|
-
import { LogConfig, Logger } from "../../../../util/logger";
|
31
29
|
import { queryParse } from "../../../../util";
|
30
|
+
import { LogConfig, Logger } from "../../../../util/logger";
|
32
31
|
import { parseSessionData } from "../../index";
|
33
32
|
import { oneAccount, sdkAction } from "../mock";
|
34
|
-
import { generateIframeSrc as _generateIframeSrc, isElementPC,
|
33
|
+
import { generateIframeSrc as _generateIframeSrc, isElementPad, isElementPC, safeStringify } from "../util";
|
35
34
|
import BaseElementProcessor from "./baseElementProcessor";
|
35
|
+
import { AMSPaymentElementAppVersion } from "../../../../config";
|
36
36
|
var logger = new Logger(LogConfig, true);
|
37
37
|
var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
38
38
|
_inherits(PaymentProcessor, _BaseElementProcessor);
|
@@ -54,11 +54,15 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
54
54
|
value: function onReady(extraParam) {
|
55
55
|
var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
|
56
56
|
var paymentContext = this.elementContainer.getPaymentContext();
|
57
|
+
this.getLogger().logInfo({
|
58
|
+
title: 'sdk_event_renderComponent'
|
59
|
+
});
|
57
60
|
this.eventCenter.dispatchToApp({
|
58
61
|
event: 'renderComponent',
|
59
62
|
data: {
|
60
63
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
61
|
-
|
64
|
+
// 极简架构需要全量sessionData, 服务端与谦评估没得影响
|
65
|
+
paymentSessionData: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSession,
|
62
66
|
queryResult: extraParam === null || extraParam === void 0 ? void 0 : extraParam.originActionQueryResult,
|
63
67
|
envInfo: {
|
64
68
|
screenHeight: screen.height,
|
@@ -79,6 +83,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
79
83
|
}
|
80
84
|
});
|
81
85
|
}
|
86
|
+
}, {
|
87
|
+
key: "getLogger",
|
88
|
+
value: function getLogger() {
|
89
|
+
return ServiceProvider.getInstance(this.instanceId).getService('Log');
|
90
|
+
}
|
82
91
|
}, {
|
83
92
|
key: "addEventListener",
|
84
93
|
value: function addEventListener() {
|
@@ -214,13 +223,12 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
214
223
|
locale = _this$options.locale;
|
215
224
|
var _ref3 = paymentSessionObj || {},
|
216
225
|
extendInfo = _ref3.extendInfo;
|
217
|
-
var
|
218
|
-
var pageUrl = "/elements/".concat(version, "/pages/element_payment/index.html");
|
226
|
+
var pageUrl = "/elements/".concat(AMSPaymentElementAppVersion, "/pages/element_payment/index.html");
|
219
227
|
try {
|
220
228
|
var _JSON$parse;
|
221
229
|
var expressCheckout = JSON.parse((_JSON$parse = JSON.parse(extendInfo)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.expressCheckout);
|
222
230
|
if (expressCheckout) {
|
223
|
-
pageUrl = "/elements/".concat(
|
231
|
+
pageUrl = "/elements/".concat(AMSPaymentElementAppVersion, "/pages/express_checkout/index.html");
|
224
232
|
}
|
225
233
|
} catch (error) {}
|
226
234
|
var url = _generateIframeSrc({
|
@@ -241,19 +249,21 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
241
249
|
key: "obtainData",
|
242
250
|
value: function () {
|
243
251
|
var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
244
|
-
var _paymentSessionObj$co
|
245
|
-
|
252
|
+
var _paymentSessionObj$co,
|
253
|
+
_this3 = this;
|
254
|
+
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
255
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
247
256
|
while (1) switch (_context2.prev = _context2.next) {
|
248
257
|
case 0:
|
249
258
|
requestService = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
250
259
|
_this$elementContaine8 = this.elementContainer.getPaymentContext(), paymentSession = _this$elementContaine8.paymentSession, paymentSessionObj = _this$elementContaine8.paymentSessionObj, displayInfo = _this$elementContaine8.displayInfo;
|
251
|
-
|
260
|
+
_displayInfo = displayInfo;
|
261
|
+
debugProps = _displayInfo.debugProps;
|
252
262
|
_this$options2 = this.options, environment = _this$options2.env.environment, locale = _this$options2.locale;
|
253
263
|
_ref4 = paymentSessionObj || {}, paymentSessionConfig = _ref4.paymentSessionConfig;
|
254
264
|
hostSign = paymentSession.split('&&')[1] || '';
|
255
265
|
isConnect = paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect;
|
256
|
-
LOCAL_MOCK =
|
266
|
+
LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock);
|
257
267
|
_queryParse = queryParse(this.getElementUrl()), appType = _queryParse.appType;
|
258
268
|
terminalType = isElementPad() ? 'WEB' : appType ? 'APP' : isElementPC() ? 'WEB' : 'WAP';
|
259
269
|
generateActionQueryPromise = function generateActionQueryPromise() {
|
@@ -267,7 +277,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
267
277
|
}
|
268
278
|
var sdkRequestData = {
|
269
279
|
paymentSessionConfig: paymentSessionConfig,
|
270
|
-
paymentSessionData: paymentSession
|
280
|
+
paymentSessionData: paymentSession,
|
281
|
+
extParams: {
|
282
|
+
// 必传,服务端用于根据前端传入locale判断是否使用用户偏好语言
|
283
|
+
isUserPreferredLocale: true
|
284
|
+
}
|
271
285
|
};
|
272
286
|
if (displayInfo !== null && displayInfo !== void 0 && (_displayInfo$merchant = displayInfo.merchantAppointParam) !== null && _displayInfo$merchant !== void 0 && _displayInfo$merchant.storedCard) {
|
273
287
|
sdkRequestData.merchantAppointParam = displayInfo.merchantAppointParam;
|
@@ -286,9 +300,31 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
286
300
|
// TODO dev环境接口超时
|
287
301
|
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
288
302
|
}).then(function (result) {
|
303
|
+
if (!result.success) {
|
304
|
+
_this3.getLogger().logError({
|
305
|
+
title: 'sdk_event_sdkQuery_failed'
|
306
|
+
}, {
|
307
|
+
config: safeStringify(paymentSessionConfig),
|
308
|
+
errorMessage: safeStringify((result === null || result === void 0 ? void 0 : result.errorMessage) || ''),
|
309
|
+
rpcTraceId: result === null || result === void 0 ? void 0 : result.traceId
|
310
|
+
});
|
311
|
+
} else {
|
312
|
+
_this3.getLogger().logInfo({
|
313
|
+
title: 'sdk_event_sdkQueryEnd'
|
314
|
+
}, {
|
315
|
+
config: safeStringify(paymentSessionConfig),
|
316
|
+
rpcTraceId: result === null || result === void 0 ? void 0 : result.traceId
|
317
|
+
});
|
318
|
+
}
|
289
319
|
resolve(result);
|
290
|
-
}, function () {
|
291
|
-
reject(
|
320
|
+
}, function (e) {
|
321
|
+
reject(e);
|
322
|
+
_this3.getLogger().logError({
|
323
|
+
title: 'sdk_event_sdkQuery_failed'
|
324
|
+
}, {
|
325
|
+
config: safeStringify(paymentSessionConfig),
|
326
|
+
errorMessage: safeStringify(e)
|
327
|
+
});
|
292
328
|
});
|
293
329
|
});
|
294
330
|
};
|
@@ -317,14 +353,14 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
317
353
|
'Operation-Type': 'com.ipay.iexpfront.one.account.query'
|
318
354
|
}).then(function (result) {
|
319
355
|
resolve(result);
|
320
|
-
}, function () {
|
321
|
-
reject(
|
356
|
+
}, function (e) {
|
357
|
+
reject(e);
|
322
358
|
});
|
323
359
|
});
|
324
360
|
};
|
325
|
-
_context2.next =
|
361
|
+
_context2.next = 15;
|
326
362
|
return Promise.all(isConnect ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
|
327
|
-
case
|
363
|
+
case 15:
|
328
364
|
_yield$Promise$all = _context2.sent;
|
329
365
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
330
366
|
originActionQueryResult = _yield$Promise$all2[0];
|
@@ -337,7 +373,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
337
373
|
originActionQueryResult: originActionQueryResult,
|
338
374
|
originOneAccountQueryResult: originOneAccountQueryResult
|
339
375
|
});
|
340
|
-
case
|
376
|
+
case 21:
|
341
377
|
case "end":
|
342
378
|
return _context2.stop();
|
343
379
|
}
|
@@ -1,12 +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
|
-
|
9
|
-
|
10
|
-
|
7
|
+
mount(renderOptions: PaymentMountOptions, sdkSelector: string): Promise<import("./type").ICommonApiResponse>;
|
8
|
+
validateFields(): Promise<{
|
9
|
+
isValid: boolean;
|
10
|
+
}>;
|
11
|
+
submitPayment(): Promise<import("./type").IPaymentApiResponse>;
|
11
12
|
destroy(): void;
|
12
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) {
|
@@ -49,10 +55,15 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
49
55
|
appearance: this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.appearance
|
50
56
|
}, renderOptions), sdkSelector);
|
51
57
|
}
|
58
|
+
}, {
|
59
|
+
key: "validateFields",
|
60
|
+
value: function validateFields() {
|
61
|
+
return this.controller.validateFields();
|
62
|
+
}
|
52
63
|
}, {
|
53
64
|
key: "submitPayment",
|
54
65
|
value: function submitPayment() {
|
55
|
-
this.controller.submitPayment();
|
66
|
+
return this.controller.submitPayment();
|
56
67
|
}
|
57
68
|
}, {
|
58
69
|
key: "destroy",
|
@@ -10,7 +10,8 @@ export declare enum ElementPaymentEvent {
|
|
10
10
|
CAPTURE_ASSET = "onCaptureAsset",
|
11
11
|
SIGN_OUT = "onSignout",
|
12
12
|
BLUR = "onBlur",
|
13
|
-
|
13
|
+
SUBMIT_PAY = "submitPay",
|
14
|
+
VALIDATE = "onValidate",
|
14
15
|
SUBMIT_RISK = "onSubmitRisk",
|
15
16
|
AFTER_SUBMIT = "onAfterSubmit",
|
16
17
|
SIZE_CHANGE = "onSizeChange",
|
@@ -35,6 +36,20 @@ export declare enum ElementType {
|
|
35
36
|
address = "address",
|
36
37
|
payment = "payment"
|
37
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
|
+
}
|
38
53
|
export declare const MountElementType: {
|
39
54
|
auth: ElementPaymentMethod;
|
40
55
|
address: ElementPaymentMethod;
|
@@ -126,6 +141,10 @@ export interface LinkAuthMountOptions extends BaseMountOptions {
|
|
126
141
|
theme?: ThemeType;
|
127
142
|
};
|
128
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
|
+
};
|
129
148
|
export interface PaymentMountOptions extends BaseMountOptions {
|
130
149
|
type: ElementType.payment;
|
131
150
|
appearance?: {
|
@@ -133,7 +152,7 @@ export interface PaymentMountOptions extends BaseMountOptions {
|
|
133
152
|
layout?: {
|
134
153
|
type: PaymentElementLayout;
|
135
154
|
};
|
136
|
-
variables?: {
|
155
|
+
variables?: Partial<CompatibleVariables<{
|
137
156
|
'content-primary': string;
|
138
157
|
'content-secondary': string;
|
139
158
|
'content-tertiary': string;
|
@@ -158,7 +177,8 @@ export interface PaymentMountOptions extends BaseMountOptions {
|
|
158
177
|
'radius-module': string;
|
159
178
|
'radius-component': string;
|
160
179
|
'radius-button': string;
|
161
|
-
|
180
|
+
'warpper-padding': string;
|
181
|
+
}>>;
|
162
182
|
};
|
163
183
|
notRedirectAfterComplete?: boolean;
|
164
184
|
merchantAppointParam?: IMerchantAppointParam;
|
@@ -188,6 +208,8 @@ export interface ValidateResult<T = {}> {
|
|
188
208
|
success: boolean;
|
189
209
|
data: {
|
190
210
|
success: boolean;
|
211
|
+
status: PaymentStatus;
|
212
|
+
message?: string;
|
191
213
|
data: T;
|
192
214
|
};
|
193
215
|
}
|
@@ -359,7 +381,7 @@ export interface IElementOptions {
|
|
359
381
|
appearance?: {
|
360
382
|
theme: ThemeType.Default | ThemeType.Night;
|
361
383
|
};
|
362
|
-
onEventCallback?: ({ code, message, result }: {
|
384
|
+
onEventCallback?: ({ code, message, result, }: {
|
363
385
|
code: EventCallbackCode;
|
364
386
|
message: string;
|
365
387
|
result?: any;
|
@@ -387,4 +409,34 @@ export interface IToastOptions {
|
|
387
409
|
icon?: 'SUCCESS' | 'FAIL';
|
388
410
|
spin?: boolean;
|
389
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
|
+
}
|
390
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); }
|
@@ -10,7 +23,8 @@ export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
|
|
10
23
|
ElementPaymentEvent["CAPTURE_ASSET"] = "onCaptureAsset";
|
11
24
|
ElementPaymentEvent["SIGN_OUT"] = "onSignout";
|
12
25
|
ElementPaymentEvent["BLUR"] = "onBlur";
|
13
|
-
ElementPaymentEvent["
|
26
|
+
ElementPaymentEvent["SUBMIT_PAY"] = "submitPay";
|
27
|
+
ElementPaymentEvent["VALIDATE"] = "onValidate";
|
14
28
|
ElementPaymentEvent["SUBMIT_RISK"] = "onSubmitRisk";
|
15
29
|
ElementPaymentEvent["AFTER_SUBMIT"] = "onAfterSubmit";
|
16
30
|
ElementPaymentEvent["SIZE_CHANGE"] = "onSizeChange";
|
@@ -35,6 +49,22 @@ export var ElementType = /*#__PURE__*/function (ElementType) {
|
|
35
49
|
ElementType["payment"] = "payment";
|
36
50
|
return ElementType;
|
37
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
|
+
}({});
|
38
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);
|
39
69
|
export var ThemeType = /*#__PURE__*/function (ThemeType) {
|
40
70
|
ThemeType["NostalgicGray"] = "nostalgicGray";
|
@@ -70,6 +100,11 @@ export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
|
|
70
100
|
ELEMENT_ENVIRONMENT["SANDBOX"] = "SANDBOX";
|
71
101
|
return ELEMENT_ENVIRONMENT;
|
72
102
|
}({});
|
103
|
+
|
104
|
+
// 将短横线命名转为小驼峰
|
105
|
+
|
106
|
+
// 同时兼容短横线和小驼峰两种键名
|
107
|
+
|
73
108
|
// export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
|
74
109
|
|
75
110
|
export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbackName) {
|
@@ -86,4 +121,28 @@ var AccountStatusEnum = /*#__PURE__*/function (AccountStatusEnum) {
|
|
86
121
|
AccountStatusEnum["EFFECTIVE"] = "EFFECTIVE";
|
87
122
|
AccountStatusEnum["UNREGISTERED"] = "UNREGISTERED";
|
88
123
|
return AccountStatusEnum;
|
89
|
-
}(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,10 @@ 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;
|
85
|
+
export declare const safeStringify: (payload: any, defaultValue?: string) => string;
|