@alipay/ams-checkout 0.0.1710212811-dev.30 → 0.0.1710212811-dev.32
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/index.d.ts +57 -1
- package/esm/core/bus/index.js +85 -26
- package/esm/core/component/index.js +1 -1
- package/esm/plugin/applepay/component.d.ts +11 -1
- package/esm/plugin/applepay/component.js +46 -26
- package/esm/plugin/applepay/index.js +19 -2
- package/esm/plugin/applepay/interface.d.ts +1 -3
- package/esm/plugin/applepay/interface.js +1 -5
- package/esm/plugin/applepay/service.d.ts +8 -4
- package/esm/plugin/applepay/service.js +89 -23
- package/esm/types/index.d.ts +7 -2
- package/esm/types/index.js +3 -1
- package/package.json +1 -1
package/esm/core/bus/index.d.ts
CHANGED
@@ -1,3 +1,58 @@
|
|
1
|
+
import { Logger } from "../../util/logger";
|
2
|
+
/**
|
3
|
+
* 公用字段:
|
4
|
+
* publish_v: string 发送者版本
|
5
|
+
* base_v: string 基础包版本
|
6
|
+
*/
|
7
|
+
export declare enum BusLogEventEnum {
|
8
|
+
/**
|
9
|
+
* 发送消息
|
10
|
+
* action:string
|
11
|
+
* sub: bool 是否订阅
|
12
|
+
*/
|
13
|
+
sdk_event_busPublishMessage = "sdk_event_busPublishMessage",
|
14
|
+
/**
|
15
|
+
* 发送消息时,返回事件结果(Web)
|
16
|
+
* action:string
|
17
|
+
*/
|
18
|
+
sdk_event_busPublishCallback = "sdk_event_busPublishCallback",
|
19
|
+
/**
|
20
|
+
* 查询是否订阅
|
21
|
+
* action:string
|
22
|
+
* sub: bool
|
23
|
+
*/
|
24
|
+
sdk_event_busIsSubscribe = "sdk_event_busIsSubscribe",
|
25
|
+
/**
|
26
|
+
* 订阅协议
|
27
|
+
* actions: string[] , 用逗号拼接
|
28
|
+
*/
|
29
|
+
sdk_event_busSubscribe = "sdk_event_busSubscribe",
|
30
|
+
/**
|
31
|
+
* 退订协议
|
32
|
+
* actions: string[] , 用逗号拼接
|
33
|
+
*/
|
34
|
+
sdk_event_busUnsubscribe = "sdk_event_busUnsubscribe",
|
35
|
+
/**
|
36
|
+
* 清除缓存(Web/Android)
|
37
|
+
*/
|
38
|
+
sdk_event_busClear = "sdk_event_busClear",
|
39
|
+
/**
|
40
|
+
* 添加拦截器(Web/Android)
|
41
|
+
*/
|
42
|
+
sdk_event_busAddInterceptor = "sdk_event_busAddInterceptor",
|
43
|
+
/**
|
44
|
+
* 发送消息时,对应aciton未订阅
|
45
|
+
*/
|
46
|
+
sdk_error_busPublishUnsubscribeError = "sdk_error_busPublishUnsubscribeError",
|
47
|
+
/**
|
48
|
+
* 发送消息时异常
|
49
|
+
*/
|
50
|
+
sdk_error_busPublishError = "sdk_error_busPublishError",
|
51
|
+
/**
|
52
|
+
* 发送消息无结果(Web)
|
53
|
+
*/
|
54
|
+
sdk_error_busPublishNoResult = "sdk_error_busPublishNoResult"
|
55
|
+
}
|
1
56
|
/**
|
2
57
|
* 扩展协议可序列化的消息定义
|
3
58
|
*/
|
@@ -56,7 +111,8 @@ export declare class BusManager {
|
|
56
111
|
private static interceptors;
|
57
112
|
private static subscribersMap;
|
58
113
|
private static isDebug;
|
59
|
-
static
|
114
|
+
private static logger;
|
115
|
+
static debugTrace(enable: boolean, logger: Logger): void;
|
60
116
|
private static traceLog;
|
61
117
|
private static traceError;
|
62
118
|
static clear(): void;
|
package/esm/core/bus/index.js
CHANGED
@@ -2,12 +2,33 @@ 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
|
+
* 公用字段:
|
15
|
+
* publish_v: string 发送者版本
|
16
|
+
* base_v: string 基础包版本
|
17
|
+
*/
|
18
|
+
export var BusLogEventEnum = /*#__PURE__*/function (BusLogEventEnum) {
|
19
|
+
BusLogEventEnum["sdk_event_busPublishMessage"] = "sdk_event_busPublishMessage";
|
20
|
+
BusLogEventEnum["sdk_event_busPublishCallback"] = "sdk_event_busPublishCallback";
|
21
|
+
BusLogEventEnum["sdk_event_busIsSubscribe"] = "sdk_event_busIsSubscribe";
|
22
|
+
BusLogEventEnum["sdk_event_busSubscribe"] = "sdk_event_busSubscribe";
|
23
|
+
BusLogEventEnum["sdk_event_busUnsubscribe"] = "sdk_event_busUnsubscribe";
|
24
|
+
BusLogEventEnum["sdk_event_busClear"] = "sdk_event_busClear";
|
25
|
+
BusLogEventEnum["sdk_event_busAddInterceptor"] = "sdk_event_busAddInterceptor";
|
26
|
+
BusLogEventEnum["sdk_error_busPublishUnsubscribeError"] = "sdk_error_busPublishUnsubscribeError";
|
27
|
+
BusLogEventEnum["sdk_error_busPublishError"] = "sdk_error_busPublishError";
|
28
|
+
BusLogEventEnum["sdk_error_busPublishNoResult"] = "sdk_error_busPublishNoResult";
|
29
|
+
return BusLogEventEnum;
|
30
|
+
}({});
|
31
|
+
|
11
32
|
/**
|
12
33
|
* 扩展协议可序列化的消息定义
|
13
34
|
*/
|
@@ -106,40 +127,50 @@ export var BusManager = /*#__PURE__*/function () {
|
|
106
127
|
}
|
107
128
|
_createClass(BusManager, null, [{
|
108
129
|
key: "debugTrace",
|
109
|
-
value: function debugTrace(enable) {
|
130
|
+
value: function debugTrace(enable, logger) {
|
110
131
|
this.isDebug = enable;
|
132
|
+
this.logger = logger;
|
111
133
|
}
|
112
134
|
}, {
|
113
135
|
key: "traceLog",
|
114
|
-
value: function traceLog(
|
136
|
+
value: function traceLog(title, optionalParams) {
|
137
|
+
var report = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
115
138
|
if (this.isDebug) {
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
139
|
+
console.log([BusManager.TAG, title].concat(optionalParams).join(this._logSplit));
|
140
|
+
}
|
141
|
+
if (report && this.logger) {
|
142
|
+
this.logger.logInfo({
|
143
|
+
title: title
|
144
|
+
}, _objectSpread({
|
145
|
+
biz: 'sdk'
|
146
|
+
}, optionalParams)).send();
|
120
147
|
}
|
121
148
|
}
|
122
149
|
}, {
|
123
150
|
key: "traceError",
|
124
|
-
value: function traceError(
|
151
|
+
value: function traceError(title, optionalParams) {
|
125
152
|
if (this.isDebug) {
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
153
|
+
console.error([BusManager.TAG, title].concat(optionalParams).join(this._logSplit));
|
154
|
+
}
|
155
|
+
if (this.logger) {
|
156
|
+
this.logger.logError({
|
157
|
+
title: title
|
158
|
+
}, _objectSpread({
|
159
|
+
biz: 'sdk'
|
160
|
+
}, optionalParams)).send();
|
130
161
|
}
|
131
162
|
}
|
132
163
|
}, {
|
133
164
|
key: "clear",
|
134
165
|
value: function clear() {
|
135
|
-
BusManager.traceLog(
|
166
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busClear);
|
136
167
|
BusManager.interceptors.length = 0;
|
137
168
|
BusManager.subscribersMap.clear();
|
138
169
|
}
|
139
170
|
}, {
|
140
171
|
key: "addInterceptor",
|
141
172
|
value: function addInterceptor(interceptor) {
|
142
|
-
BusManager.traceLog(
|
173
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busAddInterceptor);
|
143
174
|
if (!BusManager.interceptors.includes(interceptor)) {
|
144
175
|
BusManager.interceptors.push(interceptor);
|
145
176
|
}
|
@@ -148,16 +179,23 @@ export var BusManager = /*#__PURE__*/function () {
|
|
148
179
|
key: "publishForResult",
|
149
180
|
value: function publishForResult(message, config) {
|
150
181
|
var _this = this;
|
182
|
+
var failed = true;
|
151
183
|
return new Promise(function (resolve, reject) {
|
152
184
|
var _config$timeoutMs;
|
153
185
|
_this.publish(message, function (result) {
|
186
|
+
failed = true;
|
154
187
|
resolve(result);
|
155
188
|
});
|
156
189
|
setTimeout(function () {
|
157
|
-
if (
|
158
|
-
|
159
|
-
|
160
|
-
|
190
|
+
if (failed) {
|
191
|
+
BusManager.traceError(BusLogEventEnum.sdk_error_busPublishNoResult, {
|
192
|
+
action: message.getAction()
|
193
|
+
});
|
194
|
+
if ((config === null || config === void 0 ? void 0 : config.fallback) !== null) {
|
195
|
+
resolve(message.result(config === null || config === void 0 ? void 0 : config.fallback));
|
196
|
+
} else {
|
197
|
+
reject('publish timeout');
|
198
|
+
}
|
161
199
|
}
|
162
200
|
}, (_config$timeoutMs = config === null || config === void 0 ? void 0 : config.timeoutMs) !== null && _config$timeoutMs !== void 0 ? _config$timeoutMs : 2000);
|
163
201
|
});
|
@@ -166,7 +204,9 @@ export var BusManager = /*#__PURE__*/function () {
|
|
166
204
|
key: "publish",
|
167
205
|
value: function publish(message, callback) {
|
168
206
|
var _callBack = function _callBack(result) {
|
169
|
-
BusManager.traceLog(
|
207
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busPublishCallback, {
|
208
|
+
action: message.getAction()
|
209
|
+
});
|
170
210
|
if (callback) {
|
171
211
|
callback(result);
|
172
212
|
}
|
@@ -174,7 +214,9 @@ export var BusManager = /*#__PURE__*/function () {
|
|
174
214
|
var context = new BusContext(_callBack);
|
175
215
|
var actionName = message.getAction();
|
176
216
|
var subscribers = BusManager.subscribersMap.get(actionName);
|
177
|
-
BusManager.traceLog(
|
217
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busPublishMessage, {
|
218
|
+
action: message.getAction()
|
219
|
+
});
|
178
220
|
if (subscribers) {
|
179
221
|
var _iterator = _createForOfIteratorHelper(subscribers),
|
180
222
|
_step;
|
@@ -184,7 +226,10 @@ export var BusManager = /*#__PURE__*/function () {
|
|
184
226
|
try {
|
185
227
|
subscriber.onMessage(context, message);
|
186
228
|
} catch (e) {
|
187
|
-
BusManager.traceError(
|
229
|
+
BusManager.traceError(BusLogEventEnum.sdk_error_busPublishError, {
|
230
|
+
action: message.getAction(),
|
231
|
+
error: e
|
232
|
+
});
|
188
233
|
var _iterator2 = _createForOfIteratorHelper(BusManager.interceptors),
|
189
234
|
_step2;
|
190
235
|
try {
|
@@ -222,14 +267,18 @@ export var BusManager = /*#__PURE__*/function () {
|
|
222
267
|
if (handle) {
|
223
268
|
BusManager.publish(message, callback); // Re-publish the message
|
224
269
|
} else {
|
225
|
-
BusManager.traceError(
|
270
|
+
BusManager.traceError(BusLogEventEnum.sdk_error_busPublishUnsubscribeError, {
|
271
|
+
action: message.getAction()
|
272
|
+
});
|
226
273
|
}
|
227
274
|
}
|
228
275
|
}
|
229
276
|
}, {
|
230
277
|
key: "subscribe",
|
231
278
|
value: function subscribe(subscriber) {
|
232
|
-
BusManager.traceLog(
|
279
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busSubscribe, {
|
280
|
+
actions: subscriber === null || subscriber === void 0 ? void 0 : subscriber.actionNames()
|
281
|
+
});
|
233
282
|
var _iterator4 = _createForOfIteratorHelper(subscriber.actionNames()),
|
234
283
|
_step4;
|
235
284
|
try {
|
@@ -252,7 +301,9 @@ export var BusManager = /*#__PURE__*/function () {
|
|
252
301
|
}, {
|
253
302
|
key: "unsubscribe",
|
254
303
|
value: function unsubscribe(subscriber) {
|
255
|
-
BusManager.traceLog(
|
304
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busUnsubscribe, {
|
305
|
+
actions: subscriber === null || subscriber === void 0 ? void 0 : subscriber.actionNames()
|
306
|
+
});
|
256
307
|
var _iterator5 = _createForOfIteratorHelper(subscriber.actionNames()),
|
257
308
|
_step5;
|
258
309
|
try {
|
@@ -277,7 +328,10 @@ export var BusManager = /*#__PURE__*/function () {
|
|
277
328
|
value: function isSubscribed(actionName) {
|
278
329
|
var subscribers = BusManager.subscribersMap.get(actionName);
|
279
330
|
if (subscribers && subscribers.length > 0) {
|
280
|
-
BusManager.traceLog(
|
331
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busIsSubscribe, {
|
332
|
+
action: actionName,
|
333
|
+
sub: true
|
334
|
+
});
|
281
335
|
return true;
|
282
336
|
}
|
283
337
|
var handle = false;
|
@@ -294,9 +348,13 @@ export var BusManager = /*#__PURE__*/function () {
|
|
294
348
|
_iterator6.f();
|
295
349
|
}
|
296
350
|
if (handle) {
|
351
|
+
// 内部会上报
|
297
352
|
return BusManager.subscribersMap.has(actionName);
|
298
353
|
}
|
299
|
-
BusManager.traceLog(
|
354
|
+
BusManager.traceLog(BusLogEventEnum.sdk_event_busIsSubscribe, {
|
355
|
+
action: actionName,
|
356
|
+
sub: false
|
357
|
+
});
|
300
358
|
return false;
|
301
359
|
}
|
302
360
|
}]);
|
@@ -306,4 +364,5 @@ _defineProperty(BusManager, "TAG", 'BusManager');
|
|
306
364
|
_defineProperty(BusManager, "_logSplit", ' , ');
|
307
365
|
_defineProperty(BusManager, "interceptors", []);
|
308
366
|
_defineProperty(BusManager, "subscribersMap", new Map());
|
309
|
-
_defineProperty(BusManager, "isDebug", true);
|
367
|
+
_defineProperty(BusManager, "isDebug", true);
|
368
|
+
_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) {
|
@@ -7,6 +7,15 @@
|
|
7
7
|
*/
|
8
8
|
import { ApplePaySubTypeEnum, IAppendParams, IApplePayOptionsParams } from '../../types';
|
9
9
|
import { 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,28 +110,29 @@ 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
|
113
|
+
message: 'Abnormal params paymentSessionData'
|
89
114
|
});
|
90
115
|
this.logger.logError({
|
91
116
|
name: 'APPLE_PAY',
|
92
117
|
title: 'sessionDataNull',
|
93
|
-
msg: 'Abnormal
|
118
|
+
msg: 'Abnormal paymentSessionData'
|
94
119
|
}, {
|
95
120
|
type: 'error',
|
96
121
|
biz: 'sdk'
|
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: ""
|
@@ -259,18 +285,20 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
259
285
|
var _data$actionForm;
|
260
286
|
_this._isFinish = true;
|
261
287
|
_this.onEventCallback({
|
262
|
-
code: eventCodeEnum.
|
288
|
+
code: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL,
|
289
|
+
message: 'Payment successful',
|
263
290
|
result: {
|
264
291
|
redirectUrl: (data === null || data === void 0 || (_data$actionForm = data.actionForm) === null || _data$actionForm === void 0 ? void 0 : _data$actionForm.redirectUrl) || ''
|
265
292
|
}
|
266
293
|
});
|
267
294
|
};
|
268
|
-
var logError = function logError(msg, error) {
|
295
|
+
var logError = function logError(code, msg, error) {
|
269
296
|
// log error
|
270
297
|
_this.logger.logError({
|
271
298
|
name: 'APPLE_PAY',
|
272
299
|
title: msg,
|
273
300
|
label: msg,
|
301
|
+
code: code,
|
274
302
|
msg: error
|
275
303
|
}, {
|
276
304
|
type: 'error',
|
@@ -280,32 +308,24 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
280
308
|
return;
|
281
309
|
}
|
282
310
|
_this._isFinish = true;
|
283
|
-
if (
|
311
|
+
if (error !== null && error !== void 0 && error.errorCode) {
|
284
312
|
_this.onEventCallback({
|
285
|
-
code:
|
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
|
+
}
|
286
319
|
});
|
287
320
|
} else {
|
288
321
|
_this.onEventCallback({
|
289
|
-
code:
|
290
|
-
|
291
|
-
errorMsg: msg
|
292
|
-
}
|
322
|
+
code: code,
|
323
|
+
message: msg
|
293
324
|
});
|
294
325
|
}
|
295
326
|
};
|
296
|
-
var applePayTrace = function applePayTrace(msg) {
|
297
|
-
// set log funnel
|
298
|
-
_this.logger.logInfo({
|
299
|
-
name: 'APPLE_PAY',
|
300
|
-
title: msg,
|
301
|
-
label: msg
|
302
|
-
}, {
|
303
|
-
type: 'funnel',
|
304
|
-
biz: 'sdk'
|
305
|
-
}).send();
|
306
|
-
};
|
307
327
|
// set Apple Pay params
|
308
|
-
this._applePayService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError
|
328
|
+
this._applePayService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError);
|
309
329
|
// init Apple Pay service
|
310
330
|
try {
|
311
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",
|
@@ -158,6 +158,4 @@ export type ICompletePaymentAuthorized = (params: {
|
|
158
158
|
paymentToken?: string;
|
159
159
|
}) => Promise<any>;
|
160
160
|
export type ICompleteApplePay = (data: any) => void;
|
161
|
-
export type ILogError = (msg: string, error?: any) => void;
|
162
|
-
export type traceMsg = 'start' | 'sessionBegin' | 'onValidateMerchant' | 'completeMerchantValidation' | 'onpaymentauthorized' | 'completePaymentAuthorized' | 'completeApplePay';
|
163
|
-
export type IApplePayTrace = (msg: traceMsg) => void;
|
161
|
+
export type ILogError = (code: string, msg: string, error?: any) => 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 { Logger } from '../../util/logger';
|
10
11
|
/**
|
11
12
|
* Apple Pay Service
|
12
13
|
*/
|
@@ -14,12 +15,14 @@ declare class ApplePayService {
|
|
14
15
|
private merchantIdentifier;
|
15
16
|
private merchantName;
|
16
17
|
private session;
|
18
|
+
private paymentState;
|
17
19
|
private getMerchantSession;
|
18
20
|
private completePaymentAuthorized;
|
19
21
|
private completeApplePay;
|
20
22
|
private logError;
|
21
|
-
private
|
22
|
-
|
23
|
+
private isRecurring;
|
24
|
+
private logger;
|
25
|
+
constructor(logger: Logger);
|
23
26
|
/**
|
24
27
|
* set Apple Pay Params
|
25
28
|
* @param getMerchantSession
|
@@ -28,7 +31,7 @@ declare class ApplePayService {
|
|
28
31
|
* @param logError
|
29
32
|
* @param applePayTrace
|
30
33
|
*/
|
31
|
-
setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError
|
34
|
+
setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError): void;
|
32
35
|
/**
|
33
36
|
* Is Apple Pay Enabled
|
34
37
|
* @param subTypeEnum
|
@@ -41,6 +44,7 @@ declare class ApplePayService {
|
|
41
44
|
*/
|
42
45
|
hasActiveCard(merchantIdentifier: string): Promise<boolean>;
|
43
46
|
private onvalidatemerchant;
|
47
|
+
private sessionAbort;
|
44
48
|
private onpaymentauthorized;
|
45
49
|
/**
|
46
50
|
* Start Pay
|