@kushki/js 1.36.0 → 1.37.0

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.
Files changed (76) hide show
  1. package/lib/Kushki.d.ts +17 -2
  2. package/lib/Kushki.js +132 -113
  3. package/lib/KushkiInfo.js +11 -14
  4. package/lib/constant/CreditCardEspecifications.js +2 -2
  5. package/lib/constant/Identifiers.js +21 -21
  6. package/lib/gateway/KushkiGateway.js +161 -276
  7. package/lib/gateway/SiftScience.js +42 -45
  8. package/lib/generic/AurusError.js +12 -28
  9. package/lib/generic/KushkiError.js +15 -33
  10. package/lib/infrastructure/BinCardTypeEnum.js +1 -1
  11. package/lib/infrastructure/CardBrandsEnum.d.ts +5 -0
  12. package/lib/infrastructure/CardBrandsEnum.js +8 -0
  13. package/lib/infrastructure/CognitoErrorEnum.js +1 -1
  14. package/lib/infrastructure/Container.js +41 -75
  15. package/lib/infrastructure/EnvironmentEnum.js +1 -1
  16. package/lib/infrastructure/ErrorEnum.d.ts +2 -1
  17. package/lib/infrastructure/ErrorEnum.js +42 -37
  18. package/lib/infrastructure/HeadersEnum.js +1 -1
  19. package/lib/infrastructure/KPayUserPoolEnum.js +1 -1
  20. package/lib/infrastructure/KpayPaymentKind.js +1 -1
  21. package/lib/infrastructure/PathEnum.js +1 -1
  22. package/lib/infrastructure/PlatformCodeEnum.js +15 -15
  23. package/lib/infrastructure/SiftScienceEnum.js +1 -1
  24. package/lib/infrastructure/StatusCodeEnum.js +1 -1
  25. package/lib/infrastructure/ThreeDSEnum.js +1 -1
  26. package/lib/infrastructure/VisaBrandingResourceUrlEnum.d.ts +2 -2
  27. package/lib/infrastructure/VisaBrandingResourceUrlEnum.js +3 -3
  28. package/lib/lib.js +1 -1
  29. package/lib/libs/MCSensoryBranding/mastercard-sensory-branding.d.ts +21 -0
  30. package/lib/libs/MCSensoryBranding/mastercard-sensory-branding.js +781 -0
  31. package/lib/libs/VisaSensoryBranding/visa-sensory-branding.d.ts +1 -1
  32. package/lib/libs/VisaSensoryBranding/visa-sensory-branding.js +630 -158
  33. package/lib/libs/cardinal/prod.js +10 -10
  34. package/lib/libs/cardinal/staging.js +9 -9
  35. package/lib/repository/IAntiFraud.js +1 -1
  36. package/lib/repository/IAuthService.js +1 -1
  37. package/lib/repository/ICardAsyncService.js +1 -1
  38. package/lib/repository/ICardDynamicService.js +1 -1
  39. package/lib/repository/ICardService.js +1 -1
  40. package/lib/repository/ICardSubscriptionDynamicService.js +1 -1
  41. package/lib/repository/ICashService.js +1 -1
  42. package/lib/repository/ICommissionService.js +1 -1
  43. package/lib/repository/IKPayService.js +1 -1
  44. package/lib/repository/IKushkiGateway.js +1 -1
  45. package/lib/repository/IKushkiService.d.ts +9 -2
  46. package/lib/repository/IKushkiService.js +1 -1
  47. package/lib/repository/IMobileProcessorService.js +1 -1
  48. package/lib/repository/IMultiMerchantService.js +1 -1
  49. package/lib/repository/IPayoutsCashService.js +1 -1
  50. package/lib/repository/IPayoutsTransferService.js +1 -1
  51. package/lib/repository/ISecureService.js +1 -1
  52. package/lib/repository/ISiftScienceService.js +1 -1
  53. package/lib/repository/ITransferService.js +1 -1
  54. package/lib/repository/ITransferSubscriptionService.js +1 -1
  55. package/lib/service/AuthService.js +99 -161
  56. package/lib/service/CardAsyncService.js +19 -26
  57. package/lib/service/CardDynamicService.js +32 -43
  58. package/lib/service/CardService.js +271 -382
  59. package/lib/service/CardSubscriptionDynamicService.js +31 -40
  60. package/lib/service/CashService.js +15 -16
  61. package/lib/service/CommissionService.js +13 -14
  62. package/lib/service/KPayService.js +19 -23
  63. package/lib/service/KushkiService.d.ts +2 -1
  64. package/lib/service/KushkiService.js +48 -33
  65. package/lib/service/MobileProcessorService.js +59 -70
  66. package/lib/service/MultiMerchantService.js +13 -14
  67. package/lib/service/PayoutsCashService.js +15 -16
  68. package/lib/service/PayoutsTransferService.js +17 -18
  69. package/lib/service/SecureService.js +13 -14
  70. package/lib/service/SiftScienceService.js +16 -20
  71. package/lib/service/TransferService.js +21 -36
  72. package/lib/service/TransferSubscriptionsService.js +16 -17
  73. package/lib/service/UtilsService.js +51 -57
  74. package/lib/types/card_branding_request.d.ts +40 -0
  75. package/lib/types/visa_branding_request.d.ts +25 -3
  76. package/package.json +2 -2
