@kushki/js 1.30.1 → 1.32.0-alpha.13491.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/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._resolve(this._cardService.requestToken(body, this._merchantId, this._inTestEnvironment, this._regional), callback);
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._resolve(this._cardDynamicService.requestCardDynamicToken(bin, body, this._merchantId, this._inTestEnvironment, this._regional), callback);
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);
@@ -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<string>;
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(PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid);
255
- }), operators_1.map(function (response) { return response.jwt; }));
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;
@@ -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 { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_response";
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): Observable<CardAsyncTokenResponse | TokenResponse>;
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): Observable<TokenResponse>;
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
@@ -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<string>;
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
@@ -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 { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_response";
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): Observable<CardAsyncTokenResponse | TokenResponse>;
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
- CardDynamicService.prototype.requestCardDynamicToken = function (bin, body, mid, testEnv, regional) {
33
+ // istanbul ignore next
34
+ CardDynamicService.prototype.requestCardDynamicToken = function (bin, body, mid, testEnv, regional, callback) {
33
35
  var _this = this;
34
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
36
+ rxjs_1.of(1)
37
+ .pipe(operators_1.concatMap(function () {
35
38
  return _this._cardService.requestBinInfo(bin, mid, testEnv, regional);
36
- }), operators_1.concatMap(function (binInfo) {
37
- return rxjs_1.iif(function () { return binInfo.cardType === BinCardTypeEnum_1.BinCardTypeEnum.debit; }, _this._requestCardAsyncToken(body, mid, testEnv, regional), _this._requestToken(body, mid, testEnv, regional));
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
- CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional) {
52
+ // istanbul ignore next
53
+ CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional, callback) {
41
54
  var _this = this;
42
- return rxjs_1.of(1).pipe(operators_1.mergeMap(function () {
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
- var _this = this;
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): Observable<TokenResponse>;
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;
@@ -58,7 +61,12 @@ export declare class CardService implements ICardService {
58
61
  private _checkAmount;
59
62
  private _checkRequestBody;
60
63
  private _getCybersourceJwt;
64
+ private _isSandboxEnabled;
65
+ private _getCybersourceJwtSubscription;
66
+ private _is3DSSecureEnabled;
61
67
  private _initCybersource;
68
+ private _initializeCardinal;
69
+ private _initCybersourceSubscription;
62
70
  private _completeCardinal;
63
71
  private static _initCardinal;
64
72
  private static _ccaCardinal;
@@ -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
- return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.switchMap(function (merchant) {
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
- }), operators_1.concatMap(function (_a) {
133
- var final_request = _a[0], jwt = _a[1];
134
- return _this._gateway.requestToken(final_request, mid, isTest, regional, jwt);
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;
@@ -143,9 +157,7 @@ var CardService = /** @class */ (function () {
143
157
  _this._setSandboxEnable(!!merchant.sandboxEnable);
144
158
  return rxjs_1.forkJoin([
145
159
  _this._getDeviceTokenSiftScienceObject(request, mid, isTest, merchant, regional),
146
- _this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "cardNumber")
147
- ? request.cardNumber
148
- : undefined),
160
+ _this._getCybersourceJwtSubscription(merchant, mid, isTest, regional, request.subscriptionId),
149
161
  ]);
150
162
  }), operators_1.switchMap(function (_a) {
151
163
  var sift_science_obj = _a[0], jwt = _a[1];
@@ -229,13 +241,46 @@ var CardService = /** @class */ (function () {
229
241
  CardService.prototype.requestSecureInit = function (request, mid, isTest, regional) {
230
242
  var _this = this;
231
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) {
232
- 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)));
233
245
  }), operators_1.switchMap(function (merchant) {
234
246
  return _this._getCybersourceJwt(merchant, mid, isTest, regional, request.card.number);
235
247
  }), operators_1.map(function (jwt) { return ({
236
248
  jwt: jwt
237
249
  }); }));
238
250
  };
251
+ CardService.prototype._request3DSToken = function (body, mid, isTest, regional, callback, authorization) {
252
+ var _this = this;
253
+ if (isTest)
254
+ Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
255
+ _this._setupCompleteCardinal(body, mid, isTest, regional, callback, authorization);
256
+ });
257
+ else
258
+ Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
259
+ _this._setupCompleteCardinal(body, mid, isTest, regional, callback, authorization);
260
+ });
261
+ };
262
+ // istanbul ignore next
263
+ CardService.prototype._setupCompleteCardinal = function (body, mid, isTest, regional, callback, authorization) {
264
+ var _this = this;
265
+ window.Cardinal.on("payments.setupComplete", function () { return __awaiter(_this, void 0, void 0, function () {
266
+ return __generator(this, function (_a) {
267
+ this._requestTokenGateway(body, mid, isTest, regional, callback, authorization);
268
+ return [2 /*return*/];
269
+ });
270
+ }); });
271
+ };
272
+ // istanbul ignore next
273
+ CardService.prototype._requestTokenGateway = function (body, mid, testEnv, regional, callback, authorization) {
274
+ var request_token = this._gateway.requestToken(body, mid, testEnv, regional, authorization);
275
+ return request_token.subscribe({
276
+ error: function (err) {
277
+ return Kushki_1.Kushki.callbackError(err, callback);
278
+ },
279
+ next: function (response) {
280
+ callback(response);
281
+ }
282
+ });
283
+ };
239
284
  CardService.prototype._getMerchantSettings = function (mid, isTest, regional) {
240
285
  var _this = this;
241
286
  return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.map(function (merchant) {
@@ -305,24 +350,51 @@ var CardService = /** @class */ (function () {
305
350
  CardService.prototype._getCybersourceJwt = function (merchantSettings, mid, isTest, regional, cardNumber) {
306
351
  var _this = this;
307
352
  return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
308
- if (merchantSettings[_this._3Dsecure] === true &&
353
+ if (_this._is3DSSecureEnabled(merchantSettings) &&
309
354
  cardNumber !== undefined)
310
- 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));
311
367
  return rxjs_1.of(undefined);
312
368
  }));
313
369
  };
370
+ CardService.prototype._is3DSSecureEnabled = function (merchantSettings) {
371
+ return merchantSettings[this._3Dsecure] === true;
372
+ };
314
373
  CardService.prototype._initCybersource = function (cardNumber, mid, isTest, regional) {
315
374
  var _this = this;
316
- return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwt) {
317
- if (isTest)
318
- Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
319
- CardService_1._initCardinal(jwt, cardNumber);
320
- });
321
- else
322
- Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
323
- CardService_1._initCardinal(jwt, cardNumber);
324
- });
325
- return jwt;
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;
326
398
  }));
327
399
  };
328
400
  // istanbul ignore next
@@ -384,9 +456,9 @@ var CardService = /** @class */ (function () {
384
456
  };
385
457
  CardService.prototype._initCybersourceSandbox = function (mid, isTest, regional) {
386
458
  var _this = this;
387
- return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwt) {
459
+ return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwtResponse) {
388
460
  cardinal_sandbox_js_1.KushkiCardinalSandbox.init();
389
- return jwt;
461
+ return jwtResponse.jwt;
390
462
  }));
391
463
  };
392
464
  CardService.prototype._ccaSandbox = function (body, mid, isTest, regional, callback) {
@@ -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.30.1",
3
+ "version": "1.32.0-alpha.13491.2",
4
4
  "description": "kushki-js",
5
5
  "main": "lib/lib.js",
6
6
  "types": "lib/lib.d.ts",