@alipay/ams-checkout 2.0.20 → 2.0.22
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/element/elementController/index.d.ts +3 -3
- package/esm/core/component/element/elementController/index.js +66 -42
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +13 -10
- 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 +1 -1
- 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 +1818 -0
- package/esm/core/component/element/type.d.ts +16 -18
- 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 +3 -3
- package/esm/plugin/component/channel.js +28 -19
- package/esm/plugin/component/index.js +36 -29
- package/esm/tsdoc-metadata.json +1 -1
- package/esm/types/index.d.ts +1 -0
- 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 +872 -1102
- package/types.untrimmed.d.ts +1024 -1121
- 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 = "2.0.22";
|
|
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 } from "../../../../util/beforeConfirm";
|
|
40
|
+
import { executeWithTimeout, BEFORE_CONFIRM_TIMEOUT_MS, MERCHANT_CONFIRM_ABORT_CODE, MERCHANT_CONFIRM_TIMEOUT_CODE } 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, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
|
385
|
+
var startEventId, res, logParams, isApplePay, paymentMethodType, startTime, _yield$executeWithTim, shouldContinue, timedOut, isTimeout, 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 = 40;
|
|
409
416
|
break;
|
|
410
417
|
}
|
|
411
418
|
this.serviceMap.Log.logInfo({
|
|
@@ -424,49 +431,65 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
424
431
|
_yield$executeWithTim = _context4.sent;
|
|
425
432
|
shouldContinue = _yield$executeWithTim.result;
|
|
426
433
|
timedOut = _yield$executeWithTim.timedOut;
|
|
427
|
-
|
|
428
|
-
|
|
434
|
+
isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS;
|
|
435
|
+
if (!isTimeout) {
|
|
436
|
+
_context4.next = 24;
|
|
429
437
|
break;
|
|
430
438
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
439
|
+
this.serviceMap.Log.logError({
|
|
440
|
+
title: 'sdk_before_confirm_timeout'
|
|
441
|
+
}, {
|
|
442
|
+
paymentMethodType: paymentMethodType,
|
|
443
|
+
path: 'nonApplePay_sync'
|
|
444
|
+
});
|
|
445
|
+
this.changeLoading(false);
|
|
446
|
+
this.elementEventCenter.endEvent(startEventId, {
|
|
447
|
+
eventCode: PaymentStatus.FAIL,
|
|
448
|
+
errorName: MERCHANT_CONFIRM_TIMEOUT_CODE
|
|
449
|
+
});
|
|
450
|
+
return _context4.abrupt("return", {
|
|
451
|
+
status: PaymentStatus.FAIL,
|
|
452
|
+
error: {
|
|
453
|
+
code: MERCHANT_CONFIRM_TIMEOUT_CODE,
|
|
454
|
+
message: 'Merchant confirmation timed out.',
|
|
455
|
+
needChangeSessionForRetry: false
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
case 24:
|
|
459
|
+
if (shouldContinue) {
|
|
460
|
+
_context4.next = 29;
|
|
461
|
+
break;
|
|
445
462
|
}
|
|
463
|
+
this.serviceMap.Log.logInfo({
|
|
464
|
+
title: 'sdk_before_confirm_abort'
|
|
465
|
+
}, {
|
|
466
|
+
paymentMethodType: paymentMethodType,
|
|
467
|
+
path: 'nonApplePay_sync'
|
|
468
|
+
});
|
|
446
469
|
this.changeLoading(false);
|
|
447
470
|
this.elementEventCenter.endEvent(startEventId, {
|
|
448
471
|
eventCode: PaymentStatus.FAIL,
|
|
449
|
-
errorName:
|
|
472
|
+
errorName: MERCHANT_CONFIRM_ABORT_CODE
|
|
450
473
|
});
|
|
451
474
|
return _context4.abrupt("return", {
|
|
452
475
|
status: PaymentStatus.FAIL,
|
|
453
476
|
error: {
|
|
454
|
-
code:
|
|
455
|
-
message: '
|
|
477
|
+
code: MERCHANT_CONFIRM_ABORT_CODE,
|
|
478
|
+
message: 'Payment was cancelled by merchant before confirmation.',
|
|
456
479
|
needChangeSessionForRetry: false
|
|
457
480
|
}
|
|
458
481
|
});
|
|
459
|
-
case
|
|
482
|
+
case 29:
|
|
460
483
|
this.serviceMap.Log.logInfo({
|
|
461
484
|
title: 'sdk_before_confirm_success'
|
|
462
485
|
}, {
|
|
463
486
|
paymentMethodType: paymentMethodType,
|
|
464
487
|
path: 'nonApplePay_sync'
|
|
465
488
|
});
|
|
466
|
-
_context4.next =
|
|
489
|
+
_context4.next = 38;
|
|
467
490
|
break;
|
|
468
|
-
case
|
|
469
|
-
_context4.prev =
|
|
491
|
+
case 32:
|
|
492
|
+
_context4.prev = 32;
|
|
470
493
|
_context4.t0 = _context4["catch"](11);
|
|
471
494
|
this.serviceMap.Log.logError({
|
|
472
495
|
title: 'sdk_before_confirm_error'
|
|
@@ -478,20 +501,20 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
478
501
|
this.changeLoading(false);
|
|
479
502
|
this.elementEventCenter.endEvent(startEventId, {
|
|
480
503
|
eventCode: PaymentStatus.FAIL,
|
|
481
|
-
errorName:
|
|
504
|
+
errorName: MERCHANT_CONFIRM_ABORT_CODE
|
|
482
505
|
});
|
|
483
506
|
return _context4.abrupt("return", {
|
|
484
507
|
status: PaymentStatus.FAIL,
|
|
485
508
|
error: {
|
|
486
|
-
code:
|
|
487
|
-
message: '
|
|
509
|
+
code: MERCHANT_CONFIRM_ABORT_CODE,
|
|
510
|
+
message: 'Payment was cancelled by merchant before confirmation.',
|
|
488
511
|
needChangeSessionForRetry: false
|
|
489
512
|
}
|
|
490
513
|
});
|
|
491
|
-
case
|
|
492
|
-
_context4.next =
|
|
514
|
+
case 38:
|
|
515
|
+
_context4.next = 41;
|
|
493
516
|
break;
|
|
494
|
-
case
|
|
517
|
+
case 40:
|
|
495
518
|
if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm)) {
|
|
496
519
|
this.serviceMap.Log.logInfo({
|
|
497
520
|
title: 'sdk_before_confirm_skip'
|
|
@@ -500,10 +523,10 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
500
523
|
path: isApplePay ? 'applePay_eventBridge' : 'nonApplePay_sync'
|
|
501
524
|
});
|
|
502
525
|
}
|
|
503
|
-
case
|
|
526
|
+
case 41:
|
|
504
527
|
recordResult = null;
|
|
505
|
-
_context4.prev =
|
|
506
|
-
_context4.next =
|
|
528
|
+
_context4.prev = 42;
|
|
529
|
+
_context4.next = 45;
|
|
507
530
|
return new Promise( /*#__PURE__*/function () {
|
|
508
531
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
509
532
|
var that, recordResultCallback, params, processStep, hasBeforeConfirmForApplePay, hasAmount, hasCurrency, _yield$_this3$onValid2, _data, errorString, errorResult;
|
|
@@ -592,7 +615,8 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
592
615
|
}, {
|
|
593
616
|
msg: safeStringify({
|
|
594
617
|
hasBeforeConfirmForApplePay: hasBeforeConfirmForApplePay,
|
|
595
|
-
isApplePay: isApplePay
|
|
618
|
+
isApplePay: isApplePay,
|
|
619
|
+
amount: "".concat(submitParams === null || submitParams === void 0 ? void 0 : submitParams.amount, ", ").concat(submitParams === null || submitParams === void 0 ? void 0 : submitParams.currency)
|
|
596
620
|
})
|
|
597
621
|
});
|
|
598
622
|
_this3.elementProcessors[ElementType.payment].setOnBeforeConfirm(hasBeforeConfirmForApplePay ? submitParams.onBeforeConfirm : null);
|
|
@@ -660,10 +684,10 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
660
684
|
return _ref3.apply(this, arguments);
|
|
661
685
|
};
|
|
662
686
|
}());
|
|
663
|
-
case
|
|
687
|
+
case 45:
|
|
664
688
|
return _context4.abrupt("return", _context4.sent);
|
|
665
|
-
case
|
|
666
|
-
_context4.prev =
|
|
689
|
+
case 46:
|
|
690
|
+
_context4.prev = 46;
|
|
667
691
|
_logParams = {
|
|
668
692
|
eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
|
|
669
693
|
errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
|
|
@@ -674,12 +698,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
674
698
|
};
|
|
675
699
|
this.elementEventCenter.endEvent(startEventId, _logParams);
|
|
676
700
|
this.changeLoading(false);
|
|
677
|
-
return _context4.finish(
|
|
678
|
-
case
|
|
701
|
+
return _context4.finish(46);
|
|
702
|
+
case 51:
|
|
679
703
|
case "end":
|
|
680
704
|
return _context4.stop();
|
|
681
705
|
}
|
|
682
|
-
}, _callee4, this, [[11,
|
|
706
|
+
}, _callee4, this, [[11, 32], [42,, 46, 51]]);
|
|
683
707
|
}));
|
|
684
708
|
function submitPayment(_x) {
|
|
685
709
|
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, isTimeout;
|
|
234
234
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
235
235
|
while (1) switch (_context.prev = _context.next) {
|
|
236
236
|
case 0:
|
|
@@ -270,8 +270,9 @@ 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
|
-
|
|
273
|
+
shouldContinue = rawResult;
|
|
274
|
+
isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS; // 双重校验:timedOut(Promise race) + startTime(实际时间差),防止竞态误判
|
|
275
|
+
if (isTimeout) {
|
|
275
276
|
logger.logError({
|
|
276
277
|
title: 'sdk_before_confirm_timeout'
|
|
277
278
|
});
|
|
@@ -284,15 +285,17 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
284
285
|
});
|
|
285
286
|
_this2.eventCenter.dispatchToApp({
|
|
286
287
|
event: EVENT.beforeConfirm.name,
|
|
287
|
-
data: {
|
|
288
|
+
data: _objectSpread({
|
|
288
289
|
success: true,
|
|
289
290
|
result: !!shouldContinue
|
|
290
|
-
}
|
|
291
|
+
}, isTimeout ? {
|
|
292
|
+
isTimeout: true
|
|
293
|
+
} : {})
|
|
291
294
|
});
|
|
292
|
-
_context.next =
|
|
295
|
+
_context.next = 24;
|
|
293
296
|
break;
|
|
294
|
-
case
|
|
295
|
-
_context.prev =
|
|
297
|
+
case 20:
|
|
298
|
+
_context.prev = 20;
|
|
296
299
|
_context.t0 = _context["catch"](6);
|
|
297
300
|
logger.logError({
|
|
298
301
|
title: 'sdk_before_confirm_error'
|
|
@@ -308,11 +311,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
308
311
|
result: false
|
|
309
312
|
}
|
|
310
313
|
});
|
|
311
|
-
case
|
|
314
|
+
case 24:
|
|
312
315
|
case "end":
|
|
313
316
|
return _context.stop();
|
|
314
317
|
}
|
|
315
|
-
}, _callee, null, [[6,
|
|
318
|
+
}, _callee, null, [[6, 20]]);
|
|
316
319
|
})));
|
|
317
320
|
}
|
|
318
321
|
}, {
|
|
@@ -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,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
|
+
}
|