@alipay/ams-checkout 2.0.19 → 2.0.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/ams-checkout.js +3 -3
- package/dist/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -0
- package/esm/config/index.js +2 -2
- package/esm/constant/element.d.ts +2 -1
- package/esm/constant/element.js +1 -0
- package/esm/constant/index.d.ts +4 -21
- package/esm/core/component/ckp/index.d.ts +1 -1
- package/esm/core/component/ckp/index.js +5 -2
- package/esm/core/component/element/elementController/index.d.ts +3 -3
- package/esm/core/component/element/elementController/index.js +66 -42
- package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +1 -0
- package/esm/core/component/element/elementProcessor/baseElementProcessor.js +1 -0
- package/esm/core/component/element/elementProcessor/convertPaymentMethods.d.ts +22 -0
- package/esm/core/component/element/elementProcessor/convertPaymentMethods.js +159 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +5 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +107 -29
- package/esm/core/component/element/index.d.ts +4 -1
- package/esm/core/component/element/index.js +19 -4
- package/esm/core/component/element/mock.js +2 -2
- package/esm/core/component/element/modernElementController/adapter.d.ts +19 -0
- package/esm/core/component/element/modernElementController/adapter.js +79 -0
- package/esm/core/component/element/modernElementController/index.d.ts +155 -0
- package/esm/core/component/element/modernElementController/index.js +1780 -0
- package/esm/core/component/element/type.d.ts +74 -19
- package/esm/core/component/element/util.d.ts +9 -2
- package/esm/core/component/element/util.js +3 -2
- package/esm/core/instance/index.d.ts +12 -4
- package/esm/core/instance/index.js +152 -26
- package/esm/foundation/service/event-center.js +1 -1
- package/esm/foundation/service/security/index.d.ts +9 -4
- package/esm/foundation/service/security/index.js +158 -35
- package/esm/foundation/service/security/security.d.ts +22 -1
- package/esm/foundation/service/security/security.js +150 -37
- package/esm/foundation/utils/preload_helper.d.ts +6 -3
- package/esm/foundation/utils/preload_helper.js +122 -32
- package/esm/main.js +4 -4
- package/esm/modern/global.d.ts +3 -0
- package/esm/modern/index.d.ts +5 -1
- package/esm/modern/index.js +1 -51
- package/esm/modern/tools.js +1 -0
- package/esm/plugin/component/channel.d.ts +2 -2
- package/esm/plugin/component/channel.js +18 -18
- package/esm/plugin/component/index.js +36 -29
- package/esm/tsdoc-metadata.json +1 -1
- package/esm/types/index.d.ts +5 -1
- package/esm/util/beforeConfirm.d.ts +4 -2
- package/esm/util/beforeConfirm.js +15 -14
- package/esm/util/jshield-apdid/apdid-loader.js +377 -0
- package/esm/util/jshield-apdid/index.js +21 -0
- package/esm/util/logger.js +1 -2
- package/esm/util/security-registry.d.ts +72 -0
- package/esm/util/security-registry.js +175 -0
- package/esm/util/security.d.ts +22 -1
- package/esm/util/security.js +150 -39
- package/package.json +15 -9
- package/types.d.ts +843 -1103
- package/types.untrimmed.d.ts +995 -1122
- package/esm/modern/stageName.d.ts +0 -3
- package/esm/modern/stageName.js +0 -1
|
@@ -27,11 +27,13 @@ import { ELEMENT_PAGE_URL } from "../../../../constant/element";
|
|
|
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 { DisplayTypeEnum } from "../../../../types";
|
|
30
31
|
import { queryParse } from "../../../../util";
|
|
31
32
|
import { LogConfig, Logger } from "../../../../util/logger";
|
|
32
33
|
import { parseSessionData } from "../../index";
|
|
33
34
|
import { oneAccount, sdkAction } from "../mock";
|
|
34
|
-
import {
|
|
35
|
+
import { convertPaymentMethods } from "../elementProcessor/convertPaymentMethods";
|
|
36
|
+
import { generateIframeSrc as _generateIframeSrc, isElementPad, isElementPC, safeParse, safeStringify } from "../util";
|
|
35
37
|
import BaseElementProcessor from "./baseElementProcessor";
|
|
36
38
|
import { executeWithTimeout, BEFORE_CONFIRM_TIMEOUT_MS } from "../../../../util/beforeConfirm";
|
|
37
39
|
var logger = new Logger(LogConfig, true);
|
|
@@ -85,11 +87,44 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
85
87
|
}, {
|
|
86
88
|
key: "onReady",
|
|
87
89
|
value: function onReady(extraParam) {
|
|
88
|
-
var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
|
|
90
|
+
var _this$options, _paymentContext$displ, _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
|
|
89
91
|
var paymentContext = this.elementContainer.getPaymentContext();
|
|
90
92
|
this.getLogger().logInfo({
|
|
91
93
|
title: 'sdk_event_renderComponent'
|
|
92
94
|
});
|
|
95
|
+
|
|
96
|
+
// preview mobile 模式下,单普通支付方式(无表单、非快捷支付)不发送 renderComponent,阻止自动提交
|
|
97
|
+
var previewMode = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.preview;
|
|
98
|
+
if (previewMode === 'mobile') {
|
|
99
|
+
var _extraParam$originAct, _extraParam$originAct2, _paymentMethods$, _paymentMethods$2;
|
|
100
|
+
var paymentMethods = (extraParam === null || extraParam === void 0 || (_extraParam$originAct = extraParam.originActionQueryResult) === null || _extraParam$originAct === void 0 ? void 0 : _extraParam$originAct.paymentMethods) || [];
|
|
101
|
+
var savedPaymentMethods = (extraParam === null || extraParam === void 0 || (_extraParam$originAct2 = extraParam.originActionQueryResult) === null || _extraParam$originAct2 === void 0 ? void 0 : _extraParam$originAct2.savedPaymentMethods) || [];
|
|
102
|
+
if (paymentMethods.length === 1 && savedPaymentMethods.length === 0 && !((_paymentMethods$ = paymentMethods[0]) !== null && _paymentMethods$ !== void 0 && (_paymentMethods$ = _paymentMethods$.paymentElements) !== null && _paymentMethods$ !== void 0 && _paymentMethods$.length) && !['APPLEPAY', 'GOOGLEPAY'].includes((_paymentMethods$2 = paymentMethods[0]) === null || _paymentMethods$2 === void 0 ? void 0 : _paymentMethods$2.paymentMethodType)) {
|
|
103
|
+
// 跳过 renderComponent,避免触发自动提交
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ===== Element 自助化运营:appearance 二选一处理(不做 deepMerge)=====
|
|
109
|
+
// 根据 theme 值二选一:
|
|
110
|
+
// - 内置 6 大主题(非 APR_ 前缀):完全使用 SDK mount 传入的 appearance
|
|
111
|
+
// - 自定义主题模版(APR_ 前缀 AppearanceID):完全使用后端 sdkAction.query 返回的 appearance,
|
|
112
|
+
// SDK mount 中传的 layout/variables/card 全部忽略
|
|
113
|
+
var mountAppearance = paymentContext === null || paymentContext === void 0 || (_paymentContext$displ = paymentContext.displayInfo) === null || _paymentContext$displ === void 0 ? void 0 : _paymentContext$displ.appearance;
|
|
114
|
+
var isAppearanceId = typeof (mountAppearance === null || mountAppearance === void 0 ? void 0 : mountAppearance.theme) === 'string' && mountAppearance.theme.startsWith('APR_');
|
|
115
|
+
var finalAppearance;
|
|
116
|
+
if (isAppearanceId) {
|
|
117
|
+
var _extraParam$originAct3, _safeParse;
|
|
118
|
+
// 分支 A:自定义主题模版(APR_xxxx)
|
|
119
|
+
// 完全使用后端返回的配置,忽略 SDK mount 中的 layout/variables/card
|
|
120
|
+
// elementSettings 可能是 JSON string,需统一解析为对象
|
|
121
|
+
var elementSettings = extraParam === null || extraParam === void 0 || (_extraParam$originAct3 = extraParam.originActionQueryResult) === null || _extraParam$originAct3 === void 0 || (_extraParam$originAct3 = _extraParam$originAct3.pageStyle) === null || _extraParam$originAct3 === void 0 ? void 0 : _extraParam$originAct3.elementSettings;
|
|
122
|
+
finalAppearance = typeof elementSettings === 'string' ? (_safeParse = safeParse(elementSettings)) === null || _safeParse === void 0 ? void 0 : _safeParse.appearance : elementSettings === null || elementSettings === void 0 ? void 0 : elementSettings.appearance;
|
|
123
|
+
} else {
|
|
124
|
+
// 分支 B:内置 6 大主题或未指定主题
|
|
125
|
+
// 完全使用 SDK mount 传入的配置;
|
|
126
|
+
finalAppearance = mountAppearance;
|
|
127
|
+
}
|
|
93
128
|
this.eventCenter.dispatchToApp({
|
|
94
129
|
event: 'renderComponent',
|
|
95
130
|
data: {
|
|
@@ -108,7 +143,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
108
143
|
merchantId: (_this$elementContaine4 = this.elementContainer) === null || _this$elementContaine4 === void 0 || (_this$elementContaine4 = _this$elementContaine4.getPaymentContext()) === null || _this$elementContaine4 === void 0 || (_this$elementContaine4 = _this$elementContaine4.paymentSessionObj) === null || _this$elementContaine4 === void 0 ? void 0 : _this$elementContaine4.clientId,
|
|
109
144
|
paymentMethodType: (_this$elementContaine5 = this.elementContainer) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.getPaymentContext()) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.paymentSessionObj) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.paymentMethodInfoView) === null || _this$elementContaine5 === void 0 ? void 0 : _this$elementContaine5.paymentMethodType
|
|
110
145
|
},
|
|
111
|
-
appearance:
|
|
146
|
+
appearance: finalAppearance,
|
|
112
147
|
sessionResult: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionObj,
|
|
113
148
|
notRedirectAfterComplete: (extraParam === null || extraParam === void 0 ? void 0 : extraParam.notRedirectAfterComplete) === true,
|
|
114
149
|
merchantAppointParam: extraParam === null || extraParam === void 0 ? void 0 : extraParam.merchantAppointParam,
|
|
@@ -195,7 +230,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
195
230
|
// requests SDK layer to execute merchant's onBeforeConfirm callback via beforeConfirm event,
|
|
196
231
|
// and returns the result (continue/abort) to iframe via dispatchToApp.
|
|
197
232
|
this.eventCenter.listen(EVENT.beforeConfirm.name, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
198
|
-
var paymentMethodType, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue;
|
|
233
|
+
var paymentMethodType, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue, isTimeout;
|
|
199
234
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
200
235
|
while (1) switch (_context.prev = _context.next) {
|
|
201
236
|
case 0:
|
|
@@ -235,8 +270,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
235
270
|
_yield$executeWithTim = _context.sent;
|
|
236
271
|
rawResult = _yield$executeWithTim.result;
|
|
237
272
|
timedOut = _yield$executeWithTim.timedOut;
|
|
238
|
-
shouldContinue = rawResult;
|
|
239
|
-
|
|
273
|
+
shouldContinue = rawResult;
|
|
274
|
+
isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS; // 双重校验:timedOut(Promise race) + startTime(实际时间差),防止竞态误判
|
|
275
|
+
if (isTimeout) {
|
|
240
276
|
logger.logError({
|
|
241
277
|
title: 'sdk_before_confirm_timeout'
|
|
242
278
|
});
|
|
@@ -249,15 +285,17 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
249
285
|
});
|
|
250
286
|
_this2.eventCenter.dispatchToApp({
|
|
251
287
|
event: EVENT.beforeConfirm.name,
|
|
252
|
-
data: {
|
|
288
|
+
data: _objectSpread({
|
|
253
289
|
success: true,
|
|
254
290
|
result: !!shouldContinue
|
|
255
|
-
}
|
|
291
|
+
}, isTimeout ? {
|
|
292
|
+
isTimeout: true
|
|
293
|
+
} : {})
|
|
256
294
|
});
|
|
257
|
-
_context.next =
|
|
295
|
+
_context.next = 24;
|
|
258
296
|
break;
|
|
259
|
-
case
|
|
260
|
-
_context.prev =
|
|
297
|
+
case 20:
|
|
298
|
+
_context.prev = 20;
|
|
261
299
|
_context.t0 = _context["catch"](6);
|
|
262
300
|
logger.logError({
|
|
263
301
|
title: 'sdk_before_confirm_error'
|
|
@@ -273,11 +311,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
273
311
|
result: false
|
|
274
312
|
}
|
|
275
313
|
});
|
|
276
|
-
case
|
|
314
|
+
case 24:
|
|
277
315
|
case "end":
|
|
278
316
|
return _context.stop();
|
|
279
317
|
}
|
|
280
|
-
}, _callee, null, [[6,
|
|
318
|
+
}, _callee, null, [[6, 20]]);
|
|
281
319
|
})));
|
|
282
320
|
}
|
|
283
321
|
}, {
|
|
@@ -344,6 +382,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
344
382
|
}, {
|
|
345
383
|
key: "generateIframeSrc",
|
|
346
384
|
value: function generateIframeSrc(_ref3) {
|
|
385
|
+
var _this$options3;
|
|
347
386
|
var link = _ref3.link,
|
|
348
387
|
instanceId = _ref3.instanceId;
|
|
349
388
|
this.instanceId = instanceId;
|
|
@@ -351,12 +390,15 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
351
390
|
paymentSession = _ref4.paymentSession,
|
|
352
391
|
paymentSessionObj = _ref4.paymentSessionObj,
|
|
353
392
|
sdkMetaData = _ref4.sdkMetaData;
|
|
354
|
-
var _this$
|
|
355
|
-
environment = _this$
|
|
356
|
-
analytics = _this$
|
|
357
|
-
locale = _this$
|
|
393
|
+
var _this$options2 = this.options,
|
|
394
|
+
environment = _this$options2.env.environment,
|
|
395
|
+
analytics = _this$options2.analytics,
|
|
396
|
+
locale = _this$options2.locale;
|
|
358
397
|
var _ref5 = paymentSessionObj || {},
|
|
359
398
|
extendInfo = _ref5.extendInfo;
|
|
399
|
+
// 预览模式下,若为 'mobile' 需要让 iframe 以 popup(MobileElement)形态渲染
|
|
400
|
+
var previewMode = (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.preview;
|
|
401
|
+
var renderDisplayType = previewMode === 'mobile' ? DisplayTypeEnum.popup : DisplayTypeEnum.inline;
|
|
360
402
|
var url = _generateIframeSrc({
|
|
361
403
|
paymentSession: paymentSession,
|
|
362
404
|
paymentSessionObj: paymentSessionObj,
|
|
@@ -366,7 +408,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
366
408
|
link: link,
|
|
367
409
|
appVersion: sdkMetaData === null || sdkMetaData === void 0 ? void 0 : sdkMetaData.webAppVersion,
|
|
368
410
|
pageUrl: isExpressCheckout(extendInfo) ? ELEMENT_PAGE_URL.EXPRESS_CHECKOUT : ELEMENT_PAGE_URL.ELEMENT_PAYMENT,
|
|
369
|
-
instanceId: instanceId
|
|
411
|
+
instanceId: instanceId,
|
|
412
|
+
renderDisplayType: renderDisplayType
|
|
370
413
|
});
|
|
371
414
|
this.setElementUrl(url);
|
|
372
415
|
return url;
|
|
@@ -376,8 +419,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
376
419
|
value: function () {
|
|
377
420
|
var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
378
421
|
var _paymentSessionObj$co,
|
|
422
|
+
_this$options5,
|
|
379
423
|
_this3 = this;
|
|
380
|
-
var requestService, _this$elementContaine7, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$
|
|
424
|
+
var requestService, _this$elementContaine7, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options4, environment, locale, _ref6, paymentSessionConfig, hostSign, isConnect, LOCAL_MOCK, previewMode, IS_PREVIEW, SHOULD_USE_MOCK, _queryParse, appType, terminalType, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
|
|
381
425
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
382
426
|
while (1) switch (_context3.prev = _context3.next) {
|
|
383
427
|
case 0:
|
|
@@ -385,11 +429,14 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
385
429
|
_this$elementContaine7 = this.elementContainer.getPaymentContext(), paymentSession = _this$elementContaine7.paymentSession, paymentSessionObj = _this$elementContaine7.paymentSessionObj, displayInfo = _this$elementContaine7.displayInfo;
|
|
386
430
|
_displayInfo = displayInfo;
|
|
387
431
|
debugProps = _displayInfo.debugProps;
|
|
388
|
-
_this$
|
|
432
|
+
_this$options4 = this.options, environment = _this$options4.env.environment, locale = _this$options4.locale;
|
|
389
433
|
_ref6 = paymentSessionObj || {}, paymentSessionConfig = _ref6.paymentSessionConfig;
|
|
390
434
|
hostSign = paymentSession.split('&&')[1] || '';
|
|
391
435
|
isConnect = paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect;
|
|
392
|
-
LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock);
|
|
436
|
+
LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock); // 兼容三种预览开关取值:true / 'web' / 'mobile'
|
|
437
|
+
previewMode = (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.preview;
|
|
438
|
+
IS_PREVIEW = previewMode === true || previewMode === 'web' || previewMode === 'mobile';
|
|
439
|
+
SHOULD_USE_MOCK = LOCAL_MOCK || IS_PREVIEW;
|
|
393
440
|
_queryParse = queryParse(this.getElementUrl()), appType = _queryParse.appType;
|
|
394
441
|
terminalType = isElementPad() ? 'WEB' : appType ? 'APP' : isElementPC() ? 'WEB' : 'WAP';
|
|
395
442
|
/**
|
|
@@ -401,10 +448,14 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
401
448
|
generateActionQueryPromise = function generateActionQueryPromise() {
|
|
402
449
|
return new Promise(function (resolve, reject) {
|
|
403
450
|
var _displayInfo$merchant;
|
|
404
|
-
|
|
405
|
-
if (LOCAL_MOCK) {
|
|
451
|
+
if (SHOULD_USE_MOCK) {
|
|
406
452
|
setTimeout(function () {
|
|
407
|
-
|
|
453
|
+
if (IS_PREVIEW) {
|
|
454
|
+
var mockData = _this3.buildPreviewMockData(sdkAction);
|
|
455
|
+
resolve(mockData);
|
|
456
|
+
} else {
|
|
457
|
+
resolve(sdkAction);
|
|
458
|
+
}
|
|
408
459
|
}, 100);
|
|
409
460
|
return;
|
|
410
461
|
}
|
|
@@ -422,6 +473,12 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
422
473
|
}
|
|
423
474
|
};
|
|
424
475
|
|
|
476
|
+
// 自定义主题模版(APR_ 前缀 AppearanceID):额外传递 appearanceId
|
|
477
|
+
var mountAppearance = displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.appearance;
|
|
478
|
+
var isAppearanceId = typeof (mountAppearance === null || mountAppearance === void 0 ? void 0 : mountAppearance.theme) === 'string' && mountAppearance.theme.startsWith('APR_');
|
|
479
|
+
if (isAppearanceId) {
|
|
480
|
+
sdkRequestData.appearanceId = mountAppearance.theme;
|
|
481
|
+
}
|
|
425
482
|
// 可选参数:商户指定的储值卡信息
|
|
426
483
|
if (displayInfo !== null && displayInfo !== void 0 && (_displayInfo$merchant = displayInfo.merchantAppointParam) !== null && _displayInfo$merchant !== void 0 && _displayInfo$merchant.storedCard) {
|
|
427
484
|
sdkRequestData.merchantAppointParam = displayInfo.merchantAppointParam;
|
|
@@ -486,8 +543,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
486
543
|
*/
|
|
487
544
|
generateOneAccountQueryPromise = function generateOneAccountQueryPromise() {
|
|
488
545
|
return new Promise(function (resolve, reject) {
|
|
489
|
-
|
|
490
|
-
if (LOCAL_MOCK) {
|
|
546
|
+
if (SHOULD_USE_MOCK) {
|
|
491
547
|
setTimeout(function () {
|
|
492
548
|
resolve(oneAccount);
|
|
493
549
|
}, 100);
|
|
@@ -523,9 +579,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
523
579
|
});
|
|
524
580
|
});
|
|
525
581
|
};
|
|
526
|
-
_context3.next =
|
|
582
|
+
_context3.next = 18;
|
|
527
583
|
return Promise.all(isConnect ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
|
|
528
|
-
case
|
|
584
|
+
case 18:
|
|
529
585
|
_yield$Promise$all = _context3.sent;
|
|
530
586
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
531
587
|
originActionQueryResult = _yield$Promise$all2[0];
|
|
@@ -538,7 +594,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
538
594
|
originActionQueryResult: originActionQueryResult,
|
|
539
595
|
originOneAccountQueryResult: originOneAccountQueryResult
|
|
540
596
|
});
|
|
541
|
-
case
|
|
597
|
+
case 24:
|
|
542
598
|
case "end":
|
|
543
599
|
return _context3.stop();
|
|
544
600
|
}
|
|
@@ -549,6 +605,28 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
549
605
|
}
|
|
550
606
|
return obtainData;
|
|
551
607
|
}()
|
|
608
|
+
/**
|
|
609
|
+
* 构建预览模式的 mock 数据
|
|
610
|
+
* 合并 mock.ts 的硬编码数据和 mount 传入的 paymentMethods 配置
|
|
611
|
+
*/
|
|
612
|
+
}, {
|
|
613
|
+
key: "buildPreviewMockData",
|
|
614
|
+
value: function buildPreviewMockData(baseMock) {
|
|
615
|
+
var _this$elementContaine8 = this.elementContainer.getPaymentContext(),
|
|
616
|
+
displayInfo = _this$elementContaine8.displayInfo;
|
|
617
|
+
var mountOptions = displayInfo;
|
|
618
|
+
var paymentMethodsConfig = mountOptions === null || mountOptions === void 0 ? void 0 : mountOptions.previewPaymentMethods;
|
|
619
|
+
|
|
620
|
+
// 深拷贝 mock 数据,避免修改原始对象
|
|
621
|
+
var result = JSON.parse(JSON.stringify(baseMock));
|
|
622
|
+
|
|
623
|
+
// 转换 paymentMethods 配置为内部格式
|
|
624
|
+
var convertedMethods = convertPaymentMethods(paymentMethodsConfig);
|
|
625
|
+
|
|
626
|
+
// 替换 paymentMethods
|
|
627
|
+
result.paymentMethods = convertedMethods;
|
|
628
|
+
return result;
|
|
629
|
+
}
|
|
552
630
|
}, {
|
|
553
631
|
key: "getValue",
|
|
554
632
|
value: function getValue() {
|
|
@@ -3,7 +3,10 @@ export declare class ElementComponent {
|
|
|
3
3
|
private options;
|
|
4
4
|
private controller;
|
|
5
5
|
constructor(options: IElementOptions);
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated 不要使用,internal experiment方法
|
|
8
|
+
*/
|
|
9
|
+
updatePayment(paymentSessionData: any): Promise<boolean>;
|
|
7
10
|
mount(renderOptions: PaymentMountOptions, sdkSelector: string): Promise<import("./type").ICommonApiResponse>;
|
|
8
11
|
validateFields(): Promise<{
|
|
9
12
|
isValid: boolean;
|
|
@@ -1,16 +1,18 @@
|
|
|
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
8
|
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); } }
|
|
9
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
10
|
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; }
|
|
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
|
+
import { adjustSessionData, isElements2 } from "../../../modern/tools";
|
|
13
14
|
import ElementController from "./elementController";
|
|
15
|
+
import { ModernElementController } from "./modernElementController";
|
|
14
16
|
import { InvalidElementConfigError } from "./type";
|
|
15
17
|
import { formatElementOption, validateElementOption } from "./util";
|
|
16
18
|
export var ElementComponent = /*#__PURE__*/function () {
|
|
@@ -23,11 +25,23 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
23
25
|
throw new InvalidElementConfigError(validate.errors);
|
|
24
26
|
}
|
|
25
27
|
this.options = formatElementOption(options);
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
// 核心分流逻辑
|
|
30
|
+
if (isElements2(options.sessionData)) {
|
|
31
|
+
this.controller = new ModernElementController(_objectSpread(_objectSpread({}, this.options), {}, {
|
|
32
|
+
sessionData: adjustSessionData(this.options.sessionData)
|
|
33
|
+
}));
|
|
34
|
+
} else {
|
|
35
|
+
this.controller = new ElementController(this.options);
|
|
36
|
+
}
|
|
27
37
|
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated 不要使用,internal experiment方法
|
|
41
|
+
*/
|
|
28
42
|
_createClass(ElementComponent, [{
|
|
29
43
|
key: "updatePayment",
|
|
30
|
-
value: function () {
|
|
44
|
+
value: (function () {
|
|
31
45
|
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentSessionData) {
|
|
32
46
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33
47
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -47,6 +61,7 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
47
61
|
// mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
|
|
48
62
|
// mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
|
49
63
|
// mount(renderOptions: PaymentMountOptions, sdkSelector: string);
|
|
64
|
+
)
|
|
50
65
|
}, {
|
|
51
66
|
key: "mount",
|
|
52
67
|
value: function mount(renderOptions, sdkSelector) {
|
|
@@ -153,7 +153,7 @@ export var sdkAction1 = {
|
|
|
153
153
|
}, {
|
|
154
154
|
antomPage: 'paymentMetaPage',
|
|
155
155
|
category: 'AC_WALLET',
|
|
156
|
-
expressCheckout:
|
|
156
|
+
expressCheckout: false,
|
|
157
157
|
icon: 'https://cdn.marmot-cloud.com/storage/2024/05/15/5b829130-42d9-46e7-a23d-6774f7352900.svg',
|
|
158
158
|
iconName: 'Alipay',
|
|
159
159
|
interActionType: 'REDIRECT',
|
|
@@ -327,7 +327,7 @@ export var sdkAction1 = {
|
|
|
327
327
|
recommend: false,
|
|
328
328
|
webRedirectType: 'PAGE_REFRESH'
|
|
329
329
|
}],
|
|
330
|
-
redirectUrl: '
|
|
330
|
+
redirectUrl: '',
|
|
331
331
|
savedPaymentMethods: [],
|
|
332
332
|
shippingInfo: {
|
|
333
333
|
shippingAddress: {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IMerchantAppointParam } from "../../../../types";
|
|
2
|
+
import type { IPaymentApiResponse, PaymentMountOptions } from '../type';
|
|
3
|
+
import { EventCallbackCode } from '../type';
|
|
4
|
+
import type { PaymentSubmitResult, ErrorPayload } from "../../../../modern/tools";
|
|
5
|
+
export declare function adaptSubmitResult(result: PaymentSubmitResult): IPaymentApiResponse;
|
|
6
|
+
export declare function adaptErrorToEventCallback(error: ErrorPayload): {
|
|
7
|
+
code: EventCallbackCode;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 将老架构的 appearance 格式转换为新架构格式
|
|
12
|
+
*
|
|
13
|
+
* 转换规则:
|
|
14
|
+
* 1. theme: kebab-case → camelCase(如 'nostalgic-gray' → 'nostalgicGray'),其余保持不变
|
|
15
|
+
* 2. variables: 直接透传(kebab-case CSS 变量 key-value)
|
|
16
|
+
* 3. card.showBrandIcon → displaySetting.showCardBrandIcon
|
|
17
|
+
* 4. layout: 直接透传
|
|
18
|
+
*/
|
|
19
|
+
export declare function adaptAppearance(appearance?: PaymentMountOptions['appearance'], merchantAppointParam?: IMerchantAppointParam): any;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
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); }
|
|
6
|
+
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); }
|
|
7
|
+
import { EventCallbackCode } from "../type";
|
|
8
|
+
export function adaptSubmitResult(result) {
|
|
9
|
+
return {
|
|
10
|
+
status: result.status || 'FAIL',
|
|
11
|
+
error: result.error ? {
|
|
12
|
+
code: result.error.code,
|
|
13
|
+
message: result.error.message,
|
|
14
|
+
needChangeSessionForRetry: result.error.needChangeSessionForRetry
|
|
15
|
+
} : undefined,
|
|
16
|
+
userCanceled3D: result.userCanceled3D,
|
|
17
|
+
session: result.paymentSession ? {
|
|
18
|
+
nextAction: {
|
|
19
|
+
applinkUrl: result.paymentSession.returnAppUrl,
|
|
20
|
+
normalUrl: result.paymentSession.returnUrl,
|
|
21
|
+
schemeUrl: result.paymentSession.returnAppScheme
|
|
22
|
+
}
|
|
23
|
+
} : undefined
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function adaptErrorToEventCallback(error) {
|
|
27
|
+
return {
|
|
28
|
+
code: error.code || EventCallbackCode.SDK_PAYMENT_ERROR,
|
|
29
|
+
message: error.message || ''
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 将老架构的 appearance 格式转换为新架构格式
|
|
35
|
+
*
|
|
36
|
+
* 转换规则:
|
|
37
|
+
* 1. theme: kebab-case → camelCase(如 'nostalgic-gray' → 'nostalgicGray'),其余保持不变
|
|
38
|
+
* 2. variables: 直接透传(kebab-case CSS 变量 key-value)
|
|
39
|
+
* 3. card.showBrandIcon → displaySetting.showCardBrandIcon
|
|
40
|
+
* 4. layout: 直接透传
|
|
41
|
+
*/
|
|
42
|
+
export function adaptAppearance(appearance, merchantAppointParam) {
|
|
43
|
+
var _merchantAppointParam, _appearance$card, _appearance$accordion;
|
|
44
|
+
var merchantDisplaySetting = {
|
|
45
|
+
showCardCVV: !!(merchantAppointParam !== null && merchantAppointParam !== void 0 && (_merchantAppointParam = merchantAppointParam.storedCard) !== null && _merchantAppointParam !== void 0 && _merchantAppointParam.needCVV),
|
|
46
|
+
showPaymentMethodListWhenSingleOption: (merchantAppointParam === null || merchantAppointParam === void 0 ? void 0 : merchantAppointParam.singleOption) === 'list'
|
|
47
|
+
};
|
|
48
|
+
if (!appearance) {
|
|
49
|
+
return merchantAppointParam ? {
|
|
50
|
+
displaySetting: merchantDisplaySetting
|
|
51
|
+
} : undefined;
|
|
52
|
+
}
|
|
53
|
+
var result = {};
|
|
54
|
+
|
|
55
|
+
// Theme mapping: kebab-case → camelCase
|
|
56
|
+
if (appearance.theme) {
|
|
57
|
+
result.theme = appearance.theme;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Variables: 直接透传
|
|
61
|
+
if (appearance.variables && _typeof(appearance.variables) === 'object') {
|
|
62
|
+
var filtered = _objectSpread({}, appearance.variables);
|
|
63
|
+
if (Object.keys(filtered).length > 0) {
|
|
64
|
+
result.variables = filtered;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
result.displaySetting = _objectSpread(_objectSpread({
|
|
68
|
+
showCardBrandIcon: !!((_appearance$card = appearance.card) !== null && _appearance$card !== void 0 && _appearance$card.showBrandIcon)
|
|
69
|
+
}, merchantDisplaySetting), {}, {
|
|
70
|
+
showRadioWhenAccordionLayout: !!((_appearance$accordion = appearance.accordion) !== null && _appearance$accordion !== void 0 && _appearance$accordion.showRadio)
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Layout: 直接透传
|
|
74
|
+
if (appearance.layout) {
|
|
75
|
+
var _appearance$layout$ty;
|
|
76
|
+
result.layout = ((_appearance$layout$ty = appearance.layout.type) === null || _appearance$layout$ty === void 0 ? void 0 : _appearance$layout$ty.toLowerCase()) || 'accordion';
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|