@kushki/js 1.30.1-alpha-3ds-setup-complete.1 → 1.31.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.js
CHANGED
|
@@ -138,7 +138,7 @@ var Kushki = /** @class */ (function () {
|
|
|
138
138
|
this._resolve(this._mobileProcessorService.requestToken(body, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
139
139
|
};
|
|
140
140
|
Kushki.prototype.requestCardDynamicToken = function (bin, body, callback) {
|
|
141
|
-
this.
|
|
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
144
|
this._resolve(this._cardSubscriptionDynamicService.requestCardSubscriptionDynamicToken(bin, body, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* ICardDynamicService
|
|
4
4
|
*/
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
5
|
import { BinBody } from "./../../lib/types/bin_body";
|
|
7
6
|
import { CardAsyncTokenRequest } from "./../../lib/types/card_async_token_request";
|
|
8
|
-
import {
|
|
7
|
+
import { ErrorResponse } from "./../../lib/types/error_response";
|
|
9
8
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
10
9
|
import { TokenRequest } from "./../../lib/types/token_request";
|
|
11
10
|
export interface ICardDynamicService {
|
|
12
|
-
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean
|
|
11
|
+
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
13
12
|
}
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
import { ICardAsyncService } from "./../../lib/repository/ICardAsyncService";
|
|
3
3
|
import { ICardDynamicService } from "./../../lib/repository/ICardDynamicService";
|
|
4
4
|
import { ICardService } from "./../../lib/repository/ICardService";
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
5
|
import { BinBody } from "./../../lib/types/bin_body";
|
|
7
6
|
import { CardAsyncTokenRequest } from "./../../lib/types/card_async_token_request";
|
|
8
|
-
import {
|
|
7
|
+
import { ErrorResponse } from "./../../lib/types/error_response";
|
|
9
8
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
10
9
|
import { TokenRequest } from "./../../lib/types/token_request";
|
|
11
10
|
/**
|
|
@@ -15,6 +14,7 @@ export declare class CardDynamicService implements ICardDynamicService {
|
|
|
15
14
|
private readonly _cardService;
|
|
16
15
|
private readonly _cardAsyncService;
|
|
17
16
|
constructor(cardService: ICardService, cardAsyncService: ICardAsyncService);
|
|
18
|
-
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean
|
|
17
|
+
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, mid: string, testEnv: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
19
18
|
private _requestCardAsyncToken;
|
|
19
|
+
private _requestToken;
|
|
20
20
|
}
|
|
@@ -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,21 +30,43 @@ var CardDynamicService = /** @class */ (function () {
|
|
|
29
30
|
this._cardService = cardService;
|
|
30
31
|
this._cardAsyncService = cardAsyncService;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
// istanbul ignore next
|
|
34
|
+
CardDynamicService.prototype.requestCardDynamicToken = function (bin, body, mid, testEnv, regional, callback) {
|
|
33
35
|
var _this = this;
|
|
34
|
-
|
|
36
|
+
rxjs_1.of(1)
|
|
37
|
+
.pipe(operators_1.concatMap(function () {
|
|
35
38
|
return _this._cardService.requestBinInfo(bin, mid, testEnv, regional);
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
}))
|
|
40
|
+
.subscribe({
|
|
41
|
+
error: function (err) {
|
|
42
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
43
|
+
},
|
|
44
|
+
next: function (binInfo) {
|
|
45
|
+
if (binInfo.cardType === BinCardTypeEnum_1.BinCardTypeEnum.debit)
|
|
46
|
+
_this._requestCardAsyncToken(body, mid, testEnv, regional, callback);
|
|
47
|
+
else
|
|
48
|
+
_this._requestToken(body, mid, testEnv, regional, callback);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
41
51
|
};
|
|
42
|
-
|
|
52
|
+
// istanbul ignore next
|
|
53
|
+
CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional, callback) {
|
|
43
54
|
var _this = this;
|
|
44
|
-
|
|
55
|
+
rxjs_1.of(1)
|
|
56
|
+
.pipe(operators_1.mergeMap(function () {
|
|
45
57
|
return _this._cardAsyncService.requestCardAsyncToken(body, mid, testEnv, regional);
|
|
46
|
-
}))
|
|
58
|
+
}))
|
|
59
|
+
.subscribe({
|
|
60
|
+
error: function (err) {
|
|
61
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
62
|
+
},
|
|
63
|
+
next: function (token) {
|
|
64
|
+
callback(token);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
CardDynamicService.prototype._requestToken = function (body, mid, testEnv, regional, callback) {
|
|
69
|
+
this._cardService.requestToken(body, mid, testEnv, regional, callback);
|
|
47
70
|
};
|
|
48
71
|
CardDynamicService = __decorate([
|
|
49
72
|
inversify_1.injectable(),
|
|
@@ -47,8 +47,8 @@ export declare class CardService implements ICardService {
|
|
|
47
47
|
requestBinInfo(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<BinInfoResponse>;
|
|
48
48
|
validate3DS(body: Validate3DSRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: Validate3DsResponse | ErrorResponse) => void): void;
|
|
49
49
|
requestSecureInit(request: SecureInitRequest, mid: string, isTest: boolean, regional: boolean): Observable<SecureInitResponse>;
|
|
50
|
-
private _requestToken;
|
|
51
50
|
private _request3DSToken;
|
|
51
|
+
private _setupCompleteCardinal;
|
|
52
52
|
private _requestTokenGateway;
|
|
53
53
|
private _getMerchantSettings;
|
|
54
54
|
private _validateParameters;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// tslint:disable:no-identical-functions
|
|
2
3
|
/**
|
|
3
4
|
* Card Service file
|
|
4
5
|
*/
|
|
@@ -105,14 +106,42 @@ var CardService = /** @class */ (function () {
|
|
|
105
106
|
CardService_1 = CardService;
|
|
106
107
|
CardService.prototype.requestToken = function (request, mid, isTest, regional, callback) {
|
|
107
108
|
var _this = this;
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
this._gateway
|
|
110
|
+
.requestMerchantSettings(mid, isTest, regional)
|
|
111
|
+
.pipe(operators_1.switchMap(function (merchant) {
|
|
112
|
+
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
113
|
+
return rxjs_1.forkJoin([
|
|
114
|
+
_this._getScienceSession(request, mid, isTest, merchant),
|
|
115
|
+
_this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "card")
|
|
116
|
+
? request.card.number
|
|
117
|
+
: undefined),
|
|
118
|
+
rxjs_1.of(merchant),
|
|
119
|
+
]);
|
|
120
|
+
}), operators_1.mergeMap(function (_a) {
|
|
121
|
+
var sift_object = _a[0], jwt = _a[1], merchant = _a[2];
|
|
122
|
+
request.isDeferred =
|
|
123
|
+
request.isDeferred === undefined ? false : request.isDeferred;
|
|
124
|
+
if (Boolean(request.cvv))
|
|
125
|
+
request.card = { cvc: request.cvv };
|
|
126
|
+
_this._checkRequestBody(request);
|
|
127
|
+
var data_to_transform = __assign(__assign({}, request), sift_object);
|
|
128
|
+
if (jwt !== undefined)
|
|
129
|
+
data_to_transform.jwt = jwt;
|
|
130
|
+
return rxjs_1.forkJoin([
|
|
131
|
+
rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
|
|
132
|
+
request.walletId
|
|
133
|
+
? _this._authService.getAuthorizationToken()
|
|
134
|
+
: rxjs_1.of(undefined),
|
|
135
|
+
rxjs_1.of(merchant),
|
|
136
|
+
]);
|
|
137
|
+
}))
|
|
138
|
+
.subscribe({
|
|
110
139
|
error: function (err) {
|
|
111
140
|
return Kushki_1.Kushki.callbackError(err, callback);
|
|
112
141
|
},
|
|
113
142
|
next: function (_a) {
|
|
114
|
-
var final_request = _a[0], authorization = _a[1];
|
|
115
|
-
if (final_request.jwt)
|
|
143
|
+
var final_request = _a[0], authorization = _a[1], merchant = _a[2];
|
|
144
|
+
if (final_request.jwt && !merchant.sandboxEnable)
|
|
116
145
|
_this._request3DSToken(final_request, mid, isTest, regional, callback, authorization);
|
|
117
146
|
else
|
|
118
147
|
_this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
|
|
@@ -221,42 +250,28 @@ var CardService = /** @class */ (function () {
|
|
|
221
250
|
jwt: jwt
|
|
222
251
|
}); }));
|
|
223
252
|
};
|
|
224
|
-
CardService.prototype.
|
|
253
|
+
CardService.prototype._request3DSToken = function (body, mid, isTest, regional, callback, authorization) {
|
|
225
254
|
var _this = this;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}), operators_1.mergeMap(function (_a) {
|
|
235
|
-
var sift_object = _a[0], jwt = _a[1];
|
|
236
|
-
request.isDeferred =
|
|
237
|
-
request.isDeferred === undefined ? false : request.isDeferred;
|
|
238
|
-
if (Boolean(request.cvv))
|
|
239
|
-
request.card = { cvc: request.cvv };
|
|
240
|
-
_this._checkRequestBody(request);
|
|
241
|
-
var data_to_transform = __assign(__assign({}, request), sift_object);
|
|
242
|
-
if (jwt !== undefined)
|
|
243
|
-
data_to_transform.jwt = jwt;
|
|
244
|
-
return rxjs_1.forkJoin([
|
|
245
|
-
rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
|
|
246
|
-
request.walletId
|
|
247
|
-
? _this._authService.getAuthorizationToken()
|
|
248
|
-
: rxjs_1.of(undefined),
|
|
249
|
-
]);
|
|
250
|
-
}));
|
|
255
|
+
if (isTest)
|
|
256
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
|
|
257
|
+
_this._setupCompleteCardinal(body, mid, isTest, regional, callback, authorization);
|
|
258
|
+
});
|
|
259
|
+
else
|
|
260
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
|
|
261
|
+
_this._setupCompleteCardinal(body, mid, isTest, regional, callback, authorization);
|
|
262
|
+
});
|
|
251
263
|
};
|
|
252
|
-
|
|
264
|
+
// istanbul ignore next
|
|
265
|
+
CardService.prototype._setupCompleteCardinal = function (body, mid, isTest, regional, callback, authorization) {
|
|
253
266
|
var _this = this;
|
|
254
|
-
|
|
267
|
+
window.Cardinal.on("payments.setupComplete", function () { return __awaiter(_this, void 0, void 0, function () {
|
|
255
268
|
return __generator(this, function (_a) {
|
|
256
|
-
|
|
269
|
+
this._requestTokenGateway(body, mid, isTest, regional, callback, authorization);
|
|
270
|
+
return [2 /*return*/];
|
|
257
271
|
});
|
|
258
272
|
}); });
|
|
259
273
|
};
|
|
274
|
+
// istanbul ignore next
|
|
260
275
|
CardService.prototype._requestTokenGateway = function (body, mid, testEnv, regional, callback, authorization) {
|
|
261
276
|
var request_token = this._gateway.requestToken(body, mid, testEnv, regional, authorization);
|
|
262
277
|
return request_token.subscribe({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kushki/js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"description": "kushki-js",
|
|
5
5
|
"main": "lib/lib.js",
|
|
6
6
|
"types": "lib/lib.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"publish:latest": "npm run build && npm publish",
|
|
20
20
|
"publish:alpha": "npm run build && npm publish --tag alpha",
|
|
21
|
-
"prepare": "npm run tsc:interface",
|
|
21
|
+
"prepare": "npm run tsc:interface && npm run test:unit && npm run test:coverage && npm run build:npm",
|
|
22
22
|
"tsc:interface": "kushki json2ts",
|
|
23
23
|
"tsc:check": "tsc --project tsconfig.check.json --noEmit",
|
|
24
24
|
"lint": "npm run lint:format && npm run lint:duplicate && npm run lint:check",
|