@kushki/js 1.30.1-alpha-3ds-setup-complete.2 → 1.30.1-alpha.13469.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.
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._cardService.requestToken(body, this._merchantId, this._inTestEnvironment, this._regional, callback);
40
+ this._resolve(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._cardDynamicService.requestCardDynamicToken(bin, body, this._merchantId, this._inTestEnvironment, this._regional, callback);
141
+ this._resolve(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);
@@ -3,8 +3,8 @@
3
3
  * Environment enum file
4
4
  */
5
5
  export declare enum EnvironmentEnum {
6
- uat = "https://api-uat.kushkipagos.com/",
6
+ uat = "https://api-qa.kushkipagos.com/",
7
7
  prod = "https://api.kushkipagos.com/",
8
- regionalUat = "https://regional-uat.kushkipagos.com/",
8
+ regionalUat = "https://regional-qa.kushkipagos.com/",
9
9
  regionalProd = "https://regional.kushkipagos.com/"
10
10
  }
@@ -6,8 +6,8 @@ exports.EnvironmentEnum = void 0;
6
6
  */
7
7
  var EnvironmentEnum;
8
8
  (function (EnvironmentEnum) {
9
- EnvironmentEnum["uat"] = "https://api-uat.kushkipagos.com/";
9
+ EnvironmentEnum["uat"] = "https://api-qa.kushkipagos.com/";
10
10
  EnvironmentEnum["prod"] = "https://api.kushkipagos.com/";
11
- EnvironmentEnum["regionalUat"] = "https://regional-uat.kushkipagos.com/";
11
+ EnvironmentEnum["regionalUat"] = "https://regional-qa.kushkipagos.com/";
12
12
  EnvironmentEnum["regionalProd"] = "https://regional.kushkipagos.com/";
13
13
  })(EnvironmentEnum = exports.EnvironmentEnum || (exports.EnvironmentEnum = {}));
@@ -2,11 +2,12 @@
2
2
  /**
3
3
  * ICardDynamicService
4
4
  */
5
+ import { Observable } from "rxjs";
5
6
  import { BinBody } from "./../../lib/types/bin_body";
6
7
  import { CardAsyncTokenRequest } from "./../../lib/types/card_async_token_request";
7
- import { ErrorResponse } from "./../../lib/types/error_response";
8
+ import { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_response";
8
9
  import { TokenResponse } from "./../../lib/types/remote/token_response";
9
10
  import { TokenRequest } from "./../../lib/types/token_request";
10
11
  export interface ICardDynamicService {
11
- requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
12
+ requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean): Observable<CardAsyncTokenResponse | TokenResponse>;
12
13
  }
@@ -25,9 +25,8 @@ 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
29
28
  */
30
- requestToken(tokenRequest: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
29
+ requestToken(tokenRequest: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
31
30
  /**
32
31
  * Subscription Token
33
32
  * @param subscriptionTokenRequest - subscription tokens request body
@@ -2,9 +2,10 @@
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";
5
6
  import { BinBody } from "./../../lib/types/bin_body";
6
7
  import { CardAsyncTokenRequest } from "./../../lib/types/card_async_token_request";
7
- import { ErrorResponse } from "./../../lib/types/error_response";
8
+ import { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_response";
8
9
  import { TokenResponse } from "./../../lib/types/remote/token_response";
9
10
  import { TokenRequest } from "./../../lib/types/token_request";
10
11
  /**
@@ -14,7 +15,7 @@ export declare class CardDynamicService implements ICardDynamicService {
14
15
  private readonly _cardService;
15
16
  private readonly _cardAsyncService;
16
17
  constructor(cardService: ICardService, cardAsyncService: ICardAsyncService);
17
- requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
18
+ requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean): Observable<CardAsyncTokenResponse | TokenResponse>;
18
19
  private _requestCardAsyncToken;
19
20
  private _requestToken;
20
21
  }
@@ -21,7 +21,6 @@ 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");
25
24
  /**
26
25
  * Implementation
27
26
  */
@@ -30,41 +29,25 @@ var CardDynamicService = /** @class */ (function () {
30
29
  this._cardService = cardService;
31
30
  this._cardAsyncService = cardAsyncService;
32
31
  }
33
- CardDynamicService.prototype.requestCardDynamicToken = function (bin, body, mid, testEnv, regional, callback) {
32
+ CardDynamicService.prototype.requestCardDynamicToken = function (bin, body, mid, testEnv, regional) {
34
33
  var _this = this;
35
- rxjs_1.of(1)
36
- .pipe(operators_1.concatMap(function () {
34
+ return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
37
35
  return _this._cardService.requestBinInfo(bin, mid, testEnv, regional);
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
- });
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
+ }));
50
39
  };
51
- CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional, callback) {
40
+ CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional) {
52
41
  var _this = this;
53
- rxjs_1.of(1)
54
- .pipe(operators_1.mergeMap(function () {
42
+ return rxjs_1.of(1).pipe(operators_1.mergeMap(function () {
55
43
  return _this._cardAsyncService.requestCardAsyncToken(body, mid, testEnv, regional);
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
- });
44
+ }));
65
45
  };
66
- CardDynamicService.prototype._requestToken = function (body, mid, testEnv, regional, callback) {
67
- this._cardService.requestToken(body, mid, testEnv, regional, callback);
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
51
  };
69
52
  CardDynamicService = __decorate([
70
53
  inversify_1.injectable(),
@@ -40,17 +40,13 @@ 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, callback: (value: TokenResponse | ErrorResponse) => void): void;
43
+ requestToken(request: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
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 _requestToken;
51
- private _request3DSToken;
52
- private _setupCompleteCardinal;
53
- private _requestTokenGateway;
54
50
  private _getMerchantSettings;
55
51
  private _validateParameters;
56
52
  private _getDeviceTokenSiftScienceObject;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // tslint:disable:no-identical-functions
3
2
  /**
4
3
  * Card Service file
5
4
  */
@@ -104,21 +103,36 @@ var CardService = /** @class */ (function () {
104
103
  _a);
105
104
  }
106
105
  CardService_1 = CardService;
107
- CardService.prototype.requestToken = function (request, mid, isTest, regional, callback) {
106
+ CardService.prototype.requestToken = function (request, mid, isTest, regional) {
108
107
  var _this = this;
109
- var request_token = this._requestToken(request, mid, isTest, regional);
110
- request_token.subscribe({
111
- error: function (err) {
112
- return Kushki_1.Kushki.callbackError(err, callback);
113
- },
114
- next: function (_a) {
115
- var final_request = _a[0], authorization = _a[1], merchant = _a[2];
116
- if (final_request.jwt && !merchant.sandboxEnable)
117
- _this._request3DSToken(final_request, mid, isTest, regional, callback, authorization);
118
- else
119
- _this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
120
- }
121
- });
108
+ return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.switchMap(function (merchant) {
109
+ _this._setSandboxEnable(!!merchant.sandboxEnable);
110
+ return rxjs_1.forkJoin([
111
+ _this._getScienceSession(request, mid, isTest, merchant),
112
+ _this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "card")
113
+ ? request.card.number
114
+ : undefined),
115
+ ]);
116
+ }), operators_1.mergeMap(function (_a) {
117
+ var sift_object = _a[0], jwt = _a[1];
118
+ request.isDeferred =
119
+ request.isDeferred === undefined ? false : request.isDeferred;
120
+ if (Boolean(request.cvv))
121
+ request.card = { cvc: request.cvv };
122
+ _this._checkRequestBody(request);
123
+ var data_to_transform = __assign(__assign({}, request), sift_object);
124
+ if (jwt !== undefined)
125
+ data_to_transform.jwt = jwt;
126
+ return rxjs_1.forkJoin([
127
+ rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
128
+ request.walletId
129
+ ? _this._authService.getAuthorizationToken()
130
+ : rxjs_1.of(undefined),
131
+ ]);
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
+ }));
122
136
  };
123
137
  CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional) {
124
138
  var _this = this;
@@ -222,67 +236,6 @@ var CardService = /** @class */ (function () {
222
236
  jwt: jwt
223
237
  }); }));