@@ -1,42 +1,32 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
14
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
16
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
17
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
18
7
  };
19
- exports.__esModule = true;
8
+ var KushkiGateway_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
20
10
  exports.KushkiGateway = void 0;
21
11
  /**
22
12
  * Kushki Gateway File
23
13
  */
24
14
  /* tslint:disable: no-unnecessary-callback-wrapper */
25
- var axios_1 = require("axios");
26
- var AurusError_1 = require("./../../lib/generic/AurusError");
27
- var EnvironmentEnum_1 = require("./../../lib/infrastructure/EnvironmentEnum");
28
- var PathEnum_1 = require("./../../lib/infrastructure/PathEnum");
29
- var inversify_1 = require("inversify");
15
+ const axios_1 = require("axios");
16
+ const AurusError_1 = require("./../../lib/generic/AurusError");
17
+ const EnvironmentEnum_1 = require("./../../lib/infrastructure/EnvironmentEnum");
18
+ const PathEnum_1 = require("./../../lib/infrastructure/PathEnum");
19
+ const inversify_1 = require("inversify");
30
20
  require("reflect-metadata");
31
- var rxjs_1 = require("rxjs");
32
- var operators_1 = require("rxjs/operators");
33
- var UtilsService_1 = require("./../../lib/service/UtilsService");
34
- var KushkiInfo_1 = require("./../../lib/KushkiInfo");
21
+ const rxjs_1 = require("rxjs");
22
+ const operators_1 = require("rxjs/operators");
23
+ const UtilsService_1 = require("./../../lib/service/UtilsService");
24
+ const KushkiInfo_1 = require("./../../lib/KushkiInfo");
35
25
  /**
36
26
  * Kushki Gateway Implementation
37
27
  */
