@alipay/ams-checkout 0.0.1730107332-dev.4 → 0.0.1730706734-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/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +6 -1
- package/esm/constant/index.js +80 -3
- package/esm/core/bus/ability/callback.d.ts +9 -0
- package/esm/{foundation/service/api-bus → core/bus}/ability/callback.js +1 -1
- package/esm/core/bus/ability/globalData.d.ts +10 -0
- package/esm/{foundation/service/api-bus → core/bus}/ability/globalData.js +2 -2
- package/esm/{foundation/service/api-bus → core/bus}/ability/request.d.ts +1 -1
- package/esm/{foundation/service/api-bus → core/bus}/ability/request.js +2 -2
- package/esm/core/bus/ability/security.d.ts +10 -0
- package/esm/core/bus/ability/security.js +104 -0
- package/esm/core/bus/ability/tracker.d.ts +9 -0
- package/esm/core/bus/ability/tracker.js +77 -0
- package/esm/core/bus/index.d.ts +125 -0
- package/esm/core/bus/index.js +366 -0
- package/esm/core/component/address.d.ts +8 -0
- package/esm/core/component/address.js +72 -0
- package/esm/core/component/appPreloadProcessing.d.ts +1 -0
- package/esm/core/component/appPreloadProcessing.js +91 -0
- package/esm/core/component/ckp/index.d.ts +27 -0
- package/esm/core/component/ckp/index.js +166 -0
- package/esm/core/component/element/components/address.d.ts +19 -0
- package/esm/core/component/element/components/address.js +68 -0
- package/esm/core/component/element/components/auth.d.ts +17 -0
- package/esm/core/component/element/components/auth.js +59 -0
- package/esm/core/component/element/components/payment.d.ts +19 -0
- package/esm/core/component/element/components/payment.js +74 -0
- package/esm/core/component/element/element-mock.d.ts +2 -0
- package/esm/core/component/element/element-mock.js +263 -0
- package/esm/core/component/element/index.d.ts +47 -0
- package/esm/core/component/element/index.js +776 -0
- package/esm/core/component/element/mock.d.ts +3 -0
- package/esm/core/component/element/mock.js +1156 -0
- package/esm/core/component/element/type.d.ts +176 -0
- package/esm/core/component/element/type.js +34 -0
- package/esm/core/component/element/utils.d.ts +13 -0
- package/esm/core/component/element/utils.js +6 -0
- package/esm/core/component/index.d.ts +51 -0
- package/esm/core/component/index.js +535 -0
- package/esm/core/drop-in/index.d.ts +22 -0
- package/esm/core/drop-in/index.js +104 -0
- package/esm/core/instance/index.d.ts +89 -0
- package/esm/core/instance/index.js +500 -0
- package/esm/foundation/core/index.d.ts +3 -3
- package/esm/foundation/core/index.js +51 -114
- package/esm/foundation/index.d.ts +3 -5
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +4 -7
- package/esm/foundation/product-processor/easysafepay/deps.js +2 -5
- package/esm/foundation/product-processor/easysafepay/index.d.ts +4 -5
- package/esm/foundation/product-processor/easysafepay/index.js +114 -174
- package/esm/foundation/service/container/index.js +5 -5
- package/esm/foundation/service/container/popup.js +1 -1
- package/esm/foundation/service/event-bus/ability/callback.js +55 -0
- package/esm/foundation/service/{api-bus → event-bus}/ability/globalData.d.ts +1 -1
- package/esm/foundation/service/event-bus/ability/globalData.js +89 -0
- package/esm/foundation/service/event-bus/ability/request.d.ts +10 -0
- package/esm/foundation/service/event-bus/ability/request.js +151 -0
- package/esm/foundation/service/{api-bus → event-bus}/ability/security.js +19 -29
- package/esm/foundation/service/{api-bus → event-bus}/ability/tracker.js +1 -1
- package/esm/foundation/service/{api-bus → event-bus}/busManager.js +1 -1
- package/esm/foundation/service/event-center.d.ts +5 -4
- package/esm/foundation/service/event-center.js +39 -8
- package/esm/foundation/service/global-data/index.js +5 -4
- package/esm/foundation/service/index.js +1 -1
- package/esm/foundation/service/requester/requester.js +11 -14
- package/esm/foundation/service/security/index.d.ts +7 -9
- package/esm/foundation/service/security/index.js +44 -113
- package/esm/foundation/utils/redirect_utils.js +8 -24
- package/esm/foundation/utils/web_app_url_utils.d.ts +2 -11
- package/esm/foundation/utils/web_app_url_utils.js +2 -17
- package/esm/index.d.ts +30 -1
- package/esm/index.js +147 -7
- package/esm/plugin/applepay/component.d.ts +50 -0
- package/esm/plugin/applepay/component.js +339 -0
- package/esm/plugin/applepay/index.d.ts +17 -0
- package/esm/plugin/applepay/index.js +117 -0
- package/esm/plugin/applepay/interface.d.ts +161 -0
- package/esm/plugin/applepay/interface.js +69 -0
- package/esm/plugin/applepay/service.d.ts +54 -0
- package/esm/plugin/applepay/service.js +289 -0
- package/esm/plugin/component/cashierApp.d.ts +36 -0
- package/esm/plugin/component/cashierApp.js +245 -0
- package/esm/{component → plugin/component}/channel.d.ts +2 -1
- package/esm/{component → plugin/component}/channel.js +37 -1
- package/esm/{component → plugin/component}/component.inline.style.d.ts +2 -2
- package/esm/{component → plugin/component}/component.inline.style.js +7 -6
- package/esm/{component → plugin/component}/component.popup.style.d.ts +1 -1
- package/esm/{component → plugin/component}/component.popup.style.js +4 -4
- package/esm/plugin/component/index.d.ts +126 -0
- package/esm/plugin/component/index.js +1862 -0
- package/esm/{component → plugin/component}/popupWindow.style.js +2 -2
- package/esm/plugin/const.d.ts +2 -0
- package/esm/plugin/const.js +33 -0
- package/esm/plugin/drop-in/index.d.ts +71 -0
- package/esm/plugin/drop-in/index.js +324 -0
- package/esm/plugin/payment-element/utils.d.ts +2 -0
- package/esm/plugin/payment-element/utils.js +7 -0
- package/esm/plugin/paypal/index.d.ts +20 -0
- package/esm/plugin/paypal/index.js +390 -0
- package/esm/plugin/type.d.ts +34 -0
- package/esm/plugin/type.js +1 -0
- package/esm/plugin/utils.d.ts +6 -0
- package/esm/plugin/utils.js +21 -0
- package/esm/service/element.d.ts +4 -0
- package/esm/service/element.js +51 -0
- package/esm/service/index.d.ts +1 -0
- package/esm/service/index.js +2 -0
- package/esm/types/index.d.ts +218 -22
- package/esm/types/index.js +47 -4
- package/esm/util/createIframeNode.d.ts +6 -0
- package/esm/util/createIframeNode.js +48 -0
- package/esm/util/getBackScheme.d.ts +2 -2
- package/esm/util/getBackScheme.js +2 -94
- package/esm/util/index.d.ts +11 -1
- package/esm/util/index.js +84 -4
- package/esm/util/intl-callapp/es/index.js +0 -1
- package/esm/util/ua/index.d.ts +2 -0
- package/esm/util/ua/index.js +2 -0
- package/esm/util/ua/isAndroid.d.ts +4 -0
- package/esm/util/ua/isAndroid.js +7 -0
- package/esm/util/ua/isIOS.d.ts +4 -0
- package/esm/util/ua/isIOS.js +7 -0
- package/package.json +2 -1
- package/esm/foundation/utils/payment_product_utils.d.ts +0 -13
- package/esm/foundation/utils/payment_product_utils.js +0 -38
- /package/esm/{foundation/service/api-bus → core/bus}/interface.d.ts +0 -0
- /package/esm/{foundation/service/api-bus → core/bus}/interface.js +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/ability/callback.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/ability/security.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/ability/tracker.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/busManager.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/index.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/index.js +0 -0
- /package/esm/{component → plugin/component}/popupWindow.style.d.ts +0 -0
package/esm/index.js
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
-
function
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
|
+
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; }
|
3
5
|
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
6
|
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 _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; }
|
6
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
7
8
|
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); }
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10
|
+
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); }
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
12
|
+
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); }; }
|
13
|
+
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); }
|
14
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
15
|
+
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; } }
|
16
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
8
17
|
/**
|
9
18
|
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
10
19
|
*
|
@@ -12,12 +21,59 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
12
21
|
* 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
|
13
22
|
* 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.
|
14
23
|
*/
|
15
|
-
|
24
|
+
import { ADDRESSElementAppVersion, AMSAutoDebitAppVersion, AMSCashierPaymentAppVersion, AMSCheckoutAppVersion, AMSEasyPayAppVersion, AMSPaymentElementAppVersion, AMSVaultingAppVersion } from "./config/index";
|
25
|
+
import { AddressComponent } from "./core/component/address";
|
26
|
+
import { ElementComponent } from "./core/component/element";
|
27
|
+
import { AMSComponent } from "./core/component/index";
|
16
28
|
import { AntomSDKCore } from "./foundation/core";
|
17
29
|
import { EasySafePayProcessor } from "./foundation/product-processor/easysafepay";
|
18
|
-
import { DisplayTypeEnum } from "./types";
|
30
|
+
import { ComponentSignEnum, DisplayTypeEnum } from "./types";
|
19
31
|
import { ProductSceneEnum } from "./types/index";
|
32
|
+
import { LogConfig, Logger } from "./util/logger";
|
33
|
+
var logger = new Logger(LogConfig, true);
|
34
|
+
export { AMSCheckoutPage } from "./core/component/ckp";
|
20
35
|
export * from "./types";
|
36
|
+
export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
|
37
|
+
_inherits(AMSCheckout, _AMSComponent);
|
38
|
+
var _super = _createSuper(AMSCheckout);
|
39
|
+
function AMSCheckout(_options, channelType) {
|
40
|
+
var _this;
|
41
|
+
var productSceneVersion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '1.0';
|
42
|
+
_classCallCheck(this, AMSCheckout);
|
43
|
+
_this = _super.call(this, _objectSpread({
|
44
|
+
appVersion: AMSCheckoutAppVersion
|
45
|
+
}, _options));
|
46
|
+
_this.preloadComponent(channelType, productSceneVersion);
|
47
|
+
return _this;
|
48
|
+
}
|
49
|
+
return _createClass(AMSCheckout);
|
50
|
+
}(AMSComponent);
|
51
|
+
export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
|
52
|
+
_inherits(AMSAutoDebit, _AMSCheckout);
|
53
|
+
var _super2 = _createSuper(AMSAutoDebit);
|
54
|
+
function AMSAutoDebit(options) {
|
55
|
+
_classCallCheck(this, AMSAutoDebit);
|
56
|
+
var _options = Object.assign({}, options, {
|
57
|
+
product: ProductSceneEnum.AUTO_DEBIT,
|
58
|
+
appVersion: AMSAutoDebitAppVersion
|
59
|
+
});
|
60
|
+
return _super2.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_WALLET]);
|
61
|
+
}
|
62
|
+
return _createClass(AMSAutoDebit);
|
63
|
+
}(AMSCheckout);
|
64
|
+
export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
|
65
|
+
_inherits(AMSAutoDebitPay, _AMSCheckout2);
|
66
|
+
var _super3 = _createSuper(AMSAutoDebitPay);
|
67
|
+
function AMSAutoDebitPay(options) {
|
68
|
+
_classCallCheck(this, AMSAutoDebitPay);
|
69
|
+
var _options = Object.assign({}, options, {
|
70
|
+
product: ProductSceneEnum.AUTO_DEBIT_PAY,
|
71
|
+
appVersion: AMSEasyPayAppVersion
|
72
|
+
});
|
73
|
+
return _super3.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_PAY_WALLET]);
|
74
|
+
}
|
75
|
+
return _createClass(AMSAutoDebitPay);
|
76
|
+
}(AMSCheckout);
|
21
77
|
export var AMSEasyPay = /*#__PURE__*/function () {
|
22
78
|
function AMSEasyPay(options) {
|
23
79
|
_classCallCheck(this, AMSEasyPay);
|
@@ -37,10 +93,94 @@ export var AMSEasyPay = /*#__PURE__*/function () {
|
|
37
93
|
paymentSession: params.sessionData || params.paymentSessionData,
|
38
94
|
displayInfo: {
|
39
95
|
type: DisplayTypeEnum.popup
|
40
|
-
}
|
41
|
-
isAppWebview: params.isAppWebview
|
96
|
+
}
|
42
97
|
});
|
43
98
|
}
|
44
99
|
}]);
|
45
100
|
return AMSEasyPay;
|
46
|
-
}();
|
101
|
+
}();
|
102
|
+
export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
103
|
+
_inherits(AMSCashierPayment, _AMSCheckout3);
|
104
|
+
var _super4 = _createSuper(AMSCashierPayment);
|
105
|
+
function AMSCashierPayment(options) {
|
106
|
+
_classCallCheck(this, AMSCashierPayment);
|
107
|
+
var _options = Object.assign({}, options, {
|
108
|
+
product: ProductSceneEnum.CASHIER_PAYMENT,
|
109
|
+
appVersion: AMSCashierPaymentAppVersion
|
110
|
+
});
|
111
|
+
var currentChannelType;
|
112
|
+
try {
|
113
|
+
var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
|
114
|
+
var previousChannel = JSON.parse(previousChannelStr) || {};
|
115
|
+
var _ref = previousChannel || {},
|
116
|
+
_ref$channelType = _ref.channelType,
|
117
|
+
channelType = _ref$channelType === void 0 ? '' : _ref$channelType;
|
118
|
+
if ([ComponentSignEnum.CASHIER_PAYMENT_CARD, ComponentSignEnum.CASHIER_PAYMENT_APM, ComponentSignEnum.CASHIER_PAYMENT_BANK].includes(channelType)) {
|
119
|
+
currentChannelType = [channelType];
|
120
|
+
} else {
|
121
|
+
currentChannelType = [ComponentSignEnum.CASHIER_PAYMENT_CARD, ComponentSignEnum.CASHIER_PAYMENT_APM];
|
122
|
+
}
|
123
|
+
} catch (error) {
|
124
|
+
logger.logError({
|
125
|
+
title: 'performance_optimization_get_previousChannel_error'
|
126
|
+
}, {
|
127
|
+
error: error
|
128
|
+
});
|
129
|
+
}
|
130
|
+
return _super4.call(this, _options, currentChannelType);
|
131
|
+
}
|
132
|
+
return _createClass(AMSCashierPayment);
|
133
|
+
}(AMSCheckout);
|
134
|
+
export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
|
135
|
+
_inherits(AMSVaulting, _AMSCheckout4);
|
136
|
+
var _super5 = _createSuper(AMSVaulting);
|
137
|
+
function AMSVaulting(options) {
|
138
|
+
_classCallCheck(this, AMSVaulting);
|
139
|
+
var _options = Object.assign({}, options, {
|
140
|
+
product: ProductSceneEnum.VAULTING,
|
141
|
+
appVersion: AMSVaultingAppVersion
|
142
|
+
});
|
143
|
+
return _super5.call(this, _options, [ComponentSignEnum.CASHIER_PAYMENT_CARD]);
|
144
|
+
}
|
145
|
+
return _createClass(AMSVaulting);
|
146
|
+
}(AMSCheckout);
|
147
|
+
export var AntomElement = /*#__PURE__*/function (_AMSCheckout5) {
|
148
|
+
_inherits(AntomElement, _AMSCheckout5);
|
149
|
+
var _super6 = _createSuper(AntomElement);
|
150
|
+
function AntomElement(options) {
|
151
|
+
_classCallCheck(this, AntomElement);
|
152
|
+
var _options = Object.assign({}, options, {
|
153
|
+
product: ProductSceneEnum.ELEMENT_PAYMENT,
|
154
|
+
appVersion: AMSPaymentElementAppVersion
|
155
|
+
});
|
156
|
+
return _super6.call(this, _options, [ComponentSignEnum.ELEMENT_PAYMENT]);
|
157
|
+
}
|
158
|
+
return _createClass(AntomElement);
|
159
|
+
}(AMSCheckout);
|
160
|
+
export var AddressElement = /*#__PURE__*/function (_AddressComponent) {
|
161
|
+
_inherits(AddressElement, _AddressComponent);
|
162
|
+
var _super7 = _createSuper(AddressElement);
|
163
|
+
function AddressElement(options) {
|
164
|
+
_classCallCheck(this, AddressElement);
|
165
|
+
var _options = Object.assign({}, options, {
|
166
|
+
product: ProductSceneEnum.ELEMENT_ADDRESS,
|
167
|
+
appVersion: ADDRESSElementAppVersion
|
168
|
+
});
|
169
|
+
return _super7.call(this, _options);
|
170
|
+
}
|
171
|
+
return _createClass(AddressElement);
|
172
|
+
}(AddressComponent);
|
173
|
+
export var Element = /*#__PURE__*/function (_ElementComponent) {
|
174
|
+
_inherits(Element, _ElementComponent);
|
175
|
+
var _super8 = _createSuper(Element);
|
176
|
+
function Element(options) {
|
177
|
+
_classCallCheck(this, Element);
|
178
|
+
var _options = Object.assign({}, options, {
|
179
|
+
product: ProductSceneEnum.ELEMENT_PAYMENT,
|
180
|
+
environment: options.environment
|
181
|
+
});
|
182
|
+
return _super8.call(this, _options);
|
183
|
+
}
|
184
|
+
return _createClass(Element);
|
185
|
+
}(ElementComponent);
|
186
|
+
export default AMSCheckout;
|
@@ -0,0 +1,50 @@
|
|
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 { ApplePaySubTypeEnum, IAppendParams, IApplePayOptionsParams } from '../../types';
|
9
|
+
import type { Logger } from '../../util/logger';
|
10
|
+
export declare enum ApplePayComponentEvent {
|
11
|
+
sdk_event_appleAvailable = "sdk_event_appleAvailable",
|
12
|
+
sdk_event_appleCreateComponent = "sdk_event_appleCreateComponent",
|
13
|
+
sdk_event_appleShowPaymentSheet = "sdk_event_appleShowPaymentSheet",
|
14
|
+
sdk_event_appleOnvalidatemerchant = "sdk_event_appleOnvalidatemerchant",
|
15
|
+
sdk_event_appleSubmitToken = "sdk_event_appleSubmitToken",
|
16
|
+
sdk_event_applePaymentResult = "sdk_event_applePaymentResult",
|
17
|
+
sdk_event_appleDestroyComponent = "sdk_event_appleDestroyComponent"
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Apple pay Component
|
21
|
+
*/
|
22
|
+
declare class ApplePayComponent {
|
23
|
+
private _applePayService;
|
24
|
+
private _parseData;
|
25
|
+
private _sessionData;
|
26
|
+
private _isFinish;
|
27
|
+
private _options;
|
28
|
+
private logger;
|
29
|
+
private isRecurring;
|
30
|
+
constructor(options: IApplePayOptionsParams, logger: Logger);
|
31
|
+
/**
|
32
|
+
* Is Apple Pay Enabled
|
33
|
+
* @param subTypeEnum
|
34
|
+
* @returns
|
35
|
+
*/
|
36
|
+
canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): boolean;
|
37
|
+
/**
|
38
|
+
* Is Apple Pay Enabled
|
39
|
+
* @param subTypeEnum
|
40
|
+
* @returns
|
41
|
+
*/
|
42
|
+
isAppPayEnabled(subTypeEnum?: ApplePaySubTypeEnum): boolean;
|
43
|
+
private onEventCallback;
|
44
|
+
/**
|
45
|
+
* Submit Pay
|
46
|
+
* @param paymentSessionData
|
47
|
+
*/
|
48
|
+
submitPay(appendParams: IAppendParams): void;
|
49
|
+
}
|
50
|
+
export default ApplePayComponent;
|
@@ -0,0 +1,339 @@
|
|
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6
|
+
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); } }
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
8
|
+
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; }
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
10
|
+
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); }
|
11
|
+
/**
|
12
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
13
|
+
*
|
14
|
+
* 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:
|
15
|
+
* 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
|
16
|
+
* 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.
|
17
|
+
*/
|
18
|
+
import { EnvironmentEnum, eventCodeEnum, ProductSceneEnum } from "../../types";
|
19
|
+
import ApplePayService from "./service";
|
20
|
+
import { getApplePayPaymentSession, submitPayInfo } from "../../service";
|
21
|
+
import { BusManager, BusMessage } from "../../core/bus";
|
22
|
+
import { SecuritySDKActionEnum } from "../../core/bus/interface";
|
23
|
+
export var ApplePayComponentEvent = /*#__PURE__*/function (ApplePayComponentEvent) {
|
24
|
+
ApplePayComponentEvent["sdk_event_appleAvailable"] = "sdk_event_appleAvailable";
|
25
|
+
ApplePayComponentEvent["sdk_event_appleCreateComponent"] = "sdk_event_appleCreateComponent";
|
26
|
+
ApplePayComponentEvent["sdk_event_appleShowPaymentSheet"] = "sdk_event_appleShowPaymentSheet";
|
27
|
+
ApplePayComponentEvent["sdk_event_appleOnvalidatemerchant"] = "sdk_event_appleOnvalidatemerchant";
|
28
|
+
ApplePayComponentEvent["sdk_event_appleSubmitToken"] = "sdk_event_appleSubmitToken";
|
29
|
+
ApplePayComponentEvent["sdk_event_applePaymentResult"] = "sdk_event_applePaymentResult";
|
30
|
+
ApplePayComponentEvent["sdk_event_appleDestroyComponent"] = "sdk_event_appleDestroyComponent";
|
31
|
+
return ApplePayComponentEvent;
|
32
|
+
}({});
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Apple pay Component
|
36
|
+
*/
|
37
|
+
var ApplePayComponent = /*#__PURE__*/function () {
|
38
|
+
function ApplePayComponent(options, logger) {
|
39
|
+
_classCallCheck(this, ApplePayComponent);
|
40
|
+
_defineProperty(this, "_applePayService", void 0);
|
41
|
+
_defineProperty(this, "_parseData", void 0);
|
42
|
+
_defineProperty(this, "_sessionData", void 0);
|
43
|
+
_defineProperty(this, "_isFinish", false);
|
44
|
+
_defineProperty(this, "_options", void 0);
|
45
|
+
_defineProperty(this, "logger", void 0);
|
46
|
+
_defineProperty(this, "isRecurring", false);
|
47
|
+
this.logger = logger;
|
48
|
+
this._options = Object.assign({
|
49
|
+
environment: EnvironmentEnum.prod
|
50
|
+
}, options, {
|
51
|
+
product: ProductSceneEnum.CARD_APPLE_PAY
|
52
|
+
});
|
53
|
+
this._applePayService = new ApplePayService(logger);
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Is Apple Pay Enabled
|
58
|
+
* @param subTypeEnum
|
59
|
+
* @returns
|
60
|
+
*/
|
61
|
+
_createClass(ApplePayComponent, [{
|
62
|
+
key: "canMakePayments",
|
63
|
+
value: function canMakePayments(subTypeEnum) {
|
64
|
+
return ApplePayService.canMakePayments(subTypeEnum);
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Is Apple Pay Enabled
|
69
|
+
* @param subTypeEnum
|
70
|
+
* @returns
|
71
|
+
*/
|
72
|
+
}, {
|
73
|
+
key: "isAppPayEnabled",
|
74
|
+
value: function isAppPayEnabled(subTypeEnum) {
|
75
|
+
return this.canMakePayments(subTypeEnum);
|
76
|
+
}
|
77
|
+
}, {
|
78
|
+
key: "onEventCallback",
|
79
|
+
value: function onEventCallback(state) {
|
80
|
+
var _state$result, _state$result2, _this$_options;
|
81
|
+
this.logger.logInfo({
|
82
|
+
name: 'APPLE_PAY',
|
83
|
+
title: ApplePayComponentEvent.sdk_event_applePaymentResult
|
84
|
+
}, {
|
85
|
+
biz: 'sdk',
|
86
|
+
type: 'funnel',
|
87
|
+
success: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL === (state === null || state === void 0 ? void 0 : state.code),
|
88
|
+
code: state === null || state === void 0 ? void 0 : state.code,
|
89
|
+
errorCode: state === null || state === void 0 || (_state$result = state.result) === null || _state$result === void 0 ? void 0 : _state$result.errorCode,
|
90
|
+
errorMessage: state === null || state === void 0 || (_state$result2 = state.result) === null || _state$result2 === void 0 ? void 0 : _state$result2.errorMessage,
|
91
|
+
recurring: this.isRecurring
|
92
|
+
}).send();
|
93
|
+
(_this$_options = this._options) === null || _this$_options === void 0 || _this$_options.onEventCallback(state);
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Submit Pay
|
98
|
+
* @param paymentSessionData
|
99
|
+
*/
|
100
|
+
}, {
|
101
|
+
key: "submitPay",
|
102
|
+
value: function submitPay(appendParams) {
|
103
|
+
var _appendParams$iframeN,
|
104
|
+
_appendParams$iframeN2,
|
105
|
+
_this$_parseData,
|
106
|
+
_this = this;
|
107
|
+
this._isFinish = false;
|
108
|
+
this._parseData = appendParams === null || appendParams === void 0 || (_appendParams$iframeN = appendParams.iframeNodesParams) === null || _appendParams$iframeN === void 0 ? void 0 : _appendParams$iframeN.paymentSessionMetaData;
|
109
|
+
this._sessionData = appendParams === null || appendParams === void 0 || (_appendParams$iframeN2 = appendParams.iframeNodesParams) === null || _appendParams$iframeN2 === void 0 ? void 0 : _appendParams$iframeN2.sessionData;
|
110
|
+
if (!this._parseData || !this._sessionData) {
|
111
|
+
this.onEventCallback({
|
112
|
+
code: eventCodeEnum.SDK_PAYMENT_FAIL,
|
113
|
+
message: 'Abnormal params paymentSessionData'
|
114
|
+
});
|
115
|
+
this.logger.logError({
|
116
|
+
name: 'APPLE_PAY',
|
117
|
+
title: 'sessionDataNull',
|
118
|
+
msg: 'Abnormal paymentSessionData'
|
119
|
+
}, {
|
120
|
+
type: 'error',
|
121
|
+
biz: 'sdk'
|
122
|
+
}).send();
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
this.isRecurring = ((_this$_parseData = this._parseData) === null || _this$_parseData === void 0 || (_this$_parseData = _this$_parseData.paymentSessionFactor) === null || _this$_parseData === void 0 ? void 0 : _this$_parseData.recurringInfo) !== null;
|
126
|
+
var getDeviceId = /*#__PURE__*/function () {
|
127
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
128
|
+
var _yield$BusManager$pub, _this$_parseData2;
|
129
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
130
|
+
while (1) switch (_context.prev = _context.next) {
|
131
|
+
case 0:
|
132
|
+
_context.next = 2;
|
133
|
+
return BusManager.publishForResult(new BusMessage(SecuritySDKActionEnum.getSecurityDeviceId, JSON.stringify({
|
134
|
+
deviceIdParameter: {
|
135
|
+
productScene: (_this$_parseData2 = _this._parseData) === null || _this$_parseData2 === void 0 || (_this$_parseData2 = _this$_parseData2.paymentSessionConfig) === null || _this$_parseData2 === void 0 ? void 0 : _this$_parseData2.productScene
|
136
|
+
}
|
137
|
+
})), {
|
138
|
+
fallback: ""
|
139
|
+
});
|
140
|
+
case 2:
|
141
|
+
_context.t1 = _yield$BusManager$pub = _context.sent;
|
142
|
+
_context.t0 = _context.t1 === null;
|
143
|
+
if (_context.t0) {
|
144
|
+
_context.next = 6;
|
145
|
+
break;
|
146
|
+
}
|
147
|
+
_context.t0 = _yield$BusManager$pub === void 0;
|
148
|
+
case 6:
|
149
|
+
if (!_context.t0) {
|
150
|
+
_context.next = 10;
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
_context.t2 = void 0;
|
154
|
+
_context.next = 11;
|
155
|
+
break;
|
156
|
+
case 10:
|
157
|
+
_context.t2 = _yield$BusManager$pub.getJSONObject();
|
158
|
+
case 11:
|
159
|
+
return _context.abrupt("return", _context.t2);
|
160
|
+
case 12:
|
161
|
+
case "end":
|
162
|
+
return _context.stop();
|
163
|
+
}
|
164
|
+
}, _callee);
|
165
|
+
}));
|
166
|
+
return function getDeviceId() {
|
167
|
+
return _ref.apply(this, arguments);
|
168
|
+
};
|
169
|
+
}();
|
170
|
+
/**
|
171
|
+
* Get MerchantSession spi
|
172
|
+
* @param event
|
173
|
+
*/
|
174
|
+
var getMerchantSession = /*#__PURE__*/function () {
|
175
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
|
176
|
+
var validationUrl, requestParams;
|
177
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
178
|
+
while (1) switch (_context2.prev = _context2.next) {
|
179
|
+
case 0:
|
180
|
+
validationUrl = _ref2.validationUrl;
|
181
|
+
// get validateUrl
|
182
|
+
requestParams = {
|
183
|
+
validateUrl: validationUrl,
|
184
|
+
paymentSessionData: _this._sessionData
|
185
|
+
}; // get deviceId
|
186
|
+
_context2.t0 = getApplePayPaymentSession;
|
187
|
+
_context2.t1 = _this._sessionData;
|
188
|
+
_context2.t2 = requestParams;
|
189
|
+
_context2.t3 = _this._options.environment;
|
190
|
+
_context2.next = 8;
|
191
|
+
return getDeviceId();
|
192
|
+
case 8:
|
193
|
+
_context2.t4 = _context2.sent;
|
194
|
+
_context2.t5 = {
|
195
|
+
deviceId: _context2.t4
|
196
|
+
};
|
197
|
+
_context2.t6 = {
|
198
|
+
env: _context2.t3,
|
199
|
+
envInfo: _context2.t5
|
200
|
+
};
|
201
|
+
_context2.t7 = _this.logger;
|
202
|
+
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1, _context2.t2, _context2.t6, _context2.t7).then(function (res) {
|
203
|
+
if (res !== null && res !== void 0 && res.success && res.merchantSessionObject) {
|
204
|
+
return Promise.resolve(res.merchantSessionObject);
|
205
|
+
}
|
206
|
+
return Promise.reject({
|
207
|
+
errorCode: res.errorCode,
|
208
|
+
errorMessage: res.errorMessage
|
209
|
+
});
|
210
|
+
}).catch(function (error) {
|
211
|
+
return Promise.reject(error);
|
212
|
+
}));
|
213
|
+
case 13:
|
214
|
+
case "end":
|
215
|
+
return _context2.stop();
|
216
|
+
}
|
217
|
+
}, _callee2);
|
218
|
+
}));
|
219
|
+
return function getMerchantSession(_x) {
|
220
|
+
return _ref3.apply(this, arguments);
|
221
|
+
};
|
222
|
+
}();
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Complete Payment Authorized spi
|
226
|
+
* @param tokens
|
227
|
+
*/
|
228
|
+
var completePaymentAuthorized = /*#__PURE__*/function () {
|
229
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
|
230
|
+
var paymentToken, params;
|
231
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
232
|
+
while (1) switch (_context3.prev = _context3.next) {
|
233
|
+
case 0:
|
234
|
+
paymentToken = _ref4.paymentToken;
|
235
|
+
params = {
|
236
|
+
paymentFactors: {
|
237
|
+
instPaymentToken: paymentToken
|
238
|
+
},
|
239
|
+
paymentSessionData: _this._sessionData
|
240
|
+
};
|
241
|
+
_context3.t0 = submitPayInfo;
|
242
|
+
_context3.t1 = params;
|
243
|
+
_context3.t2 = _this._options.environment;
|
244
|
+
_context3.next = 7;
|
245
|
+
return getDeviceId();
|
246
|
+
case 7:
|
247
|
+
_context3.t3 = _context3.sent;
|
248
|
+
_context3.t4 = {
|
249
|
+
deviceId: _context3.t3
|
250
|
+
};
|
251
|
+
_context3.t5 = {
|
252
|
+
env: _context3.t2,
|
253
|
+
envInfo: _context3.t4
|
254
|
+
};
|
255
|
+
_context3.t6 = _this.logger;
|
256
|
+
return _context3.abrupt("return", (0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6).then(function (res) {
|
257
|
+
_this.logger.logInfo({
|
258
|
+
name: 'APPLE_PAY',
|
259
|
+
title: 'submitPayStatus',
|
260
|
+
msg: res === null || res === void 0 ? void 0 : res.errorStatus
|
261
|
+
}, {
|
262
|
+
biz: 'sdk'
|
263
|
+
}).send();
|
264
|
+
if (res !== null && res !== void 0 && res.success || (res === null || res === void 0 ? void 0 : res.errorStatus) === 'U') {
|
265
|
+
return Promise.resolve(res);
|
266
|
+
}
|
267
|
+
return Promise.reject({
|
268
|
+
errorCode: res.errorCode,
|
269
|
+
errorMessage: res.errorMessage
|
270
|
+
});
|
271
|
+
}).catch(function (error) {
|
272
|
+
return Promise.reject(error);
|
273
|
+
}));
|
274
|
+
case 12:
|
275
|
+
case "end":
|
276
|
+
return _context3.stop();
|
277
|
+
}
|
278
|
+
}, _callee3);
|
279
|
+
}));
|
280
|
+
return function completePaymentAuthorized(_x2) {
|
281
|
+
return _ref5.apply(this, arguments);
|
282
|
+
};
|
283
|
+
}();
|
284
|
+
var completeApplePay = function completeApplePay(data) {
|
285
|
+
var _data$actionForm;
|
286
|
+
_this._isFinish = true;
|
287
|
+
_this.onEventCallback({
|
288
|
+
code: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL,
|
289
|
+
message: 'Payment successful',
|
290
|
+
result: {
|
291
|
+
redirectUrl: (data === null || data === void 0 || (_data$actionForm = data.actionForm) === null || _data$actionForm === void 0 ? void 0 : _data$actionForm.redirectUrl) || ''
|
292
|
+
}
|
293
|
+
});
|
294
|
+
};
|
295
|
+
var logError = function logError(code, msg, error) {
|
296
|
+
// log error
|
297
|
+
_this.logger.logError({
|
298
|
+
name: 'APPLE_PAY',
|
299
|
+
title: msg,
|
300
|
+
label: msg,
|
301
|
+
code: code,
|
302
|
+
msg: error
|
303
|
+
}, {
|
304
|
+
type: 'error',
|
305
|
+
biz: 'sdk'
|
306
|
+
}).send();
|
307
|
+
if (_this._isFinish) {
|
308
|
+
return;
|
309
|
+
}
|
310
|
+
_this._isFinish = true;
|
311
|
+
if (error !== null && error !== void 0 && error.errorCode) {
|
312
|
+
_this.onEventCallback({
|
313
|
+
code: code,
|
314
|
+
message: msg,
|
315
|
+
result: {
|
316
|
+
errorCode: error === null || error === void 0 ? void 0 : error.errorCode,
|
317
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.errorMessage
|
318
|
+
}
|
319
|
+
});
|
320
|
+
} else {
|
321
|
+
_this.onEventCallback({
|
322
|
+
code: code,
|
323
|
+
message: msg
|
324
|
+
});
|
325
|
+
}
|
326
|
+
};
|
327
|
+
// set Apple Pay params
|
328
|
+
this._applePayService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError);
|
329
|
+
// init Apple Pay service
|
330
|
+
try {
|
331
|
+
this._applePayService.startPay(this._parseData);
|
332
|
+
} catch (error) {
|
333
|
+
logError(eventCodeEnum.SDK_PAYMENT_ERROR, "appple runtime excepiton", error);
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}]);
|
337
|
+
return ApplePayComponent;
|
338
|
+
}();
|
339
|
+
export default ApplePayComponent;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { Logger } from "../../util/logger";
|
2
|
+
import { BusContext, BusMessage, BusSubscriber } from "../../core/bus";
|
3
|
+
export declare class ApplePayInitMessage {
|
4
|
+
private environment;
|
5
|
+
private locale;
|
6
|
+
}
|
7
|
+
export declare class ApplePayBusSubscriber extends BusSubscriber {
|
8
|
+
private applePay;
|
9
|
+
logger: Logger;
|
10
|
+
constructor(logger: Logger);
|
11
|
+
actionNames(): string[];
|
12
|
+
protected onOptionalInit(context: BusContext, message: BusMessage): void;
|
13
|
+
protected onCanMakePayments(context: BusContext, message: BusMessage): void;
|
14
|
+
protected onCreateComponent(context: BusContext, message: BusMessage): void;
|
15
|
+
protected onDestroyComponent(context: BusContext, message: BusMessage): void;
|
16
|
+
onMessage(context: BusContext, message: BusMessage): void;
|
17
|
+
}
|