@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.
- package/lib/Kushki.d.ts +17 -2
- package/lib/Kushki.js +132 -113
- package/lib/KushkiInfo.js +11 -14
- package/lib/constant/CreditCardEspecifications.js +2 -2
- package/lib/constant/Identifiers.js +21 -21
- package/lib/gateway/KushkiGateway.js +161 -276
- package/lib/gateway/SiftScience.js +42 -45
- package/lib/generic/AurusError.js +12 -28
- package/lib/generic/KushkiError.js +15 -33
- package/lib/infrastructure/BinCardTypeEnum.js +1 -1
- package/lib/infrastructure/CardBrandsEnum.d.ts +5 -0
- package/lib/infrastructure/CardBrandsEnum.js +8 -0
- package/lib/infrastructure/CognitoErrorEnum.js +1 -1
- package/lib/infrastructure/Container.js +41 -75
- package/lib/infrastructure/EnvironmentEnum.js +1 -1
- package/lib/infrastructure/ErrorEnum.d.ts +2 -1
- package/lib/infrastructure/ErrorEnum.js +42 -37
- package/lib/infrastructure/HeadersEnum.js +1 -1
- package/lib/infrastructure/KPayUserPoolEnum.js +1 -1
- package/lib/infrastructure/KpayPaymentKind.js +1 -1
- package/lib/infrastructure/PathEnum.js +1 -1
- package/lib/infrastructure/PlatformCodeEnum.js +15 -15
- package/lib/infrastructure/SiftScienceEnum.js +1 -1
- package/lib/infrastructure/StatusCodeEnum.js +1 -1
- package/lib/infrastructure/ThreeDSEnum.js +1 -1
- package/lib/infrastructure/VisaBrandingResourceUrlEnum.d.ts +2 -2
- package/lib/infrastructure/VisaBrandingResourceUrlEnum.js +3 -3
- package/lib/lib.js +1 -1
- package/lib/libs/MCSensoryBranding/mastercard-sensory-branding.d.ts +21 -0
- package/lib/libs/MCSensoryBranding/mastercard-sensory-branding.js +781 -0
- package/lib/libs/VisaSensoryBranding/visa-sensory-branding.d.ts +1 -1
- package/lib/libs/VisaSensoryBranding/visa-sensory-branding.js +630 -158
- package/lib/libs/cardinal/prod.js +10 -10
- package/lib/libs/cardinal/staging.js +9 -9
- package/lib/repository/IAntiFraud.js +1 -1
- package/lib/repository/IAuthService.js +1 -1
- package/lib/repository/ICardAsyncService.js +1 -1
- package/lib/repository/ICardDynamicService.js +1 -1
- package/lib/repository/ICardService.js +1 -1
- package/lib/repository/ICardSubscriptionDynamicService.js +1 -1
- package/lib/repository/ICashService.js +1 -1
- package/lib/repository/ICommissionService.js +1 -1
- package/lib/repository/IKPayService.js +1 -1
- package/lib/repository/IKushkiGateway.js +1 -1
- package/lib/repository/IKushkiService.d.ts +9 -2
- package/lib/repository/IKushkiService.js +1 -1
- package/lib/repository/IMobileProcessorService.js +1 -1
- package/lib/repository/IMultiMerchantService.js +1 -1
- package/lib/repository/IPayoutsCashService.js +1 -1
- package/lib/repository/IPayoutsTransferService.js +1 -1
- package/lib/repository/ISecureService.js +1 -1
- package/lib/repository/ISiftScienceService.js +1 -1
- package/lib/repository/ITransferService.js +1 -1
- package/lib/repository/ITransferSubscriptionService.js +1 -1
- package/lib/service/AuthService.js +99 -161
- package/lib/service/CardAsyncService.js +19 -26
- package/lib/service/CardDynamicService.js +32 -43
- package/lib/service/CardService.js +271 -382
- package/lib/service/CardSubscriptionDynamicService.js +31 -40
- package/lib/service/CashService.js +15 -16
- package/lib/service/CommissionService.js +13 -14
- package/lib/service/KPayService.js +19 -23
- package/lib/service/KushkiService.d.ts +2 -1
- package/lib/service/KushkiService.js +48 -33
- package/lib/service/MobileProcessorService.js +59 -70
- package/lib/service/MultiMerchantService.js +13 -14
- package/lib/service/PayoutsCashService.js +15 -16
- package/lib/service/PayoutsTransferService.js +17 -18
- package/lib/service/SecureService.js +13 -14
- package/lib/service/SiftScienceService.js +16 -20
- package/lib/service/TransferService.js +21 -36
- package/lib/service/TransferSubscriptionsService.js +16 -17
- package/lib/service/UtilsService.js +51 -57
- package/lib/types/card_branding_request.d.ts +40 -0
- package/lib/types/visa_branding_request.d.ts +25 -3
- 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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
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
|
-
|
|
49
|
-
KushkiGateway._aurusError = function (data) {
|
|
38
|
+
static _aurusError(data) {
|
|
50
39
|
return data.hasOwnProperty("response_code");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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 =
|
|
291
|
-
this._prodUrl =
|
|
178
|
+
this._uatUrl = `${EnvironmentEnum_1.EnvironmentEnum.uat}${path}`;
|
|
179
|
+
this._prodUrl = `${EnvironmentEnum_1.EnvironmentEnum.prod}${path}`;
|
|
292
180
|
}
|
|
293
181
|
else {
|
|
294
|
-
this._uatUrl =
|
|
295
|
-
this._prodUrl =
|
|
182
|
+
this._uatUrl = `${EnvironmentEnum_1.EnvironmentEnum.regionalUat}${path}`;
|
|
183
|
+
this._prodUrl = `${EnvironmentEnum_1.EnvironmentEnum.regionalProd}${path}`;
|
|
296
184
|
}
|
|
297
185
|
return true;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SiftScience = void 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 (
|
|
39
|
+
if (this._validateMerchantSettings(sift_environment, merchantSettings))
|
|
41
40
|
return {
|
|
42
41
|
sessionId: null,
|
|
43
|
-
userId: null
|
|
42
|
+
userId: null,
|
|
44
43
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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 (
|
|
58
|
+
if (this._validateMerchantSettings(sift_environment, merchantSettings))
|
|
61
59
|
throw new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E013);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
67
|
+
}
|
|
68
|
+
_validateMerchantSettings(siftEnvironment, merchantSettings) {
|
|
71
69
|
return (merchantSettings[siftEnvironment] === "" ||
|
|
72
70
|
merchantSettings[siftEnvironment] === null);
|
|
73
|
-
}
|
|
74
|
-
|
|
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
|
-
|
|
81
|
+
}
|
|
82
|
+
_initSiftScience(regional) {
|
|
85
83
|
try {
|
|
86
84
|
// istanbul ignore next
|
|
87
85
|
if (!UtilsService_1.UtilsService.sIsEmpty(window)) {
|
|
88
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}());
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
SiftScience = __decorate([
|
|
100
|
+
inversify_1.injectable(),
|
|
101
|
+
__metadata("design:paramtypes", [Boolean])
|
|
102
|
+
], SiftScience);
|
|
106
103
|
exports.SiftScience = SiftScience;
|