@kushki/js 1.30.1-alpha-3ds-setup-complete.2 → 1.30.1-alpha.13469.2
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/environments/environment.d.ts +2 -0
- package/lib/environments/environment.js +1 -0
- package/lib/gateway/KushkiGateway.d.ts +2 -1
- package/lib/gateway/KushkiGateway.js +5 -3
- package/lib/infrastructure/EnvironmentEnum.d.ts +2 -2
- package/lib/infrastructure/EnvironmentEnum.js +2 -2
- 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/CardDynamicService.js +2 -0
- package/lib/service/CardService.d.ts +10 -3
- package/lib/service/CardService.js +158 -81
- package/lib/service/CardSubscriptionDynamicService.d.ts +2 -2
- package/lib/service/CardSubscriptionDynamicService.js +27 -13
- package/lib/types/jwt_response.d.ts +1 -0
- package/lib/types/payouts_transfer_token_request.d.ts +16 -1
- package/lib/types/subscriptionId_request.d.ts +0 -1
- package/package.json +2 -2
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({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -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): 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;
|
|
@@ -248,11 +248,13 @@ var KushkiGateway = /** @class */ (function () {
|
|
|
248
248
|
return _this.requestGet(path, testEnv, regional, mid);
|
|
249
249
|
}), operators_1.map(function (response) { return response; }));
|
|
250
250
|
};
|
|
251
|
-
KushkiGateway.prototype.cybersourceJwt = function (mid, testEnv, regional) {
|
|
251
|
+
KushkiGateway.prototype.cybersourceJwt = function (mid, testEnv, regional, subscriptionId) {
|
|
252
252
|
var _this = this;
|
|
253
253
|
return rxjs_1.of(1).pipe(operators_1.concatMap(function () {
|
|
254
|
-
return _this.requestGet(
|
|
255
|
-
|
|
254
|
+
return _this.requestGet(subscriptionId
|
|
255
|
+
? PathEnum_1.PathEnum.cybersource_jwt + "?subscriptionId=" + subscriptionId
|
|
256
|
+
: PathEnum_1.PathEnum.cybersource_jwt, testEnv, regional, mid);
|
|
257
|
+
}), operators_1.map(function (response) { return response; }));
|
|
256
258
|
};
|
|
257
259
|
KushkiGateway.prototype.getUserId = function (subscriptionId, mid, testEnv, regional) {
|
|
258
260
|
var _this = this;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Environment enum file
|
|
4
4
|
*/
|
|
5
5
|
export declare enum EnvironmentEnum {
|
|
6
|
-
uat = "https://api-
|
|
6
|
+
uat = "https://api-qa.ampato.kushki.dev/",
|
|
7
7
|
prod = "https://api.kushkipagos.com/",
|
|
8
|
-
regionalUat = "https://regional-
|
|
8
|
+
regionalUat = "https://regional-qa.kushkipagos.com/",
|
|
9
9
|
regionalProd = "https://regional.kushkipagos.com/"
|
|
10
10
|
}
|
|
@@ -6,8 +6,8 @@ exports.EnvironmentEnum = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
var EnvironmentEnum;
|
|
8
8
|
(function (EnvironmentEnum) {
|
|
9
|
-
EnvironmentEnum["uat"] = "https://api-
|
|
9
|
+
EnvironmentEnum["uat"] = "https://api-qa.ampato.kushki.dev/";
|
|
10
10
|
EnvironmentEnum["prod"] = "https://api.kushkipagos.com/";
|
|
11
|
-
EnvironmentEnum["regionalUat"] = "https://regional-
|
|
11
|
+
EnvironmentEnum["regionalUat"] = "https://regional-qa.kushkipagos.com/";
|
|
12
12
|
EnvironmentEnum["regionalProd"] = "https://regional.kushkipagos.com/";
|
|
13
13
|
})(EnvironmentEnum = exports.EnvironmentEnum || (exports.EnvironmentEnum = {}));
|
|
@@ -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): 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
|
|
@@ -30,6 +30,7 @@ var CardDynamicService = /** @class */ (function () {
|
|
|
30
30
|
this._cardService = cardService;
|
|
31
31
|
this._cardAsyncService = cardAsyncService;
|
|
32
32
|
}
|
|
33
|
+
// istanbul ignore next
|
|
33
34
|
CardDynamicService.prototype.requestCardDynamicToken = function (bin, body, mid, testEnv, regional, callback) {
|
|
34
35
|
var _this = this;
|
|
35
36
|
rxjs_1.of(1)
|
|
@@ -48,6 +49,7 @@ var CardDynamicService = /** @class */ (function () {
|
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
51
|
};
|
|
52
|
+
// istanbul ignore next
|
|
51
53
|
CardDynamicService.prototype._requestCardAsyncToken = function (body, mid, testEnv, regional, callback) {
|
|
52
54
|
var _this = this;
|
|
53
55
|
rxjs_1.of(1)
|
|
@@ -41,13 +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
|
|
50
|
+
private _getCreateSubscriptionDataToTransform;
|
|
51
51
|
private _request3DSToken;
|
|
52
52
|
private _setupCompleteCardinal;
|
|
53
53
|
private _requestTokenGateway;
|
|
@@ -62,7 +62,12 @@ export declare class CardService implements ICardService {
|
|
|
62
62
|
private _checkAmount;
|
|
63
63
|
private _checkRequestBody;
|
|
64
64
|
private _getCybersourceJwt;
|
|
65
|
+
private _isSandboxEnabled;
|
|
66
|
+
private _getCybersourceJwtSubscription;
|
|
67
|
+
private _is3DSSecureEnabled;
|
|
65
68
|
private _initCybersource;
|
|
69
|
+
private _initializeCardinal;
|
|
70
|
+
private _initCybersourceSubscription;
|
|
66
71
|
private _completeCardinal;
|
|
67
72
|
private static _initCardinal;
|
|
68
73
|
private static _ccaCardinal;
|
|
@@ -71,4 +76,6 @@ export declare class CardService implements ICardService {
|
|
|
71
76
|
private _initCybersourceSandbox;
|
|
72
77
|
private _ccaSandbox;
|
|
73
78
|
private _getUserId;
|
|
79
|
+
private _requestSubscriptionTokenGateway;
|
|
80
|
+
private _requestDeviceToken;
|
|
74
81
|
}
|
|
@@ -106,58 +106,97 @@ var CardService = /** @class */ (function () {
|
|
|
106
106
|
CardService_1 = CardService;
|
|
107
107
|
CardService.prototype.requestToken = function (request, mid, isTest, regional, callback) {
|
|
108
108
|
var _this = this;
|
|
109
|
-
|
|
110
|
-
|
|
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({
|
|
111
139
|
error: function (err) {
|
|
112
140
|
return Kushki_1.Kushki.callbackError(err, callback);
|
|
113
141
|
},
|
|
114
142
|
next: function (_a) {
|
|
115
143
|
var final_request = _a[0], authorization = _a[1], merchant = _a[2];
|
|
116
144
|
if (final_request.jwt && !merchant.sandboxEnable)
|
|
117
|
-
_this._request3DSToken(
|
|
145
|
+
_this._request3DSToken(isTest, function () {
|
|
146
|
+
_this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
|
|
147
|
+
});
|
|
118
148
|
else
|
|
119
149
|
_this._requestTokenGateway(final_request, mid, isTest, regional, callback, authorization);
|
|
120
150
|
}
|
|
121
151
|
});
|
|
122
152
|
};
|
|
123
|
-
CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional) {
|
|
153
|
+
CardService.prototype.requestDeviceToken = function (request, mid, isTest, regional, callback) {
|
|
124
154
|
var _this = this;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
var merchant = _a[0];
|
|
155
|
+
this._gateway
|
|
156
|
+
.requestMerchantSettings(mid, isTest, regional)
|
|
157
|
+
.pipe(operators_1.switchMap(function (merchant) {
|
|
129
158
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
130
159
|
return rxjs_1.forkJoin([
|
|
131
160
|
_this._getDeviceTokenSiftScienceObject(request, mid, isTest, merchant, regional),
|
|
132
|
-
_this.
|
|
133
|
-
? request.cardNumber
|
|
134
|
-
: undefined),
|
|
161
|
+
_this._getCybersourceJwtSubscription(merchant, mid, isTest, regional, request.subscriptionId),
|
|
135
162
|
]);
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
+
});
|
|
146
184
|
};
|
|
147
|
-
CardService.prototype.requestSubscriptionToken = function (subscriptionTokenRequest, mid, isTest, regional) {
|
|
185
|
+
CardService.prototype.requestSubscriptionToken = function (subscriptionTokenRequest, mid, isTest, regional, callback) {
|
|
148
186
|
var _this = this;
|
|
149
|
-
|
|
187
|
+
this._gateway
|
|
188
|
+
.requestMerchantSettings(mid, isTest, regional)
|
|
189
|
+
.pipe(operators_1.switchMap(function (merchant) {
|
|
150
190
|
_this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
151
191
|
return rxjs_1.forkJoin([
|
|
152
192
|
_this._getScienceSession(subscriptionTokenRequest, mid, isTest, merchant),
|
|
153
193
|
_this._getCybersourceJwt(merchant, mid, isTest, regional, UtilsService_1.UtilsService.sGet(subscriptionTokenRequest, _this._cardNumber)),
|
|
194
|
+
rxjs_1.of(merchant),
|
|
154
195
|
]);
|
|
155
|
-
}), operators_1.
|
|
156
|
-
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];
|
|
157
198
|
_this._checkRequestBody(subscriptionTokenRequest);
|
|
158
|
-
var data_to_transform =
|
|
159
|
-
if (sift_object.userId === null || sift_object.sessionId === null)
|
|
160
|
-
data_to_transform.siftObject = __assign({}, sift_object);
|
|
199
|
+
var data_to_transform = _this._getCreateSubscriptionDataToTransform(sift_object, subscriptionTokenRequest);
|
|
161
200
|
if (jwt !== undefined)
|
|
162
201
|
data_to_transform.jwt = jwt;
|
|
163
202
|
return rxjs_1.forkJoin([
|
|
@@ -165,11 +204,23 @@ var CardService = /** @class */ (function () {
|
|
|
165
204
|
subscriptionTokenRequest.walletId
|
|
166
205
|
? _this._authService.getAuthorizationToken()
|
|
167
206
|
: rxjs_1.of(undefined),
|
|
207
|
+
rxjs_1.of(merchant),
|
|
168
208
|
]);
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
+
});
|
|
173
224
|
};
|
|
174
225
|
CardService.prototype.requestDeferred = function (binBody, mid, isTest, regional) {
|
|
175
226
|
return this._gateway.requestDeferredConditions(mid, binBody.bin, isTest, regional);
|
|
@@ -215,63 +266,40 @@ var CardService = /** @class */ (function () {
|
|
|
215
266
|
CardService.prototype.requestSecureInit = function (request, mid, isTest, regional) {
|
|
216
267
|
var _this = this;
|
|
217
268
|
return rxjs_1.of(1).pipe(operators_1.map(function () { return _this._checkCardLength(request, ErrorEnum_1.ErrorCode.E014); }), operators_1.switchMap(function () { return _this._getMerchantSettings(mid, isTest, regional); }), operators_1.switchMap(function (merchantSettings) {
|
|
218
|
-
return rxjs_1.iif(function () { return
|
|
269
|
+
return rxjs_1.iif(function () { return _this._is3DSSecureEnabled(merchantSettings); }, rxjs_1.of(merchantSettings), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E013)));
|
|
219
270
|
}), operators_1.switchMap(function (merchant) {
|
|
220
271
|
return _this._getCybersourceJwt(merchant, mid, isTest, regional, request.card.number);
|
|
221
272
|
}), operators_1.map(function (jwt) { return ({
|
|
222
273
|
jwt: jwt
|
|
223
274
|
}); }));
|
|
224
275
|
};
|
|
225
|
-
CardService.prototype.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return rxjs_1.forkJoin([
|
|
230
|
-
_this._getScienceSession(request, mid, isTest, merchant),
|
|
231
|
-
_this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "card")
|
|
232
|
-
? request.card.number
|
|
233
|
-
: undefined),
|
|
234
|
-
rxjs_1.of(merchant),
|
|
235
|
-
]);
|
|
236
|
-
}), operators_1.mergeMap(function (_a) {
|
|
237
|
-
var sift_object = _a[0], jwt = _a[1], merchant = _a[2];
|
|
238
|
-
request.isDeferred =
|
|
239
|
-
request.isDeferred === undefined ? false : request.isDeferred;
|
|
240
|
-
if (Boolean(request.cvv))
|
|
241
|
-
request.card = { cvc: request.cvv };
|
|
242
|
-
_this._checkRequestBody(request);
|
|
243
|
-
var data_to_transform = __assign(__assign({}, request), sift_object);
|
|
244
|
-
if (jwt !== undefined)
|
|
245
|
-
data_to_transform.jwt = jwt;
|
|
246
|
-
return rxjs_1.forkJoin([
|
|
247
|
-
rxjs_1.of(dot.transform(_this._receipt, data_to_transform)),
|
|
248
|
-
request.walletId
|
|
249
|
-
? _this._authService.getAuthorizationToken()
|
|
250
|
-
: rxjs_1.of(undefined),
|
|
251
|
-
rxjs_1.of(merchant),
|
|
252
|
-
]);
|
|
253
|
-
}));
|
|
276
|
+
CardService.prototype._getCreateSubscriptionDataToTransform = function (siftObject, subscriptionTokenRequest) {
|
|
277
|
+
if (siftObject.userId === null || siftObject.sessionId === null)
|
|
278
|
+
return __assign({}, subscriptionTokenRequest);
|
|
279
|
+
return __assign(__assign({}, subscriptionTokenRequest), siftObject);
|
|
254
280
|
};
|
|
255
|
-
CardService.prototype._request3DSToken = function (
|
|
281
|
+
CardService.prototype._request3DSToken = function (isTest, requestToken) {
|
|
256
282
|
var _this = this;
|
|
257
283
|
if (isTest)
|
|
258
284
|
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
|
|
259
|
-
_this._setupCompleteCardinal(
|
|
285
|
+
_this._setupCompleteCardinal(requestToken);
|
|
260
286
|
});
|
|
261
287
|
else
|
|
262
288
|
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
|
|
263
|
-
_this._setupCompleteCardinal(
|
|
289
|
+
_this._setupCompleteCardinal(requestToken);
|
|
264
290
|
});
|
|
265
291
|
};
|
|
266
|
-
|
|
292
|
+
// istanbul ignore next
|
|
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
|
}); });
|
|
274
301
|
};
|
|
302
|
+
// istanbul ignore next
|
|
275
303
|
CardService.prototype._requestTokenGateway = function (body, mid, testEnv, regional, callback, authorization) {
|
|
276
304
|
var request_token = this._gateway.requestToken(body, mid, testEnv, regional, authorization);
|
|
277
305
|
return request_token.subscribe({
|
|
@@ -352,24 +380,51 @@ var CardService = /** @class */ (function () {
|
|
|
352
380
|
CardService.prototype._getCybersourceJwt = function (merchantSettings, mid, isTest, regional, cardNumber) {
|
|
353
381
|
var _this = this;
|
|
354
382
|
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
355
|
-
if (
|
|
383
|
+
if (_this._is3DSSecureEnabled(merchantSettings) &&
|
|
356
384
|
cardNumber !== undefined)
|
|
357
|
-
return rxjs_1.iif(function () { return
|
|
385
|
+
return rxjs_1.iif(function () { return _this._isSandboxEnabled(merchantSettings); }, _this._initCybersourceSandbox(mid, isTest, regional), _this._initCybersource(cardNumber, mid, isTest, regional));
|
|
358
386
|
return rxjs_1.of(undefined);
|
|
359
387
|
}));
|
|
360
388
|
};
|
|
389
|
+
CardService.prototype._isSandboxEnabled = function (merchantSettings) {
|
|
390
|
+
return !!merchantSettings.sandboxEnable;
|
|
391
|
+
};
|
|
392
|
+
CardService.prototype._getCybersourceJwtSubscription = function (merchantSettings, mid, isTest, regional, subscriptionId) {
|
|
393
|
+
var _this = this;
|
|
394
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
395
|
+
if (_this._is3DSSecureEnabled(merchantSettings))
|
|
396
|
+
return rxjs_1.iif(function () { return _this._isSandboxEnabled(merchantSettings); }, _this._initCybersourceSandbox(mid, isTest, regional), _this._initCybersourceSubscription(subscriptionId, mid, isTest, regional));
|
|
397
|
+
return rxjs_1.of(undefined);
|
|
398
|
+
}));
|
|
399
|
+
};
|
|
400
|
+
CardService.prototype._is3DSSecureEnabled = function (merchantSettings) {
|
|
401
|
+
return merchantSettings[this._3Dsecure] === true;
|
|
402
|
+
};
|
|
361
403
|
CardService.prototype._initCybersource = function (cardNumber, mid, isTest, regional) {
|
|
362
404
|
var _this = this;
|
|
363
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
405
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwtResponse) {
|
|
406
|
+
_this._initializeCardinal(isTest, jwtResponse.jwt, cardNumber);
|
|
407
|
+
return jwtResponse.jwt;
|
|
408
|
+
}));
|
|
409
|
+
};
|
|
410
|
+
CardService.prototype._initializeCardinal = function (isTest, jwt, identifier) {
|
|
411
|
+
if (isTest)
|
|
412
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/staging"); }).then(function () {
|
|
413
|
+
CardService_1._initCardinal(jwt, identifier);
|
|
414
|
+
});
|
|
415
|
+
else
|
|
416
|
+
Promise.resolve().then(function () { return require("./../../lib/libs/cardinal/prod"); }).then(function () {
|
|
417
|
+
CardService_1._initCardinal(jwt, identifier);
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
CardService.prototype._initCybersourceSubscription = function (subscriptionId, mid, isTest, regional) {
|
|
421
|
+
var _this = this;
|
|
422
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () {
|
|
423
|
+
return _this._gateway.cybersourceJwt(mid, isTest, regional, subscriptionId);
|
|
424
|
+
}), operators_1.map(function (jwtResponse) {
|
|
425
|
+
var bin = Buffer.from(jwtResponse.identifier, "base64").toString("ascii");
|
|
426
|
+
_this._initializeCardinal(isTest, jwtResponse.jwt, bin);
|
|
427
|
+
return jwtResponse.jwt;
|
|
373
428
|
}));
|
|
374
429
|
};
|
|
375
430
|
// istanbul ignore next
|
|
@@ -431,9 +486,9 @@ var CardService = /** @class */ (function () {
|
|
|
431
486
|
};
|
|
432
487
|
CardService.prototype._initCybersourceSandbox = function (mid, isTest, regional) {
|
|
433
488
|
var _this = this;
|
|
434
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (
|
|
489
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(function () { return _this._gateway.cybersourceJwt(mid, isTest, regional); }), operators_1.map(function (jwtResponse) {
|
|
435
490
|
cardinal_sandbox_js_1.KushkiCardinalSandbox.init();
|
|
436
|
-
return jwt;
|
|
491
|
+
return jwtResponse.jwt;
|
|
437
492
|
}));
|
|
438
493
|
};
|
|
439
494
|
CardService.prototype._ccaSandbox = function (body, mid, isTest, regional, callback) {
|
|
@@ -476,6 +531,28 @@ var CardService = /** @class */ (function () {
|
|
|
476
531
|
return rxjs_1.iif(function () { return UtilsService_1.UtilsService.sIsEmpty(userId); }, _this._gateway.getUserId(subscriptionId, mid, testEnv, regional), rxjs_1.of(undefined));
|
|
477
532
|
}), operators_1.catchError(function () { return rxjs_1.of(undefined); }));
|
|
478
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
|
+
};
|
|
479
556
|
var CardService_1;
|
|
480
557
|
CardService = CardService_1 = __decorate([
|
|
481
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(),
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/* tslint:disable:all */
|
|
2
2
|
/* tslint:disable:all */
|
|
3
3
|
|
|
4
|
-
export type PayoutsTransferTokenRequest =
|
|
4
|
+
export type PayoutsTransferTokenRequest =
|
|
5
|
+
| ColombianTokenRequest
|
|
6
|
+
| ChileanTokenRequest
|
|
7
|
+
| EcuadorianTokenRequest
|
|
8
|
+
| MexicanTokenRequest;
|
|
5
9
|
|
|
6
10
|
export interface ColombianTokenRequest {
|
|
7
11
|
documentNumber: string;
|
|
@@ -35,3 +39,14 @@ export interface EcuadorianTokenRequest {
|
|
|
35
39
|
paymentDescription?: string;
|
|
36
40
|
name: string;
|
|
37
41
|
}
|
|
42
|
+
export interface MexicanTokenRequest {
|
|
43
|
+
name: string;
|
|
44
|
+
documentNumber: string;
|
|
45
|
+
accountNumber: string;
|
|
46
|
+
accountType: "CB" | "TD" | "NC";
|
|
47
|
+
bankId: string;
|
|
48
|
+
totalAmount: number;
|
|
49
|
+
documentType: "CURP" | "RFC";
|
|
50
|
+
currency: "MXN";
|
|
51
|
+
paymentDescription?: string;
|
|
52
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kushki/js",
|
|
3
|
-
"version": "1.30.1-alpha
|
|
3
|
+
"version": "1.30.1-alpha.13469.2",
|
|
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",
|