@alipay/ams-checkout 0.0.1692935171-dev.1 → 0.0.1693912790-dev.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/constant/index.d.ts +32 -41
- package/esm/constant/index.js +32 -41
- package/esm/core/component/index.d.ts +9 -22
- package/esm/core/component/index.js +43 -145
- package/esm/core/drop-in/index.d.ts +1 -1
- package/esm/core/instance/index.d.ts +15 -6
- package/esm/core/instance/index.js +53 -31
- package/esm/index.d.ts +10 -4
- package/esm/index.js +30 -8
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/cashierApp.js +15 -16
- package/esm/plugin/component/component.style.d.ts +1 -4
- package/esm/plugin/component/component.style.js +4 -32
- package/esm/plugin/component/index.d.ts +10 -22
- package/esm/plugin/component/index.js +159 -218
- package/esm/plugin/drop-in/index.js +1 -1
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +3 -3
- package/esm/request/utils.d.ts +3 -3
- package/esm/request/utils.js +4 -4
- package/esm/service/index.d.ts +2 -2
- package/esm/types/index.d.ts +34 -71
- package/esm/types/index.js +47 -84
- package/esm/util/createIframeNode.d.ts +3 -3
- package/esm/util/createIframeNode.js +8 -8
- package/esm/util/index.d.ts +4 -6
- package/esm/util/index.js +5 -22
- package/esm/util/mock.js +2 -1
- package/package.json +1 -1
- package/esm/image/skeleton.svg +0 -18
package/esm/constant/index.d.ts
CHANGED
@@ -4,83 +4,74 @@
|
|
4
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
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
6
|
*/
|
7
|
-
import { eventCodeEnum } from "../types";
|
8
7
|
export declare const ERRORMESSAGE: {
|
9
8
|
DOMAIN_NOT_IN_WHITE_LIST: {
|
10
|
-
|
11
|
-
|
9
|
+
errorCode: string;
|
10
|
+
errorMessage: string;
|
12
11
|
};
|
13
12
|
NOT_JSON_FORMAT: {
|
14
|
-
|
15
|
-
|
13
|
+
errorCode: string;
|
14
|
+
errorMessage: string;
|
16
15
|
};
|
17
16
|
SDK_COMPATIBILITY_ISSUES: {
|
18
|
-
|
17
|
+
errorCode: string;
|
19
18
|
BROWSER_NOT_SUPPORT_POSTMESSAGE: {
|
20
|
-
|
21
|
-
|
19
|
+
errorCode: string;
|
20
|
+
errorMessage: string;
|
22
21
|
};
|
23
22
|
FAILED_TO_CREATE_IFRAME: {
|
24
|
-
|
25
|
-
|
23
|
+
errorCode: string;
|
24
|
+
errorMessage: string;
|
26
25
|
};
|
27
26
|
};
|
28
27
|
INIT_PARAMETER_ERROR: {
|
29
|
-
|
28
|
+
errorCode: string;
|
30
29
|
UI_MODE_NOT_SUPPORTED: {
|
31
|
-
|
32
|
-
|
30
|
+
errorCode: string;
|
31
|
+
errorMessage: string;
|
33
32
|
};
|
34
33
|
ENVIRONMENT_ERROR: {
|
35
|
-
|
36
|
-
|
34
|
+
errorCode: string;
|
35
|
+
errorMessage: string;
|
37
36
|
};
|
38
37
|
MODE_ERROR: {
|
39
|
-
|
40
|
-
|
38
|
+
errorCode: string;
|
39
|
+
errorMessage: string;
|
41
40
|
};
|
42
41
|
LOCALE_ERROR: {
|
43
|
-
|
44
|
-
|
42
|
+
errorCode: string;
|
43
|
+
errorMessage: string;
|
45
44
|
};
|
46
45
|
NET_MODE_NOT_SUPPORT: {
|
47
|
-
|
48
|
-
|
46
|
+
errorCode: string;
|
47
|
+
errorMessage: string;
|
49
48
|
};
|
50
49
|
EVENT_ERROR: {
|
51
|
-
|
52
|
-
|
50
|
+
errorCode: string;
|
51
|
+
errorMessage: string;
|
53
52
|
};
|
54
53
|
};
|
55
54
|
CREATEPAYMENT_PARAMETER_ERROR: {
|
56
|
-
|
55
|
+
errorCode: string;
|
57
56
|
};
|
58
57
|
CONFIRMPAYMENT_PARAMETER_ERROR: {
|
59
|
-
|
58
|
+
errorCode: string;
|
60
59
|
};
|
61
60
|
CREATECOMPONENT_ERROR: {
|
62
|
-
|
63
|
-
|
61
|
+
errorCode: string;
|
62
|
+
errorMessage: string;
|
64
63
|
SINGLETON_COMPONENT_ERROR: {
|
65
|
-
|
66
|
-
|
67
|
-
};
|
68
|
-
LOAD_APP_TIMEOUT: {
|
69
|
-
code: eventCodeEnum;
|
70
|
-
message: string;
|
64
|
+
errorCode: string;
|
65
|
+
errorMessage: string;
|
71
66
|
};
|
72
67
|
};
|
73
68
|
SDK_CALL_URL_ERROR: {
|
74
|
-
|
69
|
+
errorCode: string;
|
75
70
|
REDIRECT_ERROR: {
|
76
|
-
|
77
|
-
|
71
|
+
errorCode: string;
|
72
|
+
errorMessage: string;
|
78
73
|
};
|
79
74
|
};
|
80
|
-
SDK_SUBMIT_ERROR: {
|
81
|
-
code: eventCodeEnum;
|
82
|
-
message: string;
|
83
|
-
};
|
84
75
|
};
|
85
76
|
export declare const BASEPLUGINID = "CHECKOUT";
|
86
77
|
export declare const COMPONENTPLUGINID = "COMPONENT";
|
@@ -111,7 +102,7 @@ export declare const EVENT: {
|
|
111
102
|
redirect: {
|
112
103
|
name: string;
|
113
104
|
};
|
114
|
-
|
105
|
+
onClose: {
|
115
106
|
name: string;
|
116
107
|
uniqueKey: string;
|
117
108
|
};
|
package/esm/constant/index.js
CHANGED
@@ -4,82 +4,73 @@
|
|
4
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
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
6
|
*/
|
7
|
-
import { eventCodeEnum } from "../types";
|
8
7
|
export var ERRORMESSAGE = {
|
9
8
|
DOMAIN_NOT_IN_WHITE_LIST: {
|
10
|
-
|
11
|
-
|
9
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
10
|
+
errorMessage: 'Origin of the message is not in the white list'
|
12
11
|
},
|
13
12
|
NOT_JSON_FORMAT: {
|
14
|
-
|
15
|
-
|
13
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
14
|
+
errorMessage: 'The message string should conform to the json format'
|
16
15
|
},
|
17
16
|
SDK_COMPATIBILITY_ISSUES: {
|
18
|
-
|
17
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
19
18
|
BROWSER_NOT_SUPPORT_POSTMESSAGE: {
|
20
|
-
|
21
|
-
|
19
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
20
|
+
errorMessage: 'The browser does not support the postmessage communication mode'
|
22
21
|
},
|
23
22
|
FAILED_TO_CREATE_IFRAME: {
|
24
|
-
|
25
|
-
|
23
|
+
errorCode: 'SDK_INTERNAL_ERROR',
|
24
|
+
errorMessage: 'Failed to create iframe'
|
26
25
|
}
|
27
26
|
},
|
28
27
|
INIT_PARAMETER_ERROR: {
|
29
|
-
|
28
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
30
29
|
UI_MODE_NOT_SUPPORTED: {
|
31
|
-
|
32
|
-
|
30
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
31
|
+
errorMessage: 'This UI mode is not supported'
|
33
32
|
},
|
34
33
|
ENVIRONMENT_ERROR: {
|
35
|
-
|
36
|
-
|
34
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
35
|
+
errorMessage: 'The current input environment does not support or is not in the standard enumeration'
|
37
36
|
},
|
38
37
|
MODE_ERROR: {
|
39
|
-
|
40
|
-
|
38
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
39
|
+
errorMessage: 'mode value not in enum'
|
41
40
|
},
|
42
41
|
LOCALE_ERROR: {
|
43
|
-
|
44
|
-
|
42
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
43
|
+
errorMessage: 'The current input language does not support or is not in the standard enumeration'
|
45
44
|
},
|
46
45
|
NET_MODE_NOT_SUPPORT: {
|
47
|
-
|
48
|
-
|
46
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
47
|
+
errorMessage: 'The network mode is not supported'
|
49
48
|
},
|
50
49
|
EVENT_ERROR: {
|
51
|
-
|
52
|
-
|
50
|
+
errorCode: 'SDK_INIT_PARAMETER_ERROR',
|
51
|
+
errorMessage: 'Parameter type should be function'
|
53
52
|
}
|
54
53
|
},
|
55
54
|
CREATEPAYMENT_PARAMETER_ERROR: {
|
56
|
-
|
55
|
+
errorCode: 'SDK_CREATEPAYMENT_PARAMETER_ERROR'
|
57
56
|
},
|
58
57
|
CONFIRMPAYMENT_PARAMETER_ERROR: {
|
59
|
-
|
58
|
+
errorCode: 'SDK_CONFIRMPAYMENT_PARAMETER_ERROR'
|
60
59
|
},
|
61
60
|
CREATECOMPONENT_ERROR: {
|
62
|
-
|
63
|
-
|
61
|
+
errorCode: 'SDK_CREATECOMPONENT_ERROR',
|
62
|
+
errorMessage: 'Failed to create component',
|
64
63
|
SINGLETON_COMPONENT_ERROR: {
|
65
|
-
|
66
|
-
|
67
|
-
},
|
68
|
-
LOAD_APP_TIMEOUT: {
|
69
|
-
code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR,
|
70
|
-
message: 'Load resource timeout'
|
64
|
+
errorCode: 'SDK_CREATECOMPONENT_ERROR',
|
65
|
+
errorMessage: 'Only one component can be rendered simultaneously'
|
71
66
|
}
|
72
67
|
},
|
73
68
|
SDK_CALL_URL_ERROR: {
|
74
|
-
|
69
|
+
errorCode: 'SDK_CALL_URL_ERROR',
|
75
70
|
REDIRECT_ERROR: {
|
76
|
-
|
77
|
-
|
71
|
+
errorCode: 'SDK_CALL_URL_ERROR',
|
72
|
+
errorMessage: 'Redirect data exception'
|
78
73
|
}
|
79
|
-
},
|
80
|
-
SDK_SUBMIT_ERROR: {
|
81
|
-
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
82
|
-
message: 'Component not created or current browser compatibility issue, not supported'
|
83
74
|
}
|
84
75
|
};
|
85
76
|
export var BASEPLUGINID = 'CHECKOUT';
|
@@ -111,7 +102,7 @@ export var EVENT = {
|
|
111
102
|
redirect: {
|
112
103
|
name: 'onRedirect'
|
113
104
|
},
|
114
|
-
|
105
|
+
onClose: {
|
115
106
|
name: 'onClose',
|
116
107
|
uniqueKey: 'userOnClose'
|
117
108
|
},
|
@@ -5,26 +5,13 @@
|
|
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
|
-
import { IcreateComponent,
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
* @param params - The data source created by the component, necessary paymentSessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
|
18
|
-
*/
|
19
|
-
createComponent(params: IcreateComponent): Promise<void>;
|
20
|
-
/**
|
21
|
-
* @description Create and render components in the specified element area
|
22
|
-
* @param params - The data source created by the component, necessary paymentSessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
23
|
-
*/
|
24
|
-
mountComponent(params: IcreateComponent, selector: Iselector): Promise<void>;
|
25
|
-
/**
|
26
|
-
* @description Execute payment submission process
|
27
|
-
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
28
|
-
*/
|
29
|
-
submit(): void;
|
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>;
|
30
17
|
}
|
@@ -1,17 +1,3 @@
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
2
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3
|
-
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); } }
|
4
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
5
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
6
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
7
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
8
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
9
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
10
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
11
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
12
|
-
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; }
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
14
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
15
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
16
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."); }
|
17
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); }
|
@@ -26,12 +12,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
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.
|
27
13
|
*/
|
28
14
|
|
29
|
-
import { COMPONENTPLUGINID, ERRORMESSAGE
|
15
|
+
import { COMPONENTPLUGINID, ERRORMESSAGE } from "../../constant";
|
30
16
|
import ComponentApp from "../../plugin/component";
|
31
|
-
import { componentSignEnum,
|
17
|
+
import { componentSignEnum, mode, networkMode, productSceneEnum } from "../../types";
|
32
18
|
import { isPC } from "../../util";
|
33
19
|
import { createIframeNode } from "../../util/createIframeNode";
|
34
|
-
import CoreInstance from "../instance/index";
|
35
20
|
var getComponentSign = function getComponentSign(params) {
|
36
21
|
var _params$paymentSessio = params.paymentSessionConfig,
|
37
22
|
_params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
|
@@ -67,136 +52,49 @@ var handlePaymentSessionData = function handlePaymentSessionData(originPaymentSe
|
|
67
52
|
resetEasyPaySceneVersion(parseData);
|
68
53
|
return [parseData, paymentSessionData];
|
69
54
|
};
|
70
|
-
var
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
_handlePaymentSession2 = _slicedToArray(_handlePaymentSession, 2),
|
77
|
-
parseData = _handlePaymentSession2[0],
|
78
|
-
paymentSessionData = _handlePaymentSession2[1];
|
79
|
-
var componentSign = getComponentSign(parseData);
|
80
|
-
if (componentSign === componentSignEnum.NONE) {
|
81
|
-
// eslint-disable-next-line prefer-promise-reject-errors
|
82
|
-
return Promise.reject({
|
83
|
-
code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
|
84
|
-
message: "Abnormal response data, interface failure, or unsupported payment method"
|
85
|
-
});
|
86
|
-
}
|
87
|
-
_params.paymentSessionData = paymentSessionData;
|
88
|
-
_params.paymentSessionMetaData = parseData;
|
89
|
-
return Promise.resolve({
|
90
|
-
iframeNodesParams: _params,
|
91
|
-
componentSign: componentSign
|
92
|
-
});
|
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);
|
93
61
|
};
|
94
|
-
export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
95
|
-
_inherits(AMSComponent, _CoreInstance);
|
96
|
-
var _super = _createSuper(AMSComponent);
|
97
|
-
function AMSComponent(options) {
|
98
|
-
var _this;
|
99
|
-
_classCallCheck(this, AMSComponent);
|
100
|
-
_this = _super.call(this, options);
|
101
|
-
// Instantiate the plug-in and set render
|
102
|
-
_defineProperty(_assertThisInitialized(_this), "componentApp", void 0);
|
103
|
-
var ComponentPlugin = new ComponentApp();
|
104
|
-
ComponentPlugin.setRender(createIframeNode);
|
105
|
-
// Register Cashier Application Plug in
|
106
|
-
_this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
|
107
|
-
_this.componentApp = _this._getPlugin(COMPONENTPLUGINID);
|
108
|
-
return _this;
|
109
|
-
}
|
110
|
-
_createClass(AMSComponent, [{
|
111
|
-
key: "parameterInitAndCheck",
|
112
|
-
value: function parameterInitAndCheck(_ref) {
|
113
|
-
var params = _ref.params,
|
114
|
-
selector = _ref.selector,
|
115
|
-
renderDisplayType = _ref.renderDisplayType;
|
116
|
-
this.options.mode = modeEnum.component;
|
117
|
-
this.options.networkMode = this.options.networkMode || networkModeEnum.session;
|
118
|
-
var _params = Object.assign({
|
119
|
-
selector: selector,
|
120
|
-
renderDisplayType: renderDisplayType
|
121
|
-
}, params);
|
122
|
-
if (_params && !_params.paymentSessionData) {
|
123
|
-
return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
|
124
|
-
}
|
125
|
-
if (this.options.networkMode === networkModeEnum.proxy) {
|
126
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.message);
|
127
|
-
return Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT);
|
128
|
-
}
|
129
|
-
return Promise.resolve(_params);
|
130
|
-
}
|
131
|
-
}, {
|
132
|
-
key: "pluginAppendIframe",
|
133
|
-
value: function pluginAppendIframe(appendParams) {
|
134
|
-
try {
|
135
|
-
return this.componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams);
|
136
|
-
} catch (error) {
|
137
|
-
return Promise.reject(error);
|
138
|
-
}
|
139
|
-
}
|
140
62
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
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"));
|
160
88
|
}
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
value: function mountComponent(params, selector) {
|
168
|
-
var _this3 = this;
|
169
|
-
return this.parameterInitAndCheck({
|
170
|
-
params: params,
|
171
|
-
renderDisplayType: renderDisplayTypeEnum.inline,
|
172
|
-
selector: selector
|
173
|
-
}).then(function (_params) {
|
174
|
-
return handleParams(_params);
|
175
|
-
}).catch(function (error) {
|
176
|
-
_this3._eventCenter.emit(EVENT.error.name, error);
|
177
|
-
return Promise.reject(error);
|
178
|
-
}).then(function (appendParams) {
|
179
|
-
return _this3.pluginAppendIframe(appendParams);
|
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();
|
180
95
|
});
|
96
|
+
} catch (error) {
|
97
|
+
reject(error);
|
181
98
|
}
|
182
|
-
|
183
|
-
|
184
|
-
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
185
|
-
*/
|
186
|
-
}, {
|
187
|
-
key: "submit",
|
188
|
-
value: function submit() {
|
189
|
-
try {
|
190
|
-
this.componentApp.dispatchToApp({
|
191
|
-
context: {
|
192
|
-
event: 'submitPay',
|
193
|
-
data: {}
|
194
|
-
}
|
195
|
-
});
|
196
|
-
} catch (error) {
|
197
|
-
console.error(error);
|
198
|
-
}
|
199
|
-
}
|
200
|
-
}]);
|
201
|
-
return AMSComponent;
|
202
|
-
}(CoreInstance);
|
99
|
+
});
|
100
|
+
};
|
@@ -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
|
-
import { createPaymentParams } from '../../types';
|
8
|
+
import { createPaymentParams, optionsParams } from '../../types';
|
9
9
|
export declare const mixinDropInConstructor: (options: optionsParams, context: any) => void;
|
10
10
|
/**
|
11
11
|
* @description Create checkout application
|
@@ -1,16 +1,16 @@
|
|
1
|
-
import type { AMSCheckoutOptions,
|
1
|
+
import type { AMSCheckoutOptions, callOnError, callOnLog, callOnSizeChanged, checkoutState, optionsParams } from '../../types/index';
|
2
2
|
import { EventCenter } from '../../util/index';
|
3
3
|
export default class AMSSDK {
|
4
4
|
options: AMSCheckoutOptions;
|
5
|
-
checkoutState:
|
6
|
-
|
5
|
+
checkoutState: checkoutState;
|
6
|
+
eventCenter: EventCenter;
|
7
7
|
protected plugins: Map<string, any>;
|
8
8
|
_instanceId: string;
|
9
|
-
constructor(options:
|
9
|
+
constructor(options: optionsParams);
|
10
10
|
/**
|
11
11
|
* @description Destroy and process some contents of the plug-in
|
12
12
|
*/
|
13
|
-
|
13
|
+
destroy(): void;
|
14
14
|
/**
|
15
15
|
* @description Set the sdk basic configuration
|
16
16
|
*/
|
@@ -34,7 +34,7 @@ export default class AMSSDK {
|
|
34
34
|
/**
|
35
35
|
* @description Get Plug-in
|
36
36
|
*/
|
37
|
-
|
37
|
+
_getPlugin(pluginId: string): any;
|
38
38
|
/**
|
39
39
|
* @description Execute to open app or jump link
|
40
40
|
*/
|
@@ -47,4 +47,13 @@ export default class AMSSDK {
|
|
47
47
|
* @description Overlay Subscription
|
48
48
|
*/
|
49
49
|
protected _overrideSubscription(name: string, func: any, funcKey: string): void;
|
50
|
+
/**
|
51
|
+
* @description Create an event handler, called when an error occurs in AMSCheckout.
|
52
|
+
*/
|
53
|
+
onError(event: callOnError): void;
|
54
|
+
/**
|
55
|
+
* @description Create an event handler
|
56
|
+
*/
|
57
|
+
onSizeChanged(event: callOnSizeChanged): void;
|
58
|
+
onLog(event: callOnLog): void;
|
50
59
|
}
|