@alipay/ams-checkout 0.0.1710212811-dev.19 → 0.0.1710212811-dev.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/core/bus/index.d.ts
CHANGED
@@ -52,6 +52,7 @@ export interface BusInterceptor {
|
|
52
52
|
*/
|
53
53
|
export declare class BusManager {
|
54
54
|
private static TAG;
|
55
|
+
private static _logSplit;
|
55
56
|
private static interceptors;
|
56
57
|
private static subscribersMap;
|
57
58
|
private static isDebug;
|
@@ -60,7 +61,10 @@ export declare class BusManager {
|
|
60
61
|
private static traceError;
|
61
62
|
static clear(): void;
|
62
63
|
static addInterceptor(interceptor: BusInterceptor): void;
|
63
|
-
static publishForResult(message: BusMessage,
|
64
|
+
static publishForResult(message: BusMessage, config?: {
|
65
|
+
timeoutMs?: number;
|
66
|
+
fallback?: any;
|
67
|
+
}): Promise<BusMessage>;
|
64
68
|
static publish(message: BusMessage, callback?: OnBusCallback): void;
|
65
69
|
static subscribe(subscriber: BusSubscriber): void;
|
66
70
|
static unsubscribe(subscriber: BusSubscriber): void;
|
package/esm/core/bus/index.js
CHANGED
@@ -116,7 +116,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
116
116
|
for (var _len = arguments.length, optionalParams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
117
117
|
optionalParams[_key - 1] = arguments[_key];
|
118
118
|
}
|
119
|
-
console.log(message
|
119
|
+
console.log([BusManager.TAG, message].concat(optionalParams).join(this._logSplit));
|
120
120
|
}
|
121
121
|
}
|
122
122
|
}, {
|
@@ -126,43 +126,47 @@ export var BusManager = /*#__PURE__*/function () {
|
|
126
126
|
for (var _len2 = arguments.length, optionalParams = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
127
127
|
optionalParams[_key2 - 1] = arguments[_key2];
|
128
128
|
}
|
129
|
-
console.error(message
|
129
|
+
console.error([BusManager.TAG, message].concat(optionalParams).join(this._logSplit));
|
130
130
|
}
|
131
131
|
}
|
132
132
|
}, {
|
133
133
|
key: "clear",
|
134
134
|
value: function clear() {
|
135
|
-
BusManager.traceLog(
|
135
|
+
BusManager.traceLog('clear');
|
136
136
|
BusManager.interceptors.length = 0;
|
137
137
|
BusManager.subscribersMap.clear();
|
138
138
|
}
|
139
139
|
}, {
|
140
140
|
key: "addInterceptor",
|
141
141
|
value: function addInterceptor(interceptor) {
|
142
|
-
BusManager.traceLog(
|
142
|
+
BusManager.traceLog('addInterceptor');
|
143
143
|
if (!BusManager.interceptors.includes(interceptor)) {
|
144
144
|
BusManager.interceptors.push(interceptor);
|
145
145
|
}
|
146
146
|
}
|
147
147
|
}, {
|
148
148
|
key: "publishForResult",
|
149
|
-
value: function publishForResult(message) {
|
149
|
+
value: function publishForResult(message, config) {
|
150
150
|
var _this = this;
|
151
|
-
var timeoutMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
|
152
151
|
return new Promise(function (resolve, reject) {
|
152
|
+
var _config$timeoutMs;
|
153
153
|
_this.publish(message, function (result) {
|
154
154
|
resolve(result);
|
155
155
|
});
|
156
156
|
setTimeout(function () {
|
157
|
-
|
158
|
-
|
157
|
+
if ((config === null || config === void 0 ? void 0 : config.fallback) !== null) {
|
158
|
+
resolve(message.result(config === null || config === void 0 ? void 0 : config.fallback));
|
159
|
+
} else {
|
160
|
+
reject('publish timeout');
|
161
|
+
}
|
162
|
+
}, (_config$timeoutMs = config === null || config === void 0 ? void 0 : config.timeoutMs) !== null && _config$timeoutMs !== void 0 ? _config$timeoutMs : 2000);
|
159
163
|
});
|
160
164
|
}
|
161
165
|
}, {
|
162
166
|
key: "publish",
|
163
167
|
value: function publish(message, callback) {
|
164
168
|
var _callBack = function _callBack(result) {
|
165
|
-
BusManager.traceLog(
|
169
|
+
BusManager.traceLog('publish result ' + (message === null || message === void 0 ? void 0 : message.getAction()), result === null || result === void 0 ? void 0 : result.getData());
|
166
170
|
if (callback) {
|
167
171
|
callback(result);
|
168
172
|
}
|
@@ -170,7 +174,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
170
174
|
var context = new BusContext(_callBack);
|
171
175
|
var actionName = message.getAction();
|
172
176
|
var subscribers = BusManager.subscribersMap.get(actionName);
|
173
|
-
BusManager.traceLog(
|
177
|
+
BusManager.traceLog('publish', JSON.stringify(message));
|
174
178
|
if (subscribers) {
|
175
179
|
var _iterator = _createForOfIteratorHelper(subscribers),
|
176
180
|
_step;
|
@@ -180,7 +184,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
180
184
|
try {
|
181
185
|
subscriber.onMessage(context, message);
|
182
186
|
} catch (e) {
|
183
|
-
BusManager.traceError(
|
187
|
+
BusManager.traceError('excute onMessage error ', message, e);
|
184
188
|
var _iterator2 = _createForOfIteratorHelper(BusManager.interceptors),
|
185
189
|
_step2;
|
186
190
|
try {
|
@@ -207,7 +211,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
207
211
|
try {
|
208
212
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
209
213
|
var _interceptor = _step3.value;
|
210
|
-
BusManager.traceLog(
|
214
|
+
BusManager.traceLog('onUnsubscribedAction', JSON.stringify(message));
|
211
215
|
handle = handle || (_interceptor === null || _interceptor === void 0 ? void 0 : _interceptor.onUnsubscribedAction(message.getAction()));
|
212
216
|
}
|
213
217
|
} catch (err) {
|
@@ -218,14 +222,14 @@ export var BusManager = /*#__PURE__*/function () {
|
|
218
222
|
if (handle) {
|
219
223
|
BusManager.publish(message, callback); // Re-publish the message
|
220
224
|
} else {
|
221
|
-
BusManager.traceError(
|
225
|
+
BusManager.traceError('notSubscribeMessage', JSON.stringify(message));
|
222
226
|
}
|
223
227
|
}
|
224
228
|
}
|
225
229
|
}, {
|
226
230
|
key: "subscribe",
|
227
231
|
value: function subscribe(subscriber) {
|
228
|
-
BusManager.traceLog(
|
232
|
+
BusManager.traceLog('subscribe', subscriber === null || subscriber === void 0 ? void 0 : subscriber.actionNames());
|
229
233
|
var _iterator4 = _createForOfIteratorHelper(subscriber.actionNames()),
|
230
234
|
_step4;
|
231
235
|
try {
|
@@ -248,7 +252,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
248
252
|
}, {
|
249
253
|
key: "unsubscribe",
|
250
254
|
value: function unsubscribe(subscriber) {
|
251
|
-
BusManager.traceLog(
|
255
|
+
BusManager.traceLog('unsubscribe', subscriber === null || subscriber === void 0 ? void 0 : subscriber.actionNames());
|
252
256
|
var _iterator5 = _createForOfIteratorHelper(subscriber.actionNames()),
|
253
257
|
_step5;
|
254
258
|
try {
|
@@ -273,7 +277,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
273
277
|
value: function isSubscribed(actionName) {
|
274
278
|
var subscribers = BusManager.subscribersMap.get(actionName);
|
275
279
|
if (subscribers && subscribers.length > 0) {
|
276
|
-
BusManager.traceLog(
|
280
|
+
BusManager.traceLog('isSubscribed: ' + actionName, true);
|
277
281
|
return true;
|
278
282
|
}
|
279
283
|
var handle = false;
|
@@ -292,13 +296,14 @@ export var BusManager = /*#__PURE__*/function () {
|
|
292
296
|
if (handle) {
|
293
297
|
return BusManager.subscribersMap.has(actionName);
|
294
298
|
}
|
295
|
-
BusManager.traceLog(
|
299
|
+
BusManager.traceLog('isSubscribed: ' + actionName, false);
|
296
300
|
return false;
|
297
301
|
}
|
298
302
|
}]);
|
299
303
|
return BusManager;
|
300
304
|
}();
|
301
305
|
_defineProperty(BusManager, "TAG", 'BusManager');
|
306
|
+
_defineProperty(BusManager, "_logSplit", ' , ');
|
302
307
|
_defineProperty(BusManager, "interceptors", []);
|
303
308
|
_defineProperty(BusManager, "subscribersMap", new Map());
|
304
309
|
_defineProperty(BusManager, "isDebug", true);
|
@@ -241,8 +241,10 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
241
241
|
if (paymentMethod === PaymentMethodTypeEnum.ApplePay) {
|
242
242
|
BusManager.publishForResult(new BusMessage(ApplePayActionEnum.canMakePayments, JSON.stringify({
|
243
243
|
subPaymentMethod: subPaymentMethod
|
244
|
-
}))
|
245
|
-
|
244
|
+
})), {
|
245
|
+
fallback: false
|
246
|
+
}).then(function (message) {
|
247
|
+
resolve(message.getJSONObject());
|
246
248
|
}).catch(function (e) {
|
247
249
|
_this3.logger.logInfo({
|
248
250
|
title: 'canMakePayments_error'
|
package/esm/index.d.ts
CHANGED
@@ -5,15 +5,12 @@
|
|
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 ApplePayComponent from './plugin/applepay/component';
|
9
8
|
import { AMSComponent } from './core/component/index';
|
10
9
|
import { IoptionsParams, componentSignEnum } from './types';
|
11
10
|
export * from './types';
|
12
11
|
export declare class AMSCheckout extends AMSComponent {
|
13
12
|
constructor(_options: any, channelType?: componentSignEnum[], productSceneVersion?: string);
|
14
13
|
}
|
15
|
-
export declare class AMSApplePay extends ApplePayComponent {
|
16
|
-
}
|
17
14
|
export declare class AMSAutoDebit extends AMSCheckout {
|
18
15
|
constructor(options: IoptionsParams);
|
19
16
|
}
|
package/esm/index.js
CHANGED
@@ -18,7 +18,6 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
18
18
|
* 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
|
19
19
|
* 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.
|
20
20
|
*/
|
21
|
-
import ApplePayComponent from "./plugin/applepay/component";
|
22
21
|
import { AMSComponent } from "./core/component/index";
|
23
22
|
import { componentSignEnum } from "./types";
|
24
23
|
import { productSceneEnum } from "./types/index";
|
@@ -38,30 +37,21 @@ export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
|
|
38
37
|
}
|
39
38
|
return _createClass(AMSCheckout);
|
40
39
|
}(AMSComponent);
|
41
|
-
export var AMSApplePay = /*#__PURE__*/function (_ApplePayComponent) {
|
42
|
-
_inherits(AMSApplePay, _ApplePayComponent);
|
43
|
-
var _super2 = _createSuper(AMSApplePay);
|
44
|
-
function AMSApplePay() {
|
45
|
-
_classCallCheck(this, AMSApplePay);
|
46
|
-
return _super2.apply(this, arguments);
|
47
|
-
}
|
48
|
-
return _createClass(AMSApplePay);
|
49
|
-
}(ApplePayComponent);
|
50
40
|
export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
|
51
41
|
_inherits(AMSAutoDebit, _AMSCheckout);
|
52
|
-
var
|
42
|
+
var _super2 = _createSuper(AMSAutoDebit);
|
53
43
|
function AMSAutoDebit(options) {
|
54
44
|
_classCallCheck(this, AMSAutoDebit);
|
55
45
|
var _options = Object.assign({}, options, {
|
56
46
|
product: productSceneEnum.AUTO_DEBIT
|
57
47
|
});
|
58
|
-
return
|
48
|
+
return _super2.call(this, _options, [componentSignEnum.AUTO_DEBIT_WALLET]);
|
59
49
|
}
|
60
50
|
return _createClass(AMSAutoDebit);
|
61
51
|
}(AMSCheckout);
|
62
52
|
export var AMSEasyPay = /*#__PURE__*/function (_AMSCheckout2) {
|
63
53
|
_inherits(AMSEasyPay, _AMSCheckout2);
|
64
|
-
var
|
54
|
+
var _super3 = _createSuper(AMSEasyPay);
|
65
55
|
function AMSEasyPay(options) {
|
66
56
|
_classCallCheck(this, AMSEasyPay);
|
67
57
|
var _options = Object.assign({}, options, {
|
@@ -86,13 +76,13 @@ export var AMSEasyPay = /*#__PURE__*/function (_AMSCheckout2) {
|
|
86
76
|
error: error
|
87
77
|
});
|
88
78
|
}
|
89
|
-
return
|
79
|
+
return _super3.call(this, _options, [componentSignEnum.EASY_PAY_WALLET], currentProductSceneVersion);
|
90
80
|
}
|
91
81
|
return _createClass(AMSEasyPay);
|
92
82
|
}(AMSCheckout);
|
93
83
|
export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
94
84
|
_inherits(AMSCashierPayment, _AMSCheckout3);
|
95
|
-
var
|
85
|
+
var _super4 = _createSuper(AMSCashierPayment);
|
96
86
|
function AMSCashierPayment(options) {
|
97
87
|
_classCallCheck(this, AMSCashierPayment);
|
98
88
|
var _options = Object.assign({}, options, {
|
@@ -117,19 +107,19 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
|
117
107
|
error: error
|
118
108
|
});
|
119
109
|
}
|
120
|
-
return
|
110
|
+
return _super4.call(this, _options, currentChannelType);
|
121
111
|
}
|
122
112
|
return _createClass(AMSCashierPayment);
|
123
113
|
}(AMSCheckout);
|
124
114
|
export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
|
125
115
|
_inherits(AMSVaulting, _AMSCheckout4);
|
126
|
-
var
|
116
|
+
var _super5 = _createSuper(AMSVaulting);
|
127
117
|
function AMSVaulting(options) {
|
128
118
|
_classCallCheck(this, AMSVaulting);
|
129
119
|
var _options = Object.assign({}, options, {
|
130
120
|
product: productSceneEnum.VAULTING
|
131
121
|
});
|
132
|
-
return
|
122
|
+
return _super5.call(this, _options, [componentSignEnum.CASHIER_PAYMENT_CARD]);
|
133
123
|
}
|
134
124
|
return _createClass(AMSVaulting);
|
135
125
|
}(AMSCheckout);
|
@@ -137,7 +137,9 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
137
137
|
deviceIdParameter: {
|
138
138
|
productScene: (_this$_parseData = _this._parseData) === null || _this$_parseData === void 0 || (_this$_parseData = _this$_parseData.paymentSessionConfig) === null || _this$_parseData === void 0 ? void 0 : _this$_parseData.productScene
|
139
139
|
}
|
140
|
-
}))
|
140
|
+
})), {
|
141
|
+
fallback: ""
|
142
|
+
});
|
141
143
|
case 2:
|
142
144
|
_context.t1 = _yield$BusManager$pub = _context.sent;
|
143
145
|
_context.t0 = _context.t1 === null;
|