@kushki/js 1.40.2-alpha.1 → 1.40.3-alpha
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 +19 -2
- package/lib/Kushki.js +17 -0
- package/lib/KushkiInfo.js +1 -1
- package/lib/constant/Identifiers.d.ts +2 -0
- package/lib/constant/Identifiers.js +2 -0
- package/lib/gateway/KushkiGateway.d.ts +8 -2
- package/lib/gateway/KushkiGateway.js +21 -1
- package/lib/infrastructure/CognitoErrorEnum.d.ts +4 -0
- package/lib/infrastructure/CognitoErrorEnum.js +7 -0
- package/lib/infrastructure/Container.js +5 -1
- package/lib/infrastructure/KPayUserPoolEnum.d.ts +5 -0
- package/lib/infrastructure/KPayUserPoolEnum.js +8 -0
- package/lib/infrastructure/KpayPaymentKind.d.ts +6 -0
- package/lib/infrastructure/KpayPaymentKind.js +9 -0
- package/lib/infrastructure/PathEnum.d.ts +3 -0
- package/lib/infrastructure/PathEnum.js +3 -0
- package/lib/repository/IAuthService.d.ts +20 -0
- package/lib/repository/IAuthService.js +2 -0
- package/lib/repository/ICardService.d.ts +5 -3
- package/lib/repository/IKPayService.d.ts +26 -0
- package/lib/repository/IKPayService.js +2 -0
- package/lib/repository/IKushkiGateway.d.ts +24 -2
- package/lib/service/ApplePayService.js +1 -1
- package/lib/service/AuthService.d.ts +31 -0
- package/lib/service/AuthService.js +161 -0
- package/lib/service/CardService.d.ts +7 -3
- package/lib/service/CardService.js +26 -8
- package/lib/service/KPayService.d.ts +19 -0
- package/lib/service/KPayService.js +45 -0
- package/lib/types/apple_pay_get_token_events.d.ts +12 -4
- package/lib/types/delete_payment_method_request.d.ts +6 -0
- package/lib/types/payment_data_response.d.ts +37 -0
- package/lib/types/saved_payment_data_request.d.ts +10 -0
- package/lib/types/subscription_token_kpay_request.d.ts +13 -0
- package/lib/types/token_kpay_request.d.ts +12 -0
- package/package.json +5 -3
package/lib/Kushki.d.ts
CHANGED
|
@@ -15,12 +15,16 @@ 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";
|
|
18
19
|
import { DeviceTokenRequest } from "./../lib/types/device_token_request";
|
|
19
20
|
import { ErrorResponse } from "./../lib/types/error_response";
|
|
20
21
|
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";
|
|
21
24
|
import { KushkiInfo } from "./../lib/types/kushki_info";
|
|
22
25
|
import { MultiMerchantInfoRequest } from "./../lib/types/multimerchant_info_request";
|
|
23
26
|
import { MultiMerchantInfoResponse } from "./../lib/types/multimerchant_info_response";
|
|
27
|
+
import { PaymentDataResponse } from "./../lib/types/payment_data_response";
|
|
24
28
|
import { PayoutsCashTokenRequest } from "./../lib/types/payouts_cash_request";
|
|
25
29
|
import { PayoutsTransferTokenRequest } from "./../lib/types/payouts_transfer_token_request";
|
|
26
30
|
import { CommissionConfigurationAmount } from "./../lib/types/remote/commission_configuration_amount";
|
|
@@ -29,6 +33,7 @@ import { IDeferredResponse } from "./../lib/types/remote/deferred_response";
|
|
|
29
33
|
import { TokenResponse } from "./../lib/types/remote/token_response";
|
|
30
34
|
import { TransferTokenRequest } from "./../lib/types/remote/transfer_token_request";
|
|
31
35
|
import { ResponseStatusValidator } from "./../lib/types/response_status_validator";
|
|
36
|
+
import { SavedPaymentMethodRequest } from "./../lib/types/saved_payment_data_request";
|
|
32
37
|
import { SecureInitRequest } from "./../lib/types/secure_init_request";
|
|
33
38
|
import { SecureInitResponse } from "./../lib/types/secure_init_response";
|
|
34
39
|
import { SecureOtpRequest } from "./../lib/types/secure_otp_request";
|
|
@@ -36,12 +41,17 @@ import { SecureOtpResponse } from "./../lib/types/secure_otp_response";
|
|
|
36
41
|
import { SiftScienceAntiFraudSessionResponse } from "./../lib/types/sift_science_session";
|
|
37
42
|
import { SubscriptionCardAsyncTokenRequest } from "./../lib/types/subscription_card_async_token_request";
|
|
38
43
|
import { SubscriptionCardAsyncTokenResponse } from "./../lib/types/subscription_card_async_token_response";
|
|
44
|
+
import { SubscriptionTokenKPayRequest } from "./../lib/types/subscription_token_kpay_request";
|
|
39
45
|
import { SubscriptionTokenRequest } from "./../lib/types/subscription_token_request";
|
|
40
46
|
import { TokenChargeRequest } from "./../lib/types/token_charge_request";
|
|
47
|
+
import { TokenKPayRequest } from "./../lib/types/token_kpay_request";
|
|
41
48
|
import { TokenRequest } from "./../lib/types/token_request";
|
|
42
49
|
import { TransferSubscriptionTokenRequest } from "./../lib/types/transfer_subscription_token_request";
|
|
43
50
|
import { Validate3DSRequest } from "./../lib/types/validate_3ds_request";
|
|
44
51
|
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";
|
|
45
55
|
/**
|
|
46
56
|
* Implementation
|
|
47
57
|
*/
|
|
@@ -60,6 +70,8 @@ export declare class Kushki {
|
|
|
60
70
|
private readonly _payoutsCashService;
|
|
61
71
|
private readonly _transferSubscriptionService;
|
|
62
72
|
private readonly _payoutsTransferService;
|
|
73
|
+
private readonly _kPayService;
|
|
74
|
+
private readonly _authService;
|
|
63
75
|
private readonly _cardDynamicService;
|
|
64
76
|
private readonly _cardSubscriptionDynamicService;
|
|
65
77
|
private readonly _siftScience;
|
|
@@ -70,7 +82,7 @@ export declare class Kushki {
|
|
|
70
82
|
regional?: boolean;
|
|
71
83
|
kushkiInfo?: KushkiInfo;
|
|
72
84
|
});
|
|
73
|
-
requestToken(body: TokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
85
|
+
requestToken(body: TokenRequest | TokenKPayRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
74
86
|
requestInitAntiFraud(userId: string, callback: (value: SiftScienceAntiFraudSessionResponse | ErrorResponse) => void): void;
|
|
75
87
|
/**
|
|
76
88
|
* @deprecated use requestDeviceToken instead
|
|
@@ -80,7 +92,7 @@ export declare class Kushki {
|
|
|
80
92
|
*/
|
|
81
93
|
requestTokenCharge(body: TokenChargeRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
82
94
|
requestDeviceToken(body: DeviceTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
83
|
-
requestSubscriptionToken(body: SubscriptionTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
95
|
+
requestSubscriptionToken(body: SubscriptionTokenRequest | SubscriptionTokenKPayRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
84
96
|
requestTransferToken(body: TransferTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
85
97
|
checkStatus(callback: (value: ResponseStatusValidator | ErrorResponse) => void): void;
|
|
86
98
|
/**
|
|
@@ -114,6 +126,11 @@ export declare class Kushki {
|
|
|
114
126
|
requestMobileProcessorToken(_body: object, callback: (value: ErrorResponse) => void): void;
|
|
115
127
|
requestCardDynamicToken(bin: BinBody, body: CardAsyncTokenRequest | TokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
116
128
|
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;
|
|
117
134
|
requestValidate3DS(body: Validate3DSRequest, callback: (value: Validate3DsResponse | ErrorResponse) => void): void;
|
|
118
135
|
requestSecureInit(body: SecureInitRequest, callback: (value: SecureInitResponse | ErrorResponse) => void): void;
|
|
119
136
|
/**
|
package/lib/Kushki.js
CHANGED
|
@@ -34,6 +34,8 @@ 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)();
|
|
37
39
|
this._cardDynamicService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.CardDynamicService)();
|
|
38
40
|
this._cardSubscriptionDynamicService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.CardSubscriptionDynamicService)();
|
|
39
41
|
this._applePayService = Container_1.CONTAINER.get(Identifiers_1.IDENTIFIERS.ApplePayService)();
|
|
@@ -157,6 +159,21 @@ class Kushki {
|
|
|
157
159
|
requestCardSubscriptionDynamicToken(bin, body, callback) {
|
|
158
160
|
this._cardSubscriptionDynamicService.requestCardSubscriptionDynamicToken(bin, body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
159
161
|
}
|
|
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
|
+
}
|
|
160
177
|
requestValidate3DS(body, callback) {
|
|
161
178
|
this._cardService.validate3DS(body, this._merchantId, this._inTestEnvironment, this._regional, callback);
|
|
162
179
|
}
|
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.3-alpha";
|
|
16
16
|
if (kushkiInfo) {
|
|
17
17
|
if (UtilsService_1.UtilsService.sIsEmpty(kushkiInfo.platformVersion))
|
|
18
18
|
kushkiInfo.platformVersion = kushki_js_version;
|
|
@@ -19,6 +19,8 @@ export declare type containerSymbol = {
|
|
|
19
19
|
TransferSubscriptionService: symbol;
|
|
20
20
|
PayoutsTransferService: symbol;
|
|
21
21
|
SiftScienceService: symbol;
|
|
22
|
+
KPayService: symbol;
|
|
23
|
+
AuthService: symbol;
|
|
22
24
|
ApplePayService: symbol;
|
|
23
25
|
};
|
|
24
26
|
declare const IDENTIFIERS: containerSymbol;
|
|
@@ -7,12 +7,14 @@ 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"),
|
|
10
11
|
CardAsyncService: Symbol.for("CardAsyncService"),
|
|
11
12
|
CardDynamicService: Symbol.for("CardDynamicService"),
|
|
12
13
|
CardService: Symbol.for("CardService"),
|
|
13
14
|
CardSubscriptionDynamicService: Symbol.for("CardSubscriptionDynamicService"),
|
|
14
15
|
CashService: Symbol.for("CashService"),
|
|
15
16
|
CommissionService: Symbol.for("CommissionService"),
|
|
17
|
+
KPayService: Symbol.for("KPayService"),
|
|
16
18
|
KushkiGateway: Symbol.for("KushkiGateway"),
|
|
17
19
|
KushkiService: Symbol.for("KushkiService"),
|
|
18
20
|
MultiMerchantService: Symbol.for("MultiMerchantService"),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "reflect-metadata";
|
|
3
3
|
import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
|
|
4
4
|
import { Observable } from "rxjs";
|
|
5
|
-
import {
|
|
5
|
+
import { ApplePayPaymentData } from "./../../lib/types/apple_pay_get_token_events";
|
|
6
6
|
import { ApplePayStartSessionRequest } from "./../../lib/types/apple_pay_start_session_request";
|
|
7
7
|
import { BankListResponse } from "./../../lib/types/bank_list_response";
|
|
8
8
|
import { BinInfoResponse } from "./../../lib/types/bin_info_response";
|
|
@@ -10,6 +10,7 @@ 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";
|
|
13
14
|
import { GetBrandsLogosByMerchantResponse } from "./../../lib/types/get_brands_logos_by_merchant_response";
|
|
14
15
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
15
16
|
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
@@ -18,6 +19,7 @@ import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
|
18
19
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
19
20
|
import { MultiMerchantInfoRequest } from "./../../lib/types/multimerchant_info_request";
|
|
20
21
|
import { MultiMerchantInfoResponse } from "./../../lib/types/multimerchant_info_response";
|
|
22
|
+
import { PaymentDataResponse } from "./../../lib/types/payment_data_response";
|
|
21
23
|
import { PayoutsCashTokenRequest } from "./../../lib/types/payouts_cash_request";
|
|
22
24
|
import { PayoutsTransferTokenRequest } from "./../../lib/types/payouts_transfer_token_request";
|
|
23
25
|
import { CommissionConfigurationAmount } from "./../../lib/types/remote/commission_configuration_amount";
|
|
@@ -25,6 +27,7 @@ import { CommissionConfigurationRequest } from "./../../lib/types/remote/commiss
|
|
|
25
27
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
26
28
|
import { TransferTokenRequest } from "./../../lib/types/remote/transfer_token_request";
|
|
27
29
|
import { ResponseStatusValidator } from "./../../lib/types/response_status_validator";
|
|
30
|
+
import { SavedPaymentMethodRequest } from "./../../lib/types/saved_payment_data_request";
|
|
28
31
|
import { SecureOtpRequest } from "./../../lib/types/secure_otp_request";
|
|
29
32
|
import { SecureOtpResponse } from "./../../lib/types/secure_otp_response";
|
|
30
33
|
import { SubscriptionCardAsyncTokenRequest } from "./../../lib/types/subscription_card_async_token_request";
|
|
@@ -47,6 +50,7 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
47
50
|
private _kshAuthorization;
|
|
48
51
|
request<T = object>(body: object, headers: object, path: string, testEnv: boolean, regional: boolean): Observable<T>;
|
|
49
52
|
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>;
|
|
50
54
|
requestBrandsByMerchant(mid: string, testEnv: boolean, regional: boolean): Observable<string[]>;
|
|
51
55
|
requestBrandsLogosByMerchant(mid: string, testEnv: boolean, regional: boolean): Observable<GetBrandsLogosByMerchantResponse[]>;
|
|
52
56
|
requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean, authorization?: string): Observable<TokenResponse>;
|
|
@@ -69,11 +73,13 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
69
73
|
requestTokenTransferSubscription(body: TransferSubscriptionTokenRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
70
74
|
requestBankList(mid: string, testEnv: boolean, regional: boolean): Observable<BankListResponse>;
|
|
71
75
|
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[]>;
|
|
72
78
|
cybersourceJwt(mid: string, testEnv: boolean, regional: boolean, subscriptionId?: string): Observable<JwtResponse>;
|
|
73
79
|
getUserId(subscriptionId: string, mid: string, testEnv: boolean, regional: boolean): Observable<GetUserId>;
|
|
74
80
|
validateAppleDomain(domain: string, mid: string, testEnv: boolean, regional: boolean): Observable<Validate3DsResponse>;
|
|
75
81
|
startApplePaySession(body: ApplePayStartSessionRequest, mid: string, testEnv: boolean, regional: boolean): Observable<object>;
|
|
76
|
-
getApplePayToken(body:
|
|
82
|
+
getApplePayToken(body: ApplePayPaymentData, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
77
83
|
private _assignChannel;
|
|
78
84
|
private _buildHeader;
|
|
79
85
|
}
|
|
@@ -11,6 +11,7 @@ exports.KushkiGateway = void 0;
|
|
|
11
11
|
/**
|
|
12
12
|
* Kushki Gateway File
|
|
13
13
|
*/
|
|
14
|
+
/* tslint:disable: no-unnecessary-callback-wrapper */
|
|
14
15
|
const axios_1 = require("axios");
|
|
15
16
|
const AurusError_1 = require("./../../lib/generic/AurusError");
|
|
16
17
|
const EnvironmentEnum_1 = require("./../../lib/infrastructure/EnvironmentEnum");
|
|
@@ -50,11 +51,20 @@ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
|
|
|
50
51
|
requestGet(path, testEnv, regional, mid) {
|
|
51
52
|
return rxjs_1.of(this._assignChannel(regional, path)).pipe(operators_1.switchMap(() => axios_1.default.get(`${testEnv ? this._uatUrl : this._prodUrl}`, {
|
|
52
53
|
headers: {
|
|
53
|
-
[this._publicHeader]: mid
|
|
54
|
+
[this._publicHeader]: mid,
|
|
54
55
|
[this._contentHeader]: this._contentJSON,
|
|
55
56
|
},
|
|
56
57
|
})), operators_1.map((response) => response.data), operators_1.catchError((err) => rxjs_1.throwError(err)));
|
|
57
58
|
}
|
|
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
|
+
}
|
|
58
68
|
requestBrandsByMerchant(mid, testEnv, regional) {
|
|
59
69
|
return this.requestGet(`${PathEnum_1.PathEnum.brands_by_merchant}`, testEnv, regional, mid);
|
|
60
70
|
}
|
|
@@ -135,6 +145,16 @@ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
|
|
|
135
145
|
requestPayoutsTransferBankList(mid, testEnv, regional) {
|
|
136
146
|
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));
|
|
137
147
|
}
|
|
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
|
+
}
|
|
138
158
|
cybersourceJwt(mid, testEnv, regional, subscriptionId) {
|
|
139
159
|
return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.requestGet(subscriptionId
|
|
140
160
|
? `${PathEnum_1.PathEnum.cybersource_jwt}?subscriptionId=${subscriptionId}`
|
|
@@ -0,0 +1,7 @@
|
|
|
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 = {}));
|
|
@@ -9,12 +9,14 @@ 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");
|
|
12
13
|
const CardAsyncService_1 = require("./../../lib/service/CardAsyncService");
|
|
13
14
|
const CardDynamicService_1 = require("./../../lib/service/CardDynamicService");
|
|
14
15
|
const CardService_1 = require("./../../lib/service/CardService");
|
|
15
16
|
const CardSubscriptionDynamicService_1 = require("./../../lib/service/CardSubscriptionDynamicService");
|
|
16
17
|
const CashService_1 = require("./../../lib/service/CashService");
|
|
17
18
|
const CommissionService_1 = require("./../../lib/service/CommissionService");
|
|
19
|
+
const KPayService_1 = require("./../../lib/service/KPayService");
|
|
18
20
|
const KushkiService_1 = require("./../../lib/service/KushkiService");
|
|
19
21
|
const MultiMerchantService_1 = require("./../../lib/service/MultiMerchantService");
|
|
20
22
|
const PayoutsCashService_1 = require("./../../lib/service/PayoutsCashService");
|
|
@@ -26,7 +28,8 @@ const TransferSubscriptionsService_1 = require("./../../lib/service/TransferSubs
|
|
|
26
28
|
const CONTAINER = new inversify_1.Container();
|
|
27
29
|
exports.CONTAINER = CONTAINER;
|
|
28
30
|
// Service
|
|
29
|
-
CONTAINER.bind(Identifiers_1.IDENTIFIERS.
|
|
31
|
+
CONTAINER.bind(Identifiers_1.IDENTIFIERS.AuthService).toFactory((context) => () => new AuthService_1.AuthService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway)));
|
|
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)));
|
|
30
33
|
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)));
|
|
31
34
|
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)()));
|
|
32
35
|
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)()));
|
|
@@ -39,6 +42,7 @@ CONTAINER.bind(Identifiers_1.IDENTIFIERS.CardAsyncService).toFactory((context) =
|
|
|
39
42
|
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)));
|
|
40
43
|
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)));
|
|
41
44
|
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)));
|
|
42
46
|
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)));
|
|
43
47
|
CONTAINER.bind(Identifiers_1.IDENTIFIERS.ApplePayService).toFactory((context) => () => new ApplePayService_1.ApplePayService(context.container.get(Identifiers_1.IDENTIFIERS.KushkiGateway)));
|
|
44
48
|
// Gateway
|
|
@@ -0,0 +1,8 @@
|
|
|
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 = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
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 = {}));
|
|
@@ -26,6 +26,9 @@ 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",
|
|
29
32
|
get_user_id = "v1/subscriptions/",
|
|
30
33
|
validate_apple_domain = "apple-pay/v1/validate",
|
|
31
34
|
start_apple_pay_session = "apple-pay/v1/session/start",
|
|
@@ -29,6 +29,9 @@ 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";
|
|
32
35
|
PathEnum["get_user_id"] = "v1/subscriptions/";
|
|
33
36
|
PathEnum["validate_apple_domain"] = "apple-pay/v1/validate";
|
|
34
37
|
PathEnum["start_apple_pay_session"] = "apple-pay/v1/session/start";
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -10,12 +10,14 @@ 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";
|
|
13
14
|
import { SubscriptionTokenRequest } from "./../../lib/types/subscription_token_request";
|
|
14
15
|
import { SubscriptionIdRequest } from "./../../lib/types/subscriptionId_request";
|
|
16
|
+
import { TokenKPayRequest } from "./../../lib/types/token_kpay_request";
|
|
15
17
|
import { TokenRequest } from "./../../lib/types/token_request";
|
|
16
18
|
import { Validate3DSRequest } from "./../../lib/types/validate_3ds_request";
|
|
17
19
|
import { Validate3DsResponse } from "./../../lib/types/validate_3ds_response";
|
|
18
|
-
export declare type IGeneralTokenRequest = TokenRequest | SubscriptionTokenRequest;
|
|
20
|
+
export declare type IGeneralTokenRequest = TokenRequest | TokenKPayRequest | SubscriptionTokenRequest | SubscriptionTokenKPayRequest;
|
|
19
21
|
export interface ICardService {
|
|
20
22
|
/**
|
|
21
23
|
* Token
|
|
@@ -25,7 +27,7 @@ export interface ICardService {
|
|
|
25
27
|
* @param regional - Define if endpoint used regional URL
|
|
26
28
|
* @param callback
|
|
27
29
|
*/
|
|
28
|
-
requestToken(tokenRequest: TokenRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
30
|
+
requestToken(tokenRequest: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
29
31
|
/**
|
|
30
32
|
* Subscription Token
|
|
31
33
|
* @param subscriptionTokenRequest - subscription tokens request body
|
|
@@ -34,7 +36,7 @@ export interface ICardService {
|
|
|
34
36
|
* @param regional - Define if endpoint used regional URL
|
|
35
37
|
* @param callback
|
|
36
38
|
*/
|
|
37
|
-
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
39
|
+
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest | SubscriptionTokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
38
40
|
/**
|
|
39
41
|
* Subscription Token
|
|
40
42
|
* @param binBody - deferred bin request body
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Interface for Kushki Gateway.
|
|
4
4
|
*/
|
|
5
5
|
import { Observable } from "rxjs";
|
|
6
|
-
import {
|
|
6
|
+
import { ApplePayPaymentData } from "./../../lib/types/apple_pay_get_token_events";
|
|
7
7
|
import { ApplePayStartSessionRequest } from "./../../lib/types/apple_pay_start_session_request";
|
|
8
8
|
import { BankListResponse } from "./../../lib/types/bank_list_response";
|
|
9
9
|
import { BinInfoResponse } from "./../../lib/types/bin_info_response";
|
|
@@ -11,6 +11,7 @@ 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";
|
|
14
15
|
import { GetBrandsLogosByMerchantResponse } from "./../../lib/types/get_brands_logos_by_merchant_response";
|
|
15
16
|
import { GetUserId } from "./../../lib/types/get_user_id";
|
|
16
17
|
import { JwtResponse } from "./../../lib/types/jwt_response";
|
|
@@ -19,6 +20,7 @@ import { KushkiTokensRequest } from "./../../lib/types/kushki_tokens_request";
|
|
|
19
20
|
import { MerchantSettingsResponse } from "./../../lib/types/merchant_settings_response";
|
|
20
21
|
import { MultiMerchantInfoRequest } from "./../../lib/types/multimerchant_info_request";
|
|
21
22
|
import { MultiMerchantInfoResponse } from "./../../lib/types/multimerchant_info_response";
|
|
23
|
+
import { PaymentDataResponse } from "./../../lib/types/payment_data_response";
|
|
22
24
|
import { PayoutsCashTokenRequest } from "./../../lib/types/payouts_cash_request";
|
|
23
25
|
import { PayoutsTransferTokenRequest } from "./../../lib/types/payouts_transfer_token_request";
|
|
24
26
|
import { CommissionConfigurationAmount } from "./../../lib/types/remote/commission_configuration_amount";
|
|
@@ -26,6 +28,7 @@ import { CommissionConfigurationRequest } from "./../../lib/types/remote/commiss
|
|
|
26
28
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
27
29
|
import { TransferTokenRequest } from "./../../lib/types/remote/transfer_token_request";
|
|
28
30
|
import { ResponseStatusValidator } from "./../../lib/types/response_status_validator";
|
|
31
|
+
import { SavedPaymentMethodRequest } from "./../../lib/types/saved_payment_data_request";
|
|
29
32
|
import { SecureOtpRequest } from "./../../lib/types/secure_otp_request";
|
|
30
33
|
import { SecureOtpResponse } from "./../../lib/types/secure_otp_response";
|
|
31
34
|
import { SubscriptionCardAsyncTokenRequest } from "./../../lib/types/subscription_card_async_token_request";
|
|
@@ -42,6 +45,10 @@ export interface IKushkiGateway {
|
|
|
42
45
|
* Send GET requests to Kushki Gateway
|
|
43
46
|
*/
|
|
44
47
|
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>;
|
|
45
52
|
/**
|
|
46
53
|
* Send tokens request to Kushki API
|
|
47
54
|
*/
|
|
@@ -128,6 +135,21 @@ export interface IKushkiGateway {
|
|
|
128
135
|
* Request banklist payouts transfer to Kushki API
|
|
129
136
|
*/
|
|
130
137
|
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[]>;
|
|
131
153
|
/**
|
|
132
154
|
* Get JWT for 3DS
|
|
133
155
|
* @param mid - public credential for request
|
|
@@ -166,5 +188,5 @@ export interface IKushkiGateway {
|
|
|
166
188
|
* @param testEnv - is test environment
|
|
167
189
|
* @param regional - Define if endpoint used regional URL
|
|
168
190
|
*/
|
|
169
|
-
getApplePayToken(body:
|
|
191
|
+
getApplePayToken(body: ApplePayPaymentData, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
170
192
|
}
|
|
@@ -153,7 +153,7 @@ let ApplePayService = ApplePayService_1 = class ApplePayService {
|
|
|
153
153
|
_onPaymentAuthorized(event, mid, session, isTest, regional, callback) {
|
|
154
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
155
|
try {
|
|
156
|
-
const apple_token = event.payment.token.paymentData;
|
|
156
|
+
const apple_token = Object.assign(Object.assign({}, event.payment.token.paymentData), { paymentMethod: event.payment.token.paymentMethod });
|
|
157
157
|
const kushki_token = yield this._gateway
|
|
158
158
|
.getApplePayToken(apple_token, mid, isTest, regional)
|
|
159
159
|
.toPromise();
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
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;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import "reflect-metadata";
|
|
6
6
|
import { IAntiFraud } from "./../../lib/repository/IAntiFraud";
|
|
7
|
+
import { IAuthService } from "./../../lib/repository/IAuthService";
|
|
7
8
|
import { ICardService } from "./../../lib/repository/ICardService";
|
|
8
9
|
import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
|
|
9
10
|
import { Observable } from "rxjs";
|
|
@@ -14,8 +15,10 @@ import { IDeferredResponse } from "./../../lib/types/remote/deferred_response";
|
|
|
14
15
|
import { TokenResponse } from "./../../lib/types/remote/token_response";
|
|
15
16
|
import { SecureInitRequest } from "./../../lib/types/secure_init_request";
|
|
16
17
|
import { SecureInitResponse } from "./../../lib/types/secure_init_response";
|
|
18
|
+
import { SubscriptionTokenKPayRequest } from "./../../lib/types/subscription_token_kpay_request";
|
|
17
19
|
import { SubscriptionTokenRequest } from "./../../lib/types/subscription_token_request";
|
|
18
20
|
import { SubscriptionIdRequest } from "./../../lib/types/subscriptionId_request";
|
|
21
|
+
import { TokenKPayRequest } from "./../../lib/types/token_kpay_request";
|
|
19
22
|
import { TokenRequest } from "./../../lib/types/token_request";
|
|
20
23
|
import { Validate3DSRequest } from "./../../lib/types/validate_3ds_request";
|
|
21
24
|
import { Validate3DsResponse } from "./../../lib/types/validate_3ds_response";
|
|
@@ -32,15 +35,16 @@ export declare class CardService implements ICardService {
|
|
|
32
35
|
private readonly _gateway;
|
|
33
36
|
private readonly _receipt;
|
|
34
37
|
private readonly _antiFraud;
|
|
38
|
+
private readonly _authService;
|
|
35
39
|
private readonly _3Dsecure;
|
|
36
40
|
private readonly _cardNumber;
|
|
37
41
|
private _sandboxEnable;
|
|
38
42
|
private readonly _paymentValidatedEvent;
|
|
39
43
|
private readonly _paymentSetupCompleteEvent;
|
|
40
|
-
constructor(gateway: IKushkiGateway, antiFraud: IAntiFraud);
|
|
41
|
-
requestToken(request: TokenRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
44
|
+
constructor(gateway: IKushkiGateway, authService: IAuthService, antiFraud: IAntiFraud);
|
|
45
|
+
requestToken(request: TokenRequest | TokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
42
46
|
requestDeviceToken(request: SubscriptionIdRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
43
|
-
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
47
|
+
requestSubscriptionToken(subscriptionTokenRequest: SubscriptionTokenRequest | SubscriptionTokenKPayRequest, mid: string, isTest: boolean, regional: boolean, callback: (value: TokenResponse | ErrorResponse) => void): void;
|
|
44
48
|
requestDeferred(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<IDeferredResponse[]>;
|
|
45
49
|
requestBinInfo(binBody: BinBody, mid: string, isTest: boolean, regional: boolean): Observable<BinInfoResponse>;
|
|
46
50
|
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, antiFraud) {
|
|
45
|
+
constructor(gateway, authService, antiFraud) {
|
|
46
46
|
this._3Dsecure = "active_3dsecure";
|
|
47
47
|
this._cardNumber = "card.number";
|
|
48
48
|
this._sandboxEnable = false;
|
|
@@ -50,6 +50,7 @@ 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;
|
|
53
54
|
this._receipt = {
|
|
54
55
|
amount: "totalAmount",
|
|
55
56
|
"card.cvc": "card.cvv",
|
|
@@ -83,19 +84,25 @@ let CardService = CardService_1 = class CardService {
|
|
|
83
84
|
this._setSandboxEnable(!!merchant.sandboxEnable);
|
|
84
85
|
return rxjs_1.forkJoin([
|
|
85
86
|
this._getScienceSession(request, mid, isTest, merchant),
|
|
86
|
-
this._getCybersourceJwt(merchant, mid, isTest, regional, request
|
|
87
|
+
this._getCybersourceJwt(merchant, mid, isTest, regional, Object.prototype.hasOwnProperty.call(request, "card")
|
|
88
|
+
? request.card.number
|
|
89
|
+
: undefined),
|
|
87
90
|
rxjs_1.of(merchant),
|
|
88
91
|
]);
|
|
89
92
|
}), operators_1.mergeMap(([sift_object, jwt, merchant]) => {
|
|
90
93
|
request.isDeferred =
|
|
91
94
|
request.isDeferred === undefined ? false : request.isDeferred;
|
|
95
|
+
if (Boolean(request.cvv))
|
|
96
|
+
request.card = { cvc: request.cvv };
|
|
92
97
|
this._checkRequestBody(request);
|
|
93
98
|
const data_to_transform = Object.assign(Object.assign({}, request), sift_object);
|
|
94
99
|
if (jwt !== undefined)
|
|
95
100
|
data_to_transform.jwt = jwt;
|
|
96
101
|
return rxjs_1.forkJoin([
|
|
97
102
|
rxjs_1.of(dot.transform(this._receipt, Object.assign(Object.assign({}, data_to_transform), { merchantName: merchant.merchant_name }))),
|
|
98
|
-
|
|
103
|
+
request.walletId
|
|
104
|
+
? this._authService.getAuthorizationToken()
|
|
105
|
+
: rxjs_1.of(undefined),
|
|
99
106
|
rxjs_1.of(merchant),
|
|
100
107
|
]);
|
|
101
108
|
}))
|
|
@@ -159,7 +166,9 @@ let CardService = CardService_1 = class CardService {
|
|
|
159
166
|
data_to_transform.jwt = jwt;
|
|
160
167
|
return rxjs_1.forkJoin([
|
|
161
168
|
rxjs_1.of(dot.transform(this._receipt, Object.assign(Object.assign({}, data_to_transform), { merchantName: merchant.merchant_name }))),
|
|
162
|
-
|
|
169
|
+
subscriptionTokenRequest.walletId
|
|
170
|
+
? this._authService.getAuthorizationToken()
|
|
171
|
+
: rxjs_1.of(undefined),
|
|
163
172
|
rxjs_1.of(merchant),
|
|
164
173
|
]);
|
|
165
174
|
}))
|
|
@@ -267,7 +276,14 @@ let CardService = CardService_1 = class CardService {
|
|
|
267
276
|
throw new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS[ErrorEnum_1.ErrorCode.E014]);
|
|
268
277
|
}
|
|
269
278
|
_getScienceSession(request, mid, isTest, merchant) {
|
|
270
|
-
return rxjs_1.of(1).pipe(operators_1.switchMap(() =>
|
|
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
|
+
}));
|
|
271
287
|
}
|
|
272
288
|
_checkCurrency(request) {
|
|
273
289
|
request.currency =
|
|
@@ -285,7 +301,8 @@ let CardService = CardService_1 = class CardService {
|
|
|
285
301
|
}
|
|
286
302
|
_checkRequestBody(request) {
|
|
287
303
|
this._checkCurrency(request);
|
|
288
|
-
|
|
304
|
+
if (Boolean(request.card) && Boolean(request.card.number))
|
|
305
|
+
this._checkCardLength(request);
|
|
289
306
|
this._checkAmount(request);
|
|
290
307
|
}
|
|
291
308
|
_getCybersourceJwt(merchantSettings, mid, isTest, regional, cardNumber) {
|
|
@@ -470,7 +487,8 @@ let CardService = CardService_1 = class CardService {
|
|
|
470
487
|
CardService = CardService_1 = __decorate([
|
|
471
488
|
inversify_1.injectable(),
|
|
472
489
|
__param(0, inversify_1.inject(Identifiers_1.IDENTIFIERS.KushkiGateway)),
|
|
473
|
-
__param(1, inversify_1.inject(Identifiers_1.IDENTIFIERS.
|
|
474
|
-
|
|
490
|
+
__param(1, inversify_1.inject(Identifiers_1.IDENTIFIERS.AuthService)),
|
|
491
|
+
__param(2, inversify_1.inject(Identifiers_1.IDENTIFIERS.AntiFraud)),
|
|
492
|
+
__metadata("design:paramtypes", [Object, Object, Object])
|
|
475
493
|
], CardService);
|
|
476
494
|
exports.CardService = CardService;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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;
|
|
@@ -5,9 +5,7 @@ export interface ApplePaymentEvent {
|
|
|
5
5
|
payment: {
|
|
6
6
|
billingContact?: ApplePayPaymentContact;
|
|
7
7
|
shippingContact?: ApplePayPaymentContact;
|
|
8
|
-
token:
|
|
9
|
-
paymentData: ApplePayGetTokenRequest;
|
|
10
|
-
};
|
|
8
|
+
token: ApplePayPaymentToken;
|
|
11
9
|
};
|
|
12
10
|
validationURL: string;
|
|
13
11
|
appleTokenResponse?: AppleTokenResponse;
|
|
@@ -28,7 +26,11 @@ export interface ApplePayPaymentContact {
|
|
|
28
26
|
countryCode: string;
|
|
29
27
|
addressLines: string[];
|
|
30
28
|
}
|
|
31
|
-
export interface
|
|
29
|
+
export interface ApplePayPaymentToken {
|
|
30
|
+
paymentData: ApplePayPaymentData;
|
|
31
|
+
paymentMethod: ApplePayPaymentMethod;
|
|
32
|
+
}
|
|
33
|
+
export interface ApplePayPaymentData {
|
|
32
34
|
data: string;
|
|
33
35
|
header: {
|
|
34
36
|
ephemeralPublicKey: string;
|
|
@@ -38,6 +40,12 @@ export interface ApplePayGetTokenRequest {
|
|
|
38
40
|
};
|
|
39
41
|
signature: string;
|
|
40
42
|
version: string;
|
|
43
|
+
paymentMethod?: ApplePayPaymentMethod;
|
|
44
|
+
}
|
|
45
|
+
export interface ApplePayPaymentMethod {
|
|
46
|
+
network: string;
|
|
47
|
+
displayName: string;
|
|
48
|
+
type: string;
|
|
41
49
|
}
|
|
42
50
|
export interface AppleTokenResponse {
|
|
43
51
|
token: string;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kushki/js",
|
|
3
|
-
"version": "1.40.
|
|
3
|
+
"version": "1.40.3-alpha",
|
|
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,@aws-amplify/auth \""
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@kushki/cli": "1.4.1",
|
|
@@ -97,9 +97,11 @@
|
|
|
97
97
|
"webpack-dev-server": "3.3.1"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
+
"@aws-amplify/auth": "4.6.1",
|
|
100
101
|
"@kushki/cardinal-sandbox-js": "1.0.6",
|
|
101
102
|
"acorn": "6.4.1",
|
|
102
|
-
"
|
|
103
|
+
"aws-amplify": "4.3.30",
|
|
104
|
+
"axios": "0.21.3",
|
|
103
105
|
"buffer": "^6.0.3",
|
|
104
106
|
"ci": "^2.1.1",
|
|
105
107
|
"dot-object": "2.1.4",
|