@kushki/js 1.27.0-dev.12985.1 → 1.27.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.
@@ -3,7 +3,7 @@
3
3
  * Environment enum file
4
4
  */
5
5
  export declare enum EnvironmentEnum {
6
- uat = "https://api-qa.kushkipagos.com/",
6
+ uat = "https://api-uat.kushkipagos.com/",
7
7
  prod = "https://api.kushkipagos.com/",
8
8
  regionalUat = "https://regional-uat.kushkipagos.com/",
9
9
  regionalProd = "https://regional.kushkipagos.com/"
@@ -6,7 +6,7 @@ exports.EnvironmentEnum = void 0;
6
6
  */
7
7
  var EnvironmentEnum;
8
8
  (function (EnvironmentEnum) {
9
- EnvironmentEnum["uat"] = "https://api-qa.kushkipagos.com/";
9
+ EnvironmentEnum["uat"] = "https://api-uat.kushkipagos.com/";
10
10
  EnvironmentEnum["prod"] = "https://api.kushkipagos.com/";
11
11
  EnvironmentEnum["regionalUat"] = "https://regional-uat.kushkipagos.com/";
12
12
  EnvironmentEnum["regionalProd"] = "https://regional.kushkipagos.com/";
@@ -35,6 +35,7 @@ export declare class CardService implements ICardService {
35
35
  private readonly _antiFraud;
36
36
  private readonly _authService;
37
37
  private readonly _3Dsecure;
38
+ private readonly _cardNumber;
38
39
  private _sandboxEnable;
39
40
  constructor(gateway: IKushkiGateway, authService: IAuthService, antiFraud: IAntiFraud);
40
41
  requestToken(request: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
@@ -59,5 +60,5 @@ export declare class CardService implements ICardService {
59
60
  private static _is3dsValid;
60
61
  private _setSandboxEnable;
61
62
  private _initCybersourceSandbox;
62
- private static _ccaSandbox;
63
+ private _ccaSandbox;
63
64
  }
@@ -77,27 +77,30 @@ var UtilsService_1 = require("./../../lib/service/UtilsService");
77
77
  var Kushki_1 = require("./../../lib/Kushki");
78
78
  var CardService = /** @class */ (function () {
79
79
  function CardService(gateway, authService, antiFraud) {
80
+ var _a;
80
81
  this._3Dsecure = "active_3dsecure";
82
+ this._cardNumber = "card.number";
81
83
  this._sandboxEnable = false;
82
84
  this._gateway = gateway;
83
85
  this._antiFraud = antiFraud;
84
86
  this._authService = authService;
85
- this._receipt = {
86
- amount: "totalAmount",
87
- "card.cvc": "card.cvv",
88
- "card.expiryMonth": "card.expiryMonth",
89
- "card.expiryYear": "card.expiryYear",
90
- "card.name": "card.name",
91
- "card.number": "card.number",
92
- currency: "currency",
93
- isDeferred: "isDeferred",
94
- jwt: "jwt",
95
- months: "months",
96
- savePaymentData: "savePaymentData",
97
- sessionId: "sessionId",
98
- userId: "userId",
99
- walletId: "walletId"
100
- };
87
+ this._receipt = (_a = {
88
+ amount: "totalAmount",
89
+ "card.cvc": "card.cvv",
90
+ "card.expiryMonth": "card.expiryMonth",
91
+ "card.expiryYear": "card.expiryYear",
92
+ "card.name": "card.name"
93
+ },
94
+ _a[this._cardNumber] = this._cardNumber,
95
+ _a.currency = "currency",
96
+ _a.isDeferred = "isDeferred",
97
+ _a.jwt = "jwt",
98
+ _a.months = "months",
99
+ _a.savePaymentData = "savePaymentData",
100
+ _a.sessionId = "sessionId",
101
+ _a.userId = "userId",
102
+ _a.walletId = "walletId",
103
+ _a);
101
104
  }
102
105
  CardService_1 = CardService;
103
106
  CardService.prototype.requestToken = function (request, mid, isTest, regional) {
@@ -155,12 +158,19 @@ var CardService = /** @class */ (function () {
155
158
  CardService.prototype.requestSubscriptionToken = function (subscriptionTokenRequest, mid, isTest, regional) {
156
159
  var _this = this;
157
160
  return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.switchMap(function (merchant) {
158
- return _this._getScienceSession(subscriptionTokenRequest, mid, isTest, merchant);
159
- }), operators_1.concatMap(function (siftObject) {
161
+ _this._setSandboxEnable(!!merchant.sandboxEnable);
162
+ return rxjs_1.forkJoin([
163
+ _this._getScienceSession(subscriptionTokenRequest, mid, isTest, merchant),
164
+ _this._getCybersourceJwt(merchant, mid, isTest, regional, UtilsService_1.UtilsService.sGet(subscriptionTokenRequest, _this._cardNumber)),
165
+ ]);
166
+ }), operators_1.concatMap(function (_a) {
167
+ var sift_object = _a[0], jwt = _a[1];
160
168
  _this._checkRequestBody(subscriptionTokenRequest);
161
169
  var data_to_transform = __assign({}, subscriptionTokenRequest);
162
- if (siftObject.userId === null || siftObject.sessionId === null)
163
- data_to_transform.siftObject = __assign({}, siftObject);
170
+ if (sift_object.userId === null || sift_object.sessionId === null)
171
+ data_to_transform.siftObject = __assign({}, sift_object);
172
+ if (jwt !== undefined)
173
+ data_to_transform.jwt = jwt;
164
174
  return rxjs_1.forkJoin([
165
175
  rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
166
176
  subscriptionTokenRequest.walletId
@@ -193,7 +203,7 @@ var CardService = /** @class */ (function () {
193
203
  if (this._sandboxEnable ||
194
204
  UtilsService_1.UtilsService.sGet(body, "security.paReq", ThreeDSEnum_1.ThreeDSEnum.SANDBOX) ===
195
205
  ThreeDSEnum_1.ThreeDSEnum.SANDBOX)
196
- return CardService_1._ccaSandbox(body, callback);
206
+ return this._ccaSandbox(body, mid, isTest, regional, callback);
197
207
  if (isTest) {
198
208
  // tslint:disable-next-line:no-duplicate-string
199
209
  Promise.resolve().then(function () { return require("cardinal-commerce-songbird-staging"); }).then(function () {
@@ -335,8 +345,10 @@ var CardService = /** @class */ (function () {
335
345
  // istanbul ignore next
336
346
  CardService._is3dsValid = function (secureOtpResponse) {
337
347
  return ("message" in secureOtpResponse &&
338
- secureOtpResponse.message === "3DS000" &&
339
- secureOtpResponse.code === "ok");
348
+ ((secureOtpResponse.message === "3DS000" &&
349
+ secureOtpResponse.code === "ok") ||
350
+ (secureOtpResponse.code === "3DS000" &&
351
+ secureOtpResponse.message === "ok")));
340
352
  };
341
353
  CardService.prototype._setSandboxEnable = function (payload) {
342
354
  this._sandboxEnable = payload;
@@ -348,7 +360,8 @@ var CardService = /** @class */ (function () {
348
360
  return jwt;
349
361
  }));
350
362
  };
351
- CardService._ccaSandbox = function (body, callback) {
363
+ CardService.prototype._ccaSandbox = function (body, mid, isTest, regional, callback) {
364
+ var _this = this;
352
365
  cardinal_sandbox_js_1.KushkiCardinalSandbox["continue"]("cca", {
353
366
  AcsUrl: body.security.acsURL,
354
367
  Payload: body.security.paReq
@@ -358,11 +371,28 @@ var CardService = /** @class */ (function () {
358
371
  }
359
372
  });
360
373
  // istanbul ignore next
361
- cardinal_sandbox_js_1.KushkiCardinalSandbox.on("payments.validated", function (isErrorFlow) {
362
- if (isErrorFlow === true)
363
- return Kushki_1.Kushki.callbackError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E008), callback);
364
- callback({ isValid: true });
365
- });
374
+ cardinal_sandbox_js_1.KushkiCardinalSandbox.on("payments.validated", function (isErrorFlow) { return __awaiter(_this, void 0, void 0, function () {
375
+ var otp_request, secure;
376
+ return __generator(this, function (_a) {
377
+ if (isErrorFlow === true)
378
+ return [2 /*return*/, Kushki_1.Kushki.callbackError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E008), callback)];
379
+ otp_request = {
380
+ otpValue: "",
381
+ secureServiceId: body.secureId
382
+ };
383
+ secure = this._gateway.requestSecureServiceValidation(mid, otp_request, isTest, regional);
384
+ return [2 /*return*/, secure.subscribe({
385
+ error: function (err) {
386
+ return Kushki_1.Kushki.callbackError(err, callback);
387
+ },
388
+ next: function (response) {
389
+ return callback({
390
+ isValid: CardService_1._is3dsValid(response)
391
+ });
392
+ }
393
+ })];
394
+ });
395
+ }); });
366
396
  };
367
397
  var CardService_1;
368
398
  CardService = CardService_1 = __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kushki/js",
3
- "version": "1.27.0-dev.12985.1",
3
+ "version": "1.27.1",
4
4
  "description": "kushki-js",
5
5
  "main": "lib/lib.js",
6
6
  "types": "lib/lib.d.ts",