224
238
  };
225
- CardService.prototype._requestToken = function (request, mid, isTest, regional) {
226
- var _this = this;
227
- return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.switchMap(function (merchant) {
228
- _this._setSandboxEnable(!!merchant.sandboxEnable);
229
- return rxjs_1.forkJoin([
230
- _this._getScienceSession(request, mid, isTest, merchant),
231
- _this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "card")
232
- ? request.card.number
233
- : undefined),
234
- rxjs_1.of(merchant),
235
- ]);
236
- }), operators_1.mergeMap(function (_a) {
237
- var sift_object = _a[0], jwt = _a[1], merchant = _a[2];
238
- request.isDeferred =
239
- request.isDeferred === undefined ? false : request.isDeferred;
240
- if (Boolean(request.cvv))
241
- request.card = { cvc: request.cvv };
242
- _this._checkRequestBody(request);
243
- var data_to_transform = __assign(__assign({}, request), sift_object);
244
- if (jwt !== undefined)
245
- data_to_transform.jwt = jwt;
246
- return rxjs_1.forkJoin([
247
- rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
248
- request.walletId
249
- ? _this._authService.getAuthorizationToken()
250
- : rxjs_1.of(undefined),
251
- rxjs_1.of(merchant),
252
- ]);
253
- }));
254
- };
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) {
267
- var _this = this;
268
- window.Cardinal.on("payments.setupComplete", function () { return __awaiter(_this, void 0, void 0, function () {
269
- return __generator(this, function (_a) {
270
- this._requestTokenGateway(body, mid, isTest, regional, callback, authorization);
271
- return [2 /*return*/];
272
- });
273
- }); });
274
- };
275
- CardService.prototype._requestTokenGateway = function (body, mid, testEnv, regional, callback, authorization) {
276
- var request_token = this._gateway.requestToken(body, mid, testEnv, regional, authorization);
277
- return request_token.subscribe({
278
- error: function (err) {
279
- return Kushki_1.Kushki.callbackError(err, callback);
280
- },
281
- next: function (response) {
282
- callback(response);
283
- }
284
- });
285
- };
286
239
  CardService.prototype._getMerchantSettings = function (mid, isTest, regional) {
287
240
  var _this = this;
288
241
  return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.map(function (merchant) {
@@ -1,7 +1,11 @@
1
1
  /* tslint:disable:all */
2
2
  /* tslint:disable:all */
3
3
 
4
- export type PayoutsTransferTokenRequest = ColombianTokenRequest | ChileanTokenRequest | EcuadorianTokenRequest;
4
+ export type PayoutsTransferTokenRequest =
5
+ | ColombianTokenRequest
6
+ | ChileanTokenRequest
7
+ | EcuadorianTokenRequest
8
+ | MexicanTokenRequest;
5
9
 
6
10
  export interface ColombianTokenRequest {
7
11
  documentNumber: string;
@@ -35,3 +39,14 @@ export interface EcuadorianTokenRequest {
35
39
  paymentDescription?: string;
36
40
  name: string;
37
41
  }
42
+ export interface MexicanTokenRequest {
43
+ name: string;
44
+ documentNumber: string;
45
+ accountNumber: string;
46
+ accountType: "CB" | "TD" | "NC";
47
+ bankId: string;
48
+ totalAmount: number;
49
+ documentType: "CURP" | "RFC";
50
+ currency: "MXN";
51
+ paymentDescription?: string;
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kushki/js",
3
- "version": "1.30.1-alpha-3ds-setup-complete.2",
3
+ "version": "1.30.1-alpha.13469.1",
4
4
  "description": "kushki-js",
5
5
  "main": "lib/lib.js",
6
6
  "types": "lib/lib.d.ts",
@@ -18,7 +18,7 @@
18
18
  "scripts": {
19
19
  "publish:latest": "npm run build && npm publish",
20
20
  "publish:alpha": "npm run build && npm publish --tag alpha",
21
- "prepare": "npm run tsc:interface",
21
+ "prepare": "npm run tsc:interface && npm run test:unit && npm run test:coverage && npm run build:npm",
22
22
  "tsc:interface": "kushki json2ts",
23
23
  "tsc:check": "tsc --project tsconfig.check.json --noEmit",
24
24
  "lint": "npm run lint:format && npm run lint:duplicate && npm run lint:check",