@kushki/js 1.30.1-alpha-3ds-setup-complete.1 → 1.30.1-alpha-3ds-setup-complete.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
@@ -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);
@@ -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
  }
@@ -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,6 +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;
19
+ private _requestToken;
20
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,21 +30,41 @@ 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
+ CardDynamicService.prototype.requestCardDynamicToken = function (bin, body, mid, testEnv, regional, callback) {
33
34
  var _this = this;
34
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
35
+ rxjs_1.of(1)
36
+ .pipe(operators_1.concatMap(function () {
35
37
  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), rxjs_1.of({
38
- token: "12345"
39
- }));
40
- }));
38
+ }))
39
+ .subscribe({
40
+ error: function (err) {
41
+ return Kushki_1.Kushki.callbackError(err, callback);
42
+ },
43
+ next: function (binInfo) {
44
+ if (binInfo.cardType === BinCardTypeEnum_1.BinCardTypeEnum.debit)
45
+ _this._requestCardAsyncToken(body, mid, testEnv, regional, callback);
46
+ else
47
+ _this._requestToken(body, mid, testEnv, regional, callback);
48
+ }
49
+ });
41
50
  };
42
- CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional) {
51
+ CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional, callback) {
43
52
  var _this = this;
44
- return rxjs_1.of(1).pipe(operators_1.mergeMap(function () {
53
+ rxjs_1.of(1)
54
+ .pipe(operators_1.mergeMap(function () {
45
55
  return _this._cardAsyncService.requestCardAsyncToken(body, mid, testEnv, regional);
46
- }));
56
+ }))
57
+ .subscribe({
58
+ error: function (err) {
59
+ return Kushki_1.Kushki.callbackError(err, callback);
60
+ },
61
+ next: function (token) {
62
+ callback(token);
63
+ }
64
+ });
65
+ };
66
+ CardDynamicService.prototype._requestToken = function (body, mid, testEnv, regional, callback) {
67
+ this._cardService.requestToken(body, mid, testEnv, regional, callback);
47
68
  };
48
69
  CardDynamicService = __decorate([
49
70
  inversify_1.injectable(),
@@ -49,6 +49,7 @@ export declare class CardService implements ICardService {
49
49
  requestSecureInit(request: SecureInitRequest, mid: string, isTest: boolean, regional: boolean): Observable<SecureInitResponse>;
50
50
  private _requestToken;
51
51
  private _request3DSToken;
52
+ private _setupCompleteCardinal;
52
53
  private _requestTokenGateway;
53
54
  private _getMerchantSettings;
54
55
  private _validateParameters;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // tslint:disable:no-identical-functions
2
3
  /**
3
4
  * Card Service file
4
5
  */
@@ -111,8 +112,8 @@ var CardService = /** @class */ (function () {
111
112
  return Kushki_1.Kushki.callbackError(err, callback);
112
113
  },
113
114
  next: function (_a) {
114
- var final_request = _a[0], authorization = _a[1];
115
- if (final_request.jwt)
115
+ var final_request = _a[0], authorization = _a[1], merchant = _a[2];
116
+ if (final_request.jwt && !merchant.sandboxEnable)
116
117
  _this._request3DSToken(final_request, mid, isTest, regional, callback, authorization);
117
118
  else
118
119
  _this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
@@ -230,9 +231,10 @@ var CardService = /** @class */ (function () {
230
231
  _this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "card")
231
232
  ? request.card.number
232
233
  : undefined),
234
+ rxjs_1.of(merchant),
233
235
  ]);
234
236
  }), operators_1.mergeMap(function (_a) {
235
- var sift_object = _a[0], jwt = _a[1];
237
+ var sift_object = _a[0], jwt = _a[1], merchant = _a[2];
236
238
  request.isDeferred =
237
239
  request.isDeferred === undefined ? false : request.isDeferred;
238
240
  if (Boolean(request.cvv))
@@ -246,14 +248,27 @@ var CardService = /** @class */ (function () {
246
248
  request.walletId
247
249
  ? _this._authService.getAuthorizationToken()
248
250
  : rxjs_1.of(undefined),
251
+ rxjs_1.of(merchant),
249
252
  ]);
250
253
  }));
251
254
  };
252
- CardService.prototype._request3DSToken = function (body, mid, testEnv, regional, callback, authorization) {
255
+ CardService.prototype._request3DSToken = function (body, mid, isTest, regional, callback, authorization) {
256
+ var _this = this;
257
+ if (isTest)
258
+ Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
259
+ _this._setupCompleteCardinal(body, mid, isTest, regional, callback, authorization);
260
+ });
261
+ else
262
+ Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
263
+ _this._setupCompleteCardinal(body, mid, isTest, regional, callback, authorization);
264
+ });
265
+ };
266
+ CardService.prototype._setupCompleteCardinal = function (body, mid, isTest, regional, callback, authorization) {
253
267
  var _this = this;
254
- return window.Cardinal.on("payments.setupComplete", function () { return __awaiter(_this, void 0, void 0, function () {
268
+ window.Cardinal.on("payments.setupComplete", function () { return __awaiter(_this, void 0, void 0, function () {
255
269
  return __generator(this, function (_a) {
256
- return [2 /*return*/, this._requestTokenGateway(body, mid, testEnv, regional, callback, authorization)];
270
+ this._requestTokenGateway(body, mid, isTest, regional, callback, authorization);
271
+ return [2 /*return*/];
257
272
  });
258
273
  }); });
259
274
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kushki/js",
3
- "version": "1.30.1-alpha-3ds-setup-complete.1",
3
+ "version": "1.30.1-alpha-3ds-setup-complete.2",
4
4
  "description": "kushki-js",
5
5
  "main": "lib/lib.js",
6
6
  "types": "lib/lib.d.ts",