@kushki/js 1.31.4 → 1.32.0-13577
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 +3 -3
- package/lib/constant/CreditCardEspecifications.js +1 -1
- package/lib/repository/ICardService.d.ts +4 -2
- package/lib/repository/ICardSubscriptionDynamicService.d.ts +2 -2
- package/lib/service/CardService.d.ts +4 -2
- package/lib/service/CardService.js +78 -29
- package/lib/service/CardSubscriptionDynamicService.d.ts +2 -2
- package/lib/service/CardSubscriptionDynamicService.js +27 -13
- package/package.json +1 -1
package/lib/Kushki.js
CHANGED
|
@@ -55,7 +55,7 @@ var Kushki = /** @class */ (function () {
|
|
|
55
55
|
this._requestDeviceToken(body, callback);
|
|
56
56
|
};
|
|
57
57
|
Kushki.prototype.requestSubscriptionToken = function (body, callback) {
|
|
58
|
-
this.
|
|
58
|
+
this._cardService.requestSubscriptionToken(body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
59
59
|
};
|
|
60
60
|
Kushki.prototype.requestTransferToken = function (body, callback) {
|
|
61
61
|
this._resolve(this._transferService.requestTransferToken(body, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
@@ -141,7 +141,7 @@ var Kushki = /** @class */ (function () {
|
|
|
141
141
|
this._cardDynamicService.requestCardDynamicToken(bin, body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
142
142
|
};
|
|
143
143
|
Kushki.prototype.requestCardSubscriptionDynamicToken = function (bin, body, callback) {
|
|
144
|
-
this.
|
|
144
|
+
this._cardSubscriptionDynamicService.requestCardSubscriptionDynamicToken(bin, body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
145
145
|
};
|
|
146
146
|
Kushki.prototype.requestInitAuth = function (body, callback) {
|
|
147
147
|
this._resolve(this._authService.requestInitAuth(body, this._inTestEnvironment), callback);
|
|
@@ -182,7 +182,7 @@ var Kushki = /** @class */ (function () {
|
|
|
182
182
|
this._resolve(this._transferService.requestBankList(this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
183
183
|
};
|
|
184
184
|
Kushki.prototype._requestDeviceToken = function (body, callback) {
|
|
185
|
-
this.
|
|
185
|
+
this._cardService.requestDeviceToken(body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
186
186
|
};
|
|
187
187
|
Kushki.prototype._resolve = function (observable, callback) {
|
|
188
188
|
observable.subscribe({
|
|
@@ -34,8 +34,9 @@ export interface ICardService {
|
|
|
34
34
|
* @param mid - public merchant id
|
|
35
35
|
* @param isTest - is test environment
|
|
36
36
|
* @param regional - Define if endpoint used regional URL
|
|
37
|
+
* @param callback
|
|
37
38
|
*/
|
|
38
|
-
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest | SubscriptionTokenKPayRequest, mid: string, isTest: boolean, regional: boolean):
|
|
39
|
+
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest | SubscriptionTokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
39
40
|
/**
|
|
40
41
|
* Subscription Token
|
|
41
42
|
* @param binBody - deferred bin request body
|
|
@@ -50,8 +51,9 @@ export interface ICardService {
|
|
|
50
51
|
* @param mid - public merchant id
|
|
51
52
|
* @param isTest - is test environment
|
|
52
53
|
* @param regional - for single IP
|
|
54
|
+
* @param callback
|
|
53
55
|
*/
|
|
54
|
-
requestDeviceToken(deviceTokenRequest: SubscriptionIdRequest, mid: string, isTest: boolean, regional: boolean):
|
|
56
|
+
requestDeviceToken(deviceTokenRequest: SubscriptionIdRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
55
57
|
/**
|
|
56
58
|
* BinInfo
|
|
57
59
|
* @param binBody - deferred bin request body
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* ICardDynamicService
|
|
4
4
|
*/
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
5
|
import { BinBody } from "./../../lib/types/bin_body";
|
|
6
|
+
import { ErrorResponse } from "./../../lib/types/error_response";
|
|
7
7
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
8
8
|
import { SubscriptionCardAsyncTokenRequest } from "./../../lib/types/subscription_card_async_token_request";
|
|
9
9
|
import { SubscriptionCardAsyncTokenResponse } from "./../../lib/types/subscription_card_async_token_response";
|
|
10
10
|
import { SubscriptionTokenRequest } from "./../../lib/types/subscription_token_request";
|
|
11
11
|
export interface ICardSubscriptionDynamicService {
|
|
12
|
-
requestCardSubscriptionDynamicToken(bin: BinBody, body: SubscriptionCardAsyncTokenRequest | SubscriptionTokenRequest, mid: string, testEnv: boolean, regional: boolean
|
|
12
|
+
requestCardSubscriptionDynamicToken(bin: BinBody, body: SubscriptionCardAsyncTokenRequest | SubscriptionTokenRequest, mid: string, testEnv: boolean, regional: boolean, callback: (value: TokenResponse | SubscriptionCardAsyncTokenResponse | ErrorResponse) => void): void;
|
|
13
13
|
}
|
|
@@ -41,8 +41,8 @@ export declare class CardService implements ICardService {
|
|
|
41
41
|
private _sandboxEnable;
|
|
42
42
|
constructor(gateway: IKushkiGateway, authService: IAuthService, antiFraud: IAntiFraud);
|
|
43
43
|
requestToken(request: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
44
|
-
requestDeviceToken(request: SubscriptionIdRequest, mid: string, isTest: boolean, regional: boolean):
|
|
45
|
-
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest | SubscriptionTokenKPayRequest, mid: string, isTest: boolean, regional: boolean):
|
|
44
|
+
requestDeviceToken(request: SubscriptionIdRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
45
|
+
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest | SubscriptionTokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
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;
|
|
@@ -76,4 +76,6 @@ export declare class CardService implements ICardService {
|
|
|
76
76
|
private _initCybersourceSandbox;
|
|
77
77
|
private _ccaSandbox;
|
|
78
78
|
private _getUserId;
|
|
79
|
+
private _requestSubscriptionTokenGateway;
|
|
80
|
+
private _requestDeviceToken;
|
|
79
81
|
}
|
|
@@ -142,44 +142,59 @@ var CardService = /** @class */ (function () {
|
|
|
142
142
|
next: function (_a) {
|
|
143
143
|
var final_request = _a[0], authorization = _a[1], merchant = _a[2];
|
|
144
144
|
if (final_request.jwt && !merchant.sandboxEnable)
|
|
145
|
-
_this._request3DSToken(
|
|
145
|
+
_this._request3DSToken(isTest, function () {
|
|
146
|
+
_this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
|
|
147
|
+
});
|
|
146
148
|
else
|
|
147
149
|
_this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
|
|
148
150
|
}
|
|
149
151
|
});
|
|
150
152
|
};
|
|
151
|
-
CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional) {
|
|
153
|
+
CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional, callback) {
|
|
152
154
|
var _this = this;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
var merchant = _a[0];
|
|
155
|
+
this._gateway
|
|
156
|
+
.requestMerchantSettings(mid, isTest, regional)
|
|
157
|
+
.pipe(operators_1.switchMap(function (merchant) {
|
|
157
158
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
158
159
|
return rxjs_1.forkJoin([
|
|
159
160
|
_this._getDeviceTokenSiftScienceObject(request, mid, isTest, merchant, regional),
|
|
160
161
|
_this._getCybersourceJwtSubscription(merchant, mid, isTest, regional, request.subscriptionId),
|
|
161
162
|
]);
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
}))
|
|
164
|
+
.subscribe({
|
|
165
|
+
error: function (err) {
|
|
166
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
167
|
+
},
|
|
168
|
+
next: function (_a) {
|
|
169
|
+
var sift_science_obj = _a[0], jwt = _a[1];
|
|
170
|
+
if (sift_science_obj.userId === null)
|
|
171
|
+
delete sift_science_obj.userId;
|
|
172
|
+
if (sift_science_obj.sessionId === null)
|
|
173
|
+
delete sift_science_obj.sessionId;
|
|
174
|
+
if (jwt) {
|
|
175
|
+
sift_science_obj = __assign(__assign({}, sift_science_obj), { jwt: jwt, amount: request.amount, cardHolderName: request.cardHolderName, currency: request.currency });
|
|
176
|
+
_this._request3DSToken(isTest, function () {
|
|
177
|
+
_this._requestDeviceToken(__assign({ subscriptionId: request.subscriptionId }, sift_science_obj), mid, isTest, regional, callback);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
else
|
|
181
|
+
_this._requestDeviceToken(__assign({ subscriptionId: request.subscriptionId }, sift_science_obj), mid, isTest, regional, callback);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
172
184
|
};
|
|
173
|
-
CardService.prototype.requestSubscriptionToken = function (subscriptionTokenRequest, mid, isTest, regional) {
|
|
185
|
+
CardService.prototype.requestSubscriptionToken = function (subscriptionTokenRequest, mid, isTest, regional, callback) {
|
|
174
186
|
var _this = this;
|
|
175
|
-
|
|
187
|
+
this._gateway
|
|
188
|
+
.requestMerchantSettings(mid, isTest, regional)
|
|
189
|
+
.pipe(operators_1.switchMap(function (merchant) {
|
|
176
190
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
177
191
|
return rxjs_1.forkJoin([
|
|
178
192
|
_this._getScienceSession(subscriptionTokenRequest, mid, isTest, merchant),
|
|
179
193
|
_this._getCybersourceJwt(merchant, mid, isTest, regional, UtilsService_1.UtilsService.sGet(subscriptionTokenRequest, _this._cardNumber)),
|
|
194
|
+
rxjs_1.of(merchant),
|
|
180
195
|
]);
|
|
181
|
-
}), operators_1.
|
|
182
|
-
var sift_object = _a[0], jwt = _a[1];
|
|
196
|
+
}), operators_1.mergeMap(function (_a) {
|
|
197
|
+
var sift_object = _a[0], jwt = _a[1], merchant = _a[2];
|
|
183
198
|
_this._checkRequestBody(subscriptionTokenRequest);
|
|
184
199
|
var data_to_transform = _this._getCreateSubscriptionDataToTransform(sift_object, subscriptionTokenRequest);
|
|
185
200
|
if (jwt !== undefined)
|
|
@@ -189,11 +204,23 @@ var CardService = /** @class */ (function () {
|
|
|
189
204
|
subscriptionTokenRequest.walletId
|
|
190
205
|
? _this._authService.getAuthorizationToken()
|
|
191
206
|
: rxjs_1.of(undefined),
|
|
207
|
+
rxjs_1.of(merchant),
|
|
192
208
|
]);
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
209
|
+
}))
|
|
210
|
+
.subscribe({
|
|
211
|
+
error: function (err) {
|
|
212
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
213
|
+
},
|
|
214
|
+
next: function (_a) {
|
|
215
|
+
var body = _a[0], jwt = _a[1], merchant = _a[2];
|
|
216
|
+
if (body.jwt && !merchant.sandboxEnable)
|
|
217
|
+
_this._request3DSToken(isTest, function () {
|
|
218
|
+
_this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback, jwt);
|
|
219
|
+
});
|
|
220
|
+
else
|
|
221
|
+
_this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback, jwt);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
197
224
|
};
|
|
198
225
|
CardService.prototype.requestDeferred = function (binBody, mid, isTest, regional) {
|
|
199
226
|
return this._gateway.requestDeferredConditions(mid, binBody.bin, isTest, regional);
|
|
@@ -251,23 +278,23 @@ var CardService = /** @class */ (function () {
|
|
|
251
278
|
return __assign({}, subscriptionTokenRequest);
|
|
252
279
|
return __assign(__assign({}, subscriptionTokenRequest), siftObject);
|
|
253
280
|
};
|
|
254
|
-
CardService.prototype._request3DSToken = function (
|
|
281
|
+
CardService.prototype._request3DSToken = function (isTest, requestToken) {
|
|
255
282
|
var _this = this;
|
|
256
283
|
if (isTest)
|
|
257
284
|
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
|
|
258
|
-
_this._setupCompleteCardinal(
|
|
285
|
+
_this._setupCompleteCardinal(requestToken);
|
|
259
286
|
});
|
|
260
287
|
else
|
|
261
288
|
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
|
|
262
|
-
_this._setupCompleteCardinal(
|
|
289
|
+
_this._setupCompleteCardinal(requestToken);
|
|
263
290
|
});
|
|
264
291
|
};
|
|
265
292
|
// istanbul ignore next
|
|
266
|
-
CardService.prototype._setupCompleteCardinal = function (
|
|
293
|
+
CardService.prototype._setupCompleteCardinal = function (requestToken) {
|
|
267
294
|
var _this = this;
|
|
268
295
|
window.Cardinal.on("payments.setupComplete", function () { return __awaiter(_this, void 0, void 0, function () {
|
|
269
296
|
return __generator(this, function (_a) {
|
|
270
|
-
|
|
297
|
+
requestToken();
|
|
271
298
|
return [2 /*return*/];
|
|
272
299
|
});
|
|
273
300
|
}); });
|
|
@@ -504,6 +531,28 @@ var CardService = /** @class */ (function () {
|
|
|
504
531
|
return rxjs_1.iif(function () { return UtilsService_1.UtilsService.sIsEmpty(userId); }, _this._gateway.getUserId(subscriptionId, mid, testEnv, regional), rxjs_1.of(undefined));
|
|
505
532
|
}), operators_1.catchError(function () { return rxjs_1.of(undefined); }));
|
|
506
533
|
};
|
|
534
|
+
CardService.prototype._requestSubscriptionTokenGateway = function (body, mid, testEnv, regional, callback, authorization) {
|
|
535
|
+
this._gateway
|
|
536
|
+
.requestSubscriptionToken(body, mid, testEnv, regional, authorization)
|
|
537
|
+
.subscribe({
|
|
538
|
+
error: function (err) {
|
|
539
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
540
|
+
},
|
|
541
|
+
next: function (response) {
|
|
542
|
+
callback(response);
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
CardService.prototype._requestDeviceToken = function (body, mid, testEnv, regional, callback) {
|
|
547
|
+
this._gateway.requestDeviceToken(body, mid, testEnv, regional).subscribe({
|
|
548
|
+
error: function (err) {
|
|
549
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
550
|
+
},
|
|
551
|
+
next: function (response) {
|
|
552
|
+
callback(response);
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
};
|
|
507
556
|
var CardService_1;
|
|
508
557
|
CardService = CardService_1 = __decorate([
|
|
509
558
|
inversify_1.injectable(),
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { ICardAsyncService } from "./../../lib/repository/ICardAsyncService";
|
|
3
3
|
import { ICardService } from "./../../lib/repository/ICardService";
|
|
4
4
|
import { ICardSubscriptionDynamicService } from "./../../lib/repository/ICardSubscriptionDynamicService";
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
5
|
import { BinBody } from "./../../lib/types/bin_body";
|
|
6
|
+
import { ErrorResponse } from "./../../lib/types/error_response";
|
|
7
7
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
8
8
|
import { SubscriptionCardAsyncTokenRequest } from "./../../lib/types/subscription_card_async_token_request";
|
|
9
9
|
import { SubscriptionCardAsyncTokenResponse } from "./../../lib/types/subscription_card_async_token_response";
|
|
@@ -15,7 +15,7 @@ export declare class CardSubscriptionDynamicService implements ICardSubscription
|
|
|
15
15
|
private readonly _cardServiceSubscription;
|
|
16
16
|
private readonly _cardAsyncServiceSubscription;
|
|
17
17
|
constructor(cardService: ICardService, cardAsyncService: ICardAsyncService);
|
|
18
|
-
requestCardSubscriptionDynamicToken(bin: BinBody, body: SubscriptionCardAsyncTokenRequest | SubscriptionTokenRequest, mid: string, testEnv: boolean, regional: boolean
|
|
18
|
+
requestCardSubscriptionDynamicToken(bin: BinBody, body: SubscriptionCardAsyncTokenRequest | SubscriptionTokenRequest, mid: string, testEnv: boolean, regional: boolean, callback: (value: TokenResponse | SubscriptionCardAsyncTokenResponse | ErrorResponse) => void): void;
|
|
19
19
|
private _requestCardSubscriptionAsyncToken;
|
|
20
20
|
private _requestCardSubscriptionToken;
|
|
21
21
|
}
|
|
@@ -21,6 +21,7 @@ var BinCardTypeEnum_1 = require("./../../lib/infrastructure/BinCardTypeEnum");
|
|
|
21
21
|
var inversify_1 = require("inversify");
|
|
22
22
|
var rxjs_1 = require("rxjs");
|
|
23
23
|
var operators_1 = require("rxjs/operators");
|
|
24
|
+
var Kushki_1 = require("./../../lib/Kushki");
|
|
24
25
|
/**
|
|
25
26
|
* Implementation
|
|
26
27
|
*/
|
|
@@ -29,25 +30,38 @@ var CardSubscriptionDynamicService = /** @class */ (function () {
|
|
|
29
30
|
this._cardServiceSubscription = cardService;
|
|
30
31
|
this._cardAsyncServiceSubscription = cardAsyncService;
|
|
31
32
|
}
|
|
32
|
-
CardSubscriptionDynamicService.prototype.requestCardSubscriptionDynamicToken = function (bin, body, mid, testEnv, regional) {
|
|
33
|
+
CardSubscriptionDynamicService.prototype.requestCardSubscriptionDynamicToken = function (bin, body, mid, testEnv, regional, callback) {
|
|
33
34
|
var _this = this;
|
|
34
|
-
|
|
35
|
+
rxjs_1.of(1)
|
|
36
|
+
.pipe(operators_1.concatMap(function () {
|
|
35
37
|
return _this._cardServiceSubscription.requestBinInfo(bin, mid, testEnv, regional);
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
}))
|
|
39
|
+
.subscribe({
|
|
40
|
+
next: function (binInfo) {
|
|
41
|
+
if (binInfo.cardType === BinCardTypeEnum_1.BinCardTypeEnum.debit)
|
|
42
|
+
_this._requestCardSubscriptionAsyncToken(body, mid, testEnv, regional, callback);
|
|
43
|
+
else
|
|
44
|
+
_this._requestCardSubscriptionToken(body, mid, testEnv, regional, callback);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
39
47
|
};
|
|
40
|
-
CardSubscriptionDynamicService.prototype._requestCardSubscriptionAsyncToken = function (body, mid, testEnv, regional) {
|
|
48
|
+
CardSubscriptionDynamicService.prototype._requestCardSubscriptionAsyncToken = function (body, mid, testEnv, regional, callback) {
|
|
41
49
|
var _this = this;
|
|
42
|
-
|
|
50
|
+
rxjs_1.of(1)
|
|
51
|
+
.pipe(operators_1.mergeMap(function () {
|
|
43
52
|
return _this._cardAsyncServiceSubscription.requestCardSubscriptionAsyncToken(body, mid, testEnv, regional);
|
|
44
|
-
}))
|
|
53
|
+
}))
|
|
54
|
+
.subscribe({
|
|
55
|
+
error: function (err) {
|
|
56
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
57
|
+
},
|
|
58
|
+
next: function (token) {
|
|
59
|
+
callback(token);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
45
62
|
};
|
|
46
|
-
CardSubscriptionDynamicService.prototype._requestCardSubscriptionToken = function (body, mid, testEnv, regional) {
|
|
47
|
-
|
|
48
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(function () {
|
|
49
|
-
return _this._cardServiceSubscription.requestSubscriptionToken(body, mid, testEnv, regional);
|
|
50
|
-
}));
|
|
63
|
+
CardSubscriptionDynamicService.prototype._requestCardSubscriptionToken = function (body, mid, testEnv, regional, callback) {
|
|
64
|
+
this._cardServiceSubscription.requestSubscriptionToken(body, mid, testEnv, regional, callback);
|
|
51
65
|
};
|
|
52
66
|
CardSubscriptionDynamicService = __decorate([
|
|
53
67
|
inversify_1.injectable(),
|