@kushki/js 1.31.1 → 1.31.2
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 -1
- package/lib/gateway/KushkiGateway.js +5 -3
- package/lib/repository/IKushkiGateway.d.ts +2 -1
- package/lib/service/CardService.d.ts +5 -0
- package/lib/service/CardService.js +43 -18
- package/lib/types/jwt_response.d.ts +1 -0
- package/lib/types/subscriptionId_request.d.ts +0 -1
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ 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
12
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
13
|
+
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
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";
|
|
@@ -73,7 +74,7 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
73
74
|
chargeMobileProcessor(body: MobileProcessorChargeRequest, publicCredential: string, testEnv: boolean, regional: boolean): Observable<MobileProcessorChargeResponse>;
|
|
74
75
|
deletePaymentMethod(body: DeletePaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string, authorization: string): Observable<boolean>;
|
|
75
76
|
requestSavedPaymentMethods(body: SavedPaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string): Observable<PaymentDataResponse[]>;
|
|
76
|
-
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean): Observable<
|
|
77
|
+
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<JwtResponse>;
|
|
77
78
|
getUserId(subscriptionId: string, mid: string, testEnv: boolean, regional: boolean): Observable<GetUserId>;
|
|
78
79
|
private _assignChannel;
|
|
79
80
|
private _buildHeader;
|
|
@@ -248,11 +248,13 @@ var KushkiGateway = /** @class */ (function () {
|
|
|
248
248
|
return _this.requestGet(path, testEnv, regional, mid);
|
|
249
249
|
}), operators_1.map(function (response) { return response; }));
|
|
250
250
|
};
|
|
251
|
-
KushkiGateway.prototype.cybersourceJwt = function (mid, testEnv, regional) {
|
|
251
|
+
KushkiGateway.prototype.cybersourceJwt = function (mid, testEnv, regional, subscriptionId) {
|
|
252
252
|
var _this = this;
|
|
253
253
|
return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
|
|
254
|
-
return _this.requestGet(
|
|
255
|
-
|
|
254
|
+
return _this.requestGet(subscriptionId
|
|
255
|
+
? PathEnum_1.PathEnum.cybersource_jwt + "?subscriptionId=" + subscriptionId
|
|
256
|
+
: PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid);
|
|
257
|
+
}), operators_1.map(function (response) { return response; }));
|
|
256
258
|
};
|
|
257
259
|
KushkiGateway.prototype.getUserId = function (subscriptionId, mid, testEnv, regional) {
|
|
258
260
|
var _this = this;
|
|
@@ -11,6 +11,7 @@ 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
13
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
14
|
+
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
14
15
|
import { KushkiSubscriptionTokensRequest } from "./../../lib/types/kushki_subscription_tokens_request";
|
|
15
16
|
import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
16
17
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
@@ -161,7 +162,7 @@ export interface IKushkiGateway {
|
|
|
161
162
|
* @param testEnv - is test environment
|
|
162
163
|
* @param regional - Define if endpoint used regional URL
|
|
163
164
|
*/
|
|
164
|
-
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean): Observable<
|
|
165
|
+
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<JwtResponse>;
|
|
165
166
|
/**
|
|
166
167
|
* Get userId
|
|
167
168
|
* @param subscriptionId subscription id for the request
|
|
@@ -61,7 +61,12 @@ export declare class CardService implements ICardService {
|
|
|
61
61
|
private _checkAmount;
|
|
62
62
|
private _checkRequestBody;
|
|
63
63
|
private _getCybersourceJwt;
|
|
64
|
+
private _isSandboxEnabled;
|
|
65
|
+
private _getCybersourceJwtSubscription;
|
|
66
|
+
private _is3DSSecureEnabled;
|
|
64
67
|
private _initCybersource;
|
|
68
|
+
private _initializeCardinal;
|
|
69
|
+
private _initCybersourceSubscription;
|
|
65
70
|
private _completeCardinal;
|
|
66
71
|
private static _initCardinal;
|
|
67
72
|
private static _ccaCardinal;
|
|
@@ -157,9 +157,7 @@ var CardService = /** @class */ (function () {
|
|
|
157
157
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
158
158
|
return rxjs_1.forkJoin([
|
|
159
159
|
_this._getDeviceTokenSiftScienceObject(request, mid, isTest, merchant, regional),
|
|
160
|
-
_this.
|
|
161
|
-
? request.cardNumber
|
|
162
|
-
: undefined),
|
|
160
|
+
_this._getCybersourceJwtSubscription(merchant, mid, isTest, regional, request.subscriptionId),
|
|
163
161
|
]);
|
|
164
162
|
}), operators_1.switchMap(function (_a) {
|
|
165
163
|
var sift_science_obj = _a[0], jwt = _a[1];
|
|
@@ -243,7 +241,7 @@ var CardService = /** @class */ (function () {
|
|
|
243
241
|
CardService.prototype.requestSecureInit = function (request, mid, isTest, regional) {
|
|
244
242
|
var _this = this;
|
|
245
243
|
return rxjs_1.of(1).pipe(operators_1.map(function () { return _this._checkCardLength(request, ErrorEnum_1.ErrorCode.E014); }), operators_1.switchMap(function () { return _this._getMerchantSettings(mid, isTest, regional); }), operators_1.switchMap(function (merchantSettings) {
|
|
246
|
-
return rxjs_1.iif(function () { return
|
|
244
|
+
return rxjs_1.iif(function () { return _this._is3DSSecureEnabled(merchantSettings); }, rxjs_1.of(merchantSettings), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E013)));
|
|
247
245
|
}), operators_1.switchMap(function (merchant) {
|
|
248
246
|
return _this._getCybersourceJwt(merchant, mid, isTest, regional, request.card.number);
|
|
249
247
|
}), operators_1.map(function (jwt) { return ({
|
|
@@ -352,24 +350,51 @@ var CardService = /** @class */ (function () {
|
|
|
352
350
|
CardService.prototype._getCybersourceJwt = function (merchantSettings, mid, isTest, regional, cardNumber) {
|
|
353
351
|
var _this = this;
|
|
354
352
|
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
355
|
-
if (
|
|
353
|
+
if (_this._is3DSSecureEnabled(merchantSettings) &&
|
|
356
354
|
cardNumber !== undefined)
|
|
357
|
-
return rxjs_1.iif(function () { return
|
|
355
|
+
return rxjs_1.iif(function () { return _this._isSandboxEnabled(merchantSettings); }, _this._initCybersourceSandbox(mid, isTest, regional), _this._initCybersource(cardNumber, mid, isTest, regional));
|
|
356
|
+
return rxjs_1.of(undefined);
|
|
357
|
+
}));
|
|
358
|
+
};
|
|
359
|
+
CardService.prototype._isSandboxEnabled = function (merchantSettings) {
|
|
360
|
+
return !!merchantSettings.sandboxEnable;
|
|
361
|
+
};
|
|
362
|
+
CardService.prototype._getCybersourceJwtSubscription = function (merchantSettings, mid, isTest, regional, subscriptionId) {
|
|
363
|
+
var _this = this;
|
|
364
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
365
|
+
if (_this._is3DSSecureEnabled(merchantSettings))
|
|
366
|
+
return rxjs_1.iif(function () { return _this._isSandboxEnabled(merchantSettings); }, _this._initCybersourceSandbox(mid, isTest, regional), _this._initCybersourceSubscription(subscriptionId, mid, isTest, regional));
|
|
358
367
|
return rxjs_1.of(undefined);
|
|
359
368
|
}));
|
|
360
369
|
};
|
|
370
|
+
CardService.prototype._is3DSSecureEnabled = function (merchantSettings) {
|
|
371
|
+
return merchantSettings[this._3Dsecure] === true;
|
|
372
|
+
};
|
|
361
373
|
CardService.prototype._initCybersource = function (cardNumber, mid, isTest, regional) {
|
|
362
374
|
var _this = this;
|
|
363
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
375
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwtResponse) {
|
|
376
|
+
_this._initializeCardinal(isTest, jwtResponse.jwt, cardNumber);
|
|
377
|
+
return jwtResponse.jwt;
|
|
378
|
+
}));
|
|
379
|
+
};
|
|
380
|
+
CardService.prototype._initializeCardinal = function (isTest, jwt, identifier) {
|
|
381
|
+
if (isTest)
|
|
382
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
|
|
383
|
+
CardService_1._initCardinal(jwt, identifier);
|
|
384
|
+
});
|
|
385
|
+
else
|
|
386
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
|
|
387
|
+
CardService_1._initCardinal(jwt, identifier);
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
CardService.prototype._initCybersourceSubscription = function (subscriptionId, mid, isTest, regional) {
|
|
391
|
+
var _this = this;
|
|
392
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
393
|
+
return _this._gateway.cybersourceJwt(mid, isTest, regional, subscriptionId);
|
|
394
|
+
}), operators_1.map(function (jwtResponse) {
|
|
395
|
+
var bin = Buffer.from(jwtResponse.identifier, "base64").toString("ascii");
|
|
396
|
+
_this._initializeCardinal(isTest, jwtResponse.jwt, bin);
|
|
397
|
+
return jwtResponse.jwt;
|
|
373
398
|
}));
|
|
374
399
|
};
|
|
375
400
|
// istanbul ignore next
|
|
@@ -431,9 +456,9 @@ var CardService = /** @class */ (function () {
|
|
|
431
456
|
};
|
|
432
457
|
CardService.prototype._initCybersourceSandbox = function (mid, isTest, regional) {
|
|
433
458
|
var _this = this;
|
|
434
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (
|
|
459
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwtResponse) {
|
|
435
460
|
cardinal_sandbox_js_1.KushkiCardinalSandbox.init();
|
|
436
|
-
return jwt;
|
|
461
|
+
return jwtResponse.jwt;
|
|
437
462
|
}));
|
|
438
463
|
};
|
|
439
464
|
CardService.prototype._ccaSandbox = function (body, mid, isTest, regional, callback) {
|