@alipay/ams-checkout 0.0.1709715270-dev.3 → 0.0.1709727882-dev.1
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/core/bus/ability/tracker.d.ts +1 -1
- package/esm/core/bus/index.d.ts +54 -1
- package/esm/core/bus/index.js +83 -26
- package/esm/core/component/index.js +1 -1
- package/esm/plugin/applepay/component.d.ts +12 -2
- package/esm/plugin/applepay/component.js +34 -18
- package/esm/plugin/applepay/index.d.ts +1 -1
- package/esm/plugin/applepay/index.js +19 -2
- package/esm/plugin/applepay/interface.d.ts +0 -2
- package/esm/plugin/applepay/interface.js +1 -5
- package/esm/plugin/applepay/service.d.ts +7 -4
- package/esm/plugin/applepay/service.js +71 -25
- package/esm/plugin/component/index.js +1 -1
- package/esm/plugin/type.js +0 -1
- package/esm/request/index.d.ts +1 -1
- package/esm/service/index.d.ts +1 -1
- package/package.json +1 -1
package/esm/core/bus/index.d.ts
CHANGED
@@ -1,3 +1,55 @@
|
|
1
|
+
import type { Logger } from "../../util/logger";
|
2
|
+
/**
|
3
|
+
* Bus 埋点内容定义
|
4
|
+
*/
|
5
|
+
export declare enum BusLogEventEnum {
|
6
|
+
/**
|
7
|
+
* 发送消息
|
8
|
+
* action:string
|
9
|
+
*/
|
10
|
+
sdk_event_busPublishMessage = "sdk_event_busPublishMessage",
|
11
|
+
/**
|
12
|
+
* 发送消息时,返回事件结果(Web)
|
13
|
+
* action:string
|
14
|
+
*/
|
15
|
+
sdk_event_busPublishCallback = "sdk_event_busPublishCallback",
|
16
|
+
/**
|
17
|
+
* 查询是否订阅
|
18
|
+
* action:string
|
19
|
+
* sub: bool
|
20
|
+
*/
|
21
|
+
sdk_event_busIsSubscribe = "sdk_event_busIsSubscribe",
|
22
|
+
/**
|
23
|
+
* 订阅协议
|
24
|
+
* actions: string[] , 用逗号拼接
|
25
|
+
*/
|
26
|
+
sdk_event_busSubscribe = "sdk_event_busSubscribe",
|
27
|
+
/**
|
28
|
+
* 退订协议
|
29
|
+
* actions: string[] , 用逗号拼接
|
30
|
+
*/
|
31
|
+
sdk_event_busUnsubscribe = "sdk_event_busUnsubscribe",
|
32
|
+
/**
|
33
|
+
* 清除缓存(Web/Android)
|
34
|
+
*/
|
35
|
+
sdk_event_busClear = "sdk_event_busClear",
|
36
|
+
/**
|
37
|
+
* 添加拦截器(Web/Android)
|
38
|
+
*/
|
39
|
+
sdk_event_busAddInterceptor = "sdk_event_busAddInterceptor",
|
40
|
+
/**
|
41
|
+
* 发送消息时,对应aciton未订阅
|
42
|
+
*/
|
43
|
+
sdk_error_busPublishUnsubscribeError = "sdk_error_busPublishUnsubscribeError",
|
44
|
+
/**
|
45
|
+
* 发送消息时异常
|
46
|
+
*/
|
47
|
+
sdk_error_busPublishError = "sdk_error_busPublishError",
|
48
|
+
/**
|
49
|
+
* 发送消息无结果(Web)
|
50
|
+
*/
|
51
|
+
sdk_error_busPublishNoResult = "sdk_error_busPublishNoResult"
|
52
|
+
}
|
1
53
|
/**
|
2
54
|
* 扩展协议可序列化的消息定义
|
3
55
|
*/
|
@@ -56,7 +108,8 @@ export declare class BusManager {
|
|
56
108
|
private static interceptors;
|
57
109
|
private static subscribersMap;
|
58
110
|
private static isDebug;
|
59
|
-
static
|
111
|
+
private static logger;
|
112
|
+
static debugTrace(enable: boolean, logger: Logger): void;
|
60
113
|
private static traceLog;
|
61
114
|
private static traceError;
|
62
115
|
static clear(): void;
|
package/esm/core/bus/index.js
CHANGED
@@ -2,12 +2,31 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
2
2
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (_e) { function e(_x) { return _e.apply(this, arguments); } e.toString = function () { return _e.toString(); }; return e; }(function (e) { throw e; }), f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function (_e2) { function e(_x2) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
3
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
5
|
+
function 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; }
|
6
|
+
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; }
|
5
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6
8
|
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
9
|
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
10
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
9
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
10
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
13
|
+
/**
|
14
|
+
* Bus 埋点内容定义
|
15
|
+
*/
|
16
|
+
export var BusLogEventEnum = /*#__PURE__*/function (BusLogEventEnum) {
|
17
|
+
BusLogEventEnum["sdk_event_busPublishMessage"] = "sdk_event_busPublishMessage";
|
18
|
+
BusLogEventEnum["sdk_event_busPublishCallback"] = "sdk_event_busPublishCallback";
|
19
|
+
BusLogEventEnum["sdk_event_busIsSubscribe"] = "sdk_event_busIsSubscribe";
|
20
|
+
BusLogEventEnum["sdk_event_busSubscribe"] = "sdk_event_busSubscribe";
|
21
|
+
BusLogEventEnum["sdk_event_busUnsubscribe"] = "sdk_event_busUnsubscribe";
|
22
|
+
BusLogEventEnum["sdk_event_busClear"] = "sdk_event_busClear";
|
23
|
+
BusLogEventEnum["sdk_event_busAddInterceptor"] = "sdk_event_busAddInterceptor";
|
24
|
+
BusLogEventEnum["sdk_error_busPublishUnsubscribeError"] = "sdk_error_busPublishUnsubscribeError";
|
25
|
+
BusLogEventEnum["sdk_error_busPublishError"] = "sdk_error_busPublishError";
|
26
|
+
BusLogEventEnum["sdk_error_busPublishNoResult"] = "sdk_error_busPublishNoResult";
|
27
|
+
return BusLogEventEnum;
|
28
|
+
}({});
|
29
|
+
|
11
30
|
/**
|
12
31
|
* 扩展协议可序列化的消息定义
|
13
32
|
*/
|
@@ -106,40 +125,50 @@ export var BusManager = /*#__PURE__*/function () {
|
|
106
125
|
}
|
107
126
|
_createClass(BusManager, null, [{
|
108
127
|
key: "debugTrace",
|
109
|
-
value: function debugTrace(enable) {
|
128
|
+
value: function debugTrace(enable, logger) {
|
110
129
|
this.isDebug = enable;
|
130
|
+
this.logger = logger;
|
111
131
|
}
|
112
132
|
}, {
|
113
133
|
key: "traceLog",
|
114
|
-
value: function traceLog(
|
134
|
+
value: function traceLog(title, optionalParams) {
|
135
|
+
var report = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
115
136
|
if (this.isDebug) {
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
137
|
+
console.log([BusManager.TAG, title].concat(JSON.stringify(optionalParams)).join(this._logSplit));
|
138
|
+
}
|
139
|
+
if (report && this.logger) {
|
140
|
+
this.logger.logInfo({
|
141
|
+
title: title
|
142
|
+
}, _objectSpread({
|
143
|
+
biz: 'sdk'
|
144
|
+
}, optionalParams)).send();
|
120
145
|
}
|
121
146
|
}
|
122
147
|
}, {
|
123
148
|
key: "traceError",
|
124
|
-
value: function traceError(
|
149
|
+
value: function traceError(title, optionalParams) {
|
125
150
|
if (this.isDebug) {
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
151
|
+
console.error([BusManager.TAG, title].concat(JSON.stringify(optionalParams)).join(this._logSplit));
|
152
|
+
}
|
153
|
+
if (this.logger) {
|
154
|
+
this.logger.logError({
|
155
|
+
title: title
|
156
|
+
}, _objectSpread({
|
157
|
+
biz: 'sdk'
|
158
|
+
}, optionalParams)).send();
|
130
159
|
}
|
131
160
|
}
|
132
161
|
}, {
|
133
162
|
key: "clear",
|
134
163
|
value: function clear() {
|
135
|
-
BusManager.traceLog(
|
164
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busClear);
|
136
165
|
BusManager.interceptors.length = 0;
|
137
166
|
BusManager.subscribersMap.clear();
|
138
167
|
}
|
139
168
|
}, {
|
140
169
|
key: "addInterceptor",
|
141
170
|
value: function addInterceptor(interceptor) {
|
142
|
-
BusManager.traceLog(
|
171
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busAddInterceptor);
|
143
172
|
if (!BusManager.interceptors.includes(interceptor)) {
|
144
173
|
BusManager.interceptors.push(interceptor);
|
145
174
|
}
|
@@ -148,16 +177,23 @@ export var BusManager = /*#__PURE__*/function () {
|
|
148
177
|
key: "publishForResult",
|
149
178
|
value: function publishForResult(message, config) {
|
150
179
|
var _this = this;
|
180
|
+
var failed = true;
|
151
181
|
return new Promise(function (resolve, reject) {
|
152
182
|
var _config$timeoutMs;
|
153
183
|
_this.publish(message, function (result) {
|
184
|
+
failed = false;
|
154
185
|
resolve(result);
|
155
186
|
});
|
156
187
|
setTimeout(function () {
|
157
|
-
if (
|
158
|
-
|
159
|
-
|
160
|
-
|
188
|
+
if (failed) {
|
189
|
+
BusManager.traceError(BusLogEventEnum.sdk_error_busPublishNoResult, {
|
190
|
+
action: message.getAction()
|
191
|
+
});
|
192
|
+
if ((config === null || config === void 0 ? void 0 : config.fallback) !== null) {
|
193
|
+
resolve(message.result(config === null || config === void 0 ? void 0 : config.fallback));
|
194
|
+
} else {
|
195
|
+
reject('publish timeout');
|
196
|
+
}
|
161
197
|
}
|
162
198
|
}, (_config$timeoutMs = config === null || config === void 0 ? void 0 : config.timeoutMs) !== null && _config$timeoutMs !== void 0 ? _config$timeoutMs : 2000);
|
163
199
|
});
|
@@ -166,7 +202,9 @@ export var BusManager = /*#__PURE__*/function () {
|
|
166
202
|
key: "publish",
|
167
203
|
value: function publish(message, callback) {
|
168
204
|
var _callBack = function _callBack(result) {
|
169
|
-
BusManager.traceLog(
|
205
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busPublishCallback, {
|
206
|
+
action: message.getAction()
|
207
|
+
});
|
170
208
|
if (callback) {
|
171
209
|
callback(result);
|
172
210
|
}
|
@@ -174,7 +212,9 @@ export var BusManager = /*#__PURE__*/function () {
|
|
174
212
|
var context = new BusContext(_callBack);
|
175
213
|
var actionName = message.getAction();
|
176
214
|
var subscribers = BusManager.subscribersMap.get(actionName);
|
177
|
-
BusManager.traceLog(
|
215
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busPublishMessage, {
|
216
|
+
action: message.getAction()
|
217
|
+
});
|
178
218
|
if (subscribers) {
|
179
219
|
var _iterator = _createForOfIteratorHelper(subscribers),
|
180
220
|
_step;
|
@@ -184,7 +224,10 @@ export var BusManager = /*#__PURE__*/function () {
|
|
184
224
|
try {
|
185
225
|
subscriber.onMessage(context, message);
|
186
226
|
} catch (e) {
|
187
|
-
BusManager.traceError(
|
227
|
+
BusManager.traceError(BusLogEventEnum.sdk_error_busPublishError, {
|
228
|
+
action: message.getAction(),
|
229
|
+
error: e
|
230
|
+
});
|
188
231
|
var _iterator2 = _createForOfIteratorHelper(BusManager.interceptors),
|
189
232
|
_step2;
|
190
233
|
try {
|
@@ -222,14 +265,18 @@ export var BusManager = /*#__PURE__*/function () {
|
|
222
265
|
if (handle) {
|
223
266
|
BusManager.publish(message, callback); // Re-publish the message
|
224
267
|
} else {
|
225
|
-
BusManager.traceError(
|
268
|
+
BusManager.traceError(BusLogEventEnum.sdk_error_busPublishUnsubscribeError, {
|
269
|
+
action: message.getAction()
|
270
|
+
});
|
226
271
|
}
|
227
272
|
}
|
228
273
|
}
|
229
274
|
}, {
|
230
275
|
key: "subscribe",
|
231
276
|
value: function subscribe(subscriber) {
|
232
|
-
BusManager.traceLog(
|
277
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busSubscribe, {
|
278
|
+
actions: subscriber === null || subscriber === void 0 ? void 0 : subscriber.actionNames()
|
279
|
+
});
|
233
280
|
var _iterator4 = _createForOfIteratorHelper(subscriber.actionNames()),
|
234
281
|
_step4;
|
235
282
|
try {
|
@@ -252,7 +299,9 @@ export var BusManager = /*#__PURE__*/function () {
|
|
252
299
|
}, {
|
253
300
|
key: "unsubscribe",
|
254
301
|
value: function unsubscribe(subscriber) {
|
255
|
-
BusManager.traceLog(
|
302
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busUnsubscribe, {
|
303
|
+
actions: subscriber === null || subscriber === void 0 ? void 0 : subscriber.actionNames()
|
304
|
+
});
|
256
305
|
var _iterator5 = _createForOfIteratorHelper(subscriber.actionNames()),
|
257
306
|
_step5;
|
258
307
|
try {
|
@@ -277,7 +326,10 @@ export var BusManager = /*#__PURE__*/function () {
|
|
277
326
|
value: function isSubscribed(actionName) {
|
278
327
|
var subscribers = BusManager.subscribersMap.get(actionName);
|
279
328
|
if (subscribers && subscribers.length > 0) {
|
280
|
-
BusManager.traceLog(
|
329
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busIsSubscribe, {
|
330
|
+
action: actionName,
|
331
|
+
sub: true
|
332
|
+
});
|
281
333
|
return true;
|
282
334
|
}
|
283
335
|
var handle = false;
|
@@ -294,9 +346,13 @@ export var BusManager = /*#__PURE__*/function () {
|
|
294
346
|
_iterator6.f();
|
295
347
|
}
|
296
348
|
if (handle) {
|
349
|
+
// 内部会上报
|
297
350
|
return BusManager.subscribersMap.has(actionName);
|
298
351
|
}
|
299
|
-
BusManager.traceLog(
|
352
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busIsSubscribe, {
|
353
|
+
action: actionName,
|
354
|
+
sub: false
|
355
|
+
});
|
300
356
|
return false;
|
301
357
|
}
|
302
358
|
}]);
|
@@ -306,4 +362,5 @@ _defineProperty(BusManager, "TAG", 'BusManager');
|
|
306
362
|
_defineProperty(BusManager, "_logSplit", ' , ');
|
307
363
|
_defineProperty(BusManager, "interceptors", []);
|
308
364
|
_defineProperty(BusManager, "subscribersMap", new Map());
|
309
|
-
_defineProperty(BusManager, "isDebug", true);
|
365
|
+
_defineProperty(BusManager, "isDebug", true);
|
366
|
+
_defineProperty(BusManager, "logger", void 0);
|
@@ -206,7 +206,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
206
206
|
value: function registerBusAbility() {
|
207
207
|
var _this$originOptions,
|
208
208
|
_this2 = this;
|
209
|
-
BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== environmentEnum.prod);
|
209
|
+
BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== environmentEnum.prod, this.logger);
|
210
210
|
BusManager.clear();
|
211
211
|
BusManager.addInterceptor({
|
212
212
|
onPublishException: function onPublishException(message, e) {
|
@@ -6,7 +6,16 @@
|
|
6
6
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
7
7
|
*/
|
8
8
|
import { ApplePaySubTypeEnum, IAppendParams, IApplePayOptionsParams } from '../../types';
|
9
|
-
import { Logger } from '../../util/logger';
|
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_appleDestoryComponent = "sdk_event_appleDestoryComponent"
|
18
|
+
}
|
10
19
|
/**
|
11
20
|
* Apple pay Component
|
12
21
|
*/
|
@@ -16,7 +25,8 @@ declare class ApplePayComponent {
|
|
16
25
|
private _sessionData;
|
17
26
|
private _isFinish;
|
18
27
|
private _options;
|
19
|
-
logger
|
28
|
+
private logger;
|
29
|
+
private isRecurring;
|
20
30
|
constructor(options: IApplePayOptionsParams, logger: Logger);
|
21
31
|
/**
|
22
32
|
* Is Apple Pay Enabled
|
@@ -20,6 +20,17 @@ import ApplePayService from "./service";
|
|
20
20
|
import { getApplePayPaymentSession, submitPayInfo } from "../../service";
|
21
21
|
import { BusManager, BusMessage } from "../../core/bus";
|
22
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_appleDestoryComponent"] = "sdk_event_appleDestoryComponent";
|
31
|
+
return ApplePayComponentEvent;
|
32
|
+
}({});
|
33
|
+
|
23
34
|
/**
|
24
35
|
* Apple pay Component
|
25
36
|
*/
|
@@ -32,13 +43,14 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
32
43
|
_defineProperty(this, "_isFinish", false);
|
33
44
|
_defineProperty(this, "_options", void 0);
|
34
45
|
_defineProperty(this, "logger", void 0);
|
46
|
+
_defineProperty(this, "isRecurring", false);
|
35
47
|
this.logger = logger;
|
36
48
|
this._options = Object.assign({
|
37
49
|
environment: environmentEnum.prod
|
38
50
|
}, options, {
|
39
51
|
product: productSceneEnum.CARD_APPLE_PAY
|
40
52
|
});
|
41
|
-
this._applePayService = new ApplePayService();
|
53
|
+
this._applePayService = new ApplePayService(logger);
|
42
54
|
}
|
43
55
|
|
44
56
|
/**
|
@@ -65,7 +77,19 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
65
77
|
}, {
|
66
78
|
key: "onEventCallback",
|
67
79
|
value: function onEventCallback(state) {
|
68
|
-
var _this$_options;
|
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_FAIL === (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();
|
69
93
|
(_this$_options = this._options) === null || _this$_options === void 0 || _this$_options.onEventCallback(state);
|
70
94
|
}
|
71
95
|
|
@@ -78,6 +102,7 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
78
102
|
value: function submitPay(appendParams) {
|
79
103
|
var _appendParams$iframeN,
|
80
104
|
_appendParams$iframeN2,
|
105
|
+
_this$_parseData,
|
81
106
|
_this = this;
|
82
107
|
this._isFinish = false;
|
83
108
|
this._parseData = appendParams === null || appendParams === void 0 || (_appendParams$iframeN = appendParams.iframeNodesParams) === null || _appendParams$iframeN === void 0 ? void 0 : _appendParams$iframeN.paymentSessionMetaData;
|
@@ -85,7 +110,7 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
85
110
|
if (!this._parseData || !this._sessionData) {
|
86
111
|
this.onEventCallback({
|
87
112
|
code: eventCodeEnum.SDK_PAYMENT_FAIL,
|
88
|
-
message: 'Abnormal paymentSessionData'
|
113
|
+
message: 'Abnormal params paymentSessionData'
|
89
114
|
});
|
90
115
|
this.logger.logError({
|
91
116
|
name: 'APPLE_PAY',
|
@@ -97,16 +122,17 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
97
122
|
}).send();
|
98
123
|
return;
|
99
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;
|
100
126
|
var getDeviceId = /*#__PURE__*/function () {
|
101
127
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
102
|
-
var _yield$BusManager$pub, _this$
|
128
|
+
var _yield$BusManager$pub, _this$_parseData2;
|
103
129
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
104
130
|
while (1) switch (_context.prev = _context.next) {
|
105
131
|
case 0:
|
106
132
|
_context.next = 2;
|
107
133
|
return BusManager.publishForResult(new BusMessage(SecuritySDKActionEnum.getSecurityDeviceId, JSON.stringify({
|
108
134
|
deviceIdParameter: {
|
109
|
-
productScene: (_this$
|
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
|
110
136
|
}
|
111
137
|
})), {
|
112
138
|
fallback: ""
|
@@ -287,7 +313,8 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
287
313
|
code: code,
|
288
314
|
message: msg,
|
289
315
|
result: {
|
290
|
-
errorCode: error === null || error === void 0 ? void 0 : error.errorCode
|
316
|
+
errorCode: error === null || error === void 0 ? void 0 : error.errorCode,
|
317
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.errorMessage
|
291
318
|
}
|
292
319
|
});
|
293
320
|
} else {
|
@@ -297,19 +324,8 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
297
324
|
});
|
298
325
|
}
|
299
326
|
};
|
300
|
-
var applePayTrace = function applePayTrace(msg) {
|
301
|
-
// set log funnel
|
302
|
-
_this.logger.logInfo({
|
303
|
-
name: 'APPLE_PAY',
|
304
|
-
title: msg,
|
305
|
-
label: msg
|
306
|
-
}, {
|
307
|
-
type: 'funnel',
|
308
|
-
biz: 'sdk'
|
309
|
-
}).send();
|
310
|
-
};
|
311
327
|
// set Apple Pay params
|
312
|
-
this._applePayService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError
|
328
|
+
this._applePayService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError);
|
313
329
|
// init Apple Pay service
|
314
330
|
try {
|
315
331
|
this._applePayService.startPay(this._parseData);
|
@@ -16,7 +16,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
16
16
|
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); }
|
17
17
|
import { BusManager, BusMessage, BusSubscriber } from "../../core/bus";
|
18
18
|
import { ApplePayActionEnum, PaymentActionEnum, SDKCallbackActionEnum } from "../../core/bus/interface";
|
19
|
-
import ApplePayComponent from "./component";
|
19
|
+
import ApplePayComponent, { ApplePayComponentEvent } from "./component";
|
20
20
|
import ApplePayService from "./service";
|
21
21
|
export var ApplePayInitMessage = /*#__PURE__*/_createClass(function ApplePayInitMessage() {
|
22
22
|
_classCallCheck(this, ApplePayInitMessage);
|
@@ -50,8 +50,18 @@ export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
50
50
|
value: function onCanMakePayments(context, message) {
|
51
51
|
var _message$getJSONObjec;
|
52
52
|
console.log('onCanMakePayments', message.getData());
|
53
|
-
var
|
53
|
+
var subPaymentMethod = (_message$getJSONObjec = message.getJSONObject()) === null || _message$getJSONObjec === void 0 ? void 0 : _message$getJSONObjec.subPaymentMethod;
|
54
|
+
var canMakePayments = ApplePayService.canMakePayments(subPaymentMethod);
|
54
55
|
context === null || context === void 0 || context.onCallBack(message.result(canMakePayments));
|
56
|
+
this.logger.logInfo({
|
57
|
+
name: 'APPLE_PAY',
|
58
|
+
title: ApplePayComponentEvent.sdk_event_appleAvailable
|
59
|
+
}, {
|
60
|
+
biz: 'sdk',
|
61
|
+
type: 'funnel',
|
62
|
+
success: canMakePayments,
|
63
|
+
recurring: subPaymentMethod === 'ApplePayRecurringPayment'
|
64
|
+
}).send();
|
55
65
|
}
|
56
66
|
}, {
|
57
67
|
key: "onCreateComponent",
|
@@ -74,6 +84,13 @@ export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
74
84
|
value: function onDestoryComponent(context, message) {
|
75
85
|
this.applePay = null;
|
76
86
|
console.log('onDestoryComponent', context, message);
|
87
|
+
this.logger.logInfo({
|
88
|
+
name: 'APPLE_PAY',
|
89
|
+
title: ApplePayComponentEvent.sdk_event_appleDestoryComponent
|
90
|
+
}, {
|
91
|
+
biz: 'sdk',
|
92
|
+
type: 'funnel'
|
93
|
+
}).send();
|
77
94
|
}
|
78
95
|
}, {
|
79
96
|
key: "onMessage",
|
@@ -159,5 +159,3 @@ export type ICompletePaymentAuthorized = (params: {
|
|
159
159
|
}) => Promise<any>;
|
160
160
|
export type ICompleteApplePay = (data: any) => void;
|
161
161
|
export type ILogError = (code: string, msg: string, error?: any) => void;
|
162
|
-
export type traceMsg = 'start' | 'sessionBegin' | 'onValidateMerchant' | 'completeMerchantValidation' | 'onpaymentauthorized' | 'completePaymentAuthorized' | 'completeApplePay';
|
163
|
-
export type IApplePayTrace = (msg: traceMsg) => void;
|
@@ -5,8 +5,9 @@
|
|
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 { IGetMerchantSession, ICompletePaymentAuthorized, ICompleteApplePay, ILogError
|
8
|
+
import { IGetMerchantSession, ICompletePaymentAuthorized, ICompleteApplePay, ILogError } from './interface';
|
9
9
|
import { ApplePaySubTypeEnum, IpaymentSessionMetaData } from '../../types';
|
10
|
+
import type { Logger } from '../../util/logger';
|
10
11
|
/**
|
11
12
|
* Apple Pay Service
|
12
13
|
*/
|
@@ -19,8 +20,9 @@ declare class ApplePayService {
|
|
19
20
|
private completePaymentAuthorized;
|
20
21
|
private completeApplePay;
|
21
22
|
private logError;
|
22
|
-
private
|
23
|
-
|
23
|
+
private isRecurring;
|
24
|
+
private logger;
|
25
|
+
constructor(logger: Logger);
|
24
26
|
/**
|
25
27
|
* set Apple Pay Params
|
26
28
|
* @param getMerchantSession
|
@@ -29,7 +31,7 @@ declare class ApplePayService {
|
|
29
31
|
* @param logError
|
30
32
|
* @param applePayTrace
|
31
33
|
*/
|
32
|
-
setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError
|
34
|
+
setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError): void;
|
33
35
|
/**
|
34
36
|
* Is Apple Pay Enabled
|
35
37
|
* @param subTypeEnum
|
@@ -42,6 +44,7 @@ declare class ApplePayService {
|
|
42
44
|
*/
|
43
45
|
hasActiveCard(merchantIdentifier: string): Promise<boolean>;
|
44
46
|
private onvalidatemerchant;
|
47
|
+
private sessionAbort;
|
45
48
|
private onpaymentauthorized;
|
46
49
|
/**
|
47
50
|
* Start Pay
|