@kushki/js 1.40.3 → 1.40.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Kushki.d.ts +2 -19
- package/lib/Kushki.js +0 -17
- package/lib/KushkiInfo.js +1 -1
- package/lib/constant/Identifiers.d.ts +0 -2
- package/lib/constant/Identifiers.js +0 -2
- package/lib/gateway/KushkiGateway.d.ts +2 -8
- package/lib/gateway/KushkiGateway.js +7 -35
- package/lib/infrastructure/Container.js +1 -5
- package/lib/infrastructure/PathEnum.d.ts +0 -3
- package/lib/infrastructure/PathEnum.js +0 -3
- package/lib/repository/ICardService.d.ts +3 -5
- package/lib/repository/IKushkiGateway.d.ts +2 -24
- package/lib/service/CardService.d.ts +3 -7
- package/lib/service/CardService.js +20 -44
- package/package.json +3 -5
- package/lib/infrastructure/CognitoErrorEnum.d.ts +0 -4
- package/lib/infrastructure/CognitoErrorEnum.js +0 -7
- package/lib/infrastructure/KPayUserPoolEnum.d.ts +0 -5
- package/lib/infrastructure/KPayUserPoolEnum.js +0 -8
- package/lib/infrastructure/KpayPaymentKind.d.ts +0 -6
- package/lib/infrastructure/KpayPaymentKind.js +0 -9
- package/lib/repository/IAuthService.d.ts +0 -20
- package/lib/repository/IAuthService.js +0 -2
- package/lib/repository/IKPayService.d.ts +0 -26
- package/lib/repository/IKPayService.js +0 -2
- package/lib/service/AuthService.d.ts +0 -31
- package/lib/service/AuthService.js +0 -161
- package/lib/service/KPayService.d.ts +0 -19
- package/lib/service/KPayService.js +0 -45
- package/lib/types/delete_payment_method_request.d.ts +0 -6
- package/lib/types/payment_data_response.d.ts +0 -37
- package/lib/types/saved_payment_data_request.d.ts +0 -10
- package/lib/types/subscription_token_kpay_request.d.ts +0 -13
- package/lib/types/token_kpay_request.d.ts +0 -12
package/lib/Kushki.d.ts
CHANGED
|
@@ -15,16 +15,12 @@ import { CardAsyncTokenRequest } from "./../lib/types/card_async_token_request";
|
|
|
15
15
|
import { CardAsyncTokenResponse } from "./../lib/types/card_async_token_response";
|
|
16
16
|
import { CardBrandingRequest } from "./../lib/types/card_branding_request";
|
|
17
17
|
import { CashTokenRequest } from "./../lib/types/cash_token_request";
|
|
18
|
-
import { DeletePaymentMethodRequest } from "./../lib/types/delete_payment_method_request";
|
|
19
18
|
import { DeviceTokenRequest } from "./../lib/types/device_token_request";
|
|
20
19
|
import { ErrorResponse } from "./../lib/types/error_response";
|
|
21
20
|
import { GetBrandsLogosByMerchantResponse } from "./../lib/types/get_brands_logos_by_merchant_response";
|
|
22
|
-
import { InitAuthRequest } from "./../lib/types/init_auth_request";
|
|
23
|
-
import { InitAuthResponse } from "./../lib/types/init_auth_response";
|
|
24
21
|
import { KushkiInfo } from "./../lib/types/kushki_info";
|
|
25
22
|
import { MultiMerchantInfoRequest } from "./../lib/types/multimerchant_info_request";
|
|
26
23
|
import { MultiMerchantInfoResponse } from "./../lib/types/multimerchant_info_response";
|
|
27
|
-
import { PaymentDataResponse } from "./../lib/types/payment_data_response";
|
|
28
24
|
import { PayoutsCashTokenRequest } from "./../lib/types/payouts_cash_request";
|
|
29
25
|
import { PayoutsTransferTokenRequest } from "./../lib/types/payouts_transfer_token_request";
|
|
30
26
|
import { CommissionConfigurationAmount } from "./../lib/types/remote/commission_configuration_amount";
|
|
@@ -33,7 +29,6 @@ import { IDeferredResponse } from "./../lib/types/remote/deferred_response";
|
|
|
33
29
|
import { TokenResponse } from "./../lib/types/remote/token_response";
|
|
34
30
|
import { TransferTokenRequest } from "./../lib/types/remote/transfer_token_request";
|
|
35
31
|
import { ResponseStatusValidator } from "./../lib/types/response_status_validator";
|
|
36
|
-
import { SavedPaymentMethodRequest } from "./../lib/types/saved_payment_data_request";
|
|
37
32
|
import { SecureInitRequest } from "./../lib/types/secure_init_request";
|
|
38
33
|
import { SecureInitResponse } from "./../lib/types/secure_init_response";
|
|
39
34
|
import { SecureOtpRequest } from "./../lib/types/secure_otp_request";
|
|
@@ -41,17 +36,12 @@ import { SecureOtpResponse } from "./../lib/types/secure_otp_response";
|
|
|
41
36
|
import { SiftScienceAntiFraudSessionResponse } from "./../lib/types/sift_science_session";
|
|
42
37
|
import { SubscriptionCardAsyncTokenRequest } from "./../lib/types/subscription_card_async_token_request";
|
|
43
38
|
import { SubscriptionCardAsyncTokenResponse } from "./../lib/types/subscription_card_async_token_response";
|
|
44
|
-
import { SubscriptionTokenKPayRequest } from "./../lib/types/subscription_token_kpay_request";
|
|
45
39
|
import { SubscriptionTokenRequest } from "./../lib/types/subscription_token_request";
|
|
46
40
|
import { TokenChargeRequest } from "./../lib/types/token_charge_request";
|
|
47
|
-
import { TokenKPayRequest } from "./../lib/types/token_kpay_request";
|
|
48
41
|
import { TokenRequest } from "./../lib/types/token_request";
|
|
49
42
|
import { TransferSubscriptionTokenRequest } from "./../lib/types/transfer_subscription_token_request";
|
|
50
43
|
import { Validate3DSRequest } from "./../lib/types/validate_3ds_request";
|
|
51
44
|
import { Validate3DsResponse } from "./../lib/types/validate_3ds_response";
|
|
52
|
-
import { ValidateSessionResponse } from "./../lib/types/validate_session_response";
|
|
53
|
-
import { VerifyAuthRequest } from "./../lib/types/verify_auth_request";
|
|
54
|
-
import { VerifyAuthResponse } from "./../lib/types/verify_auth_response";
|
|
55
45
|
/**
|
|
56
46
|
* Implementation
|
|
57
47
|
*/
|
|
@@ -70,8 +60,6 @@ export declare class Kushki {
|
|
|
70
60
|
private readonly _payoutsCashService;
|
|
71
61
|
private readonly _transferSubscriptionService;
|
|
72
62
|
private readonly _payoutsTransferService;
|
|
73
|
-
private readonly _kPayService;
|
|
74
|
-
private readonly _authService;
|
|
75
63
|
private readonly _cardDynamicService;
|
|
76
64
|
private readonly _cardSubscriptionDynamicService;
|
|
77
65
|
private readonly _siftScience;
|
|
@@ -82,7 +70,7 @@ export declare class Kushki {
|
|
|
82
70
|
regional?: boolean;
|
|
83
71
|
kushkiInfo?: KushkiInfo;
|
|
84
72
|
});
|
|
85
|
-
requestToken(body: TokenRequest
|
|
73
|
+
requestToken(body: TokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
86
74
|
requestInitAntiFraud(userId: string, callback: (value: SiftScienceAntiFraudSessionResponse | ErrorResponse) => void): void;
|
|
87
75
|
/**
|
|
88
76
|
* @deprecated use requestDeviceToken instead
|
|
@@ -92,7 +80,7 @@ export declare class Kushki {
|
|
|
92
80
|
*/
|
|
93
81
|
requestTokenCharge(body: TokenChargeRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
94
82
|
requestDeviceToken(body: DeviceTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
95
|
-
requestSubscriptionToken(body: SubscriptionTokenRequest
|
|
83
|
+
requestSubscriptionToken(body: SubscriptionTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
96
84
|
requestTransferToken(body: TransferTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
97
85
|
checkStatus(callback: (value: ResponseStatusValidator | ErrorResponse) => void): void;
|
|
98
86
|
/**
|
|
@@ -126,11 +114,6 @@ export declare class Kushki {
|
|
|
126
114
|
requestMobileProcessorToken(_body: object, callback: (value: ErrorResponse) => void): void;
|
|
127
115
|
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
128
116
|
requestCardSubscriptionDynamicToken(bin: BinBody, body: SubscriptionCardAsyncTokenRequest | SubscriptionTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
129
|
-
requestInitAuth(body: InitAuthRequest, callback: (value: InitAuthResponse | ErrorResponse) => void): void;
|
|
130
|
-
deletePaymentMethod(body: DeletePaymentMethodRequest, callback: (value: boolean | ErrorResponse) => void): void;
|
|
131
|
-
requestSavedPaymentMethods(body: SavedPaymentMethodRequest, callback: (value: PaymentDataResponse[] | ErrorResponse) => void): void;
|
|
132
|
-
requestVerifyAuth(body: VerifyAuthRequest, callback: (value: VerifyAuthResponse | ErrorResponse) => void): void;
|
|
133
|
-
validateSession(callback: (value: ValidateSessionResponse | ErrorResponse) => void): void;
|
|
134
117
|
requestValidate3DS(body: Validate3DSRequest, callback: (value: Validate3DsResponse | ErrorResponse) => void): void;
|
|
135
118
|
requestSecureInit(body: SecureInitRequest, callback: (value: SecureInitResponse | ErrorResponse) => void): void;
|
|
136
119
|
/**
|
package/lib/Kushki.js
CHANGED
|
@@ -34,8 +34,6 @@ class Kushki {
|
|
|
34
34
|
this._payoutsCashService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.PayoutsCashService)(this._regional);
|
|
35
35
|
this._payoutsTransferService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.PayoutsTransferService)(this._regional);
|
|
36
36
|
this._transferSubscriptionService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.TransferSubscriptionService)(this._regional);
|
|
37
|
-
this._authService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.AuthService)();
|
|
38
|
-
this._kPayService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.KPayService)();
|
|
39
37
|
this._cardDynamicService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.CardDynamicService)();
|
|
40
38
|
this._cardSubscriptionDynamicService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.CardSubscriptionDynamicService)();
|
|
41
39
|
this._applePayService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.ApplePayService)();
|
|
@@ -159,21 +157,6 @@ class Kushki {
|
|
|
159
157
|
requestCardSubscriptionDynamicToken(bin, body, callback) {
|
|
160
158
|
this._cardSubscriptionDynamicService.requestCardSubscriptionDynamicToken(bin, body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
161
159
|
}
|
|
162
|
-
requestInitAuth(body, callback) {
|
|
163
|
-
this._resolve(this._authService.requestInitAuth(body, this._inTestEnvironment), callback);
|
|
164
|
-
}
|
|
165
|
-
deletePaymentMethod(body, callback) {
|
|
166
|
-
this._resolve(this._kPayService.deletePaymentMethod(body, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
167
|
-
}
|
|
168
|
-
requestSavedPaymentMethods(body, callback) {
|
|
169
|
-
this._resolve(this._kPayService.requestSavedPaymentMethods(body, this._merchantId, this._inTestEnvironment, this._regional), callback);
|
|
170
|
-
}
|
|
171
|
-
requestVerifyAuth(body, callback) {
|
|
172
|
-
this._resolve(this._authService.requestVerifyAuth(body.code, this._inTestEnvironment), callback);
|
|
173
|
-
}
|
|
174
|
-
validateSession(callback) {
|
|
175
|
-
this._resolve(this._authService.validateSession(this._inTestEnvironment), callback);
|
|
176
|
-
}
|
|
177
160
|
requestValidate3DS(body, callback) {
|
|
178
161
|
this._cardService.validate3DS(body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
179
162
|
}
|
package/lib/KushkiInfo.js
CHANGED
|
@@ -12,7 +12,7 @@ const UtilsService_1 = require("./../lib/service/UtilsService");
|
|
|
12
12
|
*/
|
|
13
13
|
class KInfo {
|
|
14
14
|
static buildKushkiInfo(kushkiInfo) {
|
|
15
|
-
const kushki_js_version = "1.40.
|
|
15
|
+
const kushki_js_version = "1.40.4";
|
|
16
16
|
if (kushkiInfo) {
|
|
17
17
|
if (UtilsService_1.UtilsService.sIsEmpty(kushkiInfo.platformVersion))
|
|
18
18
|
kushkiInfo.platformVersion = kushki_js_version;
|
|
@@ -19,8 +19,6 @@ export declare type containerSymbol = {
|
|
|
19
19
|
TransferSubscriptionService: symbol;
|
|
20
20
|
PayoutsTransferService: symbol;
|
|
21
21
|
SiftScienceService: symbol;
|
|
22
|
-
KPayService: symbol;
|
|
23
|
-
AuthService: symbol;
|
|
24
22
|
ApplePayService: symbol;
|
|
25
23
|
};
|
|
26
24
|
declare const IDENTIFIERS: containerSymbol;
|
|
@@ -7,14 +7,12 @@ exports.IDENTIFIERS = void 0;
|
|
|
7
7
|
const IDENTIFIERS = {
|
|
8
8
|
AntiFraud: Symbol.for("AntiFraud"),
|
|
9
9
|
ApplePayService: Symbol.for("ApplePayService"),
|
|
10
|
-
AuthService: Symbol.for("AuthService"),
|
|
11
10
|
CardAsyncService: Symbol.for("CardAsyncService"),
|
|
12
11
|
CardDynamicService: Symbol.for("CardDynamicService"),
|
|
13
12
|
CardService: Symbol.for("CardService"),
|
|
14
13
|
CardSubscriptionDynamicService: Symbol.for("CardSubscriptionDynamicService"),
|
|
15
14
|
CashService: Symbol.for("CashService"),
|
|
16
15
|
CommissionService: Symbol.for("CommissionService"),
|
|
17
|
-
KPayService: Symbol.for("KPayService"),
|
|
18
16
|
KushkiGateway: Symbol.for("KushkiGateway"),
|
|
19
17
|
KushkiService: Symbol.for("KushkiService"),
|
|
20
18
|
MultiMerchantService: Symbol.for("MultiMerchantService"),
|
|
@@ -10,7 +10,6 @@ import { CardAsyncTokenRequest } from "./../../lib/types/card_async_token_reques
|
|
|
10
10
|
import { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_response";
|
|
11
11
|
import { CashTokenRequest } from "./../../lib/types/cash_token_request";
|
|
12
12
|
import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
|
|
13
|
-
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
14
13
|
import { GetBrandsLogosByMerchantResponse } from "./../../lib/types/get_brands_logos_by_merchant_response";
|
|
15
14
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
16
15
|
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
@@ -19,7 +18,6 @@ import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
|
19
18
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
20
19
|
import { MultiMerchantInfoRequest } from "./../../lib/types/multimerchant_info_request";
|
|
21
20
|
import { MultiMerchantInfoResponse } from "./../../lib/types/multimerchant_info_response";
|
|
22
|
-
import { PaymentDataResponse } from "./../../lib/types/payment_data_response";
|
|
23
21
|
import { PayoutsCashTokenRequest } from "./../../lib/types/payouts_cash_request";
|
|
24
22
|
import { PayoutsTransferTokenRequest } from "./../../lib/types/payouts_transfer_token_request";
|
|
25
23
|
import { CommissionConfigurationAmount } from "./../../lib/types/remote/commission_configuration_amount";
|
|
@@ -27,7 +25,6 @@ import { CommissionConfigurationRequest } from "./../../lib/types/remote/commiss
|
|
|
27
25
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
28
26
|
import { TransferTokenRequest } from "./../../lib/types/remote/transfer_token_request";
|
|
29
27
|
import { ResponseStatusValidator } from "./../../lib/types/response_status_validator";
|
|
30
|
-
import { SavedPaymentMethodRequest } from "./../../lib/types/saved_payment_data_request";
|
|
31
28
|
import { SecureOtpRequest } from "./../../lib/types/secure_otp_request";
|
|
32
29
|
import { SecureOtpResponse } from "./../../lib/types/secure_otp_response";
|
|
33
30
|
import { SubscriptionCardAsyncTokenRequest } from "./../../lib/types/subscription_card_async_token_request";
|
|
@@ -50,12 +47,11 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
50
47
|
private _kshAuthorization;
|
|
51
48
|
request<T = object>(body: object, headers: object, path: string, testEnv: boolean, regional: boolean): Observable<T>;
|
|
52
49
|
requestGet<T extends object = object>(path: string, testEnv: boolean, regional: boolean, mid?: string): Observable<T>;
|
|
53
|
-
requestDelete<T extends object = object>(path: string, testEnv: boolean, regional: boolean, mid: string, authorization: string): Observable<T>;
|
|
54
50
|
requestBrandsByMerchant(mid: string, testEnv: boolean, regional: boolean): Observable<string[]>;
|
|
55
51
|
requestBrandsLogosByMerchant(mid: string, testEnv: boolean, regional: boolean): Observable<GetBrandsLogosByMerchantResponse[]>;
|
|
56
|
-
requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean
|
|
52
|
+
requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
57
53
|
requestDeviceToken(body: TokenChargeRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
58
|
-
requestSubscriptionToken(body: KushkiSubscriptionTokensRequest, mid: string, testEnv: boolean, regional: boolean
|
|
54
|
+
requestSubscriptionToken(body: KushkiSubscriptionTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
59
55
|
requestTransferToken(body: TransferTokenRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
60
56
|
requestMerchantSettings(mid: string, testEnv: boolean, regional: boolean): Observable<MerchantSettingsResponse>;
|
|
61
57
|
requestPseBankList(mid: string, testEnv: boolean, regional: boolean): Observable<BankListResponse>;
|
|
@@ -73,8 +69,6 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
73
69
|
requestTokenTransferSubscription(body: TransferSubscriptionTokenRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
74
70
|
requestBankList(mid: string, testEnv: boolean, regional: boolean): Observable<BankListResponse>;
|
|
75
71
|
requestPayoutsTransferBankList(mid: string, testEnv: boolean, regional: boolean): Observable<BankListResponse>;
|
|
76
|
-
deletePaymentMethod(body: DeletePaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string, authorization: string): Observable<boolean>;
|
|
77
|
-
requestSavedPaymentMethods(body: SavedPaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string): Observable<PaymentDataResponse[]>;
|
|
78
72
|
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<JwtResponse>;
|
|
79
73
|
getUserId(subscriptionId: string, mid: string, testEnv: boolean, regional: boolean): Observable<GetUserId>;
|
|
80
74
|
validateAppleDomain(domain: string, mid: string, testEnv: boolean, regional: boolean): Observable<Validate3DsResponse>;
|
|
@@ -11,7 +11,6 @@ exports.KushkiGateway = void 0;
|
|
|
11
11
|
/**
|
|
12
12
|
* Kushki Gateway File
|
|
13
13
|
*/
|
|
14
|
-
/* tslint:disable: no-unnecessary-callback-wrapper */
|
|
15
14
|
const axios_1 = require("axios");
|
|
16
15
|
const AurusError_1 = require("./../../lib/generic/AurusError");
|
|
17
16
|
const EnvironmentEnum_1 = require("./../../lib/infrastructure/EnvironmentEnum");
|
|
@@ -51,48 +50,31 @@ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
|
|
|
51
50
|
requestGet(path, testEnv, regional, mid) {
|
|
52
51
|
return rxjs_1.of(this._assignChannel(regional, path)).pipe(operators_1.switchMap(() => axios_1.default.get(`${testEnv ? this._uatUrl : this._prodUrl}`, {
|
|
53
52
|
headers: {
|
|
54
|
-
[this._publicHeader]: mid,
|
|
53
|
+
[this._publicHeader]: mid || "",
|
|
55
54
|
[this._contentHeader]: this._contentJSON,
|
|
56
55
|
},
|
|
57
56
|
})), operators_1.map((response) => response.data), operators_1.catchError((err) => rxjs_1.throwError(err)));
|
|
58
57
|
}
|
|
59
|
-
requestDelete(path, testEnv, regional, mid, authorization) {
|
|
60
|
-
return rxjs_1.of(this._assignChannel(regional, path)).pipe(operators_1.switchMap(() => axios_1.default.delete(`${testEnv ? this._uatUrl : this._prodUrl}`, {
|
|
61
|
-
headers: {
|
|
62
|
-
[this._contentHeader]: this._contentJSON,
|
|
63
|
-
[this._kshAuthorization]: authorization,
|
|
64
|
-
[this._publicHeader]: mid,
|
|
65
|
-
},
|
|
66
|
-
})), operators_1.map((response) => response.data), operators_1.catchError((err) => rxjs_1.throwError(err)));
|
|
67
|
-
}
|
|
68
58
|
requestBrandsByMerchant(mid, testEnv, regional) {
|
|
69
59
|
return this.requestGet(`${PathEnum_1.PathEnum.brands_by_merchant}`, testEnv, regional, mid);
|
|
70
60
|
}
|
|
71
61
|
requestBrandsLogosByMerchant(mid, testEnv, regional) {
|
|
72
62
|
return this.requestGet(`${PathEnum_1.PathEnum.brands_logos_by_merchant}`, testEnv, regional, mid);
|
|
73
63
|
}
|
|
74
|
-
requestToken(body, mid, testEnv, regional
|
|
75
|
-
return
|
|
64
|
+
requestToken(body, mid, testEnv, regional) {
|
|
65
|
+
return this.request(body, {
|
|
76
66
|
[this._publicHeader]: mid,
|
|
77
67
|
[this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
|
|
78
|
-
}, PathEnum_1.PathEnum.card_tokens, testEnv, regional)
|
|
79
|
-
[this._kshAuthorization]: authorization,
|
|
80
|
-
[this._publicHeader]: mid,
|
|
81
|
-
[this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
|
|
82
|
-
}, PathEnum_1.PathEnum.card_tokens, testEnv, regional))));
|
|
68
|
+
}, PathEnum_1.PathEnum.card_tokens, testEnv, regional);
|
|
83
69
|
}
|
|
84
70
|
requestDeviceToken(body, mid, testEnv, regional) {
|
|
85
71
|
return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), `${PathEnum_1.PathEnum.card_token_charge}${body.subscriptionId}/tokens`, testEnv, regional)));
|
|
86
72
|
}
|
|
87
|
-
requestSubscriptionToken(body, mid, testEnv, regional
|
|
88
|
-
return
|
|
89
|
-
[this._publicHeader]: mid,
|
|
90
|
-
[this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
|
|
91
|
-
}, PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional), this.request(body, {
|
|
92
|
-
[this._kshAuthorization]: authorization,
|
|
73
|
+
requestSubscriptionToken(body, mid, testEnv, regional) {
|
|
74
|
+
return this.request(body, {
|
|
93
75
|
[this._publicHeader]: mid,
|
|
94
76
|
[this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
|
|
95
|
-
}, PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional)
|
|
77
|
+
}, PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional);
|
|
96
78
|
}
|
|
97
79
|
requestTransferToken(body, mid, testEnv, regional) {
|
|
98
80
|
return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), PathEnum_1.PathEnum.transfer_tokens, testEnv, regional)));
|
|
@@ -145,16 +127,6 @@ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
|
|
|
145
127
|
requestPayoutsTransferBankList(mid, testEnv, regional) {
|
|
146
128
|
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => this.requestGet(PathEnum_1.PathEnum.bank_list_payouts_transfer, testEnv, regional, mid)), operators_1.map((response) => response));
|
|
147
129
|
}
|
|
148
|
-
deletePaymentMethod(body, testEnv, regional, mid, authorization) {
|
|
149
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(() => this.requestDelete(`${PathEnum_1.PathEnum.kpay_delete_payment_method}/${body.walletId}`, testEnv, regional, mid, authorization)), operators_1.map((response) => !!response));
|
|
150
|
-
}
|
|
151
|
-
requestSavedPaymentMethods(body, testEnv, regional, mid) {
|
|
152
|
-
return rxjs_1.of(1).pipe(operators_1.map(() => {
|
|
153
|
-
const { email, kind } = body;
|
|
154
|
-
const kind_path = kind !== undefined ? `?kind=${kind}` : "";
|
|
155
|
-
return `${PathEnum_1.PathEnum.kpay_get_saved_payment_methods}/${email}${kind_path}`;
|
|
156
|
-
}), operators_1.concatMap((path) => this.requestGet(path, testEnv, regional, mid)), operators_1.map((response) => response));
|
|
157
|
-
}
|
|
158
130
|
cybersourceJwt(mid, testEnv, regional, subscriptionId) {
|
|
159
131
|
return rxjs_1.of(1).pipe(operators_1.concatMap(() => {
|
|
160
132
|
const path = this._buildCybersourceJwtPath(subscriptionId);
|
|
@@ -9,14 +9,12 @@ const KushkiGateway_1 = require("./../../lib/gateway/KushkiGateway");
|
|
|
9
9
|
const SiftScience_1 = require("./../../lib/gateway/SiftScience");
|
|
10
10
|
const inversify_1 = require("inversify");
|
|
11
11
|
const ApplePayService_1 = require("./../../lib/service/ApplePayService");
|
|
12
|
-
const AuthService_1 = require("./../../lib/service/AuthService");
|
|
13
12
|
const CardAsyncService_1 = require("./../../lib/service/CardAsyncService");
|
|
14
13
|
const CardDynamicService_1 = require("./../../lib/service/CardDynamicService");
|
|
15
14
|
const CardService_1 = require("./../../lib/service/CardService");
|
|
16
15
|
const CardSubscriptionDynamicService_1 = require("./../../lib/service/CardSubscriptionDynamicService");
|
|
17
16
|
const CashService_1 = require("./../../lib/service/CashService");
|
|
18
17
|
const CommissionService_1 = require("./../../lib/service/CommissionService");
|
|
19
|
-
const KPayService_1 = require("./../../lib/service/KPayService");
|
|
20
18
|
const KushkiService_1 = require("./../../lib/service/KushkiService");
|
|
21
19
|
const MultiMerchantService_1 = require("./../../lib/service/MultiMerchantService");
|
|
22
20
|
const PayoutsCashService_1 = require("./../../lib/service/PayoutsCashService");
|
|
@@ -28,8 +26,7 @@ const TransferSubscriptionsService_1 = require("./../../lib/service/TransferSubs
|
|
|
28
26
|
const CONTAINER = new inversify_1.Container();
|
|
29
27
|
exports.CONTAINER = CONTAINER;
|
|
30
28
|
// Service
|
|
31
|
-
CONTAINER.bind(Identifiers_1.IDENTIFIERS.
|
|
32
|
-
CONTAINER.bind(Identifiers_1.IDENTIFIERS.CardService).toFactory((context) => (regional) => new CardService_1.CardService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway), context.container.get(Identifiers_1.IDENTIFIERS.AuthService)(regional), context.container.get(Identifiers_1.IDENTIFIERS.AntiFraud)(regional)));
|
|
29
|
+
CONTAINER.bind(Identifiers_1.IDENTIFIERS.CardService).toFactory((context) => (regional) => new CardService_1.CardService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway), context.container.get(Identifiers_1.IDENTIFIERS.AntiFraud)(regional)));
|
|
33
30
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.CashService).toFactory((context) => (regional) => new CashService_1.CashService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway), context.container.get(Identifiers_1.IDENTIFIERS.AntiFraud)(regional)));
|
|
34
31
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.CardDynamicService).toFactory((context) => () => new CardDynamicService_1.CardDynamicService(context.container.get(Identifiers_1.IDENTIFIERS.CardService)(), context.container.get(Identifiers_1.IDENTIFIERS.CardAsyncService)()));
|
|
35
32
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.CardSubscriptionDynamicService).toFactory((context) => () => new CardSubscriptionDynamicService_1.CardSubscriptionDynamicService(context.container.get(Identifiers_1.IDENTIFIERS.CardService)(), context.container.get(Identifiers_1.IDENTIFIERS.CardAsyncService)()));
|
|
@@ -42,7 +39,6 @@ CONTAINER.bind(Identifiers_1.IDENTIFIERS.CardAsyncService).toFactory((context) =
|
|
|
42
39
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.PayoutsCashService).toFactory((context) => (regional) => new PayoutsCashService_1.PayoutsCashService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway), context.container.get(Identifiers_1.IDENTIFIERS.AntiFraud)(regional)));
|
|
43
40
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.TransferSubscriptionService).toFactory((context) => (regional) => new TransferSubscriptionsService_1.TransferSubscriptionsService(context.container.get(Identifiers_1.IDENTIFIERS.AntiFraud)(regional), context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway)));
|
|
44
41
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.PayoutsTransferService).toFactory((context) => (regional) => new PayoutsTransferService_1.PayoutsTransferService(context.container.get(Identifiers_1.IDENTIFIERS.AntiFraud)(regional), context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway)));
|
|
45
|
-
CONTAINER.bind(Identifiers_1.IDENTIFIERS.KPayService).toFactory((context) => (regional) => new KPayService_1.KPayService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway), context.container.get(Identifiers_1.IDENTIFIERS.AuthService)(regional)));
|
|
46
42
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.SiftScienceService).toFactory((context) => (regional) => new SiftScienceService_1.SiftScienceService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway), context.container.get(Identifiers_1.IDENTIFIERS.AntiFraud)(regional)));
|
|
47
43
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.ApplePayService).toFactory((context) => () => new ApplePayService_1.ApplePayService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway)));
|
|
48
44
|
// Gateway
|
|
@@ -26,9 +26,6 @@ export declare enum PathEnum {
|
|
|
26
26
|
transfer_subscription_tokens = "transfer-subscriptions/v1/tokens",
|
|
27
27
|
payouts_transfer_tokens = "payouts/transfer/v1/tokens",
|
|
28
28
|
cybersource_jwt = "card/v1/authToken",
|
|
29
|
-
savedPaymentMethods = "/personal-wallet/v1/payment-data/",
|
|
30
|
-
kpay_delete_payment_method = "personal-wallet/v1/walletSubscription",
|
|
31
|
-
kpay_get_saved_payment_methods = "personal-wallet/v1/payment-data",
|
|
32
29
|
get_user_id = "v1/subscriptions/",
|
|
33
30
|
validate_apple_domain = "apple-pay/v1/validate",
|
|
34
31
|
start_apple_pay_session = "apple-pay/v1/session/start",
|
|
@@ -29,9 +29,6 @@ var PathEnum;
|
|
|
29
29
|
PathEnum["transfer_subscription_tokens"] = "transfer-subscriptions/v1/tokens";
|
|
30
30
|
PathEnum["payouts_transfer_tokens"] = "payouts/transfer/v1/tokens";
|
|
31
31
|
PathEnum["cybersource_jwt"] = "card/v1/authToken";
|
|
32
|
-
PathEnum["savedPaymentMethods"] = "/personal-wallet/v1/payment-data/";
|
|
33
|
-
PathEnum["kpay_delete_payment_method"] = "personal-wallet/v1/walletSubscription";
|
|
34
|
-
PathEnum["kpay_get_saved_payment_methods"] = "personal-wallet/v1/payment-data";
|
|
35
32
|
PathEnum["get_user_id"] = "v1/subscriptions/";
|
|
36
33
|
PathEnum["validate_apple_domain"] = "apple-pay/v1/validate";
|
|
37
34
|
PathEnum["start_apple_pay_session"] = "apple-pay/v1/session/start";
|
|
@@ -10,14 +10,12 @@ import { IDeferredResponse } from "./../../lib/types/remote/deferred_response";
|
|
|
10
10
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
11
11
|
import { SecureInitRequest } from "./../../lib/types/secure_init_request";
|
|
12
12
|
import { SecureInitResponse } from "./../../lib/types/secure_init_response";
|
|
13
|
-
import { SubscriptionTokenKPayRequest } from "./../../lib/types/subscription_token_kpay_request";
|
|
14
13
|
import { SubscriptionTokenRequest } from "./../../lib/types/subscription_token_request";
|
|
15
14
|
import { SubscriptionIdRequest } from "./../../lib/types/subscriptionId_request";
|
|
16
|
-
import { TokenKPayRequest } from "./../../lib/types/token_kpay_request";
|
|
17
15
|
import { TokenRequest } from "./../../lib/types/token_request";
|
|
18
16
|
import { Validate3DSRequest } from "./../../lib/types/validate_3ds_request";
|
|
19
17
|
import { Validate3DsResponse } from "./../../lib/types/validate_3ds_response";
|
|
20
|
-
export declare type IGeneralTokenRequest = TokenRequest |
|
|
18
|
+
export declare type IGeneralTokenRequest = TokenRequest | SubscriptionTokenRequest;
|
|
21
19
|
export interface ICardService {
|
|
22
20
|
/**
|
|
23
21
|
* Token
|
|
@@ -27,7 +25,7 @@ export interface ICardService {
|
|
|
27
25
|
* @param regional - Define if endpoint used regional URL
|
|
28
26
|
* @param callback
|
|
29
27
|
*/
|
|
30
|
-
requestToken(tokenRequest: TokenRequest
|
|
28
|
+
requestToken(tokenRequest: TokenRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
31
29
|
/**
|
|
32
30
|
* Subscription Token
|
|
33
31
|
* @param subscriptionTokenRequest - subscription tokens request body
|
|
@@ -36,7 +34,7 @@ export interface ICardService {
|
|
|
36
34
|
* @param regional - Define if endpoint used regional URL
|
|
37
35
|
* @param callback
|
|
38
36
|
*/
|
|
39
|
-
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest
|
|
37
|
+
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
40
38
|
/**
|
|
41
39
|
* Subscription Token
|
|
42
40
|
* @param binBody - deferred bin request body
|
|
@@ -11,7 +11,6 @@ import { CardAsyncTokenRequest } from "./../../lib/types/card_async_token_reques
|
|
|
11
11
|
import { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_response";
|
|
12
12
|
import { CashTokenRequest } from "./../../lib/types/cash_token_request";
|
|
13
13
|
import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
|
|
14
|
-
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
15
14
|
import { GetBrandsLogosByMerchantResponse } from "./../../lib/types/get_brands_logos_by_merchant_response";
|
|
16
15
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
17
16
|
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
@@ -20,7 +19,6 @@ import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
|
20
19
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
21
20
|
import { MultiMerchantInfoRequest } from "./../../lib/types/multimerchant_info_request";
|
|
22
21
|
import { MultiMerchantInfoResponse } from "./../../lib/types/multimerchant_info_response";
|
|
23
|
-
import { PaymentDataResponse } from "./../../lib/types/payment_data_response";
|
|
24
22
|
import { PayoutsCashTokenRequest } from "./../../lib/types/payouts_cash_request";
|
|
25
23
|
import { PayoutsTransferTokenRequest } from "./../../lib/types/payouts_transfer_token_request";
|
|
26
24
|
import { CommissionConfigurationAmount } from "./../../lib/types/remote/commission_configuration_amount";
|
|
@@ -28,7 +26,6 @@ import { CommissionConfigurationRequest } from "./../../lib/types/remote/commiss
|
|
|
28
26
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
29
27
|
import { TransferTokenRequest } from "./../../lib/types/remote/transfer_token_request";
|
|
30
28
|
import { ResponseStatusValidator } from "./../../lib/types/response_status_validator";
|
|
31
|
-
import { SavedPaymentMethodRequest } from "./../../lib/types/saved_payment_data_request";
|
|
32
29
|
import { SecureOtpRequest } from "./../../lib/types/secure_otp_request";
|
|
33
30
|
import { SecureOtpResponse } from "./../../lib/types/secure_otp_response";
|
|
34
31
|
import { SubscriptionCardAsyncTokenRequest } from "./../../lib/types/subscription_card_async_token_request";
|
|
@@ -45,14 +42,10 @@ export interface IKushkiGateway {
|
|
|
45
42
|
* Send GET requests to Kushki Gateway
|
|
46
43
|
*/
|
|
47
44
|
requestGet(path: string, testEnv: boolean, regional: boolean, mid?: string): Observable<object>;
|
|
48
|
-
/**
|
|
49
|
-
* Send DELETE requests to Kushki Gateway
|
|
50
|
-
*/
|
|
51
|
-
requestDelete<T extends object = object>(path: string, testEnv: boolean, regional: boolean, mid: string, authorization: string): Observable<T>;
|
|
52
45
|
/**
|
|
53
46
|
* Send tokens request to Kushki API
|
|
54
47
|
*/
|
|
55
|
-
requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean
|
|
48
|
+
requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
56
49
|
/**
|
|
57
50
|
* Send charge tokens request to Kushki API
|
|
58
51
|
*/
|
|
@@ -60,7 +53,7 @@ export interface IKushkiGateway {
|
|
|
60
53
|
/**
|
|
61
54
|
* Send tokens subscription request to Kushki API
|
|
62
55
|
*/
|
|
63
|
-
requestSubscriptionToken(body: KushkiSubscriptionTokensRequest, mid: string, testEnv: boolean, regional: boolean
|
|
56
|
+
requestSubscriptionToken(body: KushkiSubscriptionTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
64
57
|
/**
|
|
65
58
|
* Send transfer tokens request to Kushki API
|
|
66
59
|
*/
|
|
@@ -135,21 +128,6 @@ export interface IKushkiGateway {
|
|
|
135
128
|
* Request banklist payouts transfer to Kushki API
|
|
136
129
|
*/
|
|
137
130
|
requestPayoutsTransferBankList(mid: string, testEnv: boolean, regional: boolean): Observable<BankListResponse>;
|
|
138
|
-
/**
|
|
139
|
-
* @param body
|
|
140
|
-
* @param testEnv
|
|
141
|
-
* @param mid - public credential for request
|
|
142
|
-
* @param regional - Define if endpoint used regional URL
|
|
143
|
-
* @param authorization
|
|
144
|
-
*/
|
|
145
|
-
deletePaymentMethod(body: DeletePaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string, authorization: string): Observable<boolean>;
|
|
146
|
-
/**
|
|
147
|
-
* @param body
|
|
148
|
-
* @param testEnv
|
|
149
|
-
* @param mid - public credential for request
|
|
150
|
-
* @param regional - Define if endpoint used regional URL
|
|
151
|
-
*/
|
|
152
|
-
requestSavedPaymentMethods(body: SavedPaymentMethodRequest, testEnv: boolean, regional: boolean, mid: string): Observable<PaymentDataResponse[]>;
|
|
153
131
|
/**
|
|
154
132
|
* Get JWT for 3DS
|
|
155
133
|
* @param mid - public credential for request
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import "reflect-metadata";
|
|
6
6
|
import { IAntiFraud } from "./../../lib/repository/IAntiFraud";
|
|
7
|
-
import { IAuthService } from "./../../lib/repository/IAuthService";
|
|
8
7
|
import { ICardService } from "./../../lib/repository/ICardService";
|
|
9
8
|
import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
|
|
10
9
|
import { Observable } from "rxjs";
|
|
@@ -15,10 +14,8 @@ import { IDeferredResponse } from "./../../lib/types/remote/deferred_response";
|
|
|
15
14
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
16
15
|
import { SecureInitRequest } from "./../../lib/types/secure_init_request";
|
|
17
16
|
import { SecureInitResponse } from "./../../lib/types/secure_init_response";
|
|
18
|
-
import { SubscriptionTokenKPayRequest } from "./../../lib/types/subscription_token_kpay_request";
|
|
19
17
|
import { SubscriptionTokenRequest } from "./../../lib/types/subscription_token_request";
|
|
20
18
|
import { SubscriptionIdRequest } from "./../../lib/types/subscriptionId_request";
|
|
21
|
-
import { TokenKPayRequest } from "./../../lib/types/token_kpay_request";
|
|
22
19
|
import { TokenRequest } from "./../../lib/types/token_request";
|
|
23
20
|
import { Validate3DSRequest } from "./../../lib/types/validate_3ds_request";
|
|
24
21
|
import { Validate3DsResponse } from "./../../lib/types/validate_3ds_response";
|
|
@@ -35,16 +32,15 @@ export declare class CardService implements ICardService {
|
|
|
35
32
|
private readonly _gateway;
|
|
36
33
|
private readonly _receipt;
|
|
37
34
|
private readonly _antiFraud;
|
|
38
|
-
private readonly _authService;
|
|
39
35
|
private readonly _3Dsecure;
|
|
40
36
|
private readonly _cardNumber;
|
|
41
37
|
private _sandboxEnable;
|
|
42
38
|
private readonly _paymentValidatedEvent;
|
|
43
39
|
private readonly _paymentSetupCompleteEvent;
|
|
44
|
-
constructor(gateway: IKushkiGateway,
|
|
45
|
-
requestToken(request: TokenRequest
|
|
40
|
+
constructor(gateway: IKushkiGateway, antiFraud: IAntiFraud);
|
|
41
|
+
requestToken(request: TokenRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
46
42
|
requestDeviceToken(request: SubscriptionIdRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
47
|
-
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest
|
|
43
|
+
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
48
44
|
requestDeferred(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<IDeferredResponse[]>;
|
|
49
45
|
requestBinInfo(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<BinInfoResponse>;
|
|
50
46
|
validate3DS(body: Validate3DSRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: Validate3DsResponse | ErrorResponse) => void): void;
|
|
@@ -42,7 +42,7 @@ const operators_1 = require("rxjs/operators");
|
|
|
42
42
|
const UtilsService_1 = require("./../../lib/service/UtilsService");
|
|
43
43
|
const Kushki_1 = require("./../../lib/Kushki");
|
|
44
44
|
let CardService = CardService_1 = class CardService {
|
|
45
|
-
constructor(gateway,
|
|
45
|
+
constructor(gateway, antiFraud) {
|
|
46
46
|
this._3Dsecure = "active_3dsecure";
|
|
47
47
|
this._cardNumber = "card.number";
|
|
48
48
|
this._sandboxEnable = false;
|
|
@@ -50,7 +50,6 @@ let CardService = CardService_1 = class CardService {
|
|
|
50
50
|
this._paymentSetupCompleteEvent = "payments.setupComplete";
|
|
51
51
|
this._gateway = gateway;
|
|
52
52
|
this._antiFraud = antiFraud;
|
|
53
|
-
this._authService = authService;
|
|
54
53
|
this._receipt = {
|
|
55
54
|
amount: "totalAmount",
|
|
56
55
|
"card.cvc": "card.cvv",
|
|
@@ -84,37 +83,28 @@ let CardService = CardService_1 = class CardService {
|
|
|
84
83
|
this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
85
84
|
return rxjs_1.forkJoin([
|
|
86
85
|
this._getScienceSession(request, mid, isTest, merchant),
|
|
87
|
-
this._getCybersourceJwt(merchant, mid, isTest, regional,
|
|
88
|
-
? request.card.number
|
|
89
|
-
: undefined),
|
|
86
|
+
this._getCybersourceJwt(merchant, mid, isTest, regional, request.card.number),
|
|
90
87
|
rxjs_1.of(merchant),
|
|
91
88
|
]);
|
|
92
89
|
}), operators_1.mergeMap(([sift_object, jwt, merchant]) => {
|
|
93
90
|
request.isDeferred =
|
|
94
91
|
request.isDeferred === undefined ? false : request.isDeferred;
|
|
95
|
-
if (Boolean(request.cvv))
|
|
96
|
-
request.card = { cvc: request.cvv };
|
|
97
92
|
this._checkRequestBody(request);
|
|
98
93
|
const data_to_transform = Object.assign(Object.assign({}, request), sift_object);
|
|
99
94
|
if (jwt !== undefined)
|
|
100
95
|
data_to_transform.jwt = jwt;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
request.walletId
|
|
104
|
-
? this._authService.getAuthorizationToken()
|
|
105
|
-
: rxjs_1.of(undefined),
|
|
106
|
-
rxjs_1.of(merchant),
|
|
107
|
-
]);
|
|
96
|
+
const final_request = dot.transform(this._receipt, Object.assign(Object.assign({}, data_to_transform), { merchantName: merchant.merchant_name }));
|
|
97
|
+
return rxjs_1.of({ final_request, merchant });
|
|
108
98
|
}))
|
|
109
99
|
.subscribe({
|
|
110
100
|
error: (err) => Kushki_1.Kushki.callbackError(err, callback),
|
|
111
|
-
next: (
|
|
101
|
+
next: ({ final_request, merchant, }) => {
|
|
112
102
|
if (final_request.jwt && !merchant.sandboxEnable)
|
|
113
103
|
this._request3DSToken(() => {
|
|
114
|
-
this._requestTokenGateway(final_request, mid, isTest, regional, callback
|
|
104
|
+
this._requestTokenGateway(final_request, mid, isTest, regional, callback);
|
|
115
105
|
});
|
|
116
106
|
else
|
|
117
|
-
this._requestTokenGateway(final_request, mid, isTest, regional, callback
|
|
107
|
+
this._requestTokenGateway(final_request, mid, isTest, regional, callback);
|
|
118
108
|
},
|
|
119
109
|
});
|
|
120
110
|
}
|
|
@@ -164,23 +154,18 @@ let CardService = CardService_1 = class CardService {
|
|
|
164
154
|
const data_to_transform = this._getCreateSubscriptionDataToTransform(sift_object, subscriptionTokenRequest);
|
|
165
155
|
if (jwt !== undefined)
|
|
166
156
|
data_to_transform.jwt = jwt;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
subscriptionTokenRequest.walletId
|
|
170
|
-
? this._authService.getAuthorizationToken()
|
|
171
|
-
: rxjs_1.of(undefined),
|
|
172
|
-
rxjs_1.of(merchant),
|
|
173
|
-
]);
|
|
157
|
+
const body = dot.transform(this._receipt, Object.assign(Object.assign({}, data_to_transform), { merchantName: merchant.merchant_name }));
|
|
158
|
+
return rxjs_1.of({ body, merchant });
|
|
174
159
|
}))
|
|
175
160
|
.subscribe({
|
|
176
161
|
error: (err) => Kushki_1.Kushki.callbackError(err, callback),
|
|
177
|
-
next: (
|
|
162
|
+
next: ({ body, merchant, }) => {
|
|
178
163
|
if (body.jwt && !merchant.sandboxEnable)
|
|
179
164
|
this._request3DSToken(() => {
|
|
180
|
-
this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback
|
|
165
|
+
this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback);
|
|
181
166
|
});
|
|
182
167
|
else
|
|
183
|
-
this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback
|
|
168
|
+
this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback);
|
|
184
169
|
},
|
|
185
170
|
});
|
|
186
171
|
}
|
|
@@ -239,8 +224,8 @@ let CardService = CardService_1 = class CardService {
|
|
|
239
224
|
});
|
|
240
225
|
}
|
|
241
226
|
// istanbul ignore next
|
|
242
|
-
_requestTokenGateway(body, mid, testEnv, regional, callback
|
|
243
|
-
const request_token = this._gateway.requestToken(body, mid, testEnv, regional
|
|
227
|
+
_requestTokenGateway(body, mid, testEnv, regional, callback) {
|
|
228
|
+
const request_token = this._gateway.requestToken(body, mid, testEnv, regional);
|
|
244
229
|
return request_token.subscribe({
|
|
245
230
|
error: (err) => Kushki_1.Kushki.callbackError(err, callback),
|
|
246
231
|
next: (response) => {
|
|
@@ -276,14 +261,7 @@ let CardService = CardService_1 = class CardService {
|
|
|
276
261
|
throw new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS[ErrorEnum_1.ErrorCode.E014]);
|
|
277
262
|
}
|
|
278
263
|
_getScienceSession(request, mid, isTest, merchant) {
|
|
279
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(() =>
|
|
280
|
-
if (request.card && request.card.number !== undefined)
|
|
281
|
-
return this._antiFraud.createSiftScienceSession(UtilsService_1.getBinFromCreditCardNumberSift(request.card.number), request.card.number.slice(-4), mid, isTest, merchant);
|
|
282
|
-
return rxjs_1.of({
|
|
283
|
-
sessionId: null,
|
|
284
|
-
userId: null,
|
|
285
|
-
});
|
|
286
|
-
}));
|
|
264
|
+
return rxjs_1.of(1).pipe(operators_1.switchMap(() => this._antiFraud.createSiftScienceSession(UtilsService_1.getBinFromCreditCardNumberSift(request.card.number), request.card.number.slice(-4), mid, isTest, merchant)));
|
|
287
265
|
}
|
|
288
266
|
_checkCurrency(request) {
|
|
289
267
|
request.currency =
|
|
@@ -301,8 +279,7 @@ let CardService = CardService_1 = class CardService {
|
|
|
301
279
|
}
|
|
302
280
|
_checkRequestBody(request) {
|
|
303
281
|
this._checkCurrency(request);
|
|
304
|
-
|
|
305
|
-
this._checkCardLength(request);
|
|
282
|
+
this._checkCardLength(request);
|
|
306
283
|
this._checkAmount(request);
|
|
307
284
|
}
|
|
308
285
|
_getCybersourceJwt(merchantSettings, mid, isTest, regional, cardNumber) {
|
|
@@ -464,9 +441,9 @@ let CardService = CardService_1 = class CardService {
|
|
|
464
441
|
_getUserId(subscriptionId, mid, testEnv, regional, userId) {
|
|
465
442
|
return rxjs_1.of(1).pipe(operators_1.switchMap(() => rxjs_1.iif(() => UtilsService_1.UtilsService.sIsEmpty(userId), this._gateway.getUserId(subscriptionId, mid, testEnv, regional), rxjs_1.of(undefined))), operators_1.catchError(() => rxjs_1.of(undefined)));
|
|
466
443
|
}
|
|
467
|
-
_requestSubscriptionTokenGateway(body, mid, testEnv, regional, callback
|
|
444
|
+
_requestSubscriptionTokenGateway(body, mid, testEnv, regional, callback) {
|
|
468
445
|
this._gateway
|
|
469
|
-
.requestSubscriptionToken(body, mid, testEnv, regional
|
|
446
|
+
.requestSubscriptionToken(body, mid, testEnv, regional)
|
|
470
447
|
.subscribe({
|
|
471
448
|
error: (err) => Kushki_1.Kushki.callbackError(err, callback),
|
|
472
449
|
next: (response) => {
|
|
@@ -491,8 +468,7 @@ let CardService = CardService_1 = class CardService {
|
|
|
491
468
|
CardService = CardService_1 = __decorate([
|
|
492
469
|
inversify_1.injectable(),
|
|
493
470
|
__param(0, inversify_1.inject(Identifiers_1.IDENTIFIERS.KushkiGateway)),
|
|
494
|
-
__param(1, inversify_1.inject(Identifiers_1.IDENTIFIERS.
|
|
495
|
-
|
|
496
|
-
__metadata("design:paramtypes", [Object, Object, Object])
|
|
471
|
+
__param(1, inversify_1.inject(Identifiers_1.IDENTIFIERS.AntiFraud)),
|
|
472
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
497
473
|
], CardService);
|
|
498
474
|
exports.CardService = CardService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kushki/js",
|
|
3
|
-
"version": "1.40.
|
|
3
|
+
"version": "1.40.4",
|
|
4
4
|
"description": "kushki-js",
|
|
5
5
|
"main": "lib/lib.js",
|
|
6
6
|
"types": "lib/lib.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"build:cdn": "webpack --optimize-minimize",
|
|
37
37
|
"build:npm": "npm run tsc:interface && gulp",
|
|
38
38
|
"postinstall": "echo postinstall",
|
|
39
|
-
"depcheck": "depcheck . --ignores=\"serverless-*,@types/*,@kushki/*,rollbar,aws-lambda,prettier,chai,husky,express,lint-staged,ajv,ts-loader,tslint-config-prettier,infrastructure,constant,middleware,core,gateway,service,error,moment-timezone,moment,faker, numeral,dot-object
|
|
39
|
+
"depcheck": "depcheck . --ignores=\"serverless-*,@types/*,@kushki/*,rollbar,aws-lambda,prettier,chai,husky,express,lint-staged,ajv,ts-loader,tslint-config-prettier,infrastructure,constant,middleware,core,gateway,service,error,moment-timezone,moment,faker, numeral,dot-object\""
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@kushki/cli": "1.4.1",
|
|
@@ -97,11 +97,9 @@
|
|
|
97
97
|
"webpack-dev-server": "3.3.1"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@aws-amplify/auth": "4.6.1",
|
|
101
100
|
"@kushki/cardinal-sandbox-js": "1.0.6",
|
|
102
101
|
"acorn": "6.4.1",
|
|
103
|
-
"
|
|
104
|
-
"axios": "0.21.3",
|
|
102
|
+
"axios": "0.27.2",
|
|
105
103
|
"buffer": "^6.0.3",
|
|
106
104
|
"ci": "^2.1.1",
|
|
107
105
|
"dot-object": "2.1.4",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CognitoErrorEnum = void 0;
|
|
4
|
-
var CognitoErrorEnum;
|
|
5
|
-
(function (CognitoErrorEnum) {
|
|
6
|
-
CognitoErrorEnum["UsernameExistsException"] = "UsernameExistsException";
|
|
7
|
-
})(CognitoErrorEnum = exports.CognitoErrorEnum || (exports.CognitoErrorEnum = {}));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KPayUserPoolEnum = void 0;
|
|
4
|
-
var KPayUserPoolEnum;
|
|
5
|
-
(function (KPayUserPoolEnum) {
|
|
6
|
-
KPayUserPoolEnum["uat"] = "https://kushki-static-dev.s3.amazonaws.com/kpay/kpay_user_pool_dev.json";
|
|
7
|
-
KPayUserPoolEnum["prod"] = "https://kushki-static.s3.amazonaws.com/kpay/kpay_user_pool_prod.json";
|
|
8
|
-
})(KPayUserPoolEnum = exports.KPayUserPoolEnum || (exports.KPayUserPoolEnum = {}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KpayPaymentKind = void 0;
|
|
4
|
-
var KpayPaymentKind;
|
|
5
|
-
(function (KpayPaymentKind) {
|
|
6
|
-
KpayPaymentKind["CARD"] = "card";
|
|
7
|
-
KpayPaymentKind["TRANSFER"] = "transfer";
|
|
8
|
-
KpayPaymentKind["CASH"] = "cash";
|
|
9
|
-
})(KpayPaymentKind = exports.KpayPaymentKind || (exports.KpayPaymentKind = {}));
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* tslint:disable:all */
|
|
2
|
-
/**
|
|
3
|
-
* ICardService file.
|
|
4
|
-
*/
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
|
-
import { InitAuthRequest } from "./../../lib/types/init_auth_request";
|
|
7
|
-
import { InitAuthResponse } from "./../../lib/types/init_auth_response";
|
|
8
|
-
import { ValidateSessionResponse } from "./../../lib/types/validate_session_response";
|
|
9
|
-
import { VerifyAuthResponse } from "./../../lib/types/verify_auth_response";
|
|
10
|
-
export interface IAuthService {
|
|
11
|
-
/**
|
|
12
|
-
* Get Log in credentials
|
|
13
|
-
* @param body - required mail from user and name as a optional value
|
|
14
|
-
* @param isTestEnvironment
|
|
15
|
-
*/
|
|
16
|
-
requestInitAuth(body: InitAuthRequest, isTestEnvironment: boolean): Observable<InitAuthResponse>;
|
|
17
|
-
requestVerifyAuth(code: string, isTestEnvironment: boolean): Observable<VerifyAuthResponse>;
|
|
18
|
-
validateSession(isTestEnvironment: boolean): Observable<ValidateSessionResponse>;
|
|
19
|
-
getAuthorizationToken(): Observable<string>;
|
|
20
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* tslint:disable:all */
|
|
2
|
-
/**
|
|
3
|
-
* ICardService file.
|
|
4
|
-
*/
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
|
-
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
7
|
-
import { PaymentDataResponse } from "./../../lib/types/payment_data_response";
|
|
8
|
-
import { SavedPaymentMethodRequest } from "./../../lib/types/saved_payment_data_request";
|
|
9
|
-
export interface IKPayService {
|
|
10
|
-
/**
|
|
11
|
-
* deletePaymentMethod from user
|
|
12
|
-
* @param body - delete payment method id
|
|
13
|
-
* @param mid - public merchant id
|
|
14
|
-
* @param isTest - is test environment
|
|
15
|
-
* @param regional - Define if endpoint used regional URL
|
|
16
|
-
*/
|
|
17
|
-
deletePaymentMethod(body: DeletePaymentMethodRequest, mid: string, isTest: boolean, regional: boolean): Observable<boolean>;
|
|
18
|
-
/**
|
|
19
|
-
* requestSavedPaymentMethods from user
|
|
20
|
-
* @param body - user email and payment kind
|
|
21
|
-
* @param mid - public merchant id
|
|
22
|
-
* @param isTest - is test environment
|
|
23
|
-
* @param regional - Define if endpoint used regional URL
|
|
24
|
-
*/
|
|
25
|
-
requestSavedPaymentMethods(body: SavedPaymentMethodRequest, mid: string, isTest: boolean, regional: boolean): Observable<PaymentDataResponse[]>;
|
|
26
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* tslint:disable:all */
|
|
2
|
-
import "reflect-metadata";
|
|
3
|
-
import { IAuthService } from "./../../lib/repository/IAuthService";
|
|
4
|
-
import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
|
-
import { InitAuthRequest } from "./../../lib/types/init_auth_request";
|
|
7
|
-
import { InitAuthResponse } from "./../../lib/types/init_auth_response";
|
|
8
|
-
import { ValidateSessionResponse } from "./../../lib/types/validate_session_response";
|
|
9
|
-
import { VerifyAuthResponse } from "./../../lib/types/verify_auth_response";
|
|
10
|
-
/**
|
|
11
|
-
* Implementation
|
|
12
|
-
*/
|
|
13
|
-
export declare class AuthService implements IAuthService {
|
|
14
|
-
private readonly _gateway;
|
|
15
|
-
private _cognitoUser?;
|
|
16
|
-
constructor(gateway: IKushkiGateway);
|
|
17
|
-
requestInitAuth(body: InitAuthRequest, isTestEnvironment: boolean): Observable<InitAuthResponse>;
|
|
18
|
-
requestVerifyAuth(code: string, isTestEnvironment: boolean): Observable<VerifyAuthResponse>;
|
|
19
|
-
validateSession(isTestEnvironment: boolean): Observable<ValidateSessionResponse>;
|
|
20
|
-
getAuthorizationToken(): Observable<string>;
|
|
21
|
-
private _currentAuthenticatedUser;
|
|
22
|
-
private _verifyCurrentSession;
|
|
23
|
-
private _handleInitAuth;
|
|
24
|
-
private _validateCurrentSession;
|
|
25
|
-
private _getCurrentUserEmail;
|
|
26
|
-
private _signOut;
|
|
27
|
-
private _userSignIn;
|
|
28
|
-
private _userSignInPasswordles;
|
|
29
|
-
private static _configureAmplifyCredentials;
|
|
30
|
-
private static _getRandomString;
|
|
31
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
var AuthService_1;
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.AuthService = void 0;
|
|
26
|
-
const aws_amplify_1 = require("aws-amplify");
|
|
27
|
-
const axios_1 = require("axios");
|
|
28
|
-
const Identifiers_1 = require("./../../lib/constant/Identifiers");
|
|
29
|
-
const KushkiError_1 = require("./../../lib/generic/KushkiError");
|
|
30
|
-
const CognitoErrorEnum_1 = require("./../../lib/infrastructure/CognitoErrorEnum");
|
|
31
|
-
const ErrorEnum_1 = require("./../../lib/infrastructure/ErrorEnum");
|
|
32
|
-
const KPayUserPoolEnum_1 = require("./../../lib/infrastructure/KPayUserPoolEnum");
|
|
33
|
-
const inversify_1 = require("inversify");
|
|
34
|
-
require("reflect-metadata");
|
|
35
|
-
const rxjs_1 = require("rxjs");
|
|
36
|
-
const operators_1 = require("rxjs/operators");
|
|
37
|
-
const UtilsService_1 = require("./../../lib/service/UtilsService");
|
|
38
|
-
/**
|
|
39
|
-
* Implementation
|
|
40
|
-
*/
|
|
41
|
-
let AuthService = AuthService_1 = class AuthService {
|
|
42
|
-
constructor(gateway) {
|
|
43
|
-
this._gateway = gateway;
|
|
44
|
-
}
|
|
45
|
-
requestInitAuth(body, isTestEnvironment) {
|
|
46
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => AuthService_1._configureAmplifyCredentials(isTestEnvironment)), operators_1.mergeMap(() => this._validateCurrentSession(body.email)), operators_1.mergeMap(sessionJwt => rxjs_1.iif(() => !!sessionJwt, rxjs_1.of({ result: true }), this._handleInitAuth(body.email))));
|
|
47
|
-
}
|
|
48
|
-
requestVerifyAuth(code, isTestEnvironment) {
|
|
49
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(() => AuthService_1._configureAmplifyCredentials(isTestEnvironment)), operators_1.concatMap(() => rxjs_1.from(aws_amplify_1.Auth.sendCustomChallengeAnswer(this._cognitoUser, code))), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E009))), operators_1.concatMap(() => this._verifyCurrentSession()), operators_1.map(session => ({
|
|
50
|
-
authorization: session.getRefreshToken().getToken(),
|
|
51
|
-
})));
|
|
52
|
-
}
|
|
53
|
-
validateSession(isTestEnvironment) {
|
|
54
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(() => AuthService_1._configureAmplifyCredentials(isTestEnvironment)), operators_1.concatMap(() => this._getCurrentUserEmail()));
|
|
55
|
-
}
|
|
56
|
-
getAuthorizationToken() {
|
|
57
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => this._currentAuthenticatedUser()), operators_1.mergeMap((cognitoUser) => {
|
|
58
|
-
const session = cognitoUser ? cognitoUser.getSignInUserSession() : null;
|
|
59
|
-
if (!session)
|
|
60
|
-
return rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011));
|
|
61
|
-
return rxjs_1.of(session.getAccessToken().getJwtToken());
|
|
62
|
-
}), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011))));
|
|
63
|
-
}
|
|
64
|
-
_currentAuthenticatedUser() {
|
|
65
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => rxjs_1.from(aws_amplify_1.Auth.currentAuthenticatedUser())));
|
|
66
|
-
}
|
|
67
|
-
_verifyCurrentSession() {
|
|
68
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(() => rxjs_1.from(aws_amplify_1.Auth.currentSession())), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E008))));
|
|
69
|
-
}
|
|
70
|
-
_handleInitAuth(email) {
|
|
71
|
-
const password = AuthService_1._getRandomString();
|
|
72
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => {
|
|
73
|
-
const user_attributes = {
|
|
74
|
-
"custom:merchant": email,
|
|
75
|
-
given_name: email,
|
|
76
|
-
preferred_username: email,
|
|
77
|
-
};
|
|
78
|
-
const params = {
|
|
79
|
-
password,
|
|
80
|
-
attributes: user_attributes,
|
|
81
|
-
username: email,
|
|
82
|
-
};
|
|
83
|
-
return rxjs_1.from(aws_amplify_1.Auth.signUp(params));
|
|
84
|
-
}), operators_1.concatMap(() => this._userSignIn(email, password)), operators_1.concatMap((cognitoUser) => {
|
|
85
|
-
this._cognitoUser = cognitoUser;
|
|
86
|
-
return cognitoUser
|
|
87
|
-
.getSignInUserSession()
|
|
88
|
-
.getAccessToken()
|
|
89
|
-
.getJwtToken();
|
|
90
|
-
}), operators_1.concatMap((authorization) => rxjs_1.iif(() => !!authorization, rxjs_1.of({ result: true }), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E001)))), operators_1.catchError((error) => {
|
|
91
|
-
const error_code = UtilsService_1.UtilsService.sGet(error, "code", "");
|
|
92
|
-
return rxjs_1.iif(() => error_code === CognitoErrorEnum_1.CognitoErrorEnum.UsernameExistsException, this._userSignInPasswordles(email), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E007)));
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
_validateCurrentSession(email) {
|
|
96
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(() => aws_amplify_1.Auth.currentSession()), operators_1.concatMap(session => rxjs_1.forkJoin([rxjs_1.of(session), rxjs_1.from(aws_amplify_1.Auth.currentUserInfo())])), operators_1.concatMap(([session, current_user_info]) => {
|
|
97
|
-
if (email &&
|
|
98
|
-
current_user_info.attributes.email.toLowerCase() !==
|
|
99
|
-
email.toLowerCase())
|
|
100
|
-
return this._signOut();
|
|
101
|
-
return rxjs_1.of(session.getAccessToken().getJwtToken());
|
|
102
|
-
}), operators_1.catchError(() => this._signOut()));
|
|
103
|
-
}
|
|
104
|
-
_getCurrentUserEmail() {
|
|
105
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(() => aws_amplify_1.Auth.currentUserInfo()), operators_1.concatMap(currentInfo => rxjs_1.iif(() => !!currentInfo.attributes.email, rxjs_1.of({
|
|
106
|
-
email: currentInfo.attributes.email.toLowerCase(),
|
|
107
|
-
}), rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011)))), operators_1.catchError(() => rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E011))));
|
|
108
|
-
}
|
|
109
|
-
_signOut() {
|
|
110
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(() => aws_amplify_1.Auth.signOut()), operators_1.mapTo(false));
|
|
111
|
-
}
|
|
112
|
-
_userSignIn(email, password) {
|
|
113
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(() => rxjs_1.from(aws_amplify_1.Auth.signIn(email, password))));
|
|
114
|
-
}
|
|
115
|
-
_userSignInPasswordles(email) {
|
|
116
|
-
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => rxjs_1.from(aws_amplify_1.Auth.signIn(email))), operators_1.mergeMap((cognitoUser) => {
|
|
117
|
-
this._cognitoUser = cognitoUser;
|
|
118
|
-
return rxjs_1.throwError(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E010));
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
static _configureAmplifyCredentials(test) {
|
|
122
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
const remote_kpay_user_pool_url = `${test ? KPayUserPoolEnum_1.KPayUserPoolEnum.uat : KPayUserPoolEnum_1.KPayUserPoolEnum.prod}`;
|
|
124
|
-
const { data: cognito_config } = yield axios_1.default.get(remote_kpay_user_pool_url);
|
|
125
|
-
const auth = {
|
|
126
|
-
cognito: {
|
|
127
|
-
APP_CLIENT_ID: cognito_config.appClientId,
|
|
128
|
-
REGION: cognito_config.region,
|
|
129
|
-
USER_POOL_ID: cognito_config.userPoolId,
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
aws_amplify_1.Auth.configure({
|
|
133
|
-
Auth: {
|
|
134
|
-
mandatorySignId: true,
|
|
135
|
-
region: auth.cognito.REGION,
|
|
136
|
-
storage: UtilsService_1.UtilsService.sIsEmpty(window) ? "" : window.sessionStorage,
|
|
137
|
-
userPoolId: auth.cognito.USER_POOL_ID,
|
|
138
|
-
userPoolWebClientId: auth.cognito.APP_CLIENT_ID,
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
static _getRandomString() {
|
|
144
|
-
return (
|
|
145
|
-
// tslint:disable-next-line:insecure-random
|
|
146
|
-
Math.random()
|
|
147
|
-
.toString(36)
|
|
148
|
-
.slice(2) +
|
|
149
|
-
// tslint:disable-next-line:insecure-random
|
|
150
|
-
Math.random()
|
|
151
|
-
.toString(36)
|
|
152
|
-
.toUpperCase()
|
|
153
|
-
.slice(2));
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
AuthService = AuthService_1 = __decorate([
|
|
157
|
-
inversify_1.injectable(),
|
|
158
|
-
__param(0, inversify_1.inject(Identifiers_1.IDENTIFIERS.KushkiGateway)),
|
|
159
|
-
__metadata("design:paramtypes", [Object])
|
|
160
|
-
], AuthService);
|
|
161
|
-
exports.AuthService = AuthService;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* tslint:disable:all */
|
|
2
|
-
import "reflect-metadata";
|
|
3
|
-
import { IAuthService } from "./../../lib/repository/IAuthService";
|
|
4
|
-
import { IKPayService } from "./../../lib/repository/IKPayService";
|
|
5
|
-
import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
|
|
6
|
-
import { Observable } from "rxjs";
|
|
7
|
-
import { DeletePaymentMethodRequest } from "./../../lib/types/delete_payment_method_request";
|
|
8
|
-
import { PaymentDataResponse } from "./../../lib/types/payment_data_response";
|
|
9
|
-
import { SavedPaymentMethodRequest } from "./../../lib/types/saved_payment_data_request";
|
|
10
|
-
/**
|
|
11
|
-
* Implementation
|
|
12
|
-
*/
|
|
13
|
-
export declare class KPayService implements IKPayService {
|
|
14
|
-
private readonly _gateway;
|
|
15
|
-
private readonly _authService;
|
|
16
|
-
constructor(gateway: IKushkiGateway, authService: IAuthService);
|
|
17
|
-
deletePaymentMethod(body: DeletePaymentMethodRequest, mid: string, isTest: boolean, regional: boolean): Observable<boolean>;
|
|
18
|
-
requestSavedPaymentMethods(body: SavedPaymentMethodRequest, mid: string, isTest: boolean, regional: boolean): Observable<PaymentDataResponse[]>;
|
|
19
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.KPayService = void 0;
|
|
16
|
-
/**
|
|
17
|
-
* Kushki Service file
|
|
18
|
-
*/
|
|
19
|
-
const Identifiers_1 = require("./../../lib/constant/Identifiers");
|
|
20
|
-
const inversify_1 = require("inversify");
|
|
21
|
-
require("reflect-metadata");
|
|
22
|
-
const rxjs_1 = require("rxjs");
|
|
23
|
-
const operators_1 = require("rxjs/operators");
|
|
24
|
-
/**
|
|
25
|
-
* Implementation
|
|
26
|
-
*/
|
|
27
|
-
let KPayService = class KPayService {
|
|
28
|
-
constructor(gateway, authService) {
|
|
29
|
-
this._gateway = gateway;
|
|
30
|
-
this._authService = authService;
|
|
31
|
-
}
|
|
32
|
-
deletePaymentMethod(body, mid, isTest, regional) {
|
|
33
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(() => this._authService.getAuthorizationToken()), operators_1.concatMap(jwt => this._gateway.deletePaymentMethod(body, isTest, regional, mid, jwt)));
|
|
34
|
-
}
|
|
35
|
-
requestSavedPaymentMethods(body, mid, isTest, regional) {
|
|
36
|
-
return this._gateway.requestSavedPaymentMethods(body, isTest, regional, mid);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
KPayService = __decorate([
|
|
40
|
-
inversify_1.injectable(),
|
|
41
|
-
__param(0, inversify_1.inject(Identifiers_1.IDENTIFIERS.KushkiGateway)),
|
|
42
|
-
__param(1, inversify_1.inject(Identifiers_1.IDENTIFIERS.AuthService)),
|
|
43
|
-
__metadata("design:paramtypes", [Object, Object])
|
|
44
|
-
], KPayService);
|
|
45
|
-
exports.KPayService = KPayService;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/* tslint:disable:all */
|
|
2
|
-
/* tslint:disable:all */
|
|
3
|
-
|
|
4
|
-
export type PaymentDataResponse = CardPaymentDataResponse | TransferPaymentDataResponse | CashPaymentDataResponse;
|
|
5
|
-
|
|
6
|
-
export interface CardPaymentDataResponse {
|
|
7
|
-
id: string;
|
|
8
|
-
email: string;
|
|
9
|
-
kind: "card";
|
|
10
|
-
brand: string;
|
|
11
|
-
cardHolderName: string;
|
|
12
|
-
expDate: string;
|
|
13
|
-
lastFourDigits: string;
|
|
14
|
-
maskedCardNumber: string;
|
|
15
|
-
}
|
|
16
|
-
export interface TransferPaymentDataResponse {
|
|
17
|
-
id: string;
|
|
18
|
-
bankId: string;
|
|
19
|
-
brand: string;
|
|
20
|
-
documentNumber: string;
|
|
21
|
-
documentType: string;
|
|
22
|
-
email: string;
|
|
23
|
-
kind: "transfer";
|
|
24
|
-
name: string;
|
|
25
|
-
userType: string;
|
|
26
|
-
}
|
|
27
|
-
export interface CashPaymentDataResponse {
|
|
28
|
-
id: string;
|
|
29
|
-
brand: string;
|
|
30
|
-
documentNumber: string;
|
|
31
|
-
documentType: string;
|
|
32
|
-
email: string;
|
|
33
|
-
kind: "cash";
|
|
34
|
-
name: string;
|
|
35
|
-
firstName?: string;
|
|
36
|
-
lastName?: string;
|
|
37
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* tslint:disable:all */
|
|
2
|
-
/* tslint:disable:all */
|
|
3
|
-
|
|
4
|
-
export interface SubscriptionTokenKPayRequest {
|
|
5
|
-
walletId: string;
|
|
6
|
-
currency?: "USD" | "COP" | "CLP" | "UF" | "PEN" | "MXN" | "CRC" | "GTQ" | "HNL" | "NIO" | "PAB" | "BRL";
|
|
7
|
-
userId?: string;
|
|
8
|
-
sessionId?: string;
|
|
9
|
-
card?: {
|
|
10
|
-
cvc: string;
|
|
11
|
-
};
|
|
12
|
-
[k: string]: any;
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* tslint:disable:all */
|
|
2
|
-
/* tslint:disable:all */
|
|
3
|
-
|
|
4
|
-
export interface TokenKPayRequest {
|
|
5
|
-
walletId: string;
|
|
6
|
-
currency?: "USD" | "COP" | "CLP" | "UF" | "PEN" | "MXN" | "BRL" | "CRC" | "GTQ" | "HNL" | "NIO" | "PAB";
|
|
7
|
-
isDeferred?: boolean;
|
|
8
|
-
amount: number | string;
|
|
9
|
-
months?: number;
|
|
10
|
-
cvv?: string;
|
|
11
|
-
[k: string]: any;
|
|
12
|
-
}
|