@kushki/js 1.28.0-alpha.2 → 1.28.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/gateway/KushkiGateway.d.ts +2 -0
- package/lib/gateway/KushkiGateway.js +12 -0
- package/lib/gateway/SiftScience.d.ts +1 -1
- package/lib/gateway/SiftScience.js +2 -2
- package/lib/infrastructure/EnvironmentEnum.d.ts +1 -1
- package/lib/infrastructure/EnvironmentEnum.js +1 -1
- package/lib/infrastructure/PathEnum.d.ts +2 -1
- package/lib/infrastructure/PathEnum.js +1 -0
- package/lib/repository/IAntiFraud.d.ts +1 -1
- package/lib/repository/IKushkiGateway.d.ts +9 -0
- package/lib/service/CardService.d.ts +2 -0
- package/lib/service/CardService.js +21 -4
- package/lib/types/get_user_id.d.ts +6 -0
- package/lib/types/get_user_id_response.d.ts +6 -0
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_respo
|
|
|
9
9
|
import { CashTokenRequest } from "./../../lib/types/cash_token_request";
|
|
10
10
|
import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
|
|
11
11
|
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
12
|
+
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
12
13
|
import { KushkiSubscriptionTokensRequest } from "./../../lib/types/kushki_subscription_tokens_request";
|
|
13
14
|
import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
14
15
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
@@ -73,6 +74,7 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
73
74
|
deletePaymentMethod(body: DeletePaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string, authorization: string): Observable<boolean>;
|
|
74
75
|
requestSavedPaymentMethods(body: SavedPaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string): Observable<PaymentDataResponse[]>;
|
|
75
76
|
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean): Observable<string>;
|
|
77
|
+
getUserId(subscriptionId: string, mid: string, testEnv: boolean, regional: boolean): Observable<GetUserId>;
|
|
76
78
|
private _assignChannel;
|
|
77
79
|
private _buildHeader;
|
|
78
80
|
}
|
|
@@ -254,6 +254,18 @@ var KushkiGateway = /** @class */ (function () {
|
|
|
254
254
|
return _this.requestGet(PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid);
|
|
255
255
|
}), operators_1.map(function (response) { return response.jwt; }));
|
|
256
256
|
};
|
|
257
|
+
KushkiGateway.prototype.getUserId = function (subscriptionId, mid, testEnv, regional) {
|
|
258
|
+
var _this = this;
|
|
259
|
+
return rxjs_1.of(1).pipe(operators_1.map(function () { return "" + PathEnum_1.PathEnum.get_user_id + subscriptionId + "/user"; }), operators_1.concatMap(function (path) {
|
|
260
|
+
var _a;
|
|
261
|
+
return _this.request({}, (_a = {},
|
|
262
|
+
_a[_this._publicHeader] = mid,
|
|
263
|
+
_a[_this._contentHeader] = _this._contentJSON,
|
|
264
|
+
_a), path, testEnv, regional);
|
|
265
|
+
}), operators_1.map(function (response) { return ({
|
|
266
|
+
userId: response.userId
|
|
267
|
+
}); }));
|
|
268
|
+
};
|
|
257
269
|
KushkiGateway.prototype._assignChannel = function (regional, path) {
|
|
258
270
|
if (!regional) {
|
|
259
271
|
this._uatUrl = "" + EnvironmentEnum_1.EnvironmentEnum.uat + path;
|
|
@@ -14,6 +14,6 @@ export declare class SiftScience implements IAntiFraud {
|
|
|
14
14
|
private readonly _siftProperty;
|
|
15
15
|
private _sift;
|
|
16
16
|
constructor(regional: boolean);
|
|
17
|
-
createSiftScienceSession(processor: string, clientIdentification: string, mid: string, isTest: boolean, merchantSettingsResponse: MerchantSettingsResponse): Observable<SiftScienceObject>;
|
|
17
|
+
createSiftScienceSession(processor: string, clientIdentification: string, mid: string, isTest: boolean, merchantSettingsResponse: MerchantSettingsResponse, userId?: string): Observable<SiftScienceObject>;
|
|
18
18
|
private _initSiftScience;
|
|
19
19
|
}
|
|
@@ -29,7 +29,7 @@ var SiftScience = /** @class */ (function () {
|
|
|
29
29
|
this._sift = [];
|
|
30
30
|
this._initSiftScience(regional);
|
|
31
31
|
}
|
|
32
|
-
SiftScience.prototype.createSiftScienceSession = function (processor, clientIdentification, mid, isTest, merchantSettingsResponse) {
|
|
32
|
+
SiftScience.prototype.createSiftScienceSession = function (processor, clientIdentification, mid, isTest, merchantSettingsResponse, userId) {
|
|
33
33
|
var _this = this;
|
|
34
34
|
return rxjs_1.of(merchantSettingsResponse).pipe(operators_1.map(function (merchantSettings) {
|
|
35
35
|
var sift_environment = isTest
|
|
@@ -41,7 +41,7 @@ var SiftScience = /** @class */ (function () {
|
|
|
41
41
|
sessionId: null,
|
|
42
42
|
userId: null
|
|
43
43
|
};
|
|
44
|
-
var user_id = "" + mid + processor + clientIdentification;
|
|
44
|
+
var user_id = userId || "" + mid + processor + clientIdentification;
|
|
45
45
|
var session_id = uuid_1.v4();
|
|
46
46
|
_this._sift =
|
|
47
47
|
window[_this._siftProperty] === undefined
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Environment enum file
|
|
4
4
|
*/
|
|
5
5
|
export declare enum EnvironmentEnum {
|
|
6
|
-
uat = "https://api-
|
|
6
|
+
uat = "https://api-uat.kushkipagos.com/",
|
|
7
7
|
prod = "https://api.kushkipagos.com/",
|
|
8
8
|
regionalUat = "https://regional-uat.kushkipagos.com/",
|
|
9
9
|
regionalProd = "https://regional.kushkipagos.com/"
|
|
@@ -6,7 +6,7 @@ exports.EnvironmentEnum = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
var EnvironmentEnum;
|
|
8
8
|
(function (EnvironmentEnum) {
|
|
9
|
-
EnvironmentEnum["uat"] = "https://api-
|
|
9
|
+
EnvironmentEnum["uat"] = "https://api-uat.kushkipagos.com/";
|
|
10
10
|
EnvironmentEnum["prod"] = "https://api.kushkipagos.com/";
|
|
11
11
|
EnvironmentEnum["regionalUat"] = "https://regional-uat.kushkipagos.com/";
|
|
12
12
|
EnvironmentEnum["regionalProd"] = "https://regional.kushkipagos.com/";
|
|
@@ -29,5 +29,6 @@ export declare enum PathEnum {
|
|
|
29
29
|
cybersource_jwt = "card/v1/authToken",
|
|
30
30
|
savedPaymentMethods = "/personal-wallet/v1/payment-data/",
|
|
31
31
|
kpay_delete_payment_method = "personal-wallet/v1/walletSubscription",
|
|
32
|
-
kpay_get_saved_payment_methods = "personal-wallet/v1/payment-data"
|
|
32
|
+
kpay_get_saved_payment_methods = "personal-wallet/v1/payment-data",
|
|
33
|
+
get_user_id = "v1/subscriptions/"
|
|
33
34
|
}
|
|
@@ -33,4 +33,5 @@ var PathEnum;
|
|
|
33
33
|
PathEnum["savedPaymentMethods"] = "/personal-wallet/v1/payment-data/";
|
|
34
34
|
PathEnum["kpay_delete_payment_method"] = "personal-wallet/v1/walletSubscription";
|
|
35
35
|
PathEnum["kpay_get_saved_payment_methods"] = "personal-wallet/v1/payment-data";
|
|
36
|
+
PathEnum["get_user_id"] = "v1/subscriptions/";
|
|
36
37
|
})(PathEnum = exports.PathEnum || (exports.PathEnum = {}));
|
|
@@ -9,5 +9,5 @@ export interface IAntiFraud {
|
|
|
9
9
|
/**
|
|
10
10
|
* create anti-fraud identification
|
|
11
11
|
*/
|
|
12
|
-
createSiftScienceSession(processor: string, clientIdentification: string, mid: string, isTest: boolean, merchantSettingsResponse: MerchantSettingsResponse): Observable<SiftScienceObject>;
|
|
12
|
+
createSiftScienceSession(processor: string, clientIdentification: string, mid: string, isTest: boolean, merchantSettingsResponse: MerchantSettingsResponse, userId?: string): Observable<SiftScienceObject>;
|
|
13
13
|
}
|
|
@@ -10,6 +10,7 @@ import { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_respo
|
|
|
10
10
|
import { CashTokenRequest } from "./../../lib/types/cash_token_request";
|
|
11
11
|
import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
|
|
12
12
|
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
13
|
+
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
13
14
|
import { KushkiSubscriptionTokensRequest } from "./../../lib/types/kushki_subscription_tokens_request";
|
|
14
15
|
import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
15
16
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
@@ -161,4 +162,12 @@ export interface IKushkiGateway {
|
|
|
161
162
|
* @param regional - Define if endpoint used regional URL
|
|
162
163
|
*/
|
|
163
164
|
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean): Observable<string>;
|
|
165
|
+
/**
|
|
166
|
+
* Get userId
|
|
167
|
+
* @param subscriptionId subscription id for the request
|
|
168
|
+
* @param mid public credential for request
|
|
169
|
+
* @param testEnv - is test environment
|
|
170
|
+
* @param regional - Define if endpoint used regional URL
|
|
171
|
+
*/
|
|
172
|
+
getUserId(subscriptionId: string, mid: string, testEnv: boolean, regional: boolean): Observable<GetUserId>;
|
|
164
173
|
}
|
|
@@ -46,6 +46,7 @@ export declare class CardService implements ICardService {
|
|
|
46
46
|
validate3DS(body: Validate3DSRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: Validate3DsResponse | ErrorResponse) => void): void;
|
|
47
47
|
private _validateParameters;
|
|
48
48
|
private _getDeviceTokenSiftScienceObject;
|
|
49
|
+
private _createSubscriptionSiftScienceSession;
|
|
49
50
|
private _checkCardLength;
|
|
50
51
|
private _getScienceSession;
|
|
51
52
|
private _checkCurrency;
|
|
@@ -61,4 +62,5 @@ export declare class CardService implements ICardService {
|
|
|
61
62
|
private _setSandboxEnable;
|
|
62
63
|
private _initCybersourceSandbox;
|
|
63
64
|
private _ccaSandbox;
|
|
65
|
+
private _getUserId;
|
|
64
66
|
}
|
|
@@ -136,10 +136,13 @@ var CardService = /** @class */ (function () {
|
|
|
136
136
|
};
|
|
137
137
|
CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional) {
|
|
138
138
|
var _this = this;
|
|
139
|
-
return
|
|
139
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
140
|
+
return rxjs_1.forkJoin([_this._gateway.requestMerchantSettings(mid, isTest, regional)]);
|
|
141
|
+
}), operators_1.switchMap(function (_a) {
|
|
142
|
+
var merchant = _a[0];
|
|
140
143
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
141
144
|
return rxjs_1.forkJoin([
|
|
142
|
-
_this._getDeviceTokenSiftScienceObject(request, mid, isTest, merchant),
|
|
145
|
+
_this._getDeviceTokenSiftScienceObject(request, mid, isTest, merchant, regional),
|
|
143
146
|
_this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "cardNumber")
|
|
144
147
|
? request.cardNumber
|
|
145
148
|
: undefined),
|
|
@@ -228,14 +231,22 @@ var CardService = /** @class */ (function () {
|
|
|
228
231
|
body.security.paReq === undefined ||
|
|
229
232
|
body.security.authenticationTransactionId === undefined);
|
|
230
233
|
};
|
|
231
|
-
CardService.prototype._getDeviceTokenSiftScienceObject = function (request, mid, isTest, merchant) {
|
|
234
|
+
CardService.prototype._getDeviceTokenSiftScienceObject = function (request, mid, isTest, merchant, regional) {
|
|
232
235
|
var _this = this;
|
|
233
236
|
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
234
237
|
return rxjs_1.iif(function () {
|
|
235
238
|
return request.sessionId !== undefined &&
|
|
236
239
|
request.sessionId !== null &&
|
|
237
240
|
(request.userId !== undefined && request.userId !== null);
|
|
238
|
-
}, _this._getRequestSiftObject(request.userId, request.sessionId), _this.
|
|
241
|
+
}, _this._getRequestSiftObject(request.userId, request.sessionId), _this._createSubscriptionSiftScienceSession(request.subscriptionId, mid, isTest, merchant, regional, request));
|
|
242
|
+
}));
|
|
243
|
+
};
|
|
244
|
+
CardService.prototype._createSubscriptionSiftScienceSession = function (subscriptionId, mid, isTest, merchantSettingsResponse, regional, request) {
|
|
245
|
+
var _this = this;
|
|
246
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
247
|
+
return _this._getUserId(subscriptionId, mid, isTest, regional, request.userId);
|
|
248
|
+
}), operators_1.switchMap(function (getUserIdResponse) {
|
|
249
|
+
return _this._antiFraud.createSiftScienceSession(subscriptionId, "", mid, isTest, merchantSettingsResponse, UtilsService_1.UtilsService.sGet(getUserIdResponse, "userId"));
|
|
239
250
|
}));
|
|
240
251
|
};
|
|
241
252
|
CardService.prototype._checkCardLength = function (request) {
|
|
@@ -394,6 +405,12 @@ var CardService = /** @class */ (function () {
|
|
|
394
405
|
});
|
|
395
406
|
}); });
|
|
396
407
|
};
|
|
408
|
+
CardService.prototype._getUserId = function (subscriptionId, mid, testEnv, regional, userId) {
|
|
409
|
+
var _this = this;
|
|
410
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
411
|
+
return rxjs_1.iif(function () { return UtilsService_1.UtilsService.sIsEmpty(userId); }, _this._gateway.getUserId(subscriptionId, mid, testEnv, regional), rxjs_1.of(undefined));
|
|
412
|
+
}), operators_1.catchError(function () { return rxjs_1.of(undefined); }));
|
|
413
|
+
};
|
|
397
414
|
var CardService_1;
|
|
398
415
|
CardService = CardService_1 = __decorate([
|
|
399
416
|
inversify_1.injectable(),
|