@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
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.21";
|
|
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
|
+
}>;
|
|
@@ -20,7 +20,7 @@ export declare class AMSCheckoutPage {
|
|
|
20
20
|
/**
|
|
21
21
|
* 挂载组件
|
|
22
22
|
*/
|
|
23
|
-
mountComponent(params: Pick<IcreateComponent, 'sessionData'>, selector: string): Promise<void>;
|
|
23
|
+
mountComponent(params: Pick<IcreateComponent, 'sessionData' | 'isDemoMode'>, selector: string): Promise<void>;
|
|
24
24
|
/**
|
|
25
25
|
* 卸载组件
|
|
26
26
|
*/
|
|
@@ -50,7 +50,7 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
|
|
|
50
50
|
_defineProperty(this, "originOptions", void 0);
|
|
51
51
|
_defineProperty(this, "APP_IFRAME_ID", 'antom-checkout-page-sub-page-iframe');
|
|
52
52
|
_defineProperty(this, "eventListener", void 0);
|
|
53
|
-
_defineProperty(this, "generateIframeSrc", function (sessionData) {
|
|
53
|
+
_defineProperty(this, "generateIframeSrc", function (sessionData, isDemoMode) {
|
|
54
54
|
var env = _this.originOptions.environment || 'prod';
|
|
55
55
|
var session = sessionData || '';
|
|
56
56
|
var lang = _this.originOptions.locale || 'en_US';
|
|
@@ -66,6 +66,9 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
|
|
|
66
66
|
if (env === 'sandbox') {
|
|
67
67
|
queryObj.shadow = 'true';
|
|
68
68
|
}
|
|
69
|
+
if (isDemoMode) {
|
|
70
|
+
queryObj.demoMode = 'true';
|
|
71
|
+
}
|
|
69
72
|
Object.keys(queryObj).forEach(function (key) {
|
|
70
73
|
url += "".concat(url.includes('?') ? '&' : '?').concat(key, "=").concat(encodeURIComponent(queryObj[key]));
|
|
71
74
|
});
|
|
@@ -177,7 +180,7 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
|
|
|
177
180
|
throw new Error('PARAMS_ERROR_ALREADY_MOUNTED');
|
|
178
181
|
}
|
|
179
182
|
this.addListener();
|
|
180
|
-
var ckpPageAddress = this.generateIframeSrc(params.sessionData);
|
|
183
|
+
var ckpPageAddress = this.generateIframeSrc(params.sessionData, params.isDemoMode);
|
|
181
184
|
var iframe = document.createElement('iframe');
|
|
182
185
|
iframe.id = this.APP_IFRAME_ID;
|
|
183
186
|
iframe.src = ckpPageAddress;
|
|
@@ -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);
|
|
@@ -57,6 +57,7 @@ var BaseElementProcessor = /*#__PURE__*/function () {
|
|
|
57
57
|
_setEnv();
|
|
58
58
|
this.options.locale = (options === null || options === void 0 ? void 0 : options.locale) || '';
|
|
59
59
|
this.options.product = options === null || options === void 0 ? void 0 : options.product;
|
|
60
|
+
this.options.preview = options === null || options === void 0 ? void 0 : options.preview;
|
|
60
61
|
}
|
|
61
62
|
}, {
|
|
62
63
|
key: "registerElementContainer",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IPaymentMethod } from "../../../../types";
|
|
2
|
+
interface PaymentMethodsConfig {
|
|
3
|
+
expressCheckout?: {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
methods?: {
|
|
6
|
+
paymentMethodName: string;
|
|
7
|
+
paymentMethodType: string;
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
supportedMethods?: {
|
|
11
|
+
paymentMethodName: string;
|
|
12
|
+
paymentMethodType: string;
|
|
13
|
+
logoUrl?: string;
|
|
14
|
+
}[];
|
|
15
|
+
topping?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 将 paymentMethods 配置转换为内部格式
|
|
19
|
+
* 与 CKP 的 convertPaymentMethods 逻辑保持一致
|
|
20
|
+
*/
|
|
21
|
+
export declare function convertPaymentMethods(paymentMethodsConf?: PaymentMethodsConfig): IPaymentMethod[];
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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
|
+
/**
|
|
14
|
+
* 为 GOOGLEPAY 支付方式补充 mock 的 paymentMethodDetail 数据
|
|
15
|
+
* 预览模式下 GooglePay 需要完整的 googlePayProps 才能正常渲染
|
|
16
|
+
*/
|
|
17
|
+
function handleGooglePayMethodDetail(method) {
|
|
18
|
+
if (method.paymentMethodType === 'GOOGLEPAY') {
|
|
19
|
+
method.paymentMethodDetail = _objectSpread(_objectSpread({}, method.paymentMethodDetail), {}, {
|
|
20
|
+
googlePayProps: {
|
|
21
|
+
environment: 'TEST',
|
|
22
|
+
existingPaymentMethodRequired: true,
|
|
23
|
+
paymentRequest: {
|
|
24
|
+
allowedPaymentMethods: [{
|
|
25
|
+
parameters: {
|
|
26
|
+
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
|
|
27
|
+
allowedCardNetworks: ['VISA', 'JCB']
|
|
28
|
+
},
|
|
29
|
+
tokenizationSpecification: {
|
|
30
|
+
parameters: {
|
|
31
|
+
protocolVersion: 'ECv2',
|
|
32
|
+
publicKey: 'BDM6GVTLZmxSmTQzm04QKI2av54kFpkqjhbkejtdDUx+VMvUtJ6vc+ZlDp8TygNTf+QeihxpD869sCVWaa0KMJc='
|
|
33
|
+
},
|
|
34
|
+
type: 'DIRECT'
|
|
35
|
+
},
|
|
36
|
+
type: 'CARD'
|
|
37
|
+
}],
|
|
38
|
+
apiVersion: 2,
|
|
39
|
+
apiVersionMinor: 0,
|
|
40
|
+
callbackIntents: ['PAYMENT_AUTHORIZATION'],
|
|
41
|
+
merchantInfo: {
|
|
42
|
+
merchantId: '123',
|
|
43
|
+
merchantName: 'merchantName'
|
|
44
|
+
},
|
|
45
|
+
shippingAddressRequired: true,
|
|
46
|
+
transactionInfo: {
|
|
47
|
+
countryCode: 'US',
|
|
48
|
+
currencyCode: 'EUR',
|
|
49
|
+
totalPrice: '10',
|
|
50
|
+
totalPriceStatus: 'FINAL'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 为 ONLINEBANKING_YAPILY 支付方式处理 mock 数据
|
|
60
|
+
* Yapily 在预览模式下需要清空 paymentElements
|
|
61
|
+
*/
|
|
62
|
+
function handleYapilyMethodDetail(method) {
|
|
63
|
+
if (method.paymentMethodType === 'ONLINEBANKING_YAPILY') {
|
|
64
|
+
method.paymentElements = [];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 合并所有的 Card 类支付方式
|
|
70
|
+
* 与 CKP handleAllCardsData 逻辑一致
|
|
71
|
+
*/
|
|
72
|
+
function handleAllCardsData() {
|
|
73
|
+
var supportedMethods = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
74
|
+
var firstCardIndex = -1;
|
|
75
|
+
var logoList = [];
|
|
76
|
+
supportedMethods.forEach(function (item, index) {
|
|
77
|
+
if (item.paymentMethodName === 'CARD') {
|
|
78
|
+
logoList.push({
|
|
79
|
+
cardBrand: item.paymentMethodType,
|
|
80
|
+
logoUrl: item.logoUrl || ''
|
|
81
|
+
});
|
|
82
|
+
if (firstCardIndex === -1) {
|
|
83
|
+
firstCardIndex = index;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
if (logoList.length) {
|
|
88
|
+
return {
|
|
89
|
+
firstCardIndex: firstCardIndex,
|
|
90
|
+
cardPaymentMethod: {
|
|
91
|
+
antomPage: 'paymentMetaPage',
|
|
92
|
+
category: 'CARD',
|
|
93
|
+
expressCheckout: false,
|
|
94
|
+
logoList: logoList,
|
|
95
|
+
paymentMethod: 'CARD',
|
|
96
|
+
paymentMethodName: 'Card',
|
|
97
|
+
paymentMethodType: 'CARD',
|
|
98
|
+
recommend: false,
|
|
99
|
+
webRedirectType: 'PAGE_REFRESH'
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 将 paymentMethods 配置转换为内部格式
|
|
108
|
+
* 与 CKP 的 convertPaymentMethods 逻辑保持一致
|
|
109
|
+
*/
|
|
110
|
+
export function convertPaymentMethods(paymentMethodsConf) {
|
|
111
|
+
if (!paymentMethodsConf) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
var expressCheckout = paymentMethodsConf.expressCheckout,
|
|
115
|
+
supportedMethods = paymentMethodsConf.supportedMethods,
|
|
116
|
+
topping = paymentMethodsConf.topping;
|
|
117
|
+
|
|
118
|
+
// 1. 处理极速支付(排在最前面)
|
|
119
|
+
var supportedExpressCheckoutMethods = ((expressCheckout === null || expressCheckout === void 0 ? void 0 : expressCheckout.methods) || []).map(function (item) {
|
|
120
|
+
var method = {
|
|
121
|
+
paymentMethodName: item.paymentMethodName,
|
|
122
|
+
paymentMethodType: item.paymentMethodType,
|
|
123
|
+
category: item.paymentMethodType,
|
|
124
|
+
expressCheckout: true
|
|
125
|
+
};
|
|
126
|
+
handleGooglePayMethodDetail(method);
|
|
127
|
+
return method;
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// 2. 处理普通支付方式(跳过 CARD,CARD 统一合并处理)
|
|
131
|
+
var supportedPaymentMethods = [];
|
|
132
|
+
(supportedMethods || []).forEach(function (item) {
|
|
133
|
+
if (item.paymentMethodName === 'CARD') {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
var method = {
|
|
137
|
+
paymentMethodName: item.paymentMethodName,
|
|
138
|
+
paymentMethodType: item.paymentMethodType,
|
|
139
|
+
category: item.paymentMethodType,
|
|
140
|
+
icon: item.logoUrl,
|
|
141
|
+
recommend: false
|
|
142
|
+
};
|
|
143
|
+
if (method.paymentMethodType === topping) {
|
|
144
|
+
method.recommend = true;
|
|
145
|
+
}
|
|
146
|
+
handleGooglePayMethodDetail(method);
|
|
147
|
+
handleYapilyMethodDetail(method);
|
|
148
|
+
supportedPaymentMethods.push(method);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// 3. 合并所有的 Card 类支付方式
|
|
152
|
+
var cardPaymentMethods = handleAllCardsData(supportedMethods);
|
|
153
|
+
|
|
154
|
+
// 4. 插入 Card 类支付方式 (card 第一次出现的位置)
|
|
155
|
+
if (cardPaymentMethods) {
|
|
156
|
+
supportedPaymentMethods.splice(cardPaymentMethods.firstCardIndex, 0, cardPaymentMethods.cardPaymentMethod);
|
|
157
|
+
}
|
|
158
|
+
return [].concat(_toConsumableArray(supportedExpressCheckoutMethods), supportedPaymentMethods);
|
|
159
|
+
}
|
|
@@ -23,6 +23,11 @@ declare class PaymentProcessor extends BaseElementProcessor {
|
|
|
23
23
|
instanceId: any;
|
|
24
24
|
}): string;
|
|
25
25
|
obtainData(): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* 构建预览模式的 mock 数据
|
|
28
|
+
* 合并 mock.ts 的硬编码数据和 mount 传入的 paymentMethods 配置
|
|
29
|
+
*/
|
|
30
|
+
private buildPreviewMockData;
|
|
26
31
|
getValue(): any;
|
|
27
32
|
update({ data, paymentSessionData }: {
|
|
28
33
|
data: any;
|