38
- var KushkiGateway = /** @class */ (function () {
39
- function KushkiGateway() {
28
+ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
29
+ constructor() {
40
30
  this._publicHeader = "Public-Merchant-Id";
41
31
  this._contentHeader = "Content-Type";
42
32
  this._contentJSON = "application/json";
@@ -45,267 +35,162 @@ var KushkiGateway = /** @class */ (function () {
45
35
  this._prodUrl = "";
46
36
  this._kshAuthorization = "KSH-Authorization";
47
37
  }
48
- KushkiGateway_1 = KushkiGateway;
49
- KushkiGateway._aurusError = function (data) {
38
+ static _aurusError(data) {
50
39
  return data.hasOwnProperty("response_code");
51
- };
52
- KushkiGateway.prototype.request = function (body, headers, path, testEnv, regional) {
53
- var _this = this;
54
- return rxjs_1.of(this._assignChannel(regional, path)).pipe(operators_1.switchMap(function () {
55
- var _a;
56
- return axios_1["default"].post("" + (testEnv ? _this._uatUrl : _this._prodUrl), body, {
57
- headers: __assign(__assign({}, headers), (_a = {}, _a[_this._contentHeader] = _this._contentJSON, _a))
58
- });
59
- }), operators_1.map(function (response) { return response.data; }), operators_1.catchError(function (err) {
40
+ }
41
+ request(body, headers, path, testEnv, regional) {
42
+ return rxjs_1.of(this._assignChannel(regional, path)).pipe(operators_1.switchMap(() => axios_1.default.post(`${testEnv ? this._uatUrl : this._prodUrl}`, body, {
43
+ headers: Object.assign(Object.assign({}, headers), { [this._contentHeader]: this._contentJSON }),
44
+ })), operators_1.map((response) => response.data), operators_1.catchError((err) => {
60
45
  if (KushkiGateway_1._aurusError(UtilsService_1.UtilsService.sGet(err, "response.data", {})))
61
46
  throw new AurusError_1.AurusError(UtilsService_1.UtilsService.sGet(err, "response.data.response_code"), UtilsService_1.UtilsService.sGet(err, "response.data.response_text"));
62
47
  return rxjs_1.throwError(err);
63
48
  }));
64
- };
65
- KushkiGateway.prototype.requestGet = function (path, testEnv, regional, mid) {
66
- var _this = this;
67
- return rxjs_1.of(this._assignChannel(regional, path)).pipe(operators_1.switchMap(function () {
68
- var _a;
69
- return axios_1["default"].get("" + (testEnv ? _this._uatUrl : _this._prodUrl), {
70
- headers: (_a = {},
71
- _a[_this._publicHeader] = mid,
72
- _a[_this._contentHeader] = _this._contentJSON,
73
- _a)
74
- });
75
- }), operators_1.map(function (response) { return response.data; }), operators_1.catchError(function (err) { return rxjs_1.throwError(err); }));
76
- };
77
- KushkiGateway.prototype.requestDelete = function (path, testEnv, regional, mid, authorization) {
78
- var _this = this;
79
- return rxjs_1.of(this._assignChannel(regional, path)).pipe(operators_1.switchMap(function () {
80
- var _a;
81
- return axios_1["default"]["delete"]("" + (testEnv ? _this._uatUrl : _this._prodUrl), {
82
- headers: (_a = {},
83
- _a[_this._contentHeader] = _this._contentJSON,
84
- _a[_this._kshAuthorization] = authorization,
85
- _a[_this._publicHeader] = mid,
86
- _a)
87
- });
88
- }), operators_1.map(function (response) { return response.data; }), operators_1.catchError(function (err) { return rxjs_1.throwError(err); }));
89
- };
90
- KushkiGateway.prototype.requestBrandsByMerchant = function (mid, testEnv, regional) {
91
- return this.requestGet("" + PathEnum_1.PathEnum.brands_by_merchant, testEnv, regional, mid);
92
- };
93
- KushkiGateway.prototype.requestBrandsLogosByMerchant = function (mid, testEnv, regional) {
94
- return this.requestGet("" + PathEnum_1.PathEnum.brands_logos_by_merchant, testEnv, regional, mid);
95
- };
96
- KushkiGateway.prototype.requestToken = function (body, mid, testEnv, regional, authorization) {
97
- var _this = this;
98
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
99
- var _a, _b;
100
- return rxjs_1.iif(function () { return authorization === undefined; }, _this.request(body, (_a = {},
101
- _a[_this._publicHeader] = mid,
102
- _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo,
103
- _a), PathEnum_1.PathEnum.card_tokens, testEnv, regional), _this.request(body, (_b = {},
104
- _b[_this._kshAuthorization] = authorization,
105
- _b[_this._publicHeader] = mid,
106
- _b[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo,
107
- _b), PathEnum_1.PathEnum.card_tokens, testEnv, regional));
108
- }));
109
- };
110
- KushkiGateway.prototype.requestDeviceToken = function (body, mid, testEnv, regional) {
111
- var _this = this;
112
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
113
- var _a;
114
- return _this.request(body, __assign(__assign({}, _this._buildHeader(mid)), (_a = {}, _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo, _a)), "" + PathEnum_1.PathEnum.card_token_charge + body.subscriptionId + "/tokens", testEnv, regional);
115
- }));
116
- };
117
- KushkiGateway.prototype.requestSubscriptionToken = function (body, mid, testEnv, regional, authorization) {
118
- var _this = this;
119
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
120
- var _a, _b;
121
- return rxjs_1.iif(function () { return authorization === undefined; }, _this.request(body, (_a = {},
122
- _a[_this._publicHeader] = mid,
123
- _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo,
124
- _a), PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional), _this.request(body, (_b = {},
125
- _b[_this._kshAuthorization] = authorization,
126
- _b[_this._publicHeader] = mid,
127
- _b[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo,
128
- _b), PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional));
129
- }), operators_1.map(function (response) { return response; }));
130
- };
131
- KushkiGateway.prototype.requestTransferToken = function (body, mid, testEnv, regional) {
132
- var _this = this;
133
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
134
- var _a;
135
- return _this.request(body, __assign(__assign({}, _this._buildHeader(mid)), (_a = {}, _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo, _a)), PathEnum_1.PathEnum.transfer_tokens, testEnv, regional);
136
- }));
137
- };
138
- KushkiGateway.prototype.requestMerchantSettings = function (mid, testEnv, regional) {
139
- var _this = this;
140
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
141
- return _this.requestGet(PathEnum_1.PathEnum.merchant_settings + "settings", testEnv, regional, mid);
142
- }), operators_1.map(function (response) { return response; }));
143
- };
144
- KushkiGateway.prototype.requestPseBankList = function (mid, testEnv, regional) {
145
- var _this = this;
146
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
147
- return _this.requestGet(PathEnum_1.PathEnum.bank_list, testEnv, regional, mid);
148
- }), operators_1.map(function (response) { return response; }));
149
- };
150
- KushkiGateway.prototype.requestDeferredConditions = function (mid, bin, testEnv, regional) {
151
- var _this = this;
152
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
153
- return _this.requestGet("" + PathEnum_1.PathEnum.deferred_options + bin, testEnv, regional, mid);
154
- }), operators_1.map(function (response) { return response; }));
155
- };
156
- KushkiGateway.prototype.requestBinInfo = function (mid, bin, testEnv, regional) {
157
- var _this = this;
158
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
159
- return _this.requestGet("" + PathEnum_1.PathEnum.bin_info + bin, testEnv, regional, mid);
160
- }), operators_1.map(function (response) { return response; }));
161
- };
162
- KushkiGateway.prototype.requestCashToken = function (body, mid, testEnv, regional) {
163
- var _this = this;
164
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
165
- var _a;
166
- return _this.request(body, __assign(__assign({}, _this._buildHeader(mid)), (_a = {}, _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo, _a)), PathEnum_1.PathEnum.cash_tokens, testEnv, regional);
167
- }), operators_1.map(function (response) { return response; }));
168
- };
169
- KushkiGateway.prototype.checkStatus = function (mid, testEnv, regional) {
170
- var _this = this;
171
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
172
- return _this.requestGet("" + PathEnum_1.PathEnum.gateway_status, testEnv, regional, mid);
173
- }), operators_1.map(function (response) { return response; }));
174
- };
175
- KushkiGateway.prototype.requestSecureServiceValidation = function (mid, request, isTest, regional) {
176
- var _this = this;
177
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
178
- return _this.request(request, _this._buildHeader(mid), "" + PathEnum_1.PathEnum.secure_validation, isTest, regional);
179
- }));
180
- };
181
- KushkiGateway.prototype.requestCardAsyncToken = function (body, mid, testEnv, regional) {
182
- var _this = this;
183
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
184
- var _a;
185
- return _this.request(body, __assign(__assign({}, _this._buildHeader(mid)), (_a = {}, _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo, _a)), PathEnum_1.PathEnum.card_async_tokens, testEnv, regional);
186
- }));
187
- };
188
- KushkiGateway.prototype.requestSubscriptionCardAsyncToken = function (body, mid, testEnv, regional) {
189
- var _this = this;
190
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
191
- var _a;
192
- return _this.request(body, __assign(__assign({}, _this._buildHeader(mid)), (_a = {}, _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo, _a)), PathEnum_1.PathEnum.subscription_card_async_tokens, testEnv, regional);
193
- }));
194
- };
195
- KushkiGateway.prototype.multiMerchantInfo = function (request, mid, isTest, regional) {
196
- var _this = this;
197
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
198
- return _this.request(request, _this._buildHeader(mid), "" + PathEnum_1.PathEnum.multi_merchant_commission, isTest, regional);
199
- }));
200
- };
201
- KushkiGateway.prototype.requestPayoutsCashToken = function (body, mid, testEnv, regional) {
202
- var _this = this;
203
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
204
- var _a;
205
- return _this.request(body, __assign(__assign({}, _this._buildHeader(mid)), (_a = {}, _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo, _a)), PathEnum_1.PathEnum.payouts_cash_tokens, testEnv, regional);
206
- }), operators_1.map(function (response) { return response; }));
207
- };
208
- KushkiGateway.prototype.requestPayoutsTransferToken = function (body, mid, testEnv, regional) {
209
- var _this = this;
210
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
211
- var _a;
212
- return _this.request(body, __assign(__assign({}, _this._buildHeader(mid)), (_a = {}, _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo, _a)), PathEnum_1.PathEnum.payouts_transfer_tokens, testEnv, regional);
213
- }), operators_1.map(function (response) { return response; }));
214
- };
215
- KushkiGateway.prototype.getCommissionConfiguration = function (request, mid, isTest, regional) {
216
- var _this = this;
217
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
218
- return _this.request(request, _this._buildHeader(mid), "" + PathEnum_1.PathEnum.commission_configuration, isTest, regional);
219
- }));
220
- };
221
- KushkiGateway.prototype.requestTokenTransferSubscription = function (body, mid, testEnv, regional) {
222
- var _this = this;
223
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
224
- var _a;
225
- return _this.request(body, __assign(__assign({}, _this._buildHeader(mid)), (_a = {}, _a[_this._kushkiInfoHeader] = KushkiInfo_1.KInfo.sKushkiInfo, _a)), PathEnum_1.PathEnum.transfer_subscription_tokens, testEnv, regional);
226
- }));
227
- };
228
- KushkiGateway.prototype.requestBankList = function (mid, testEnv, regional) {
229
- var _this = this;
230
- return rxjs_1.of(1).pipe(operators_1.mergeMap(function () {
231
- return _this.requestGet(PathEnum_1.PathEnum.bank_list_transfer_subscription, testEnv, regional, mid);
232
- }), operators_1.map(function (response) { return response; }));
233
- };
234
- KushkiGateway.prototype.requestPayoutsTransferBankList = function (mid, testEnv, regional) {
235
- var _this = this;
236
- return rxjs_1.of(1).pipe(operators_1.mergeMap(function () {
237
- return _this.requestGet(PathEnum_1.PathEnum.bank_list_payouts_transfer, testEnv, regional, mid);
238
- }), operators_1.map(function (response) { return response; }));
239
- };
240
- KushkiGateway.prototype.requestMobileProcessorToken = function (body, publicCredential, testEnv, regional) {
241
- var _this = this;
242
- return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
243
- return _this.request(body, _this._buildHeader(publicCredential), PathEnum_1.PathEnum.mobile_processor_token, testEnv, regional);
244
- }), operators_1.map(function (response) { return response; }));
245
- };
246
- KushkiGateway.prototype.chargeMobileProcessor = function (body, publicCredential, testEnv, regional) {
247
- var _this = this;
248
- return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
249
- return _this.request(body, _this._buildHeader(publicCredential), PathEnum_1.PathEnum.mobile_processor_charge, testEnv, regional);
250
- }), operators_1.map(function (response) { return response; }));
251
- };
252
- KushkiGateway.prototype.deletePaymentMethod = function (body, testEnv, regional, mid, authorization) {
253
- var _this = this;
254
- return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
255
- return _this.requestDelete(PathEnum_1.PathEnum.kpay_delete_payment_method + "/" + body.walletId, testEnv, regional, mid, authorization);
256
- }), operators_1.map(function (response) { return !!response; }));
257
- };
258
- KushkiGateway.prototype.requestSavedPaymentMethods = function (body, testEnv, regional, mid) {
259
- var _this = this;
260
- return rxjs_1.of(1).pipe(operators_1.map(function () {
261
- var email = body.email, kind = body.kind;
262
- var kind_path = kind !== undefined ? "?kind=" + kind : "";
263
- return PathEnum_1.PathEnum.kpay_get_saved_payment_methods + "/" + email + kind_path;
264
- }), operators_1.concatMap(function (path) {
265
- return _this.requestGet(path, testEnv, regional, mid);
266
- }), operators_1.map(function (response) { return response; }));
267
- };
268
- KushkiGateway.prototype.cybersourceJwt = function (mid, testEnv, regional, subscriptionId) {
269
- var _this = this;
270
- return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
271
- return _this.requestGet(subscriptionId
272
- ? PathEnum_1.PathEnum.cybersource_jwt + "?subscriptionId=" + subscriptionId
273
- : PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid);
274
- }), operators_1.map(function (response) { return response; }));
275
- };
276
- KushkiGateway.prototype.getUserId = function (subscriptionId, mid, testEnv, regional) {
277
- var _this = this;
278
- return rxjs_1.of(1).pipe(operators_1.map(function () { return "" + PathEnum_1.PathEnum.get_user_id + subscriptionId + "/user"; }), operators_1.concatMap(function (path) {
279
- var _a;
280
- return _this.request({}, (_a = {},
281
- _a[_this._publicHeader] = mid,
282
- _a[_this._contentHeader] = _this._contentJSON,
283
- _a), path, testEnv, regional);
284
- }), operators_1.map(function (response) { return ({
285
- userId: response.userId
286
- }); }));
287
- };
288
- KushkiGateway.prototype._assignChannel = function (regional, path) {
49
+ }
50
+ requestGet(path, testEnv, regional, mid) {
51
+ return rxjs_1.of(this._assignChannel(regional, path)).pipe(operators_1.switchMap(() => axios_1.default.get(`${testEnv ? this._uatUrl : this._prodUrl}`, {
52
+ headers: {
53
+ [this._publicHeader]: mid,
54
+ [this._contentHeader]: this._contentJSON,
55
+ },
56
+ })), operators_1.map((response) => response.data), operators_1.catchError((err) => rxjs_1.throwError(err)));
57
+ }
58
+ requestDelete(path, testEnv, regional, mid, authorization) {
59
+ return rxjs_1.of(this._assignChannel(regional, path)).pipe(operators_1.switchMap(() => axios_1.default.delete(`${testEnv ? this._uatUrl : this._prodUrl}`, {
60
+ headers: {
61
+ [this._contentHeader]: this._contentJSON,
62
+ [this._kshAuthorization]: authorization,
63
+ [this._publicHeader]: mid,
64
+ },
65
+ })), operators_1.map((response) => response.data), operators_1.catchError((err) => rxjs_1.throwError(err)));
66
+ }
67
+ requestBrandsByMerchant(mid, testEnv, regional) {
68
+ return this.requestGet(`${PathEnum_1.PathEnum.brands_by_merchant}`, testEnv, regional, mid);
69
+ }
70
+ requestBrandsLogosByMerchant(mid, testEnv, regional) {
71
+ return this.requestGet(`${PathEnum_1.PathEnum.brands_logos_by_merchant}`, testEnv, regional, mid);
72
+ }
73
+ requestToken(body, mid, testEnv, regional, authorization) {
74
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => rxjs_1.iif(() => authorization === undefined, this.request(body, {
75
+ [this._publicHeader]: mid,
76
+ [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
77
+ }, PathEnum_1.PathEnum.card_tokens, testEnv, regional), this.request(body, {
78
+ [this._kshAuthorization]: authorization,
79
+ [this._publicHeader]: mid,
80
+ [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
81
+ }, PathEnum_1.PathEnum.card_tokens, testEnv, regional))));
82
+ }
83
+ requestDeviceToken(body, mid, testEnv, regional) {
84
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), `${PathEnum_1.PathEnum.card_token_charge}${body.subscriptionId}/tokens`, testEnv, regional)));
85
+ }
86
+ requestSubscriptionToken(body, mid, testEnv, regional, authorization) {
87
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => rxjs_1.iif(() => authorization === undefined, this.request(body, {
88
+ [this._publicHeader]: mid,
89
+ [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
90
+ }, PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional), this.request(body, {
91
+ [this._kshAuthorization]: authorization,
92
+ [this._publicHeader]: mid,
93
+ [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
94
+ }, PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional))), operators_1.map((response) => response));
95
+ }
96
+ requestTransferToken(body, mid, testEnv, regional) {
97
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), PathEnum_1.PathEnum.transfer_tokens, testEnv, regional)));
98
+ }
99
+ requestMerchantSettings(mid, testEnv, regional) {
100
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.requestGet(`${PathEnum_1.PathEnum.merchant_settings}settings`, testEnv, regional, mid)), operators_1.map((response) => response));
101
+ }
102
+ requestPseBankList(mid, testEnv, regional) {
103
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.requestGet(PathEnum_1.PathEnum.bank_list, testEnv, regional, mid)), operators_1.map((response) => response));
104
+ }
105
+ requestDeferredConditions(mid, bin, testEnv, regional) {
106
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.requestGet(`${PathEnum_1.PathEnum.deferred_options}${bin}`, testEnv, regional, mid)), operators_1.map((response) => response));
107
+ }
108
+ requestBinInfo(mid, bin, testEnv, regional) {
109
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.requestGet(`${PathEnum_1.PathEnum.bin_info}${bin}`, testEnv, regional, mid)), operators_1.map((response) => response));
110
+ }
111
+ requestCashToken(body, mid, testEnv, regional) {
112
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), PathEnum_1.PathEnum.cash_tokens, testEnv, regional)), operators_1.map((response) => response));
113
+ }
114
+ checkStatus(mid, testEnv, regional) {
115
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.requestGet(`${PathEnum_1.PathEnum.gateway_status}`, testEnv, regional, mid)), operators_1.map((response) => response));
116
+ }
117
+ requestSecureServiceValidation(mid, request, isTest, regional) {
118
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(request, this._buildHeader(mid), `${PathEnum_1.PathEnum.secure_validation}`, isTest, regional)));
119
+ }
120
+ requestCardAsyncToken(body, mid, testEnv, regional) {
121
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), PathEnum_1.PathEnum.card_async_tokens, testEnv, regional)));
122
+ }
123
+ requestSubscriptionCardAsyncToken(body, mid, testEnv, regional) {
124
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), PathEnum_1.PathEnum.subscription_card_async_tokens, testEnv, regional)));
125
+ }
126
+ multiMerchantInfo(request, mid, isTest, regional) {
127
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(request, this._buildHeader(mid), `${PathEnum_1.PathEnum.multi_merchant_commission}`, isTest, regional)));
128
+ }
129
+ requestPayoutsCashToken(body, mid, testEnv, regional) {
130
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), PathEnum_1.PathEnum.payouts_cash_tokens, testEnv, regional)), operators_1.map((response) => response));
131
+ }
132
+ requestPayoutsTransferToken(body, mid, testEnv, regional) {
133
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), PathEnum_1.PathEnum.payouts_transfer_tokens, testEnv, regional)), operators_1.map((response) => response));
134
+ }
135
+ getCommissionConfiguration(request, mid, isTest, regional) {
136
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(request, this._buildHeader(mid), `${PathEnum_1.PathEnum.commission_configuration}`, isTest, regional)));
137
+ }
138
+ requestTokenTransferSubscription(body, mid, testEnv, regional) {
139
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), PathEnum_1.PathEnum.transfer_subscription_tokens, testEnv, regional)));
140
+ }
141
+ requestBankList(mid, testEnv, regional) {
142
+ return rxjs_1.of(1).pipe(operators_1.mergeMap(() => this.requestGet(PathEnum_1.PathEnum.bank_list_transfer_subscription, testEnv, regional, mid)), operators_1.map((response) => response));
143
+ }
144
+ requestPayoutsTransferBankList(mid, testEnv, regional) {
145
+ return rxjs_1.of(1).pipe(operators_1.mergeMap(() => this.requestGet(PathEnum_1.PathEnum.bank_list_payouts_transfer, testEnv, regional, mid)), operators_1.map((response) => response));
146
+ }
147
+ requestMobileProcessorToken(body, publicCredential, testEnv, regional) {
148
+ return rxjs_1.of(1).pipe(operators_1.switchMap(() => this.request(body, this._buildHeader(publicCredential), PathEnum_1.PathEnum.mobile_processor_token, testEnv, regional)), operators_1.map((response) => response));
149
+ }
150
+ chargeMobileProcessor(body, publicCredential, testEnv, regional) {
151
+ return rxjs_1.of(1).pipe(operators_1.switchMap(() => this.request(body, this._buildHeader(publicCredential), PathEnum_1.PathEnum.mobile_processor_charge, testEnv, regional)), operators_1.map((response) => response));
152
+ }
153
+ deletePaymentMethod(body, testEnv, regional, mid, authorization) {
154
+ return rxjs_1.of(1).pipe(operators_1.switchMap(() => this.requestDelete(`${PathEnum_1.PathEnum.kpay_delete_payment_method}/${body.walletId}`, testEnv, regional, mid, authorization)), operators_1.map((response) => !!response));
155
+ }
156
+ requestSavedPaymentMethods(body, testEnv, regional, mid) {
157
+ return rxjs_1.of(1).pipe(operators_1.map(() => {
158
+ const { email, kind } = body;
159
+ const kind_path = kind !== undefined ? `?kind=${kind}` : "";
160
+ return `${PathEnum_1.PathEnum.kpay_get_saved_payment_methods}/${email}${kind_path}`;
161
+ }), operators_1.concatMap((path) => this.requestGet(path, testEnv, regional, mid)), operators_1.map((response) => response));
162
+ }
163
+ cybersourceJwt(mid, testEnv, regional, subscriptionId) {
164
+ return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.requestGet(subscriptionId
165
+ ? `${PathEnum_1.PathEnum.cybersource_jwt}?subscriptionId=${subscriptionId}`
166
+ : PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid)), operators_1.map((response) => response));
167
+ }
168
+ getUserId(subscriptionId, mid, testEnv, regional) {
169
+ return rxjs_1.of(1).pipe(operators_1.map(() => `${PathEnum_1.PathEnum.get_user_id}${subscriptionId}/user`), operators_1.concatMap((path) => this.request({}, {
170
+ [this._publicHeader]: mid,
171
+ [this._contentHeader]: this._contentJSON,
172
+ }, path, testEnv, regional)), operators_1.map((response) => ({
173
+ userId: response.userId,
174
+ })));
175
+ }
176
+ _assignChannel(regional, path) {
289
177
  if (!regional) {
290
- this._uatUrl = "" + EnvironmentEnum_1.EnvironmentEnum.uat + path;
291
- this._prodUrl = "" + EnvironmentEnum_1.EnvironmentEnum.prod + path;
178
+ this._uatUrl = `${EnvironmentEnum_1.EnvironmentEnum.uat}${path}`;
179
+ this._prodUrl = `${EnvironmentEnum_1.EnvironmentEnum.prod}${path}`;
292
180
  }
293
181
  else {
294
- this._uatUrl = "" + EnvironmentEnum_1.EnvironmentEnum.regionalUat + path;
295
- this._prodUrl = "" + EnvironmentEnum_1.EnvironmentEnum.regionalProd + path;
182
+ this._uatUrl = `${EnvironmentEnum_1.EnvironmentEnum.regionalUat}${path}`;
183
+ this._prodUrl = `${EnvironmentEnum_1.EnvironmentEnum.regionalProd}${path}`;
296
184
  }
297
185
  return true;
298
- };
299
- KushkiGateway.prototype._buildHeader = function (mid) {
300
- var _a;
301
- return _a = {},
302
- _a[this._publicHeader] = mid,
303
- _a;
304
- };
305
- var KushkiGateway_1;
306
- KushkiGateway = KushkiGateway_1 = __decorate([
307
- inversify_1.injectable()
308
- ], KushkiGateway);
309
- return KushkiGateway;
310
- }());
186
+ }
187
+ _buildHeader(mid) {
188
+ return {
189
+ [this._publicHeader]: mid,
190
+ };
191
+ }
192
+ };
193
+ KushkiGateway = KushkiGateway_1 = __decorate([
194
+ inversify_1.injectable()
195
+ ], KushkiGateway);
311
196
  exports.KushkiGateway = KushkiGateway;
