@alipay/ams-checkout 0.0.1758505806-dev.5 → 0.0.1758783821-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -17
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/popupWindow.style.d.ts +18 -9
- package/esm/component/popupWindow.style.js +21 -11
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +37 -0
- package/esm/constant/index.js +38 -0
- package/esm/core/component/element/EventCenter/index.d.ts +29 -0
- package/esm/core/component/element/EventCenter/index.js +141 -0
- package/esm/core/component/element/elementContainerService/containerService.js +3 -2
- package/esm/core/component/element/elementController/index.d.ts +28 -2
- package/esm/core/component/element/elementController/index.js +453 -190
- 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 +9 -1
- package/esm/core/component/element/index.js +10 -2
- package/esm/core/component/element/type.d.ts +37 -4
- package/esm/core/component/element/type.js +45 -2
- package/esm/core/component/element/util.d.ts +17 -4
- package/esm/core/component/element/util.js +45 -6
- 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 +2 -0
- package/esm/foundation/service/requester/requester.js +2 -3
- package/esm/plugin/component/channel.js +1 -0
- package/esm/types/index.d.ts +5 -1
- package/esm/util/spm-map.d.ts +2 -0
- package/esm/util/spm-map.js +2 -1
- package/package.json +7 -12
|
@@ -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
|
}
|
|
@@ -7,6 +7,14 @@ export declare class ElementComponent {
|
|
|
7
7
|
mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
|
|
8
8
|
mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
|
9
9
|
mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
|
|
10
|
-
|
|
10
|
+
validateFields(): Promise<{
|
|
11
|
+
isValid: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
submitPayment(): Promise<import("./type").IMerchantResponse | {
|
|
14
|
+
error: {
|
|
15
|
+
code: string;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
11
19
|
destroy(): void;
|
|
12
20
|
}
|
|
@@ -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
|
}
|
|
@@ -49,10 +52,15 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
49
52
|
appearance: this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.appearance
|
|
50
53
|
}, renderOptions), sdkSelector);
|
|
51
54
|
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "validateFields",
|
|
57
|
+
value: function validateFields() {
|
|
58
|
+
return this.controller.validateFields();
|
|
59
|
+
}
|
|
52
60
|
}, {
|
|
53
61
|
key: "submitPayment",
|
|
54
62
|
value: function submitPayment() {
|
|
55
|
-
this.controller.submitPayment();
|
|
63
|
+
return this.controller.submitPayment();
|
|
56
64
|
}
|
|
57
65
|
}, {
|
|
58
66
|
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",
|
|
@@ -126,6 +127,10 @@ export interface LinkAuthMountOptions extends BaseMountOptions {
|
|
|
126
127
|
theme?: ThemeType;
|
|
127
128
|
};
|
|
128
129
|
}
|
|
130
|
+
type ToCamelCase<S extends string> = S extends `${infer First}-${infer Rest}` ? `${First}${Capitalize<ToCamelCase<Rest>>}` : S;
|
|
131
|
+
type CompatibleVariables<T extends Record<string, string>> = {
|
|
132
|
+
[K in keyof T as K | ToCamelCase<K & string>]: string;
|
|
133
|
+
};
|
|
129
134
|
export interface PaymentMountOptions extends BaseMountOptions {
|
|
130
135
|
type: ElementType.payment;
|
|
131
136
|
appearance?: {
|
|
@@ -133,7 +138,7 @@ export interface PaymentMountOptions extends BaseMountOptions {
|
|
|
133
138
|
layout?: {
|
|
134
139
|
type: PaymentElementLayout;
|
|
135
140
|
};
|
|
136
|
-
variables?: {
|
|
141
|
+
variables?: Partial<CompatibleVariables<{
|
|
137
142
|
'content-primary': string;
|
|
138
143
|
'content-secondary': string;
|
|
139
144
|
'content-tertiary': string;
|
|
@@ -158,7 +163,8 @@ export interface PaymentMountOptions extends BaseMountOptions {
|
|
|
158
163
|
'radius-module': string;
|
|
159
164
|
'radius-component': string;
|
|
160
165
|
'radius-button': string;
|
|
161
|
-
|
|
166
|
+
'warpper-padding': string;
|
|
167
|
+
}>>;
|
|
162
168
|
};
|
|
163
169
|
notRedirectAfterComplete?: boolean;
|
|
164
170
|
merchantAppointParam?: IMerchantAppointParam;
|
|
@@ -359,7 +365,7 @@ export interface IElementOptions {
|
|
|
359
365
|
appearance?: {
|
|
360
366
|
theme: ThemeType.Default | ThemeType.Night;
|
|
361
367
|
};
|
|
362
|
-
onEventCallback?: ({ code, message, result }: {
|
|
368
|
+
onEventCallback?: ({ code, message, result, }: {
|
|
363
369
|
code: EventCallbackCode;
|
|
364
370
|
message: string;
|
|
365
371
|
result?: any;
|
|
@@ -387,4 +393,31 @@ export interface IToastOptions {
|
|
|
387
393
|
icon?: 'SUCCESS' | 'FAIL';
|
|
388
394
|
spin?: boolean;
|
|
389
395
|
}
|
|
396
|
+
export interface IMerchantResponse {
|
|
397
|
+
success?: boolean;
|
|
398
|
+
error?: {
|
|
399
|
+
code: string;
|
|
400
|
+
message?: string;
|
|
401
|
+
traceId?: string;
|
|
402
|
+
context?: any;
|
|
403
|
+
};
|
|
404
|
+
status?: string;
|
|
405
|
+
}
|
|
406
|
+
export declare class InvalidElementConfigError extends Error {
|
|
407
|
+
errors: Array<{
|
|
408
|
+
field: keyof IElementOptions;
|
|
409
|
+
message: string;
|
|
410
|
+
}>;
|
|
411
|
+
constructor(errors: Array<{
|
|
412
|
+
field: keyof IElementOptions;
|
|
413
|
+
message: string;
|
|
414
|
+
}>);
|
|
415
|
+
}
|
|
416
|
+
export declare enum EXPOSURE_API_EVENT {
|
|
417
|
+
DESTORY = "destroy",
|
|
418
|
+
MOUNT = "mount",
|
|
419
|
+
SUBMITPAYMENT = "submitPayment",
|
|
420
|
+
VALIDATAFIELDS = "validateFields",
|
|
421
|
+
UPDATEPAYMENT = "updatePayment"
|
|
422
|
+
}
|
|
390
423
|
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";
|
|
@@ -70,6 +84,11 @@ export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
|
|
|
70
84
|
ELEMENT_ENVIRONMENT["SANDBOX"] = "SANDBOX";
|
|
71
85
|
return ELEMENT_ENVIRONMENT;
|
|
72
86
|
}({});
|
|
87
|
+
|
|
88
|
+
// 将短横线命名转为小驼峰
|
|
89
|
+
|
|
90
|
+
// 同时兼容短横线和小驼峰两种键名
|
|
91
|
+
|
|
73
92
|
// export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
|
|
74
93
|
|
|
75
94
|
export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbackName) {
|
|
@@ -86,4 +105,28 @@ var AccountStatusEnum = /*#__PURE__*/function (AccountStatusEnum) {
|
|
|
86
105
|
AccountStatusEnum["EFFECTIVE"] = "EFFECTIVE";
|
|
87
106
|
AccountStatusEnum["UNREGISTERED"] = "UNREGISTERED";
|
|
88
107
|
return AccountStatusEnum;
|
|
89
|
-
}(AccountStatusEnum || {}); // element 接口start
|
|
108
|
+
}(AccountStatusEnum || {}); // element 接口start
|
|
109
|
+
export var InvalidElementConfigError = /*#__PURE__*/function (_Error) {
|
|
110
|
+
_inherits(InvalidElementConfigError, _Error);
|
|
111
|
+
var _super = _createSuper(InvalidElementConfigError);
|
|
112
|
+
function InvalidElementConfigError(errors) {
|
|
113
|
+
var _this;
|
|
114
|
+
_classCallCheck(this, InvalidElementConfigError);
|
|
115
|
+
var errorMessages = errors.map(function (e) {
|
|
116
|
+
return "".concat(e.field, ": ").concat(e.message);
|
|
117
|
+
});
|
|
118
|
+
_this = _super.call(this, "Invalid config:\n".concat(errorMessages.join('\n')));
|
|
119
|
+
_this.errors = errors;
|
|
120
|
+
_this.name = 'InvalidElementConfigError';
|
|
121
|
+
return _this;
|
|
122
|
+
}
|
|
123
|
+
return _createClass(InvalidElementConfigError);
|
|
124
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
125
|
+
export var EXPOSURE_API_EVENT = /*#__PURE__*/function (EXPOSURE_API_EVENT) {
|
|
126
|
+
EXPOSURE_API_EVENT["DESTORY"] = "destroy";
|
|
127
|
+
EXPOSURE_API_EVENT["MOUNT"] = "mount";
|
|
128
|
+
EXPOSURE_API_EVENT["SUBMITPAYMENT"] = "submitPayment";
|
|
129
|
+
EXPOSURE_API_EVENT["VALIDATAFIELDS"] = "validateFields";
|
|
130
|
+
EXPOSURE_API_EVENT["UPDATEPAYMENT"] = "updatePayment";
|
|
131
|
+
return EXPOSURE_API_EVENT;
|
|
132
|
+
}({});
|
|
@@ -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,7 +20,10 @@ 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
|
* 校验当前sdkSelector结点是否存在
|
|
@@ -32,6 +35,10 @@ export declare function checkCanMount({ sdkSelector, containerService, status, }
|
|
|
32
35
|
}): {
|
|
33
36
|
success: boolean;
|
|
34
37
|
errorMsg?: string;
|
|
38
|
+
error?: {
|
|
39
|
+
code: string;
|
|
40
|
+
message?: string;
|
|
41
|
+
};
|
|
35
42
|
};
|
|
36
43
|
export declare function checkCanUpdate({ status, paymentContainerService, newPaymentSessionData, oldPaymentSessionData, }: {
|
|
37
44
|
status: IElementStatus;
|
|
@@ -67,3 +74,9 @@ export declare const isElementMobile: () => boolean;
|
|
|
67
74
|
*/
|
|
68
75
|
export declare const isElementPad: () => boolean;
|
|
69
76
|
export declare const isElementPC: () => boolean;
|
|
77
|
+
/**
|
|
78
|
+
* 判断是否需要加载错误页
|
|
79
|
+
* @param {CashierSdkActionQueryResult} params
|
|
80
|
+
* @returns {boolean} - 是否需要加载错误页
|
|
81
|
+
*/
|
|
82
|
+
export declare const isLoadErrorPage: (params: CashierSdkActionQueryResult) => boolean;
|
|
@@ -25,15 +25,24 @@ 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
|
+
errors.push({
|
|
31
|
+
field: 'sessionData',
|
|
32
|
+
message: 'sessionData is empty'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (errors.length > 0) {
|
|
29
36
|
var _options$onEventCallb;
|
|
30
37
|
options === null || options === void 0 || (_options$onEventCallb = options.onEventCallback) === null || _options$onEventCallb === void 0 || _options$onEventCallb.call(options, {
|
|
31
38
|
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
|
32
39
|
message: 'sessionData is empty'
|
|
33
40
|
});
|
|
34
|
-
return false;
|
|
35
41
|
}
|
|
36
|
-
return
|
|
42
|
+
return {
|
|
43
|
+
isValid: errors.length === 0,
|
|
44
|
+
errors: errors
|
|
45
|
+
};
|
|
37
46
|
};
|
|
38
47
|
|
|
39
48
|
/**
|
|
@@ -50,13 +59,15 @@ export function checkCanMount(_ref) {
|
|
|
50
59
|
console.error("Element with selector ".concat(sdkSelector, " not found."));
|
|
51
60
|
return {
|
|
52
61
|
success: false,
|
|
53
|
-
errorMsg: "Element with selector ".concat(sdkSelector, " not found.")
|
|
62
|
+
errorMsg: "Element with selector ".concat(sdkSelector, " not found."),
|
|
63
|
+
error: ERRORMESSAGE.PARAM_INVALID
|
|
54
64
|
};
|
|
55
65
|
}
|
|
56
66
|
if (status === IElementStatus.DESTROYED) {
|
|
57
67
|
return {
|
|
58
68
|
success: false,
|
|
59
|
-
errorMsg: "Creating components in the destroyed state is forbidden."
|
|
69
|
+
errorMsg: "Creating components in the destroyed state is forbidden.",
|
|
70
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
60
71
|
};
|
|
61
72
|
}
|
|
62
73
|
if (status === IElementStatus.READY) {
|
|
@@ -67,7 +78,8 @@ export function checkCanMount(_ref) {
|
|
|
67
78
|
if (containerService) {
|
|
68
79
|
return {
|
|
69
80
|
success: false,
|
|
70
|
-
errorMsg: "SDK status error."
|
|
81
|
+
errorMsg: "SDK status error.",
|
|
82
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
71
83
|
};
|
|
72
84
|
}
|
|
73
85
|
return {
|
|
@@ -429,7 +441,7 @@ export function showToast() {
|
|
|
429
441
|
textAlign: 'center',
|
|
430
442
|
marginTop: '12px',
|
|
431
443
|
lineHeight: '20px',
|
|
432
|
-
fontFamily:
|
|
444
|
+
fontFamily: 'Noto Sans',
|
|
433
445
|
fontWeight: 400,
|
|
434
446
|
fontSize: '14px'
|
|
435
447
|
}
|
|
@@ -474,4 +486,31 @@ export var isElementPad = function isElementPad() {
|
|
|
474
486
|
};
|
|
475
487
|
export var isElementPC = function isElementPC() {
|
|
476
488
|
return !isElementMobile();
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* 判断是否需要加载错误页
|
|
493
|
+
* @param {CashierSdkActionQueryResult} params
|
|
494
|
+
* @returns {boolean} - 是否需要加载错误页
|
|
495
|
+
*/
|
|
496
|
+
export var isLoadErrorPage = function isLoadErrorPage(params) {
|
|
497
|
+
var success = params.success,
|
|
498
|
+
paymentMethods = params.paymentMethods,
|
|
499
|
+
savedPaymentMethods = params.savedPaymentMethods,
|
|
500
|
+
orderAmountView = params.orderAmountView,
|
|
501
|
+
paymentAmountView = params.paymentAmountView;
|
|
502
|
+
|
|
503
|
+
// 校验是否存在支付方式
|
|
504
|
+
var hasValidPaymentMethods = paymentMethods && Array.isArray(paymentMethods) && paymentMethods.length > 0 || savedPaymentMethods && Array.isArray(savedPaymentMethods) && savedPaymentMethods.length > 0;
|
|
505
|
+
|
|
506
|
+
// 金额存在性校验
|
|
507
|
+
var hasAmountViews = !!orderAmountView && !!paymentAmountView;
|
|
508
|
+
|
|
509
|
+
// 错误条件判断(满足任意条件即需要展示错误页)
|
|
510
|
+
return !success ||
|
|
511
|
+
// 接口请求失败
|
|
512
|
+
!hasValidPaymentMethods ||
|
|
513
|
+
// 无有效支付方式
|
|
514
|
+
!hasAmountViews // 缺少金额展示
|
|
515
|
+
;
|
|
477
516
|
};
|
|
@@ -6,6 +6,11 @@ export type IPopUpParams = {
|
|
|
6
6
|
platform: PlatformEnum;
|
|
7
7
|
showCloseOnLoading: boolean;
|
|
8
8
|
onCloseOnLoading: () => void;
|
|
9
|
+
textDirection?: 'ltr' | 'rtl';
|
|
10
|
+
loadingConfig?: {
|
|
11
|
+
theme?: string;
|
|
12
|
+
backgroundPrimary?: string;
|
|
13
|
+
};
|
|
9
14
|
};
|
|
10
15
|
/**
|
|
11
16
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
|
@@ -15,6 +20,12 @@ export declare class PopupManager {
|
|
|
15
20
|
private popupUrlQuery;
|
|
16
21
|
popupApp: HTMLIFrameElement;
|
|
17
22
|
setPopupUrlQuery(queryParams: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* 合并URL参数, 优先加载弹窗参数作为基准, 用baseUrl参数覆盖弹窗参数
|
|
25
|
+
* @param baseUrl 基础URL
|
|
26
|
+
* @returns 合并后的URL
|
|
27
|
+
*/
|
|
28
|
+
private mergeUrlParams;
|
|
18
29
|
popup(data: IPopUpParams): Promise<void>;
|
|
19
30
|
pop(): void;
|
|
20
31
|
}
|
|
@@ -25,6 +25,26 @@ export var PopupManager = /*#__PURE__*/function () {
|
|
|
25
25
|
value: function setPopupUrlQuery(queryParams) {
|
|
26
26
|
this.popupUrlQuery = queryParams;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* 合并URL参数, 优先加载弹窗参数作为基准, 用baseUrl参数覆盖弹窗参数
|
|
30
|
+
* @param baseUrl 基础URL
|
|
31
|
+
* @returns 合并后的URL
|
|
32
|
+
*/
|
|
33
|
+
}, {
|
|
34
|
+
key: "mergeUrlParams",
|
|
35
|
+
value: function mergeUrlParams(baseUrl) {
|
|
36
|
+
var urlObj = new URL(baseUrl);
|
|
37
|
+
// 优先加载弹窗参数作为基准
|
|
38
|
+
var mergedParams = new URLSearchParams(this.popupUrlQuery.replace(/^(?:\?|%3F)/i, ''));
|
|
39
|
+
// 用baseUrl参数覆盖弹窗参数(set方法自动覆盖)
|
|
40
|
+
urlObj.searchParams.forEach(function (value, key) {
|
|
41
|
+
mergedParams.set(key, value);
|
|
42
|
+
});
|
|
43
|
+
// 将合并后的参数设置到URL对象中
|
|
44
|
+
urlObj.search = mergedParams.toString();
|
|
45
|
+
// 返回合并后的URL
|
|
46
|
+
return urlObj.toString();
|
|
47
|
+
}
|
|
28
48
|
}, {
|
|
29
49
|
key: "popup",
|
|
30
50
|
value: function () {
|
|
@@ -45,7 +65,7 @@ export var PopupManager = /*#__PURE__*/function () {
|
|
|
45
65
|
pageUrl = data.url;
|
|
46
66
|
_context.prev = 6;
|
|
47
67
|
if (this.popupUrlQuery) {
|
|
48
|
-
pageUrl =
|
|
68
|
+
pageUrl = this.mergeUrlParams(data.url);
|
|
49
69
|
}
|
|
50
70
|
isLoad = false;
|
|
51
71
|
_context.next = 11;
|
|
@@ -55,7 +75,8 @@ export var PopupManager = /*#__PURE__*/function () {
|
|
|
55
75
|
url: pageUrl,
|
|
56
76
|
loadingConfig: undefined,
|
|
57
77
|
showCloseOnLoading: data.showCloseOnLoading,
|
|
58
|
-
onCloseOnLoading: data.onCloseOnLoading
|
|
78
|
+
onCloseOnLoading: data.onCloseOnLoading,
|
|
79
|
+
textDirection: data === null || data === void 0 ? void 0 : data.textDirection
|
|
59
80
|
});
|
|
60
81
|
case 11:
|
|
61
82
|
this.popupApp = _context.sent;
|
|
@@ -12,8 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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 axios from 'axios';
|
|
14
14
|
import { ServiceProvider } from '..';
|
|
15
|
-
import { errorEnum } from "./deps";
|
|
16
|
-
import { appId, device, fomatGetwayError, get, hostSignMap, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
|
|
15
|
+
import { appId, device, errorEnum, fomatGetwayError, get, hostSignMap, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* @author congle.zzq <congle.zzq@alipay.com>
|
|
@@ -116,7 +115,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
|
116
115
|
errorMessage: _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message
|
|
117
116
|
});
|
|
118
117
|
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
|
|
119
|
-
_errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode)
|
|
118
|
+
_errorCode = timeoutCode || (_error === null || _error === void 0 ? void 0 : _error.errorCode);
|
|
120
119
|
this.reportRequestTimeCost({
|
|
121
120
|
title: 'a3753.b101271.c388193.d521387',
|
|
122
121
|
name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
|
package/esm/types/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { IApplePayContactField } from '../plugin/applepay/interface';
|
|
9
9
|
export type onChange = () => onCnageResult;
|
|
10
|
-
export { ElementType, PaymentElementLayout, ThemeType, type IElementOptions } from '../core/component/oldElement/type';
|
|
10
|
+
export { ElementType, PaymentElementLayout, ThemeType, type IElementOptions, } from '../core/component/oldElement/type';
|
|
11
11
|
interface onCnageResult {
|
|
12
12
|
complete: boolean;
|
|
13
13
|
addressValue: AddressItem[];
|
|
@@ -594,6 +594,10 @@ export interface CashierSdkActionQueryResult {
|
|
|
594
594
|
channelOrderId?: string;
|
|
595
595
|
};
|
|
596
596
|
errorActions?: Record<string, string>;
|
|
597
|
+
orderAmountView?: IAmountView;
|
|
598
|
+
paymentAmountView?: IAmountView;
|
|
599
|
+
paymentMethods?: IPaymentMethod[];
|
|
600
|
+
savedPaymentMethods?: IPaymentMethod[];
|
|
597
601
|
}
|
|
598
602
|
export interface CashierSdkActionQuerySessionResult extends IPaymentSessionMetaData {
|
|
599
603
|
success: boolean;
|
package/esm/util/spm-map.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const ELEMENT_SPM_MAP: {
|
|
|
7
7
|
auto_apple_pay_start: string;
|
|
8
8
|
auto_apple_pay_failed: string;
|
|
9
9
|
auto_apple_pay_success: string;
|
|
10
|
+
sdk_element_handleHeartBeat: string;
|
|
10
11
|
};
|
|
11
12
|
export declare const SPM_MAP: {
|
|
12
13
|
sdk_event_mount_element: string;
|
|
@@ -17,6 +18,7 @@ export declare const SPM_MAP: {
|
|
|
17
18
|
auto_apple_pay_start: string;
|
|
18
19
|
auto_apple_pay_failed: string;
|
|
19
20
|
auto_apple_pay_success: string;
|
|
21
|
+
sdk_element_handleHeartBeat: string;
|
|
20
22
|
sdk_error_runtime_error: string;
|
|
21
23
|
sdk_event_sdkQuery_failed: string;
|
|
22
24
|
container_error_error_insert_js: string;
|
package/esm/util/spm-map.js
CHANGED
|
@@ -14,7 +14,8 @@ export var ELEMENT_SPM_MAP = {
|
|
|
14
14
|
multiple_instance_error: 'a3753.b101271.c403950',
|
|
15
15
|
auto_apple_pay_start: 'a3753.b107385.c398110',
|
|
16
16
|
auto_apple_pay_failed: 'a3753.b107385.c398111',
|
|
17
|
-
auto_apple_pay_success: 'a3753.b107385.c398112'
|
|
17
|
+
auto_apple_pay_success: 'a3753.b107385.c398112',
|
|
18
|
+
sdk_element_handleHeartBeat: 'a3753.b101271.c388217.d624449'
|
|
18
19
|
};
|
|
19
20
|
export var SPM_MAP = _objectSpread({
|
|
20
21
|
sdk_error_runtime_error: 'a3753.b101271.c388188.d512342',
|