@alipay/ams-checkout 0.0.1783403875-dev.2 → 0.0.1783496600-dev.2
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 +4 -3
- package/dist/ams-checkout.min.js +2 -1
- package/dist/ams-checkout.min.js.map +1 -0
- 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/element/elementController/index.d.ts +3 -3
- package/esm/core/component/element/elementController/index.js +49 -59
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +10 -13
- package/esm/core/component/element/index.d.ts +4 -1
- package/esm/core/component/element/index.js +19 -4
- package/esm/core/component/element/modernElementController/adapter.d.ts +19 -0
- package/esm/core/component/element/modernElementController/adapter.js +73 -0
- package/esm/core/component/element/modernElementController/index.d.ts +149 -0
- package/esm/core/component/element/modernElementController/index.js +1665 -0
- package/esm/core/component/element/type.d.ts +15 -19
- package/esm/foundation/service/event-center.js +1 -1
- 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/types/index.d.ts +1 -0
- package/esm/util/beforeConfirm.d.ts +2 -4
- package/esm/util/beforeConfirm.js +14 -15
- package/esm/util/logger.js +1 -2
- package/package.json +15 -9
- package/types.d.ts +785 -94
- package/types.untrimmed.d.ts +929 -108
- package/esm/modern/stageName.d.ts +0 -3
- package/esm/modern/stageName.js +0 -1
package/esm/config/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
|
6
|
+
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
|
7
|
+
*/
|
|
1
8
|
export declare const marmotMap: Record<string, string>;
|
|
2
9
|
export declare const marmotConfigMap: Record<string, string>;
|
|
3
10
|
export declare const v2AppMarmotMap: Record<string, string>;
|
package/esm/config/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
|
6
6
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
export var marmotMap = {
|
|
10
10
|
dev: 'http://page.alipay.net/page/antom-web-checkout/src/component-app',
|
|
11
11
|
sit: 'http://page.test.alipay.net/page/antom-web-checkout/src/component-app',
|
|
@@ -30,7 +30,7 @@ export var v2AppMarmotMap = {
|
|
|
30
30
|
light_sandbox: 'https://checkout.antom.com',
|
|
31
31
|
prod: 'https://checkout.antom.com'
|
|
32
32
|
};
|
|
33
|
-
export var sdkVersion =
|
|
33
|
+
export var sdkVersion = "0.0.1783496600-dev.2";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
|
@@ -22,5 +22,6 @@ export declare enum ELEMENT_PAGE_URL {
|
|
|
22
22
|
INSTRUCTION_GUIDE = "/elements/pages/instruction-guide/index.html",
|
|
23
23
|
THREED_PAGE = "/elements/pages/threed-page/index.html",
|
|
24
24
|
ELEMENT_AUTH = "/auth-element/pages/element_auth/index.html",
|
|
25
|
-
ADDRESS = "/element-address/pages/address/index.html"
|
|
25
|
+
ADDRESS = "/element-address/pages/address/index.html",
|
|
26
|
+
NEW_ELEMENT_PAYMENT = "/elements2/pages/element_payment/index.html"
|
|
26
27
|
}
|
package/esm/constant/element.js
CHANGED
|
@@ -26,5 +26,6 @@ export var ELEMENT_PAGE_URL = /*#__PURE__*/function (ELEMENT_PAGE_URL) {
|
|
|
26
26
|
ELEMENT_PAGE_URL["THREED_PAGE"] = "/elements/pages/threed-page/index.html";
|
|
27
27
|
ELEMENT_PAGE_URL["ELEMENT_AUTH"] = "/auth-element/pages/element_auth/index.html";
|
|
28
28
|
ELEMENT_PAGE_URL["ADDRESS"] = "/element-address/pages/address/index.html";
|
|
29
|
+
ELEMENT_PAGE_URL["NEW_ELEMENT_PAYMENT"] = "/elements2/pages/element_payment/index.html";
|
|
29
30
|
return ELEMENT_PAGE_URL;
|
|
30
31
|
}({});
|
package/esm/constant/index.d.ts
CHANGED
|
@@ -325,24 +325,7 @@ export declare const LOADINGIMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA
|
|
|
325
325
|
/**
|
|
326
326
|
* @description Promise回调code映射
|
|
327
327
|
*/
|
|
328
|
-
export declare const PROMISE_CALLBACK_CODE: {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
UNKNOWN_EXCEPTION: {
|
|
333
|
-
code: string;
|
|
334
|
-
message: string;
|
|
335
|
-
};
|
|
336
|
-
REPEAT_REQ_REJECT: {
|
|
337
|
-
code: string;
|
|
338
|
-
message: string;
|
|
339
|
-
};
|
|
340
|
-
PROCESS_FAIL: {
|
|
341
|
-
code: string;
|
|
342
|
-
message: string;
|
|
343
|
-
};
|
|
344
|
-
INQUIRY_PAYMENT_SESSION_FAILED: {
|
|
345
|
-
code: string;
|
|
346
|
-
message: string;
|
|
347
|
-
};
|
|
348
|
-
};
|
|
328
|
+
export declare const PROMISE_CALLBACK_CODE: Record<string, {
|
|
329
|
+
code: string;
|
|
330
|
+
message?: string;
|
|
331
|
+
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AddressMountOptions, EventDataMap, EVENTNAME, ICommonApiResponse, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions, SubmitFuncParams } from '../type';
|
|
2
|
-
declare class ElementController {
|
|
1
|
+
import { AddressMountOptions, EventDataMap, EVENTNAME, ICommonApiResponse, IElementController, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions, SubmitFuncParams } from '../type';
|
|
2
|
+
declare class ElementController implements IElementController {
|
|
3
3
|
private options;
|
|
4
4
|
private elementContainer;
|
|
5
5
|
private serviceMap;
|
|
@@ -44,7 +44,7 @@ declare class ElementController {
|
|
|
44
44
|
private getErrorFromResponse;
|
|
45
45
|
private areAllContainersReady;
|
|
46
46
|
private sendReady;
|
|
47
|
-
updatePayment(paymentSessionData:
|
|
47
|
+
updatePayment(paymentSessionData: string): Promise<boolean>;
|
|
48
48
|
private destroyHandle;
|
|
49
49
|
destroy(): void;
|
|
50
50
|
private setControllerStatusOrView;
|
|
@@ -37,7 +37,7 @@ import { ServiceProvider } from "../../../../foundation/service";
|
|
|
37
37
|
import { convertPaymentSession } from "../../../../foundation/utils/payment_context_utils";
|
|
38
38
|
import { ProductSceneEnum } from "../../../../types";
|
|
39
39
|
import { ELEMENT_SPM_MAP } from "../../../../util/spm-map";
|
|
40
|
-
import { executeWithTimeout, BEFORE_CONFIRM_TIMEOUT_MS
|
|
40
|
+
import { executeWithTimeout, BEFORE_CONFIRM_TIMEOUT_MS } from "../../../../util/beforeConfirm";
|
|
41
41
|
import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
|
|
42
42
|
import { IContainerStatus } from "../elementContainerService/containerService";
|
|
43
43
|
import { EventCenter as ElementEventCenter } from "../EventCenter/index";
|
|
@@ -233,6 +233,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
233
233
|
}, {
|
|
234
234
|
key: "initializeAndMountProcessor",
|
|
235
235
|
value: function initializeAndMountProcessor(type, selector, options) {
|
|
236
|
+
var _this$serviceMap$Log, _options$appearance;
|
|
236
237
|
this.initElementProcessors(type);
|
|
237
238
|
// 创建 iframe,拉起应用页面,同时监听全局的数据更新和获取事件
|
|
238
239
|
this.elementContainerService.mount({
|
|
@@ -248,6 +249,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
248
249
|
ServiceProvider.getInstance(newInstanceId).update(paymentContext);
|
|
249
250
|
// 更新埋点service
|
|
250
251
|
this.serviceMap.Log = ServiceProvider.getInstance(newInstanceId).getService('Log');
|
|
252
|
+
(_this$serviceMap$Log = this.serviceMap.Log) === null || _this$serviceMap$Log === void 0 || _this$serviceMap$Log.logInfo({
|
|
253
|
+
title: 'sdk_event_appearance'
|
|
254
|
+
}, {
|
|
255
|
+
variables: options !== null && options !== void 0 && (_options$appearance = options.appearance) !== null && _options$appearance !== void 0 && _options$appearance.variables ? true : false,
|
|
256
|
+
theme: options === null || options === void 0 ? void 0 : options.theme
|
|
257
|
+
});
|
|
251
258
|
this.elementProcessors[type].beforeMount();
|
|
252
259
|
}
|
|
253
260
|
// 处理业务流程启动失败
|
|
@@ -375,7 +382,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
375
382
|
value: function () {
|
|
376
383
|
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(submitParams) {
|
|
377
384
|
var _this3 = this;
|
|
378
|
-
var startEventId, res, logParams, isApplePay, paymentMethodType, startTime, _yield$executeWithTim, shouldContinue, timedOut,
|
|
385
|
+
var startEventId, res, logParams, isApplePay, paymentMethodType, startTime, _yield$executeWithTim, shouldContinue, timedOut, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
|
379
386
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
380
387
|
while (1) switch (_context4.prev = _context4.next) {
|
|
381
388
|
case 0:
|
|
@@ -405,7 +412,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
405
412
|
isApplePay = this.currentPaymentMethodType === 'APPLEPAY';
|
|
406
413
|
paymentMethodType = this.currentPaymentMethodType || 'UNKNOWN';
|
|
407
414
|
if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm && !isApplePay)) {
|
|
408
|
-
_context4.next =
|
|
415
|
+
_context4.next = 34;
|
|
409
416
|
break;
|
|
410
417
|
}
|
|
411
418
|
this.serviceMap.Log.logInfo({
|
|
@@ -424,65 +431,49 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
424
431
|
_yield$executeWithTim = _context4.sent;
|
|
425
432
|
shouldContinue = _yield$executeWithTim.result;
|
|
426
433
|
timedOut = _yield$executeWithTim.timedOut;
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
_context4.next = 24;
|
|
434
|
+
if (!(timedOut || !shouldContinue || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS)) {
|
|
435
|
+
_context4.next = 23;
|
|
430
436
|
break;
|
|
431
437
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
code: MERCHANT_CONFIRM_TIMEOUT_CODE,
|
|
447
|
-
message: 'Merchant confirmation timed out.',
|
|
448
|
-
needChangeSessionForRetry: false
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
case 24:
|
|
452
|
-
if (shouldContinue) {
|
|
453
|
-
_context4.next = 29;
|
|
454
|
-
break;
|
|
438
|
+
if (timedOut) {
|
|
439
|
+
this.serviceMap.Log.logError({
|
|
440
|
+
title: 'sdk_before_confirm_timeout'
|
|
441
|
+
}, {
|
|
442
|
+
paymentMethodType: paymentMethodType,
|
|
443
|
+
path: 'nonApplePay_sync'
|
|
444
|
+
});
|
|
445
|
+
} else {
|
|
446
|
+
this.serviceMap.Log.logInfo({
|
|
447
|
+
title: 'sdk_before_confirm_abort'
|
|
448
|
+
}, {
|
|
449
|
+
paymentMethodType: paymentMethodType,
|
|
450
|
+
path: 'nonApplePay_sync'
|
|
451
|
+
});
|
|
455
452
|
}
|
|
456
|
-
this.serviceMap.Log.logInfo({
|
|
457
|
-
title: 'sdk_before_confirm_abort'
|
|
458
|
-
}, {
|
|
459
|
-
paymentMethodType: paymentMethodType,
|
|
460
|
-
path: 'nonApplePay_sync'
|
|
461
|
-
});
|
|
462
453
|
this.changeLoading(false);
|
|
463
454
|
this.elementEventCenter.endEvent(startEventId, {
|
|
464
455
|
eventCode: PaymentStatus.FAIL,
|
|
465
|
-
errorName:
|
|
456
|
+
errorName: 'MERCHANT_CONFIRM_ABORT'
|
|
466
457
|
});
|
|
467
458
|
return _context4.abrupt("return", {
|
|
468
459
|
status: PaymentStatus.FAIL,
|
|
469
460
|
error: {
|
|
470
|
-
code:
|
|
471
|
-
message: '
|
|
461
|
+
code: 'MERCHANT_CONFIRM_ABORT',
|
|
462
|
+
message: 'Merchant canceled payment.',
|
|
472
463
|
needChangeSessionForRetry: false
|
|
473
464
|
}
|
|
474
465
|
});
|
|
475
|
-
case
|
|
466
|
+
case 23:
|
|
476
467
|
this.serviceMap.Log.logInfo({
|
|
477
468
|
title: 'sdk_before_confirm_success'
|
|
478
469
|
}, {
|
|
479
470
|
paymentMethodType: paymentMethodType,
|
|
480
471
|
path: 'nonApplePay_sync'
|
|
481
472
|
});
|
|
482
|
-
_context4.next =
|
|
473
|
+
_context4.next = 32;
|
|
483
474
|
break;
|
|
484
|
-
case
|
|
485
|
-
_context4.prev =
|
|
475
|
+
case 26:
|
|
476
|
+
_context4.prev = 26;
|
|
486
477
|
_context4.t0 = _context4["catch"](11);
|
|
487
478
|
this.serviceMap.Log.logError({
|
|
488
479
|
title: 'sdk_before_confirm_error'
|
|
@@ -494,20 +485,20 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
494
485
|
this.changeLoading(false);
|
|
495
486
|
this.elementEventCenter.endEvent(startEventId, {
|
|
496
487
|
eventCode: PaymentStatus.FAIL,
|
|
497
|
-
errorName:
|
|
488
|
+
errorName: 'MERCHANT_CONFIRM_ABORT'
|
|
498
489
|
});
|
|
499
490
|
return _context4.abrupt("return", {
|
|
500
491
|
status: PaymentStatus.FAIL,
|
|
501
492
|
error: {
|
|
502
|
-
code:
|
|
503
|
-
message: '
|
|
493
|
+
code: 'MERCHANT_CONFIRM_ABORT',
|
|
494
|
+
message: 'Merchant canceled payment.',
|
|
504
495
|
needChangeSessionForRetry: false
|
|
505
496
|
}
|
|
506
497
|
});
|
|
507
|
-
case
|
|
508
|
-
_context4.next =
|
|
498
|
+
case 32:
|
|
499
|
+
_context4.next = 35;
|
|
509
500
|
break;
|
|
510
|
-
case
|
|
501
|
+
case 34:
|
|
511
502
|
if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm)) {
|
|
512
503
|
this.serviceMap.Log.logInfo({
|
|
513
504
|
title: 'sdk_before_confirm_skip'
|
|
@@ -516,10 +507,10 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
516
507
|
path: isApplePay ? 'applePay_eventBridge' : 'nonApplePay_sync'
|
|
517
508
|
});
|
|
518
509
|
}
|
|
519
|
-
case
|
|
510
|
+
case 35:
|
|
520
511
|
recordResult = null;
|
|
521
|
-
_context4.prev =
|
|
522
|
-
_context4.next =
|
|
512
|
+
_context4.prev = 36;
|
|
513
|
+
_context4.next = 39;
|
|
523
514
|
return new Promise( /*#__PURE__*/function () {
|
|
524
515
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
525
516
|
var that, recordResultCallback, params, processStep, hasBeforeConfirmForApplePay, hasAmount, hasCurrency, _yield$_this3$onValid2, _data, errorString, errorResult;
|
|
@@ -608,8 +599,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
608
599
|
}, {
|
|
609
600
|
msg: safeStringify({
|
|
610
601
|
hasBeforeConfirmForApplePay: hasBeforeConfirmForApplePay,
|
|
611
|
-
isApplePay: isApplePay
|
|
612
|
-
amount: "".concat(submitParams === null || submitParams === void 0 ? void 0 : submitParams.amount, ", ").concat(submitParams === null || submitParams === void 0 ? void 0 : submitParams.currency)
|
|
602
|
+
isApplePay: isApplePay
|
|
613
603
|
})
|
|
614
604
|
});
|
|
615
605
|
_this3.elementProcessors[ElementType.payment].setOnBeforeConfirm(hasBeforeConfirmForApplePay ? submitParams.onBeforeConfirm : null);
|
|
@@ -677,10 +667,10 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
677
667
|
return _ref3.apply(this, arguments);
|
|
678
668
|
};
|
|
679
669
|
}());
|
|
680
|
-
case
|
|
670
|
+
case 39:
|
|
681
671
|
return _context4.abrupt("return", _context4.sent);
|
|
682
|
-
case
|
|
683
|
-
_context4.prev =
|
|
672
|
+
case 40:
|
|
673
|
+
_context4.prev = 40;
|
|
684
674
|
_logParams = {
|
|
685
675
|
eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
|
|
686
676
|
errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
|
|
@@ -691,12 +681,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
691
681
|
};
|
|
692
682
|
this.elementEventCenter.endEvent(startEventId, _logParams);
|
|
693
683
|
this.changeLoading(false);
|
|
694
|
-
return _context4.finish(
|
|
695
|
-
case
|
|
684
|
+
return _context4.finish(40);
|
|
685
|
+
case 45:
|
|
696
686
|
case "end":
|
|
697
687
|
return _context4.stop();
|
|
698
688
|
}
|
|
699
|
-
}, _callee4, this, [[11,
|
|
689
|
+
}, _callee4, this, [[11, 26], [36,, 40, 45]]);
|
|
700
690
|
}));
|
|
701
691
|
function submitPayment(_x) {
|
|
702
692
|
return _submitPayment.apply(this, arguments);
|
|
@@ -230,7 +230,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
230
230
|
// requests SDK layer to execute merchant's onBeforeConfirm callback via beforeConfirm event,
|
|
231
231
|
// and returns the result (continue/abort) to iframe via dispatchToApp.
|
|
232
232
|
this.eventCenter.listen(EVENT.beforeConfirm.name, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
233
|
-
var paymentMethodType, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue
|
|
233
|
+
var paymentMethodType, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue;
|
|
234
234
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
235
235
|
while (1) switch (_context.prev = _context.next) {
|
|
236
236
|
case 0:
|
|
@@ -270,9 +270,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
270
270
|
_yield$executeWithTim = _context.sent;
|
|
271
271
|
rawResult = _yield$executeWithTim.result;
|
|
272
272
|
timedOut = _yield$executeWithTim.timedOut;
|
|
273
|
-
shouldContinue = rawResult;
|
|
274
|
-
|
|
275
|
-
if (isTimeout) {
|
|
273
|
+
shouldContinue = rawResult; // 双重校验:timedOut(Promise race) + startTime(实际时间差),防止竞态误判
|
|
274
|
+
if (timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS) {
|
|
276
275
|
logger.logError({
|
|
277
276
|
title: 'sdk_before_confirm_timeout'
|
|
278
277
|
});
|
|
@@ -285,17 +284,15 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
285
284
|
});
|
|
286
285
|
_this2.eventCenter.dispatchToApp({
|
|
287
286
|
event: EVENT.beforeConfirm.name,
|
|
288
|
-
data:
|
|
287
|
+
data: {
|
|
289
288
|
success: true,
|
|
290
289
|
result: !!shouldContinue
|
|
291
|
-
}
|
|
292
|
-
isTimeout: true
|
|
293
|
-
} : {})
|
|
290
|
+
}
|
|
294
291
|
});
|
|
295
|
-
_context.next =
|
|
292
|
+
_context.next = 23;
|
|
296
293
|
break;
|
|
297
|
-
case
|
|
298
|
-
_context.prev =
|
|
294
|
+
case 19:
|
|
295
|
+
_context.prev = 19;
|
|
299
296
|
_context.t0 = _context["catch"](6);
|
|
300
297
|
logger.logError({
|
|
301
298
|
title: 'sdk_before_confirm_error'
|
|
@@ -311,11 +308,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
311
308
|
result: false
|
|
312
309
|
}
|
|
313
310
|
});
|
|
314
|
-
case
|
|
311
|
+
case 23:
|
|
315
312
|
case "end":
|
|
316
313
|
return _context.stop();
|
|
317
314
|
}
|
|
318
|
-
}, _callee, null, [[6,
|
|
315
|
+
}, _callee, null, [[6, 19]]);
|
|
319
316
|
})));
|
|
320
317
|
}
|
|
321
318
|
}, {
|
|
@@ -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) {
|
|
@@ -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,73 @@
|
|
|
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
|
+
var _result$error;
|
|
10
|
+
return {
|
|
11
|
+
status: result.status || 'FAIL',
|
|
12
|
+
error: result.error ? {
|
|
13
|
+
code: result.error.code,
|
|
14
|
+
message: result.error.message,
|
|
15
|
+
needChangeSessionForRetry: (_result$error = result.error) === null || _result$error === void 0 ? void 0 : _result$error.needChangeSessionForRetry
|
|
16
|
+
} : undefined,
|
|
17
|
+
userCanceled3D: result.userCanceled3D,
|
|
18
|
+
session: result.paymentSession ? {
|
|
19
|
+
nextAction: {
|
|
20
|
+
applinkUrl: result.paymentSession.returnAppUrl,
|
|
21
|
+
normalUrl: result.paymentSession.returnUrl,
|
|
22
|
+
schemeUrl: result.paymentSession.returnAppScheme
|
|
23
|
+
}
|
|
24
|
+
} : undefined
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function adaptErrorToEventCallback(error) {
|
|
28
|
+
return {
|
|
29
|
+
code: error.code || EventCallbackCode.SDK_PAYMENT_ERROR,
|
|
30
|
+
message: error.message || ''
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 将老架构的 appearance 格式转换为新架构格式
|
|
36
|
+
*
|
|
37
|
+
* 转换规则:
|
|
38
|
+
* 1. theme: kebab-case → camelCase(如 'nostalgic-gray' → 'nostalgicGray'),其余保持不变
|
|
39
|
+
* 2. variables: 直接透传(kebab-case CSS 变量 key-value)
|
|
40
|
+
* 3. card.showBrandIcon → displaySetting.showCardBrandIcon
|
|
41
|
+
* 4. layout: 直接透传
|
|
42
|
+
*/
|
|
43
|
+
export function adaptAppearance(appearance, merchantAppointParam) {
|
|
44
|
+
var _appearance$card, _merchantAppointParam, _appearance$accordion;
|
|
45
|
+
if (!appearance) return undefined;
|
|
46
|
+
var result = {};
|
|
47
|
+
|
|
48
|
+
// Theme mapping: kebab-case → camelCase
|
|
49
|
+
if (appearance.theme) {
|
|
50
|
+
result.theme = appearance.theme;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Variables: 直接透传
|
|
54
|
+
if (appearance.variables && _typeof(appearance.variables) === 'object') {
|
|
55
|
+
var filtered = _objectSpread({}, appearance.variables);
|
|
56
|
+
if (Object.keys(filtered).length > 0) {
|
|
57
|
+
result.variables = filtered;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
result.displaySetting = {
|
|
61
|
+
showCardBrandIcon: !!((_appearance$card = appearance.card) !== null && _appearance$card !== void 0 && _appearance$card.showBrandIcon),
|
|
62
|
+
showCardCVV: !!(merchantAppointParam !== null && merchantAppointParam !== void 0 && (_merchantAppointParam = merchantAppointParam.storedCard) !== null && _merchantAppointParam !== void 0 && _merchantAppointParam.needCVV),
|
|
63
|
+
showPaymentMethodListWhenSingleOption: (merchantAppointParam === null || merchantAppointParam === void 0 ? void 0 : merchantAppointParam.singleOption) === 'list',
|
|
64
|
+
showRadioWhenAccordionLayout: !!((_appearance$accordion = appearance.accordion) !== null && _appearance$accordion !== void 0 && _appearance$accordion.showRadio)
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Layout: 直接透传
|
|
68
|
+
if (appearance.layout) {
|
|
69
|
+
var _appearance$layout$ty;
|
|
70
|
+
result.layout = ((_appearance$layout$ty = appearance.layout.type) === null || _appearance$layout$ty === void 0 ? void 0 : _appearance$layout$ty.toLowerCase()) || 'accordion';
|
|
71
|
+
}
|
|
72
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
73
|
+
}
|