@@ -11,67 +11,65 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
11
11
  var __metadata = (this && this.__metadata) || function (k, v) {
12
12
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
13
13
  };
14
- exports.__esModule = true;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.SiftScience = void 0;
16
- var KushkiError_1 = require("./../../lib/generic/KushkiError");
17
- var ErrorEnum_1 = require("./../../lib/infrastructure/ErrorEnum");
18
- var SiftScienceEnum_1 = require("./../../lib/infrastructure/SiftScienceEnum");
19
- var inversify_1 = require("inversify");
16
+ const KushkiError_1 = require("./../../lib/generic/KushkiError");
17
+ const ErrorEnum_1 = require("./../../lib/infrastructure/ErrorEnum");
18
+ const SiftScienceEnum_1 = require("./../../lib/infrastructure/SiftScienceEnum");
19
+ const inversify_1 = require("inversify");
20
20
  require("reflect-metadata");
21
- var rxjs_1 = require("rxjs");
22
- var operators_1 = require("rxjs/operators");
23
- var UtilsService_1 = require("./../../lib/service/UtilsService");
24
- var uuid_1 = require("uuid");
21
+ const rxjs_1 = require("rxjs");
22
+ const operators_1 = require("rxjs/operators");
23
+ const UtilsService_1 = require("./../../lib/service/UtilsService");
24
+ const uuid_1 = require("uuid");
25
25
  /**
26
26
  * Kushki SiftScience Implementation
27
27
  */
