@kushki/js 1.32.0-alpha.13491.1 → 1.32.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 +3 -3
- package/lib/gateway/KushkiGateway.d.ts +2 -1
- package/lib/gateway/KushkiGateway.js +1 -1
- package/lib/repository/ICardService.d.ts +4 -2
- package/lib/repository/ICardSubscriptionDynamicService.d.ts +2 -2
- package/lib/repository/IKushkiGateway.d.ts +2 -1
- package/lib/service/CardService.d.ts +5 -2
- package/lib/service/CardService.js +96 -39
- package/lib/service/CardSubscriptionDynamicService.d.ts +2 -2
- package/lib/service/CardSubscriptionDynamicService.js +27 -13
- package/lib/types/subscription_token_request.d.ts +1 -0
- package/lib/types/token_request.d.ts +1 -0
- package/package.json +3 -3
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({
|
|
@@ -10,6 +10,7 @@ import { CashTokenRequest } from "./../../lib/types/cash_token_request";
|
|
|
10
10
|
import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
|
|
11
11
|
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
12
12
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
13
|
+
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
13
14
|
import { KushkiSubscriptionTokensRequest } from "./../../lib/types/kushki_subscription_tokens_request";
|
|
14
15
|
import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
15
16
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
@@ -73,7 +74,7 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
73
74
|
chargeMobileProcessor(body: MobileProcessorChargeRequest, publicCredential: string, testEnv: boolean, regional: boolean): Observable<MobileProcessorChargeResponse>;
|
|
74
75
|
deletePaymentMethod(body: DeletePaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string, authorization: string): Observable<boolean>;
|
|
75
76
|
requestSavedPaymentMethods(body: SavedPaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string): Observable<PaymentDataResponse[]>;
|
|
76
|
-
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<
|
|
77
|
+
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<JwtResponse>;
|
|
77
78
|
getUserId(subscriptionId: string, mid: string, testEnv: boolean, regional: boolean): Observable<GetUserId>;
|
|
78
79
|
private _assignChannel;
|
|
79
80
|
private _buildHeader;
|
|
@@ -254,7 +254,7 @@ var KushkiGateway = /** @class */ (function () {
|
|
|
254
254
|
return _this.requestGet(subscriptionId
|
|
255
255
|
? PathEnum_1.PathEnum.cybersource_jwt + "?subscriptionId=" + subscriptionId
|
|
256
256
|
: PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid);
|
|
257
|
-
}), operators_1.map(function (response) { return response
|
|
257
|
+
}), operators_1.map(function (response) { return response; }));
|
|
258
258
|
};
|
|
259
259
|
KushkiGateway.prototype.getUserId = function (subscriptionId, mid, testEnv, regional) {
|
|
260
260
|
var _this = this;
|
|
@@ -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
|
}
|
|
@@ -11,6 +11,7 @@ import { CashTokenRequest } from "./../../lib/types/cash_token_request";
|
|
|
11
11
|
import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
|
|
12
12
|
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
13
13
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
14
|
+
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
14
15
|
import { KushkiSubscriptionTokensRequest } from "./../../lib/types/kushki_subscription_tokens_request";
|
|
15
16
|
import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
16
17
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
@@ -161,7 +162,7 @@ export interface IKushkiGateway {
|
|
|
161
162
|
* @param testEnv - is test environment
|
|
162
163
|
* @param regional - Define if endpoint used regional URL
|
|
163
164
|
*/
|
|
164
|
-
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<
|
|
165
|
+
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<JwtResponse>;
|
|
165
166
|
/**
|
|
166
167
|
* Get userId
|
|
167
168
|
* @param subscriptionId subscription id for the request
|
|
@@ -41,12 +41,13 @@ 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;
|
|
49
49
|
requestSecureInit(request: SecureInitRequest, mid: string, isTest: boolean, regional: boolean): Observable<SecureInitResponse>;
|
|
50
|
+
private _getCreateSubscriptionDataToTransform;
|
|
50
51
|
private _request3DSToken;
|
|
51
52
|
private _setupCompleteCardinal;
|
|
52
53
|
private _requestTokenGateway;
|
|
@@ -75,4 +76,6 @@ export declare class CardService implements ICardService {
|
|
|
75
76
|
private _initCybersourceSandbox;
|
|
76
77
|
private _ccaSandbox;
|
|
77
78
|
private _getUserId;
|
|
79
|
+
private _requestSubscriptionTokenGateway;
|
|
80
|
+
private _requestDeviceToken;
|
|
78
81
|
}
|
|
@@ -94,8 +94,10 @@ var CardService = /** @class */ (function () {
|
|
|
94
94
|
},
|
|
95
95
|
_a[this._cardNumber] = this._cardNumber,
|
|
96
96
|
_a.currency = "currency",
|
|
97
|
+
_a.emailRequest = "email",
|
|
97
98
|
_a.isDeferred = "isDeferred",
|
|
98
99
|
_a.jwt = "jwt",
|
|
100
|
+
_a.merchantName = "merchantName",
|
|
99
101
|
_a.months = "months",
|
|
100
102
|
_a.savePaymentData = "savePaymentData",
|
|
101
103
|
_a.sessionId = "sessionId",
|
|
@@ -128,7 +130,7 @@ var CardService = /** @class */ (function () {
|
|
|
128
130
|
if (jwt !== undefined)
|
|
129
131
|
data_to_transform.jwt = jwt;
|
|
130
132
|
return rxjs_1.forkJoin([
|
|
131
|
-
rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
|
|
133
|
+
rxjs_1.of(dot.transform(_this._receipt, __assign(__assign({}, data_to_transform), { merchantName: merchant.merchant_name }))),
|
|
132
134
|
request.walletId
|
|
133
135
|
? _this._authService.getAuthorizationToken()
|
|
134
136
|
: rxjs_1.of(undefined),
|
|
@@ -142,60 +144,88 @@ var CardService = /** @class */ (function () {
|
|
|
142
144
|
next: function (_a) {
|
|
143
145
|
var final_request = _a[0], authorization = _a[1], merchant = _a[2];
|
|
144
146
|
if (final_request.jwt && !merchant.sandboxEnable)
|
|
145
|
-
_this._request3DSToken(
|
|
147
|
+
_this._request3DSToken(isTest, function () {
|
|
148
|
+
_this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
|
|
149
|
+
});
|
|
146
150
|
else
|
|
147
151
|
_this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
|
|
148
152
|
}
|
|
149
153
|
});
|
|
150
154
|
};
|
|
151
|
-
CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional) {
|
|
155
|
+
CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional, callback) {
|
|
152
156
|
var _this = this;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
var merchant = _a[0];
|
|
157
|
+
this._gateway
|
|
158
|
+
.requestMerchantSettings(mid, isTest, regional)
|
|
159
|
+
.pipe(operators_1.switchMap(function (merchant) {
|
|
157
160
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
158
161
|
return rxjs_1.forkJoin([
|
|
159
162
|
_this._getDeviceTokenSiftScienceObject(request, mid, isTest, merchant, regional),
|
|
160
163
|
_this._getCybersourceJwtSubscription(merchant, mid, isTest, regional, request.subscriptionId),
|
|
161
164
|
]);
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
}))
|
|
166
|
+
.subscribe({
|
|
167
|
+
error: function (err) {
|
|
168
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
169
|
+
},
|
|
170
|
+
next: function (_a) {
|
|
171
|
+
var sift_science_obj = _a[0], jwt = _a[1];
|
|
172
|
+
if (sift_science_obj.userId === null)
|
|
173
|
+
delete sift_science_obj.userId;
|
|
174
|
+
if (sift_science_obj.sessionId === null)
|
|
175
|
+
delete sift_science_obj.sessionId;
|
|
176
|
+
if (jwt && !_this._sandboxEnable) {
|
|
177
|
+
sift_science_obj = __assign(__assign({}, sift_science_obj), { jwt: jwt, amount: request.amount, cardHolderName: request.cardHolderName, currency: request.currency });
|
|
178
|
+
_this._request3DSToken(isTest, function () {
|
|
179
|
+
sift_science_obj = __assign(__assign({}, sift_science_obj), { jwt: jwt });
|
|
180
|
+
_this._requestDeviceToken(__assign({ subscriptionId: request.subscriptionId }, sift_science_obj), mid, isTest, regional, callback);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
sift_science_obj = __assign(__assign({}, sift_science_obj), { jwt: jwt });
|
|
185
|
+
_this._requestDeviceToken(__assign({ subscriptionId: request.subscriptionId }, sift_science_obj), mid, isTest, regional, callback);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
});
|
|
172
189
|
};
|
|
173
|
-
CardService.prototype.requestSubscriptionToken = function (subscriptionTokenRequest, mid, isTest, regional) {
|
|
190
|
+
CardService.prototype.requestSubscriptionToken = function (subscriptionTokenRequest, mid, isTest, regional, callback) {
|
|
174
191
|
var _this = this;
|
|
175
|
-
|
|
192
|
+
this._gateway
|
|
193
|
+
.requestMerchantSettings(mid, isTest, regional)
|
|
194
|
+
.pipe(operators_1.switchMap(function (merchant) {
|
|
176
195
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
177
196
|
return rxjs_1.forkJoin([
|
|
178
197
|
_this._getScienceSession(subscriptionTokenRequest, mid, isTest, merchant),
|
|
179
198
|
_this._getCybersourceJwt(merchant, mid, isTest, regional, UtilsService_1.UtilsService.sGet(subscriptionTokenRequest, _this._cardNumber)),
|
|
199
|
+
rxjs_1.of(merchant),
|
|
180
200
|
]);
|
|
181
|
-
}), operators_1.
|
|
182
|
-
var sift_object = _a[0], jwt = _a[1];
|
|
201
|
+
}), operators_1.mergeMap(function (_a) {
|
|
202
|
+
var sift_object = _a[0], jwt = _a[1], merchant = _a[2];
|
|
183
203
|
_this._checkRequestBody(subscriptionTokenRequest);
|
|
184
|
-
var data_to_transform =
|
|
185
|
-
if (sift_object.userId === null || sift_object.sessionId === null)
|
|
186
|
-
data_to_transform.siftObject = __assign({}, sift_object);
|
|
204
|
+
var data_to_transform = _this._getCreateSubscriptionDataToTransform(sift_object, subscriptionTokenRequest);
|
|
187
205
|
if (jwt !== undefined)
|
|
188
206
|
data_to_transform.jwt = jwt;
|
|
189
207
|
return rxjs_1.forkJoin([
|
|
190
|
-
rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
|
|
208
|
+
rxjs_1.of(dot.transform(_this._receipt, __assign(__assign({}, data_to_transform), { merchantName: merchant.merchant_name }))),
|
|
191
209
|
subscriptionTokenRequest.walletId
|
|
192
210
|
? _this._authService.getAuthorizationToken()
|
|
193
211
|
: rxjs_1.of(undefined),
|
|
212
|
+
rxjs_1.of(merchant),
|
|
194
213
|
]);
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
214
|
+
}))
|
|
215
|
+
.subscribe({
|
|
216
|
+
error: function (err) {
|
|
217
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
218
|
+
},
|
|
219
|
+
next: function (_a) {
|
|
220
|
+
var body = _a[0], jwt = _a[1], merchant = _a[2];
|
|
221
|
+
if (body.jwt && !merchant.sandboxEnable)
|
|
222
|
+
_this._request3DSToken(isTest, function () {
|
|
223
|
+
_this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback, jwt);
|
|
224
|
+
});
|
|
225
|
+
else
|
|
226
|
+
_this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback, jwt);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
199
229
|
};
|
|
200
230
|
CardService.prototype.requestDeferred = function (binBody, mid, isTest, regional) {
|
|
201
231
|
return this._gateway.requestDeferredConditions(mid, binBody.bin, isTest, regional);
|
|
@@ -248,23 +278,28 @@ var CardService = /** @class */ (function () {
|
|
|
248
278
|
jwt: jwt
|
|
249
279
|
}); }));
|
|
250
280
|
};
|
|
251
|
-
CardService.prototype.
|
|
281
|
+
CardService.prototype._getCreateSubscriptionDataToTransform = function (siftObject, subscriptionTokenRequest) {
|
|
282
|
+
if (siftObject.userId === null || siftObject.sessionId === null)
|
|
283
|
+
return __assign({}, subscriptionTokenRequest);
|
|
284
|
+
return __assign(__assign({}, subscriptionTokenRequest), siftObject);
|
|
285
|
+
};
|
|
286
|
+
CardService.prototype._request3DSToken = function (isTest, requestToken) {
|
|
252
287
|
var _this = this;
|
|
253
288
|
if (isTest)
|
|
254
289
|
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
|
|
255
|
-
_this._setupCompleteCardinal(
|
|
290
|
+
_this._setupCompleteCardinal(requestToken);
|
|
256
291
|
});
|
|
257
292
|
else
|
|
258
293
|
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
|
|
259
|
-
_this._setupCompleteCardinal(
|
|
294
|
+
_this._setupCompleteCardinal(requestToken);
|
|
260
295
|
});
|
|
261
296
|
};
|
|
262
297
|
// istanbul ignore next
|
|
263
|
-
CardService.prototype._setupCompleteCardinal = function (
|
|
298
|
+
CardService.prototype._setupCompleteCardinal = function (requestToken) {
|
|
264
299
|
var _this = this;
|
|
265
300
|
window.Cardinal.on("payments.setupComplete", function () { return __awaiter(_this, void 0, void 0, function () {
|
|
266
301
|
return __generator(this, function (_a) {
|
|
267
|
-
|
|
302
|
+
requestToken();
|
|
268
303
|
return [2 /*return*/];
|
|
269
304
|
});
|
|
270
305
|
}); });
|
|
@@ -372,9 +407,9 @@ var CardService = /** @class */ (function () {
|
|
|
372
407
|
};
|
|
373
408
|
CardService.prototype._initCybersource = function (cardNumber, mid, isTest, regional) {
|
|
374
409
|
var _this = this;
|
|
375
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (
|
|
376
|
-
_this._initializeCardinal(isTest, jwt, cardNumber);
|
|
377
|
-
return jwt;
|
|
410
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwtResponse) {
|
|
411
|
+
_this._initializeCardinal(isTest, jwtResponse.jwt, cardNumber);
|
|
412
|
+
return jwtResponse.jwt;
|
|
378
413
|
}));
|
|
379
414
|
};
|
|
380
415
|
CardService.prototype._initializeCardinal = function (isTest, jwt, identifier) {
|
|
@@ -456,9 +491,9 @@ var CardService = /** @class */ (function () {
|
|
|
456
491
|
};
|
|
457
492
|
CardService.prototype._initCybersourceSandbox = function (mid, isTest, regional) {
|
|
458
493
|
var _this = this;
|
|
459
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (
|
|
494
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwtResponse) {
|
|
460
495
|
cardinal_sandbox_js_1.KushkiCardinalSandbox.init();
|
|
461
|
-
return jwt;
|
|
496
|
+
return jwtResponse.jwt;
|
|
462
497
|
}));
|
|
463
498
|
};
|
|
464
499
|
CardService.prototype._ccaSandbox = function (body, mid, isTest, regional, callback) {
|
|
@@ -501,6 +536,28 @@ var CardService = /** @class */ (function () {
|
|
|
501
536
|
return rxjs_1.iif(function () { return UtilsService_1.UtilsService.sIsEmpty(userId); }, _this._gateway.getUserId(subscriptionId, mid, testEnv, regional), rxjs_1.of(undefined));
|
|
502
537
|
}), operators_1.catchError(function () { return rxjs_1.of(undefined); }));
|
|
503
538
|
};
|
|
539
|
+
CardService.prototype._requestSubscriptionTokenGateway = function (body, mid, testEnv, regional, callback, authorization) {
|
|
540
|
+
this._gateway
|
|
541
|
+
.requestSubscriptionToken(body, mid, testEnv, regional, authorization)
|
|
542
|
+
.subscribe({
|
|
543
|
+
error: function (err) {
|
|
544
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
545
|
+
},
|
|
546
|
+
next: function (response) {
|
|
547
|
+
callback(response);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
};
|
|
551
|
+
CardService.prototype._requestDeviceToken = function (body, mid, testEnv, regional, callback) {
|
|
552
|
+
this._gateway.requestDeviceToken(body, mid, testEnv, regional).subscribe({
|
|
553
|
+
error: function (err) {
|
|
554
|
+
return Kushki_1.Kushki.callbackError(err, callback);
|
|
555
|
+
},
|
|
556
|
+
next: function (response) {
|
|
557
|
+
callback(response);
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
};
|
|
504
561
|
var CardService_1;
|
|
505
562
|
CardService = CardService_1 = __decorate([
|
|
506
563
|
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(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kushki/js",
|
|
3
|
-
"version": "1.32.0
|
|
3
|
+
"version": "1.32.0",
|
|
4
4
|
"description": "kushki-js",
|
|
5
5
|
"main": "lib/lib.js",
|
|
6
6
|
"types": "lib/lib.d.ts",
|
|
@@ -96,10 +96,10 @@
|
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@aws-amplify/auth": "4.6.1",
|
|
99
|
-
"@kushki/cardinal-sandbox-js": "1.0.
|
|
99
|
+
"@kushki/cardinal-sandbox-js": "1.0.4",
|
|
100
100
|
"acorn": "6.4.1",
|
|
101
101
|
"aws-amplify": "4.3.30",
|
|
102
|
-
"axios": "0.21.
|
|
102
|
+
"axios": "0.21.3",
|
|
103
103
|
"ci": "^2.1.1",
|
|
104
104
|
"dot-object": "2.1.4",
|
|
105
105
|
"inversify": "5.0.1",
|