@kushki/js 1.31.0 → 1.32.0-alpha.13491.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.
@@ -73,7 +73,7 @@ export declare class KushkiGateway implements IKushkiGateway {
73
73
  chargeMobileProcessor(body: MobileProcessorChargeRequest, publicCredential: string, testEnv: boolean, regional: boolean): Observable<MobileProcessorChargeResponse>;
74
74
  deletePaymentMethod(body: DeletePaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string, authorization: string): Observable<boolean>;
75
75
  requestSavedPaymentMethods(body: SavedPaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string): Observable<PaymentDataResponse[]>;
76
- cybersourceJwt(mid: string, testEnv: boolean, regional: boolean): Observable<string>;
76
+ cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<string>;
77
77
  getUserId(subscriptionId: string, mid: string, testEnv: boolean, regional: boolean): Observable<GetUserId>;
78
78
  private _assignChannel;
79
79
  private _buildHeader;
@@ -248,10 +248,12 @@ 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(PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid);
254
+ return _this.requestGet(subscriptionId
255
+ ? PathEnum_1.PathEnum.cybersource_jwt + "?subscriptionId=" + subscriptionId
256
+ : PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid);
255
257
  }), operators_1.map(function (response) { return response.jwt; }));
256
258
  };
257
259
  KushkiGateway.prototype.getUserId = function (subscriptionId, mid, testEnv, regional) {
@@ -161,7 +161,7 @@ export interface IKushkiGateway {
161
161
  * @param testEnv - is test environment
162
162
  * @param regional - Define if endpoint used regional URL
163
163
  */
164
- cybersourceJwt(mid: string, testEnv: boolean, regional: boolean): Observable<string>;
164
+ cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<string>;
165
165
  /**
166
166
  * Get userId
167
167
  * @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._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "cardNumber")
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 merchantSettings[_this._3Dsecure] === true; }, rxjs_1.of(merchantSettings), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E013)));
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,26 +350,53 @@ 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 (merchantSettings[_this._3Dsecure] === true &&
353
+ if (_this._is3DSSecureEnabled(merchantSettings) &&
356
354
  cardNumber !== undefined)
357
- return rxjs_1.iif(function () { return !!merchantSettings.sandboxEnable; }, _this._initCybersourceSandbox(mid, isTest, regional), _this._initCybersource(cardNumber, mid, isTest, regional));
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
375
  return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwt) {
364
- if (isTest)
365
- Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
366
- CardService_1._initCardinal(jwt, cardNumber);
367
- });
368
- else
369
- Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
370
- CardService_1._initCardinal(jwt, cardNumber);
371
- });
376
+ _this._initializeCardinal(isTest, jwt, cardNumber);
372
377
  return jwt;
373
378
  }));
374
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;
398
+ }));
399
+ };
375
400
  // istanbul ignore next
376
401
  CardService.prototype._completeCardinal = function (secureServiceId, mid, isTest, regional, callback) {
377
402
  var _this = this;
@@ -3,4 +3,5 @@
3
3
 
4
4
  export interface JwtResponse {
5
5
  jwt: string;
6
+ identifier?: string;
6
7
  }
@@ -9,7 +9,6 @@ export interface SubscriptionIdRequest {
9
9
  sessionId?: string | null;
10
10
  amount?: Amount;
11
11
  currency?: Currency;
12
- cardNumber?: string;
13
12
  cardHolderName?: string;
14
13
  [k: string]: any;
15
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kushki/js",
3
- "version": "1.31.0",
3
+ "version": "1.32.0-alpha.13491.1",
4
4
  "description": "kushki-js",
5
5
  "main": "lib/lib.js",
6
6
  "types": "lib/lib.d.ts",