28
- var SiftScience = /** @class */ (function () {
29
- function SiftScience(regional) {
28
+ let SiftScience = class SiftScience {
29
+ constructor(regional) {
30
30
  this._siftProperty = "_sift";
31
31
  this._sift = [];
32
32
  this._initSiftScience(regional);
33
33
  }
34
- SiftScience.prototype.createSiftScienceSession = function (processor, clientIdentification, mid, isTest, merchantSettingsResponse, userId) {
35
- var _this = this;
36
- return rxjs_1.of(merchantSettingsResponse).pipe(operators_1.map(function (merchantSettings) {
37
- var sift_environment = isTest
34
+ createSiftScienceSession(processor, clientIdentification, mid, isTest, merchantSettingsResponse, userId) {
35
+ return rxjs_1.of(merchantSettingsResponse).pipe(operators_1.map((merchantSettings) => {
36
+ const sift_environment = isTest
38
37
  ? SiftScienceEnum_1.SiftScienceEnum.siftScienceTest
39
38
  : SiftScienceEnum_1.SiftScienceEnum.siftScienceProd;
40
- if (_this._validateMerchantSettings(sift_environment, merchantSettings))
39
+ if (this._validateMerchantSettings(sift_environment, merchantSettings))
41
40
  return {
42
41
  sessionId: null,
43
- userId: null
42
+ userId: null,
44
43
  };
45
- var user_id = userId || "" + mid + processor + clientIdentification;
46
- var session_id = uuid_1.v4();
47
- _this._setSiftProperties(merchantSettings, sift_environment, user_id, session_id);
44
+ const user_id = userId || `${mid}${processor}${clientIdentification}`;
45
+ const session_id = uuid_1.v4();
46
+ this._setSiftProperties(merchantSettings, sift_environment, user_id, session_id);
48
47
  return {
49
48
  sessionId: session_id,
50
- userId: user_id
49
+ userId: user_id,
51
50
  };
52
51
  }));
53
- };
54
- SiftScience.prototype.createSiftScienceAntiFraudSession = function (userId, mid, isTest, merchantSettingsResponse) {
55
- var _this = this;
56
- return rxjs_1.of(merchantSettingsResponse).pipe(operators_1.map(function (merchantSettings) {
57
- var sift_environment = isTest
52
+ }
53
+ createSiftScienceAntiFraudSession(userId, mid, isTest, merchantSettingsResponse) {
54
+ return rxjs_1.of(merchantSettingsResponse).pipe(operators_1.map((merchantSettings) => {
55
+ const sift_environment = isTest
58
56
  ? SiftScienceEnum_1.SiftScienceEnum.siftScienceTest
59
57
  : SiftScienceEnum_1.SiftScienceEnum.siftScienceProd;
60
- if (_this._validateMerchantSettings(sift_environment, merchantSettings))
58
+ if (this._validateMerchantSettings(sift_environment, merchantSettings))
61
59
  throw new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E013);
62
- var user_id = "" + userId + mid;
63
- var session_id = uuid_1.v4();
64
- _this._setSiftProperties(merchantSettings, sift_environment, user_id, session_id);
60
+ const user_id = `${userId}${mid}`;
61
+ const session_id = uuid_1.v4();
62
+ this._setSiftProperties(merchantSettings, sift_environment, user_id, session_id);
65
63
  return {
66
- sessionId: session_id
64
+ sessionId: session_id,
67
65
  };
68
66
  }));
69
- };
70
- SiftScience.prototype._validateMerchantSettings = function (siftEnvironment, merchantSettings) {
67
+ }
68
+ _validateMerchantSettings(siftEnvironment, merchantSettings) {
71
69
  return (merchantSettings[siftEnvironment] === "" ||
72
70
  merchantSettings[siftEnvironment] === null);
73
- };
74
- SiftScience.prototype._setSiftProperties = function (merchantSettings, siftEnvironment, userId, sessionId) {
71
+ }
72
+ _setSiftProperties(merchantSettings, siftEnvironment, userId, sessionId) {
75
73
  this._sift =
76
74
  window[this._siftProperty] === undefined
77
75
  ? []
@@ -80,12 +78,12 @@ var SiftScience = /** @class */ (function () {
80
78
  this._sift.push(["_setUserId", userId]);
81
79
  this._sift.push(["_setSessionId", sessionId]);
82
80
  this._sift.push(["_trackPageview"]);
83
- };
84
- SiftScience.prototype._initSiftScience = function (regional) {
81
+ }
82
+ _initSiftScience(regional) {
85
83
  try {
86
84
  // istanbul ignore next
87
85
  if (!UtilsService_1.UtilsService.sIsEmpty(window)) {
88
- var e = window.document.createElement("script");
86
+ const e = window.document.createElement("script");
89
87
  e.src = regional
90
88
  ? "https://regional-cdn.kushkipagos.com/siftscience/s.js"
91
89
  : "https://cdn.siftscience.com/s.js";
@@ -96,11 +94,10 @@ var SiftScience = /** @class */ (function () {
96
94
  // istanbul ignore next
97
95
  return;
98
96
  }
99
- };
100
- SiftScience = __decorate([
101
- inversify_1.injectable(),
102
- __metadata("design:paramtypes", [Boolean])
103
- ], SiftScience);
104
- return SiftScience;
105
- }());
97
+ }
98
+ };
99
+ SiftScience = __decorate([
100
+ inversify_1.injectable(),
101
+ __metadata("design:paramtypes", [Boolean])
102
+ ], SiftScience);
106
103
  exports.SiftScience = SiftScience;