@kushki/js 1.30.1 → 1.31.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/lib/Kushki.js +2 -2
- package/lib/repository/ICardDynamicService.d.ts +2 -3
- package/lib/repository/ICardService.d.ts +2 -1
- package/lib/service/CardDynamicService.d.ts +2 -3
- package/lib/service/CardDynamicService.js +32 -13
- package/lib/service/CardService.d.ts +4 -1
- package/lib/service/CardService.js +54 -7
- package/package.json +1 -1
package/lib/Kushki.js
CHANGED
|
@@ -37,7 +37,7 @@ var Kushki = /** @class */ (function () {
|
|
|
37
37
|
this._cardSubscriptionDynamicService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.CardSubscriptionDynamicService)();
|
|
38
38
|
}
|
|
39
39
|
Kushki.prototype.requestToken = function (body, callback) {
|
|
40
|
-
this.
|
|
40
|
+
this._cardService.requestToken(body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
41
41
|
};
|
|
42
42
|
Kushki.prototype.requestInitAntiFraud = function (userId, callback) {
|
|
43
43
|
this._resolve(this._siftScience.requestInitAntiFraud(userId, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
@@ -138,7 +138,7 @@ var Kushki = /** @class */ (function () {
|
|
|
138
138
|
this._resolve(this._mobileProcessorService.requestToken(body, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
139
139
|
};
|
|
140
140
|
Kushki.prototype.requestCardDynamicToken = function (bin, body, callback) {
|
|
141
|
-
this.
|
|
141
|
+
this._cardDynamicService.requestCardDynamicToken(bin, body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
142
142
|
};
|
|
143
143
|
Kushki.prototype.requestCardSubscriptionDynamicToken = function (bin, body, callback) {
|
|
144
144
|
this._resolve(this._cardSubscriptionDynamicService.requestCardSubscriptionDynamicToken(bin, body, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* ICardDynamicService
|
|
4
4
|
*/
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
5
|
import { BinBody } from "./../../lib/types/bin_body";
|
|
7
6
|
import { CardAsyncTokenRequest } from "./../../lib/types/card_async_token_request";
|
|
8
|
-
import {
|
|
7
|
+
import { ErrorResponse } from "./../../lib/types/error_response";
|
|
9
8
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
10
9
|
import { TokenRequest } from "./../../lib/types/token_request";
|
|
11
10
|
export interface ICardDynamicService {
|
|
12
|
-
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean
|
|
11
|
+
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
13
12
|
}
|
|
@@ -25,8 +25,9 @@ export interface ICardService {
|
|
|
25
25
|
* @param mid - public merchant id
|
|
26
26
|
* @param isTest - is test environment
|
|
27
27
|
* @param regional - Define if endpoint used regional URL
|
|
28
|
+
* @param callback
|
|
28
29
|
*/
|
|
29
|
-
requestToken(tokenRequest: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean):
|
|
30
|
+
requestToken(tokenRequest: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
30
31
|
/**
|
|
31
32
|
* Subscription Token
|
|
32
33
|
* @param subscriptionTokenRequest - subscription tokens request body
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
import { ICardAsyncService } from "./../../lib/repository/ICardAsyncService";
|
|
3
3
|
import { ICardDynamicService } from "./../../lib/repository/ICardDynamicService";
|
|
4
4
|
import { ICardService } from "./../../lib/repository/ICardService";
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
5
|
import { BinBody } from "./../../lib/types/bin_body";
|
|
7
6
|
import { CardAsyncTokenRequest } from "./../../lib/types/card_async_token_request";
|
|
8
|
-
import {
|
|
7
|
+
import { ErrorResponse } from "./../../lib/types/error_response";
|
|
9
8
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
10
9
|
import { TokenRequest } from "./../../lib/types/token_request";
|
|
11
10
|
/**
|
|
@@ -15,7 +14,7 @@ export declare class CardDynamicService implements ICardDynamicService {
|
|
|
15
14
|
private readonly _cardService;
|
|
16
15
|
private readonly _cardAsyncService;
|
|
17
16
|
constructor(cardService: ICardService, cardAsyncService: ICardAsyncService);
|
|
18
|
-
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean
|
|
17
|
+
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
19
18
|
private _requestCardAsyncToken;
|
|
20
19
|
private _requestToken;
|
|
21
20
|
}
|
|
@@ -21,6 +21,7 @@ var BinCardTypeEnum_1 = require("./../../lib/infrastructure/BinCardTypeEnum");
|
|
|
21
21
|
var inversify_1 = require("inversify");
|
|
22
22
|
var rxjs_1 = require("rxjs");
|
|
23
23
|
var operators_1 = require("rxjs/operators");
|
|
24
|
+
var Kushki_1 = require("./../../lib/Kushki");
|
|
24
25
|
/**
|
|
25
26
|
* Implementation
|
|
26
27
|
*/
|
|
@@ -29,25 +30,43 @@ var CardDynamicService = /** @class */ (function () {
|
|
|
29
30
|
this._cardService = cardService;
|
|
30
31
|
this._cardAsyncService = cardAsyncService;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
// istanbul ignore next
|
|
34
|
+
CardDynamicService.prototype.requestCardDynamicToken = function (bin, body, mid, testEnv, regional, callback) {
|
|
33
35
|
var _this = this;
|
|
34
|
-
|
|
36
|
+
rxjs_1.of(1)
|
|
37
|
+
.pipe(operators_1.concatMap(function () {
|
|
35
38
|
return _this._cardService.requestBinInfo(bin, mid, testEnv, regional);
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
}))
|
|
40
|
+
.subscribe({
|
|
41
|
+
error: function (err) {
|
|
42
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
43
|
+
},
|
|
44
|
+
next: function (binInfo) {
|
|
45
|
+
if (binInfo.cardType === BinCardTypeEnum_1.BinCardTypeEnum.debit)
|
|
46
|
+
_this._requestCardAsyncToken(body, mid, testEnv, regional, callback);
|
|
47
|
+
else
|
|
48
|
+
_this._requestToken(body, mid, testEnv, regional, callback);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
39
51
|
};
|
|
40
|
-
|
|
52
|
+
// istanbul ignore next
|
|
53
|
+
CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional, callback) {
|
|
41
54
|
var _this = this;
|
|
42
|
-
|
|
55
|
+
rxjs_1.of(1)
|
|
56
|
+
.pipe(operators_1.mergeMap(function () {
|
|
43
57
|
return _this._cardAsyncService.requestCardAsyncToken(body, mid, testEnv, regional);
|
|
44
|
-
}))
|
|
58
|
+
}))
|
|
59
|
+
.subscribe({
|
|
60
|
+
error: function (err) {
|
|
61
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
62
|
+
},
|
|
63
|
+
next: function (token) {
|
|
64
|
+
callback(token);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
45
67
|
};
|
|
46
|
-
CardDynamicService.prototype._requestToken = function (body, mid, testEnv, regional) {
|
|
47
|
-
|
|
48
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(function () {
|
|
49
|
-
return _this._cardService.requestToken(body, mid, testEnv, regional);
|
|
50
|
-
}));
|
|
68
|
+
CardDynamicService.prototype._requestToken = function (body, mid, testEnv, regional, callback) {
|
|
69
|
+
this._cardService.requestToken(body, mid, testEnv, regional, callback);
|
|
51
70
|
};
|
|
52
71
|
CardDynamicService = __decorate([
|
|
53
72
|
inversify_1.injectable(),
|
|
@@ -40,13 +40,16 @@ export declare class CardService implements ICardService {
|
|
|
40
40
|
private readonly _cardNumber;
|
|
41
41
|
private _sandboxEnable;
|
|
42
42
|
constructor(gateway: IKushkiGateway, authService: IAuthService, antiFraud: IAntiFraud);
|
|
43
|
-
requestToken(request: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean):
|
|
43
|
+
requestToken(request: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
44
44
|
requestDeviceToken(request: SubscriptionIdRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
|
|
45
45
|
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest | SubscriptionTokenKPayRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
|
|
46
46
|
requestDeferred(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<IDeferredResponse[]>;
|
|
47
47
|
requestBinInfo(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<BinInfoResponse>;
|
|
48
48
|
validate3DS(body: Validate3DSRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: Validate3DsResponse | ErrorResponse) => void): void;
|
|
49
49
|
requestSecureInit(request: SecureInitRequest, mid: string, isTest: boolean, regional: boolean): Observable<SecureInitResponse>;
|
|
50
|
+
private _request3DSToken;
|
|
51
|
+
private _setupCompleteCardinal;
|
|
52
|
+
private _requestTokenGateway;
|
|
50
53
|
private _getMerchantSettings;
|
|
51
54
|
private _validateParameters;
|
|
52
55
|
private _getDeviceTokenSiftScienceObject;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// tslint:disable:no-identical-functions
|
|
2
3
|
/**
|
|
3
4
|
* Card Service file
|
|
4
5
|
*/
|
|
@@ -103,18 +104,21 @@ var CardService = /** @class */ (function () {
|
|
|
103
104
|
_a);
|
|
104
105
|
}
|
|
105
106
|
CardService_1 = CardService;
|
|
106
|
-
CardService.prototype.requestToken = function (request, mid, isTest, regional) {
|
|
107
|
+
CardService.prototype.requestToken = function (request, mid, isTest, regional, callback) {
|
|
107
108
|
var _this = this;
|
|
108
|
-
|
|
109
|
+
this._gateway
|
|
110
|
+
.requestMerchantSettings(mid, isTest, regional)
|
|
111
|
+
.pipe(operators_1.switchMap(function (merchant) {
|
|
109
112
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
110
113
|
return rxjs_1.forkJoin([
|
|
111
114
|
_this._getScienceSession(request, mid, isTest, merchant),
|
|
112
115
|
_this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "card")
|
|
113
116
|
? request.card.number
|
|
114
117
|
: undefined),
|
|
118
|
+
rxjs_1.of(merchant),
|
|
115
119
|
]);
|
|
116
120
|
}), operators_1.mergeMap(function (_a) {
|
|
117
|
-
var sift_object = _a[0], jwt = _a[1];
|
|
121
|
+
var sift_object = _a[0], jwt = _a[1], merchant = _a[2];
|
|
118
122
|
request.isDeferred =
|
|
119
123
|
request.isDeferred === undefined ? false : request.isDeferred;
|
|
120
124
|
if (Boolean(request.cvv))
|
|
@@ -128,11 +132,21 @@ var CardService = /** @class */ (function () {
|
|
|
128
132
|
request.walletId
|
|
129
133
|
? _this._authService.getAuthorizationToken()
|
|
130
134
|
: rxjs_1.of(undefined),
|
|
135
|
+
rxjs_1.of(merchant),
|
|
131
136
|
]);
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
137
|
+
}))
|
|
138
|
+
.subscribe({
|
|
139
|
+
error: function (err) {
|
|
140
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
141
|
+
},
|
|
142
|
+
next: function (_a) {
|
|
143
|
+
var final_request = _a[0], authorization = _a[1], merchant = _a[2];
|
|
144
|
+
if (final_request.jwt && !merchant.sandboxEnable)
|
|
145
|
+
_this._request3DSToken(final_request, mid, isTest, regional, callback, authorization);
|
|
146
|
+
else
|
|
147
|
+
_this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
136
150
|
};
|
|
137
151
|
CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional) {
|
|
138
152
|
var _this = this;
|
|
@@ -236,6 +250,39 @@ var CardService = /** @class */ (function () {
|
|
|
236
250
|
jwt: jwt
|
|
237
251
|
}); }));
|
|
238
252
|
};
|
|
253
|
+
CardService.prototype._request3DSToken = function (body, mid, isTest, regional, callback, authorization) {
|
|
254
|
+
var _this = this;
|
|
255
|
+
if (isTest)
|
|
256
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
|
|
257
|
+
_this._setupCompleteCardinal(body, mid, isTest, regional, callback, authorization);
|
|
258
|
+
});
|
|
259
|
+
else
|
|
260
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
|
|
261
|
+
_this._setupCompleteCardinal(body, mid, isTest, regional, callback, authorization);
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
// istanbul ignore next
|
|
265
|
+
CardService.prototype._setupCompleteCardinal = function (body, mid, isTest, regional, callback, authorization) {
|
|
266
|
+
var _this = this;
|
|
267
|
+
window.Cardinal.on("payments.setupComplete", function () { return __awaiter(_this, void 0, void 0, function () {
|
|
268
|
+
return __generator(this, function (_a) {
|
|
269
|
+
this._requestTokenGateway(body, mid, isTest, regional, callback, authorization);
|
|
270
|
+
return [2 /*return*/];
|
|
271
|
+
});
|
|
272
|
+
}); });
|
|
273
|
+
};
|
|
274
|
+
// istanbul ignore next
|
|
275
|
+
CardService.prototype._requestTokenGateway = function (body, mid, testEnv, regional, callback, authorization) {
|
|
276
|
+
var request_token = this._gateway.requestToken(body, mid, testEnv, regional, authorization);
|
|
277
|
+
return request_token.subscribe({
|
|
278
|
+
error: function (err) {
|
|
279
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
280
|
+
},
|
|
281
|
+
next: function (response) {
|
|
282
|
+
callback(response);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
};
|
|
239
286
|
CardService.prototype._getMerchantSettings = function (mid, isTest, regional) {
|
|
240
287
|
var _this = this;
|
|
241
288
|
return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.map(function (merchant) {
|