@alipay/ams-checkout 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +2 -0
- package/esm/config/index.js +17 -0
- package/esm/config/request.d.ts +21 -0
- package/esm/config/request.js +67 -0
- package/esm/constant/index.d.ts +136 -0
- package/esm/constant/index.js +136 -0
- package/esm/core/component/index.d.ts +17 -0
- package/esm/core/component/index.js +100 -0
- package/esm/core/drop-in/index.d.ts +29 -0
- package/esm/core/drop-in/index.js +104 -0
- package/esm/core/instance/index.d.ts +59 -0
- package/esm/core/instance/index.js +254 -0
- package/esm/image/cta.svg +9 -0
- package/esm/index.d.ts +22 -0
- package/esm/plugin/component/cashierApp.d.ts +23 -0
- package/esm/plugin/component/cashierApp.js +122 -0
- package/esm/plugin/component/component.style.d.ts +8 -0
- package/esm/plugin/component/component.style.js +15 -0
- package/esm/plugin/component/index.d.ts +102 -0
- package/esm/plugin/component/index.js +900 -0
- package/esm/plugin/drop-in/index.d.ts +73 -0
- package/esm/plugin/drop-in/index.js +323 -0
- package/esm/request/index.d.ts +15 -0
- package/esm/request/index.js +145 -0
- package/esm/request/utils.d.ts +28 -0
- package/esm/request/utils.js +59 -0
- package/esm/service/index.d.ts +2 -0
- package/esm/service/index.js +40 -0
- package/esm/types/index.d.ts +216 -0
- package/esm/types/index.js +97 -0
- package/esm/util/createIframeNode.d.ts +5 -0
- package/esm/util/createIframeNode.js +35 -0
- package/esm/util/get.d.ts +25 -0
- package/esm/util/get.js +145 -0
- package/esm/util/index.d.ts +53 -0
- package/esm/util/index.js +237 -0
- package/esm/util/intl-callapp/es/browser.d.ts +21 -0
- package/esm/util/intl-callapp/es/browser.js +42 -0
- package/esm/util/intl-callapp/es/evoke.d.ts +13 -0
- package/esm/util/intl-callapp/es/evoke.js +39 -0
- package/esm/util/intl-callapp/es/generate.d.ts +29 -0
- package/esm/util/intl-callapp/es/generate.js +44 -0
- package/esm/util/intl-callapp/es/index.d.ts +43 -0
- package/esm/util/intl-callapp/es/index.js +298 -0
- package/esm/util/intl-callapp/es/main.d.ts +41 -0
- package/esm/util/intl-callapp/es/main.js +305 -0
- package/esm/util/intl-callapp/es/openWallet.d.ts +15 -0
- package/esm/util/intl-callapp/es/openWallet.js +197 -0
- package/esm/util/intl-callapp/es/types.d.ts +46 -0
- package/esm/util/intl-callapp/es/types.js +1 -0
- package/esm/util/intl-callapp/es/utils/config.d.ts +24 -0
- package/esm/util/intl-callapp/es/utils/config.js +57 -0
- package/esm/util/intl-callapp/es/utils/index.d.ts +15 -0
- package/esm/util/intl-callapp/es/utils/index.js +98 -0
- package/esm/util/mock.d.ts +1 -0
- package/esm/util/mock.js +4 -0
- package/package.json +1 -1
@@ -0,0 +1,17 @@
|
|
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
|
+
*/
|
8
|
+
import json from "../../package.json";
|
9
|
+
export var marmptMap = {
|
10
|
+
dev: 'http://page.alipay.net/page/antom-web-checkout/src/component-app',
|
11
|
+
sit: 'http://page.test.alipay.net/page/antom-web-checkout/src/component-app',
|
12
|
+
pre: 'https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app',
|
13
|
+
sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
|
14
|
+
light_sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
|
15
|
+
prod: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app'
|
16
|
+
};
|
17
|
+
export var sdkVersion = json.version;
|
@@ -0,0 +1,21 @@
|
|
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
|
+
*/
|
8
|
+
export declare const requestHost: {
|
9
|
+
[key: string]: string;
|
10
|
+
};
|
11
|
+
export declare const clientId = "5J5Y8X4E2Y25GR00690";
|
12
|
+
export declare const tntInstId = "ALIPW3SG";
|
13
|
+
export declare const appId = "ANTOM_PAYMENT_WEB";
|
14
|
+
export declare const sofaId: any;
|
15
|
+
export declare const hostSignMap: (hostSign: string | undefined, env: string) => string;
|
16
|
+
export declare const lightSandboxMap: (operationType: string | undefined, env: string) => {
|
17
|
+
appId: string;
|
18
|
+
sofaId: any;
|
19
|
+
baseURL: string;
|
20
|
+
'Operation-Type': string;
|
21
|
+
};
|
@@ -0,0 +1,67 @@
|
|
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
|
+
*/
|
8
|
+
|
9
|
+
import { queryParse } from "../util";
|
10
|
+
var _queryParse = queryParse(),
|
11
|
+
_light_sandbox = _queryParse._light_sandbox,
|
12
|
+
groupId = _queryParse.groupId,
|
13
|
+
host = _queryParse.requestHost;
|
14
|
+
export var requestHost = {
|
15
|
+
local: 'http://imgs-1164.gz00b.dev.alipay.net/mgw.htm',
|
16
|
+
dev: host || 'http://imgs-1164.gz00b.dev.alipay.net/mgw.htm',
|
17
|
+
sit: host || 'http://imgs-9.sggz00a.test.alipay.net/mgw.htm',
|
18
|
+
pre: 'https://imgs-sea-pre.alipay.com/mgw.htm',
|
19
|
+
prod: 'https://imgs-sea-global.alipay.com/mgw.htm',
|
20
|
+
sandbox: 'https://imgs-sea-global.alipay.com/mgw.htm'
|
21
|
+
};
|
22
|
+
export var clientId = '5J5Y8X4E2Y25GR00690';
|
23
|
+
export var tntInstId = 'ALIPW3SG';
|
24
|
+
export var appId = 'ANTOM_PAYMENT_WEB';
|
25
|
+
export var sofaId = groupId || 'GROUP_20230523202227';
|
26
|
+
export var hostSignMap = function hostSignMap(hostSign, env) {
|
27
|
+
var map = {
|
28
|
+
SG: 'https://imgs-sea-global.alipay.com/mgw.htm',
|
29
|
+
US: 'https://imgs-na-global.alipay.com/mgw.htm',
|
30
|
+
DE: 'https://imgs-de-global.alipay.com/mgw.htm'
|
31
|
+
};
|
32
|
+
var preMap = {
|
33
|
+
SG: 'https://imgs-sea-pre.alipay.com/mgw.htm',
|
34
|
+
US: 'https://imgs-pre.alipay.com/mgw.htm',
|
35
|
+
DE: 'https://imgs-de-pre.alipay.com/mgw.htm'
|
36
|
+
};
|
37
|
+
if (env === 'prod' || env === 'sandbox' || env === 'light_sandbox') {
|
38
|
+
return map[hostSign || 'SG'];
|
39
|
+
} else if (env === 'pre') {
|
40
|
+
return preMap[hostSign || 'SG'];
|
41
|
+
} else return '';
|
42
|
+
};
|
43
|
+
export var lightSandboxMap = function lightSandboxMap() {
|
44
|
+
var operationType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
45
|
+
var env = arguments.length > 1 ? arguments[1] : undefined;
|
46
|
+
var map = {
|
47
|
+
pre: 'https://imgs-sea-pre.alipay.com/mgw.htm',
|
48
|
+
sit: host || 'http://imgs-9.sggz00a.test.alipay.net/mgw.htm',
|
49
|
+
dev: host || 'http://imgs-13.sggz00b.stable.alipay.net/mgw.htm'
|
50
|
+
};
|
51
|
+
var typeMap = {
|
52
|
+
'com.ipay.iexpcashier.sdkAction.query': 'com.ipay.iopensandbox.sdk.paymentSession.query'
|
53
|
+
};
|
54
|
+
var appId = 'SDK_MOCK_SANDBOX';
|
55
|
+
var sofaId = groupId || 'GROUP_20230315210531';
|
56
|
+
if (typeMap[operationType] && env === 'light_sandbox' || _light_sandbox === 'true') return {
|
57
|
+
appId: appId,
|
58
|
+
sofaId: sofaId,
|
59
|
+
baseURL: map[env],
|
60
|
+
'Operation-Type': typeMap[operationType]
|
61
|
+
};else return {
|
62
|
+
appId: '',
|
63
|
+
sofaId: '',
|
64
|
+
baseURL: '',
|
65
|
+
'Operation-Type': ''
|
66
|
+
};
|
67
|
+
};
|
@@ -0,0 +1,136 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
+
* 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:
|
4
|
+
* 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
|
5
|
+
* 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.
|
6
|
+
*/
|
7
|
+
export declare const ERRORMESSAGE: {
|
8
|
+
DOMAIN_NOT_IN_WHITE_LIST: {
|
9
|
+
errorCode: string;
|
10
|
+
errorMessage: string;
|
11
|
+
};
|
12
|
+
NOT_JSON_FORMAT: {
|
13
|
+
errorCode: string;
|
14
|
+
errorMessage: string;
|
15
|
+
};
|
16
|
+
SDK_COMPATIBILITY_ISSUES: {
|
17
|
+
errorCode: string;
|
18
|
+
BROWSER_NOT_SUPPORT_POSTMESSAGE: {
|
19
|
+
errorCode: string;
|
20
|
+
errorMessage: string;
|
21
|
+
};
|
22
|
+
FAILED_TO_CREATE_IFRAME: {
|
23
|
+
errorCode: string;
|
24
|
+
errorMessage: string;
|
25
|
+
};
|
26
|
+
};
|
27
|
+
INIT_PARAMETER_ERROR: {
|
28
|
+
errorCode: string;
|
29
|
+
UI_MODE_NOT_SUPPORTED: {
|
30
|
+
errorCode: string;
|
31
|
+
errorMessage: string;
|
32
|
+
};
|
33
|
+
ENVIRONMENT_ERROR: {
|
34
|
+
errorCode: string;
|
35
|
+
errorMessage: string;
|
36
|
+
};
|
37
|
+
MODE_ERROR: {
|
38
|
+
errorCode: string;
|
39
|
+
errorMessage: string;
|
40
|
+
};
|
41
|
+
LOCALE_ERROR: {
|
42
|
+
errorCode: string;
|
43
|
+
errorMessage: string;
|
44
|
+
};
|
45
|
+
NET_MODE_NOT_SUPPORT: {
|
46
|
+
errorCode: string;
|
47
|
+
errorMessage: string;
|
48
|
+
};
|
49
|
+
EVENT_ERROR: {
|
50
|
+
errorCode: string;
|
51
|
+
errorMessage: string;
|
52
|
+
};
|
53
|
+
};
|
54
|
+
CREATEPAYMENT_PARAMETER_ERROR: {
|
55
|
+
errorCode: string;
|
56
|
+
};
|
57
|
+
CONFIRMPAYMENT_PARAMETER_ERROR: {
|
58
|
+
errorCode: string;
|
59
|
+
};
|
60
|
+
CREATECOMPONENT_ERROR: {
|
61
|
+
errorCode: string;
|
62
|
+
errorMessage: string;
|
63
|
+
SINGLETON_COMPONENT_ERROR: {
|
64
|
+
errorCode: string;
|
65
|
+
errorMessage: string;
|
66
|
+
};
|
67
|
+
};
|
68
|
+
SDK_CALL_URL_ERROR: {
|
69
|
+
errorCode: string;
|
70
|
+
REDIRECT_ERROR: {
|
71
|
+
errorCode: string;
|
72
|
+
errorMessage: string;
|
73
|
+
};
|
74
|
+
};
|
75
|
+
};
|
76
|
+
export declare const BASEPLUGINID = "CHECKOUT";
|
77
|
+
export declare const COMPONENTPLUGINID = "COMPONENT";
|
78
|
+
export declare const EVENT: {
|
79
|
+
ready: {
|
80
|
+
name: string;
|
81
|
+
uniqueKey: string;
|
82
|
+
};
|
83
|
+
error: {
|
84
|
+
name: string;
|
85
|
+
uniqueKey: string;
|
86
|
+
};
|
87
|
+
paymentMethodSelected: {
|
88
|
+
name: string;
|
89
|
+
uniqueKey: string;
|
90
|
+
};
|
91
|
+
sizeChanged: {
|
92
|
+
name: string;
|
93
|
+
uniqueKey: string;
|
94
|
+
};
|
95
|
+
log: {
|
96
|
+
name: string;
|
97
|
+
uniqueKey: string;
|
98
|
+
};
|
99
|
+
launch: {
|
100
|
+
name: string;
|
101
|
+
};
|
102
|
+
redirect: {
|
103
|
+
name: string;
|
104
|
+
};
|
105
|
+
onClose: {
|
106
|
+
name: string;
|
107
|
+
uniqueKey: string;
|
108
|
+
};
|
109
|
+
eventCallback: {
|
110
|
+
name: string;
|
111
|
+
uniqueKey: string;
|
112
|
+
};
|
113
|
+
submitForm: {
|
114
|
+
name: string;
|
115
|
+
};
|
116
|
+
hideCloseButton: {
|
117
|
+
name: string;
|
118
|
+
};
|
119
|
+
showCloseButton: {
|
120
|
+
name: string;
|
121
|
+
};
|
122
|
+
setAllowRetention: {
|
123
|
+
name: string;
|
124
|
+
};
|
125
|
+
declareCheckoutInfo: {
|
126
|
+
name: string;
|
127
|
+
};
|
128
|
+
showPopup: {
|
129
|
+
name: string;
|
130
|
+
};
|
131
|
+
dismissLoading: {
|
132
|
+
name: string;
|
133
|
+
};
|
134
|
+
};
|
135
|
+
export declare const closeImg = "https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg";
|
136
|
+
export declare const LOADINGIMG = "data:image/png;base64,iV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oZW7WSdHiCGvXTBMtHDHtvI4yy1yQ4IHDbfquuMZMcfJMYmPhn3sIQE13JGTVaEJsHCGS6CGy6o0ykN1CrkcWjjDJVDDIwm34g69McUKSIDjnSHj4PNiEpWKWyoNWelewXEoCuhj5EPpEzeEVFa3L3X1bgHaKOQcjOOD0YFXqYtSCRkDEPW7ApbjMJExZ5LasyCIW8M9mBZ4FQLkHB7G2MfzJ3Q8eKyGtVIsFlcKvBwayfh/ldW8Ck4Va7USEorFAkEoi1zu3KQrEu+Ca6wwi54GpFmYeC6ruLRAgffCLVgv2EchwkuGgGVZWe15bElAL5FeUwSUBR1f5AQUESCQR2mVh1FkjfAkohJgLj1GEVtZIRFACP0fCm/AgmdREnzYqIRhFHkvq+J77MBFQpEPpCQOYPcntwIWeK6Mu0P9D9pzJq4u5hj+AAAAAElFTkSuQmCC";
|
@@ -0,0 +1,136 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
+
* 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:
|
4
|
+
* 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
|
5
|
+
* 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.
|
6
|
+
*/
|
7
|
+
export var ERRORMESSAGE = {
|
8
|
+
DOMAIN_NOT_IN_WHITE_LIST: {
|
9
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
10
|
+
errorMessage: 'Origin of the message is not in the white list'
|
11
|
+
},
|
12
|
+
NOT_JSON_FORMAT: {
|
13
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
14
|
+
errorMessage: 'The message string should conform to the json format'
|
15
|
+
},
|
16
|
+
SDK_COMPATIBILITY_ISSUES: {
|
17
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
18
|
+
BROWSER_NOT_SUPPORT_POSTMESSAGE: {
|
19
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
20
|
+
errorMessage: 'The browser does not support the postmessage communication mode'
|
21
|
+
},
|
22
|
+
FAILED_TO_CREATE_IFRAME: {
|
23
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
24
|
+
errorMessage: 'Failed to create iframe'
|
25
|
+
}
|
26
|
+
},
|
27
|
+
INIT_PARAMETER_ERROR: {
|
28
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
29
|
+
UI_MODE_NOT_SUPPORTED: {
|
30
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
31
|
+
errorMessage: 'This UI mode is not supported'
|
32
|
+
},
|
33
|
+
ENVIRONMENT_ERROR: {
|
34
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
35
|
+
errorMessage: 'The current input environment does not support or is not in the standard enumeration'
|
36
|
+
},
|
37
|
+
MODE_ERROR: {
|
38
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
39
|
+
errorMessage: 'mode value not in enum'
|
40
|
+
},
|
41
|
+
LOCALE_ERROR: {
|
42
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
43
|
+
errorMessage: 'The current input language does not support or is not in the standard enumeration'
|
44
|
+
},
|
45
|
+
NET_MODE_NOT_SUPPORT: {
|
46
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
47
|
+
errorMessage: 'The network mode is not supported'
|
48
|
+
},
|
49
|
+
EVENT_ERROR: {
|
50
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
51
|
+
errorMessage: 'Parameter type should be function'
|
52
|
+
}
|
53
|
+
},
|
54
|
+
CREATEPAYMENT_PARAMETER_ERROR: {
|
55
|
+
errorCode: 'SDK_CREATEPAYMENT_PARAMETER_ERROR'
|
56
|
+
},
|
57
|
+
CONFIRMPAYMENT_PARAMETER_ERROR: {
|
58
|
+
errorCode: 'SDK_CONFIRMPAYMENT_PARAMETER_ERROR'
|
59
|
+
},
|
60
|
+
CREATECOMPONENT_ERROR: {
|
61
|
+
errorCode: 'SDK_CREATECOMPONENT_ERROR',
|
62
|
+
errorMessage: 'Failed to create component',
|
63
|
+
SINGLETON_COMPONENT_ERROR: {
|
64
|
+
errorCode: 'SDK_CREATECOMPONENT_ERROR',
|
65
|
+
errorMessage: 'Only one component can be rendered simultaneously'
|
66
|
+
}
|
67
|
+
},
|
68
|
+
SDK_CALL_URL_ERROR: {
|
69
|
+
errorCode: 'SDK_CALL_URL_ERROR',
|
70
|
+
REDIRECT_ERROR: {
|
71
|
+
errorCode: 'SDK_CALL_URL_ERROR',
|
72
|
+
errorMessage: 'Redirect data exception'
|
73
|
+
}
|
74
|
+
}
|
75
|
+
};
|
76
|
+
export var BASEPLUGINID = 'CHECKOUT';
|
77
|
+
export var COMPONENTPLUGINID = 'COMPONENT';
|
78
|
+
export var EVENT = {
|
79
|
+
ready: {
|
80
|
+
name: 'onReady',
|
81
|
+
uniqueKey: 'userOnReady'
|
82
|
+
},
|
83
|
+
error: {
|
84
|
+
name: 'onError',
|
85
|
+
uniqueKey: 'userOnError'
|
86
|
+
},
|
87
|
+
paymentMethodSelected: {
|
88
|
+
name: 'onPaymentMethodSelected',
|
89
|
+
uniqueKey: 'userOnPaymentMethodSelected'
|
90
|
+
},
|
91
|
+
sizeChanged: {
|
92
|
+
name: 'onSizeChanged',
|
93
|
+
uniqueKey: 'userOnSizeChanged'
|
94
|
+
},
|
95
|
+
log: {
|
96
|
+
name: 'onLog',
|
97
|
+
uniqueKey: 'userOnLog'
|
98
|
+
},
|
99
|
+
launch: {
|
100
|
+
name: 'onLaunch'
|
101
|
+
},
|
102
|
+
redirect: {
|
103
|
+
name: 'onRedirect'
|
104
|
+
},
|
105
|
+
onClose: {
|
106
|
+
name: 'onClose',
|
107
|
+
uniqueKey: 'userOnClose'
|
108
|
+
},
|
109
|
+
eventCallback: {
|
110
|
+
name: 'onEventCallback',
|
111
|
+
uniqueKey: 'userEventCallback'
|
112
|
+
},
|
113
|
+
submitForm: {
|
114
|
+
name: 'submitForm'
|
115
|
+
},
|
116
|
+
hideCloseButton: {
|
117
|
+
name: 'hideCloseButton'
|
118
|
+
},
|
119
|
+
showCloseButton: {
|
120
|
+
name: 'showCloseButton'
|
121
|
+
},
|
122
|
+
setAllowRetention: {
|
123
|
+
name: 'setAllowRetention'
|
124
|
+
},
|
125
|
+
declareCheckoutInfo: {
|
126
|
+
name: 'declareCheckoutInfo'
|
127
|
+
},
|
128
|
+
showPopup: {
|
129
|
+
name: 'showPopup'
|
130
|
+
},
|
131
|
+
dismissLoading: {
|
132
|
+
name: 'dismissLoading'
|
133
|
+
}
|
134
|
+
};
|
135
|
+
export var closeImg = 'https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg';
|
136
|
+
export var LOADINGIMG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACEBAMAAACjap6UAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAAITgAACE4AUWWMWAAAAAqUExURUdwTKe3zKGxyK27z7K/05ytxLbD1bvH2Jaowb/K28DL3JCjvYueucDL2xLcxpgAAAAOdFJOUwCKoHRft0w5zCgY4fYKKSYvdQAABvtJREFUaN6lmt+LG1UUx6fddbcZHOgkpWutBTPbVBEfNp1xS6uF2oQURUGnBBbqw7Yd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+Ca6wwi54GpFmYeC6ruLRAgffCLVgv2EchwkuGgGVZWe15bElAL5FeUwSUBR1f5AQUESCQR2mVh1FkjfAkohJgLj1GEVtZIRFACP0fCm/AgmdREnzYqIRhFHkvq+J77MBFQpEPpCQOYPcntwIWeK6Mu0P9D9pzJq4u5hj+AAAAAElFTkSuQmCC';
|
@@ -0,0 +1,17 @@
|
|
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
|
+
*/
|
8
|
+
import { IcreateComponent, optionsParams } from '../../types';
|
9
|
+
export declare const mixinComponentConstructor: (options: optionsParams, context: any) => void;
|
10
|
+
/**
|
11
|
+
* @description Create component application
|
12
|
+
* @description component
|
13
|
+
*/
|
14
|
+
export declare const createComponent: (params: IcreateComponent) => Promise<void>;
|
15
|
+
export interface IcreateComponentFunc {
|
16
|
+
(params: IcreateComponent): Promise<void>;
|
17
|
+
}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
|
+
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); }
|
4
|
+
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; }
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
7
|
+
/**
|
8
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
9
|
+
*
|
10
|
+
* 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:
|
11
|
+
* 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
|
12
|
+
* 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.
|
13
|
+
*/
|
14
|
+
|
15
|
+
import { COMPONENTPLUGINID, ERRORMESSAGE } from "../../constant";
|
16
|
+
import ComponentApp from "../../plugin/component";
|
17
|
+
import { componentSignEnum, mode, networkMode, productSceneEnum } from "../../types";
|
18
|
+
import { isPC } from "../../util";
|
19
|
+
import { createIframeNode } from "../../util/createIframeNode";
|
20
|
+
var getComponentSign = function getComponentSign(params) {
|
21
|
+
var _params$paymentSessio = params.paymentSessionConfig,
|
22
|
+
_params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
|
23
|
+
_params$paymentSessio3 = _params$paymentSessio2.productScene,
|
24
|
+
productScene = _params$paymentSessio3 === void 0 ? '' : _params$paymentSessio3,
|
25
|
+
_params$paymentSessio4 = _params$paymentSessio2.paymentMethodCategoryType,
|
26
|
+
paymentMethodCategoryType = _params$paymentSessio4 === void 0 ? '' : _params$paymentSessio4;
|
27
|
+
return productScene && paymentMethodCategoryType ? "".concat(productScene, "_").concat(paymentMethodCategoryType) : componentSignEnum.NONE;
|
28
|
+
};
|
29
|
+
var parsePaymentSessionData = function parsePaymentSessionData(paymentSessionData) {
|
30
|
+
try {
|
31
|
+
return [JSON.parse(atob(paymentSessionData.split('&&')[3])), paymentSessionData.split('&&').slice(0, 3).join('&&')];
|
32
|
+
} catch (error) {
|
33
|
+
console.error('Parsing paymentSessionData is abnormal and may affect the payment link. Please ensure to use the new version of SDK.');
|
34
|
+
return [{}, paymentSessionData];
|
35
|
+
}
|
36
|
+
};
|
37
|
+
|
38
|
+
// pc easy-pay execute 1.0 Process
|
39
|
+
var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
|
40
|
+
if (isPC() && parseData !== null && parseData !== void 0 && parseData.paymentSessionConfig) {
|
41
|
+
var productScene = parseData.paymentSessionConfig.productScene;
|
42
|
+
if (productScene === productSceneEnum.EASY_PAY) {
|
43
|
+
parseData.paymentSessionConfig.productSceneVersion = '1.0';
|
44
|
+
}
|
45
|
+
}
|
46
|
+
};
|
47
|
+
var handlePaymentSessionData = function handlePaymentSessionData(originPaymentSessionData) {
|
48
|
+
var _parsePaymentSessionD = parsePaymentSessionData(originPaymentSessionData),
|
49
|
+
_parsePaymentSessionD2 = _slicedToArray(_parsePaymentSessionD, 2),
|
50
|
+
parseData = _parsePaymentSessionD2[0],
|
51
|
+
paymentSessionData = _parsePaymentSessionD2[1];
|
52
|
+
resetEasyPaySceneVersion(parseData);
|
53
|
+
return [parseData, paymentSessionData];
|
54
|
+
};
|
55
|
+
export var mixinComponentConstructor = function mixinComponentConstructor(options, context) {
|
56
|
+
// Instantiate the plug-in and set render
|
57
|
+
var ComponentPlugin = new ComponentApp();
|
58
|
+
ComponentPlugin.setRender(createIframeNode);
|
59
|
+
// Register Cashier Application Plug in
|
60
|
+
context._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
|
61
|
+
};
|
62
|
+
|
63
|
+
/**
|
64
|
+
* @description Create component application
|
65
|
+
* @description component
|
66
|
+
*/
|
67
|
+
export var createComponent = function createComponent(params) {
|
68
|
+
var _this = this;
|
69
|
+
this.options.mode = mode.component;
|
70
|
+
this.options.networkMode = this.options.networkMode || networkMode.session;
|
71
|
+
var _params = params;
|
72
|
+
if (_params && !_params.paymentSessionData) {
|
73
|
+
return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR);
|
74
|
+
}
|
75
|
+
if (this.options.networkMode === networkMode.proxy) {
|
76
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
|
77
|
+
return Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT);
|
78
|
+
}
|
79
|
+
return new Promise(function (resolve, reject) {
|
80
|
+
var _handlePaymentSession = handlePaymentSessionData(_params.paymentSessionData),
|
81
|
+
_handlePaymentSession2 = _slicedToArray(_handlePaymentSession, 2),
|
82
|
+
parseData = _handlePaymentSession2[0],
|
83
|
+
paymentSessionData = _handlePaymentSession2[1];
|
84
|
+
var componentSign = getComponentSign(parseData);
|
85
|
+
if (componentSign === componentSignEnum.NONE) {
|
86
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
87
|
+
return reject("".concat(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.errorCode, "\uFF1AAbnormal response data, interface failure, or unsupported payment method"));
|
88
|
+
}
|
89
|
+
_params.paymentSessionData = paymentSessionData;
|
90
|
+
_params.paymentSessionMetaData = parseData;
|
91
|
+
try {
|
92
|
+
var componentApp = _this._getPlugin(COMPONENTPLUGINID);
|
93
|
+
componentApp.appendIframeNodes(componentSign, _params).then(function () {
|
94
|
+
resolve();
|
95
|
+
});
|
96
|
+
} catch (error) {
|
97
|
+
reject(error);
|
98
|
+
}
|
99
|
+
});
|
100
|
+
};
|
@@ -0,0 +1,29 @@
|
|
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
|
+
*/
|
8
|
+
import { createPaymentParams, optionsParams } from '../../types';
|
9
|
+
export declare const mixinDropInConstructor: (options: optionsParams, context: any) => void;
|
10
|
+
/**
|
11
|
+
* @description Create checkout application
|
12
|
+
* @description drop-in
|
13
|
+
*/
|
14
|
+
export declare const createPayment: (params: createPaymentParams) => Promise<void>;
|
15
|
+
export interface IcreatePaymentFunc {
|
16
|
+
(params: createPaymentParams): Promise<void>;
|
17
|
+
}
|
18
|
+
/**
|
19
|
+
* @description Take action on the interface result of payment submission
|
20
|
+
* @description drop-in
|
21
|
+
*/
|
22
|
+
export declare const confirmPayment: (result: any) => Promise<void>;
|
23
|
+
export interface IconfirmPaymentFunc {
|
24
|
+
(result: any): Promise<void>;
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* @description Subscribe to the message of the cashier application plug-in
|
28
|
+
*/
|
29
|
+
export declare const _subscribeFromCheckoutPlugin: () => void;
|
@@ -0,0 +1,104 @@
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
2
|
+
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); }
|
3
|
+
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; }
|
4
|
+
/**
|
5
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
6
|
+
*
|
7
|
+
* 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:
|
8
|
+
* 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
|
9
|
+
* 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.
|
10
|
+
*/
|
11
|
+
|
12
|
+
import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
13
|
+
import CheckoutApp from "../../plugin/drop-in";
|
14
|
+
import { messageName, networkMode } from "../../types";
|
15
|
+
import { createIframeNode } from "../../util/createIframeNode";
|
16
|
+
export var mixinDropInConstructor = function mixinDropInConstructor(options, context) {
|
17
|
+
// Instantiate the plug-in and set render
|
18
|
+
var checkoutPlugin = new CheckoutApp();
|
19
|
+
checkoutPlugin.setRender(createIframeNode);
|
20
|
+
// Register Cashier Application Plug in
|
21
|
+
context._registerPlugin(BASEPLUGINID, checkoutPlugin);
|
22
|
+
context._subscribeFromCheckoutPlugin();
|
23
|
+
};
|
24
|
+
|
25
|
+
/**
|
26
|
+
* @description Create checkout application
|
27
|
+
* @description drop-in
|
28
|
+
*/
|
29
|
+
export var createPayment = function createPayment(params) {
|
30
|
+
var _this = this;
|
31
|
+
if (this.options.networkMode === networkMode.proxy) {
|
32
|
+
return new Promise(function (resolve, reject) {
|
33
|
+
try {
|
34
|
+
var checkoutApp = _this._getPlugin(BASEPLUGINID);
|
35
|
+
resolve(checkoutApp.render(params));
|
36
|
+
} catch (error) {
|
37
|
+
reject(error);
|
38
|
+
}
|
39
|
+
});
|
40
|
+
} else {
|
41
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
|
42
|
+
return Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT);
|
43
|
+
}
|
44
|
+
};
|
45
|
+
/**
|
46
|
+
* @description Take action on the interface result of payment submission
|
47
|
+
* @description drop-in
|
48
|
+
*/
|
49
|
+
export var confirmPayment = function confirmPayment(result) {
|
50
|
+
var _this2 = this;
|
51
|
+
return new Promise(function (resolve, reject) {
|
52
|
+
_this2.eventCenter.once('onRedirect', function (playload) {
|
53
|
+
_this2._redirect(playload).then(function () {
|
54
|
+
resolve();
|
55
|
+
}).catch(function (err) {
|
56
|
+
reject(err);
|
57
|
+
});
|
58
|
+
});
|
59
|
+
_this2.eventCenter.emit("".concat(BASEPLUGINID, "-handleRequestPayment"), {
|
60
|
+
name: messageName.SDK_TO_APP,
|
61
|
+
mode: _this2.options.mode,
|
62
|
+
appId: BASEPLUGINID,
|
63
|
+
instanceId: _this2._instanceId,
|
64
|
+
context: {
|
65
|
+
event: 'handleRequestPayment',
|
66
|
+
data: result
|
67
|
+
}
|
68
|
+
});
|
69
|
+
});
|
70
|
+
};
|
71
|
+
/**
|
72
|
+
* @description Subscribe to the message of the cashier application plug-in
|
73
|
+
*/
|
74
|
+
export var _subscribeFromCheckoutPlugin = function _subscribeFromCheckoutPlugin() {
|
75
|
+
var _this3 = this;
|
76
|
+
var eventKeyMap = new Map([[EVENT.error.name, function (playload) {
|
77
|
+
_this3.eventCenter.emit(EVENT.error.name, playload.context.data);
|
78
|
+
}], [EVENT.ready.name, function (playload) {
|
79
|
+
_this3.eventCenter.emit(EVENT.ready.name, playload.context.data);
|
80
|
+
}], [EVENT.redirect.name, function (playload) {
|
81
|
+
_this3.eventCenter.emit(EVENT.redirect.name, playload.context.data);
|
82
|
+
}], [EVENT.paymentMethodSelected.name, function (playload) {
|
83
|
+
_this3.checkoutState.paymentMethodType = playload.context.data.paymentMethodType;
|
84
|
+
_this3.eventCenter.emit(EVENT.paymentMethodSelected.name, {
|
85
|
+
paymentMethodType: playload.context.data.paymentMethodType
|
86
|
+
});
|
87
|
+
}], [EVENT.sizeChanged.name, function (playload) {
|
88
|
+
_this3.eventCenter.emit(EVENT.sizeChanged.name, playload.context.data);
|
89
|
+
}], [EVENT.log.name, function (playload) {
|
90
|
+
_this3.eventCenter.emit(EVENT.log.name, playload.context.data);
|
91
|
+
}]]);
|
92
|
+
var _iterator = _createForOfIteratorHelper(eventKeyMap.keys()),
|
93
|
+
_step;
|
94
|
+
try {
|
95
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
96
|
+
var key = _step.value;
|
97
|
+
this.eventCenter.on("".concat(BASEPLUGINID, "-").concat(key), eventKeyMap.get(key));
|
98
|
+
}
|
99
|
+
} catch (err) {
|
100
|
+
_iterator.e(err);
|
101
|
+
} finally {
|
102
|
+
_iterator.f();
|
103
|
+
}
|
104
|
+
};
|