@kushki/js 1.40.5 → 1.41.0-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 CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { AxiosError } from "axios";
6
6
  import { KushkiError } from "./../lib/generic/KushkiError";
7
+ import { TransferPaymentTypeEnum } from "./../lib/infrastructure/TransferPaymentTypeEnum";
7
8
  import "reflect-metadata";
8
9
  import { AppleTokenResponse } from "./../lib/types/apple_pay_get_token_events";
9
10
  import { ApplePayGetTokenOptions } from "./../lib/types/apple_pay_get_token_options";
@@ -18,6 +19,7 @@ import { CashTokenRequest } from "./../lib/types/cash_token_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 { GetTransferConfigResponse } from "./../lib/types/get_transfer_config_response";
21
23
  import { KushkiInfo } from "./../lib/types/kushki_info";
22
24
  import { MultiMerchantInfoRequest } from "./../lib/types/multimerchant_info_request";
23
25
  import { MultiMerchantInfoResponse } from "./../lib/types/multimerchant_info_response";
@@ -27,7 +29,6 @@ import { CommissionConfigurationAmount } from "./../lib/types/remote/commission_
27
29
  import { CommissionConfigurationRequest } from "./../lib/types/remote/commission_configuration_request";
28
30
  import { IDeferredResponse } from "./../lib/types/remote/deferred_response";
29
31
  import { TokenResponse } from "./../lib/types/remote/token_response";
30
- import { TransferTokenRequest } from "./../lib/types/remote/transfer_token_request";
31
32
  import { ResponseStatusValidator } from "./../lib/types/response_status_validator";
32
33
  import { SecureInitRequest } from "./../lib/types/secure_init_request";
33
34
  import { SecureInitResponse } from "./../lib/types/secure_init_response";
@@ -40,6 +41,7 @@ import { SubscriptionTokenRequest } from "./../lib/types/subscription_token_requ
40
41
  import { TokenChargeRequest } from "./../lib/types/token_charge_request";
41
42
  import { TokenRequest } from "./../lib/types/token_request";
42
43
  import { TransferSubscriptionTokenRequest } from "./../lib/types/transfer_subscription_token_request";
44
+ import { TransferTokenRequest } from "./../lib/types/transfer_token_request";
43
45
  import { Validate3DSRequest } from "./../lib/types/validate_3ds_request";
44
46
  import { Validate3DsResponse } from "./../lib/types/validate_3ds_response";
45
47
  /**
@@ -81,7 +83,86 @@ export declare class Kushki {
81
83
  requestTokenCharge(body: TokenChargeRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
82
84
  requestDeviceToken(body: DeviceTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
83
85
  requestSubscriptionToken(body: SubscriptionTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
86
+ /**
87
+ * Requests a transfer token.
88
+ *
89
+ * Legacy single-processor merchants send the country specific body (PSE,
90
+ * Webpay, SPEI, etc.).
91
+ *
92
+ * Multi-processor merchants send `MultiProcessorTokenRequest`: `amount`,
93
+ * `currency` and a `processor` object taken from `getTransferConfig`:
94
+ * `processor.name` is `processors[].name` and `processor.channel` is one of
95
+ * the `channels` of a `supportedFlows` product with `paymentType`
96
+ * `"PAYMENT"` (omit it when the processor has no such products). Extra
97
+ * fields a processor needs go in the body or inside `processor`; the
98
+ * backend validates them.
99
+ *
100
+ * @param {TransferTokenRequest} body transfer token request
101
+ * @param {Function} callback with value
102
+ * @returns {void}
103
+ * @example
104
+ * kushki.getTransferConfig((config) => {
105
+ * const processor = config.processors[0];
106
+ * const payment = processor.supportedFlows.find(
107
+ * (flow) => flow.paymentType === TransferPaymentTypeEnum.PAYMENT
108
+ * );
109
+ *
110
+ * kushki.requestTransferToken(
111
+ * {
112
+ * amount: { subtotalIva: 0, subtotalIva0: 9000, iva: 0 },
113
+ * currency: processor.currency,
114
+ * processor: { name: processor.name, channel: payment.channels[0] },
115
+ * },
116
+ * (response) => console.log(response)
117
+ * );
118
+ * });
119
+ */
84
120
  requestTransferToken(body: TransferTokenRequest, callback: (value: TokenResponse | ErrorResponse) => void): void;
121
+ /**
122
+ * Retrieves the configuration of the transfer processors enabled for the
123
+ * merchant.
124
+ *
125
+ * Transfer supports multiple processors per merchant, so the response may
126
+ * contain zero, one or more enabled processors. The end user is expected to
127
+ * pick which processor will handle the payment.
128
+ *
129
+ * - Legacy processors (e.g. PSE) only expose `name` and `currency`.
130
+ * - Multi-processor entries also expose `supportedFlows`: one item per
131
+ * product (`paymentType` `PAYMENT` or `SUBSCRIPTION`) with the `channels`
132
+ * that offer it. `processor.name` and the chosen channel of a `PAYMENT`
133
+ * product are later sent as-is in `requestTransferToken`.
134
+ *
135
+ * An empty `processors` array is a valid success response, not an error.
136
+ *
137
+ * `paymentType` is forwarded as a query param so the backend returns only
138
+ * the products of that type; processors left without products are omitted.
139
+ * Use `PAYMENT` for a one-time payment checkout.
140
+ *
141
+ * The merchant id, environment (test/production) and region are taken from
142
+ * the Kushki instance options.
143
+ *
144
+ * @param {Function} callback invoked with a `GetTransferConfigResponse` on
145
+ * success or an `ErrorResponse` on failure
146
+ * @param {TransferPaymentTypeEnum} [paymentType] optional product type filter
147
+ * @returns {void}
148
+ * @example
149
+ * kushki.getTransferConfig((response) => {
150
+ * if ("code" in response) {
151
+ * console.error(response.message);
152
+ * return;
153
+ * }
154
+ * response.processors.forEach((processor) => {
155
+ * if (processor.supportedFlows) {
156
+ * // Multi-processor: let the user choose a product and channel
157
+ * console.log(processor.name, processor.supportedFlows);
158
+ * } else {
159
+ * // Legacy processor: only name and currency are available
160
+ * console.log(processor.name, processor.currency);
161
+ * }
162
+ * });
163
+ * }, TransferPaymentTypeEnum.PAYMENT);
164
+ */
165
+ getTransferConfig(callback: (value: GetTransferConfigResponse | ErrorResponse) => void, paymentType?: TransferPaymentTypeEnum): void;
85
166
  checkStatus(callback: (value: ResponseStatusValidator | ErrorResponse) => void): void;
86
167
  /**
87
168
  * @deprecated since version 1.19.8 use requestBankList instead
package/lib/Kushki.js CHANGED
@@ -59,9 +59,90 @@ class Kushki {
59
59
  requestSubscriptionToken(body, callback) {
60
60
  this._cardService.requestSubscriptionToken(body, this._merchantId, this._inTestEnvironment, this._regional, callback);
61
61
  }
62
+ /**
63
+ * Requests a transfer token.
64
+ *
65
+ * Legacy single-processor merchants send the country specific body (PSE,
66
+ * Webpay, SPEI, etc.).
67
+ *
68
+ * Multi-processor merchants send `MultiProcessorTokenRequest`: `amount`,
69
+ * `currency` and a `processor` object taken from `getTransferConfig`:
70
+ * `processor.name` is `processors[].name` and `processor.channel` is one of
71
+ * the `channels` of a `supportedFlows` product with `paymentType`
72
+ * `"PAYMENT"` (omit it when the processor has no such products). Extra
73
+ * fields a processor needs go in the body or inside `processor`; the
74
+ * backend validates them.
75
+ *
76
+ * @param {TransferTokenRequest} body transfer token request
77
+ * @param {Function} callback with value
78
+ * @returns {void}
79
+ * @example
80
+ * kushki.getTransferConfig((config) => {
81
+ * const processor = config.processors[0];
82
+ * const payment = processor.supportedFlows.find(
83
+ * (flow) => flow.paymentType === TransferPaymentTypeEnum.PAYMENT
84
+ * );
85
+ *
86
+ * kushki.requestTransferToken(
87
+ * {
88
+ * amount: { subtotalIva: 0, subtotalIva0: 9000, iva: 0 },
89
+ * currency: processor.currency,
90
+ * processor: { name: processor.name, channel: payment.channels[0] },
91
+ * },
92
+ * (response) => console.log(response)
93
+ * );
94
+ * });
95
+ */
62
96
  requestTransferToken(body, callback) {
63
97
  this._resolve(this._transferService.requestTransferToken(body, this._merchantId, this._inTestEnvironment, this._regional), callback);
64
98
  }
99
+ /**
100
+ * Retrieves the configuration of the transfer processors enabled for the
101
+ * merchant.
102
+ *
103
+ * Transfer supports multiple processors per merchant, so the response may
104
+ * contain zero, one or more enabled processors. The end user is expected to
105
+ * pick which processor will handle the payment.
106
+ *
107
+ * - Legacy processors (e.g. PSE) only expose `name` and `currency`.
108
+ * - Multi-processor entries also expose `supportedFlows`: one item per
109
+ * product (`paymentType` `PAYMENT` or `SUBSCRIPTION`) with the `channels`
110
+ * that offer it. `processor.name` and the chosen channel of a `PAYMENT`
111
+ * product are later sent as-is in `requestTransferToken`.
112
+ *
113
+ * An empty `processors` array is a valid success response, not an error.
114
+ *
115
+ * `paymentType` is forwarded as a query param so the backend returns only
116
+ * the products of that type; processors left without products are omitted.
117
+ * Use `PAYMENT` for a one-time payment checkout.
118
+ *
119
+ * The merchant id, environment (test/production) and region are taken from
120
+ * the Kushki instance options.
121
+ *
122
+ * @param {Function} callback invoked with a `GetTransferConfigResponse` on
123
+ * success or an `ErrorResponse` on failure
124
+ * @param {TransferPaymentTypeEnum} [paymentType] optional product type filter
125
+ * @returns {void}
126
+ * @example
127
+ * kushki.getTransferConfig((response) => {
128
+ * if ("code" in response) {
129
+ * console.error(response.message);
130
+ * return;
131
+ * }
132
+ * response.processors.forEach((processor) => {
133
+ * if (processor.supportedFlows) {
134
+ * // Multi-processor: let the user choose a product and channel
135
+ * console.log(processor.name, processor.supportedFlows);
136
+ * } else {
137
+ * // Legacy processor: only name and currency are available
138
+ * console.log(processor.name, processor.currency);
139
+ * }
140
+ * });
141
+ * }, TransferPaymentTypeEnum.PAYMENT);
142
+ */
143
+ getTransferConfig(callback, paymentType) {
144
+ this._resolve(this._transferService.getTransferConfig(this._merchantId, this._inTestEnvironment, this._regional, paymentType), callback);
145
+ }
65
146
  checkStatus(callback) {
66
147
  this._resolve(this._kushkiService.checkStatus(this._merchantId, this._inTestEnvironment, this._regional), callback);
67
148
  }
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.5";
15
+ const kushki_js_version = "1.41.0-alpha";
16
16
  if (kushkiInfo) {
17
17
  if (UtilsService_1.UtilsService.sIsEmpty(kushkiInfo.platformVersion))
18
18
  kushkiInfo.platformVersion = kushki_js_version;
@@ -1,4 +1,5 @@
1
1
  /* tslint:disable:all */
2
+ import { TransferPaymentTypeEnum } from "./../../lib/infrastructure/TransferPaymentTypeEnum";
2
3
  import "reflect-metadata";
3
4
  import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
4
5
  import { Observable } from "rxjs";
@@ -11,6 +12,7 @@ import { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_respo
11
12
  import { CashTokenRequest } from "./../../lib/types/cash_token_request";
12
13
  import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
13
14
  import { GetBrandsLogosByMerchantResponse } from "./../../lib/types/get_brands_logos_by_merchant_response";
15
+ import { GetTransferConfigResponse } from "./../../lib/types/get_transfer_config_response";
14
16
  import { GetUserId } from "./../../lib/types/get_user_id";
15
17
  import { JwtResponse } from "./../../lib/types/jwt_response";
16
18
  import { KushkiSubscriptionTokensRequest } from "./../../lib/types/kushki_subscription_tokens_request";
@@ -23,7 +25,6 @@ import { PayoutsTransferTokenRequest } from "./../../lib/types/payouts_transfer_
23
25
  import { CommissionConfigurationAmount } from "./../../lib/types/remote/commission_configuration_amount";
24
26
  import { CommissionConfigurationRequest } from "./../../lib/types/remote/commission_configuration_request";
25
27
  import { TokenResponse } from "./../../lib/types/remote/token_response";
26
- import { TransferTokenRequest } from "./../../lib/types/remote/transfer_token_request";
27
28
  import { ResponseStatusValidator } from "./../../lib/types/response_status_validator";
28
29
  import { SecureOtpRequest } from "./../../lib/types/secure_otp_request";
29
30
  import { SecureOtpResponse } from "./../../lib/types/secure_otp_response";
@@ -31,6 +32,7 @@ import { SubscriptionCardAsyncTokenRequest } from "./../../lib/types/subscriptio
31
32
  import { SubscriptionCardAsyncTokenResponse } from "./../../lib/types/subscription_card_async_token_response";
32
33
  import { TokenChargeRequest } from "./../../lib/types/token_charge_request";
33
34
  import { TransferSubscriptionTokenRequest } from "./../../lib/types/transfer_subscription_token_request";
35
+ import { TransferTokenRequest } from "./../../lib/types/transfer_token_request";
34
36
  import { Validate3DsResponse } from "./../../lib/types/validate_3ds_response";
35
37
  /**
36
38
  * Kushki Gateway Implementation
@@ -49,6 +51,7 @@ export declare class KushkiGateway implements IKushkiGateway {
49
51
  requestGet<T extends object = object>(path: string, testEnv: boolean, regional: boolean, mid?: string): Observable<T>;
50
52
  requestBrandsByMerchant(mid: string, testEnv: boolean, regional: boolean): Observable<string[]>;
51
53
  requestBrandsLogosByMerchant(mid: string, testEnv: boolean, regional: boolean): Observable<GetBrandsLogosByMerchantResponse[]>;
54
+ requestTransferConfig(mid: string, testEnv: boolean, regional: boolean, paymentType?: TransferPaymentTypeEnum): Observable<GetTransferConfigResponse>;
52
55
  requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
53
56
  requestDeviceToken(body: TokenChargeRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
54
57
  requestSubscriptionToken(body: KushkiSubscriptionTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
@@ -74,6 +77,7 @@ export declare class KushkiGateway implements IKushkiGateway {
74
77
  validateAppleDomain(domain: string, mid: string, testEnv: boolean, regional: boolean): Observable<Validate3DsResponse>;
75
78
  startApplePaySession(body: ApplePayStartSessionRequest, mid: string, testEnv: boolean, regional: boolean): Observable<object>;
76
79
  getApplePayToken(body: ApplePayPaymentData, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
80
+ private _buildTransferConfigPath;
77
81
  private _buildCybersourceJwtPath;
78
82
  private _assignChannel;
79
83
  private _buildHeader;
@@ -61,6 +61,9 @@ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
61
61
  requestBrandsLogosByMerchant(mid, testEnv, regional) {
62
62
  return this.requestGet(`${PathEnum_1.PathEnum.brands_logos_by_merchant}`, testEnv, regional, mid);
63
63
  }
64
+ requestTransferConfig(mid, testEnv, regional, paymentType) {
65
+ return this.requestGet(this._buildTransferConfigPath(paymentType), testEnv, regional, mid);
66
+ }
64
67
  requestToken(body, mid, testEnv, regional) {
65
68
  return this.request(body, {
66
69
  [this._publicHeader]: mid,
@@ -153,6 +156,11 @@ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
153
156
  [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
154
157
  }, `${PathEnum_1.PathEnum.get_apple_pay_token}?switch=${this._multiRegionEcommSwitch}`, testEnv, regional)));
155
158
  }
159
+ _buildTransferConfigPath(paymentType) {
160
+ if (!paymentType)
161
+ return PathEnum_1.PathEnum.transfer_config;
162
+ return `${PathEnum_1.PathEnum.transfer_config}?paymentType=${encodeURIComponent(paymentType)}`;
163
+ }
156
164
  _buildCybersourceJwtPath(subscriptionId) {
157
165
  let path = PathEnum_1.PathEnum.cybersource_jwt;
158
166
  const params = [];
@@ -29,5 +29,6 @@ export declare enum PathEnum {
29
29
  get_user_id = "v1/subscriptions/",
30
30
  validate_apple_domain = "apple-pay/v1/validate",
31
31
  start_apple_pay_session = "apple-pay/v1/session/start",
32
- get_apple_pay_token = "apple-pay/v1/token"
32
+ get_apple_pay_token = "apple-pay/v1/token",
33
+ transfer_config = "transfer/v1/config"
33
34
  }
@@ -33,4 +33,5 @@ var PathEnum;
33
33
  PathEnum["validate_apple_domain"] = "apple-pay/v1/validate";
34
34
  PathEnum["start_apple_pay_session"] = "apple-pay/v1/session/start";
35
35
  PathEnum["get_apple_pay_token"] = "apple-pay/v1/token";
36
+ PathEnum["transfer_config"] = "transfer/v1/config";
36
37
  })(PathEnum = exports.PathEnum || (exports.PathEnum = {}));
@@ -0,0 +1,8 @@
1
+ /* tslint:disable:all */
2
+ /**
3
+ * Transfer payment type enum file
4
+ */
5
+ export declare enum TransferPaymentTypeEnum {
6
+ PAYMENT = "PAYMENT",
7
+ SUBSCRIPTION = "SUBSCRIPTION"
8
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransferPaymentTypeEnum = void 0;
4
+ /**
5
+ * Transfer payment type enum file
6
+ */
7
+ var TransferPaymentTypeEnum;
8
+ (function (TransferPaymentTypeEnum) {
9
+ TransferPaymentTypeEnum["PAYMENT"] = "PAYMENT";
10
+ TransferPaymentTypeEnum["SUBSCRIPTION"] = "SUBSCRIPTION";
11
+ })(TransferPaymentTypeEnum = exports.TransferPaymentTypeEnum || (exports.TransferPaymentTypeEnum = {}));
package/lib/lib.d.ts CHANGED
@@ -3,3 +3,4 @@
3
3
  * Main exports
4
4
  */
5
5
  export * from "./Kushki";
6
+ export * from "./infrastructure/TransferPaymentTypeEnum";
package/lib/lib.js CHANGED
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  __exportStar(require("./Kushki"), exports);
19
+ __exportStar(require("././../lib/infrastructure/TransferPaymentTypeEnum"), exports);
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * Interface for Kushki Gateway.
4
4
  */
5
+ import { TransferPaymentTypeEnum } from "./../../lib/infrastructure/TransferPaymentTypeEnum";
5
6
  import { Observable } from "rxjs";
6
7
  import { ApplePayPaymentData } from "./../../lib/types/apple_pay_get_token_events";
7
8
  import { ApplePayStartSessionRequest } from "./../../lib/types/apple_pay_start_session_request";
@@ -12,6 +13,7 @@ import { CardAsyncTokenResponse } from "./../../lib/types/card_async_token_respo
12
13
  import { CashTokenRequest } from "./../../lib/types/cash_token_request";
13
14
  import { DeferredOptionsResponse } from "./../../lib/types/deferred_options_response";
14
15
  import { GetBrandsLogosByMerchantResponse } from "./../../lib/types/get_brands_logos_by_merchant_response";
16
+ import { GetTransferConfigResponse } from "./../../lib/types/get_transfer_config_response";
15
17
  import { GetUserId } from "./../../lib/types/get_user_id";
16
18
  import { JwtResponse } from "./../../lib/types/jwt_response";
17
19
  import { KushkiSubscriptionTokensRequest } from "./../../lib/types/kushki_subscription_tokens_request";
@@ -24,7 +26,6 @@ import { PayoutsTransferTokenRequest } from "./../../lib/types/payouts_transfer_
24
26
  import { CommissionConfigurationAmount } from "./../../lib/types/remote/commission_configuration_amount";
25
27
  import { CommissionConfigurationRequest } from "./../../lib/types/remote/commission_configuration_request";
26
28
  import { TokenResponse } from "./../../lib/types/remote/token_response";
27
- import { TransferTokenRequest } from "./../../lib/types/remote/transfer_token_request";
28
29
  import { ResponseStatusValidator } from "./../../lib/types/response_status_validator";
29
30
  import { SecureOtpRequest } from "./../../lib/types/secure_otp_request";
30
31
  import { SecureOtpResponse } from "./../../lib/types/secure_otp_response";
@@ -32,6 +33,7 @@ import { SubscriptionCardAsyncTokenRequest } from "./../../lib/types/subscriptio
32
33
  import { SubscriptionCardAsyncTokenResponse } from "./../../lib/types/subscription_card_async_token_response";
33
34
  import { TokenChargeRequest } from "./../../lib/types/token_charge_request";
34
35
  import { TransferSubscriptionTokenRequest } from "./../../lib/types/transfer_subscription_token_request";
36
+ import { TransferTokenRequest } from "./../../lib/types/transfer_token_request";
35
37
  import { Validate3DsResponse } from "./../../lib/types/validate_3ds_response";
36
38
  export interface IKushkiGateway {
37
39
  /**
@@ -105,6 +107,14 @@ export interface IKushkiGateway {
105
107
  * @return GetBrandsLogosByMerchantResponse[]
106
108
  */
107
109
  requestBrandsLogosByMerchant(mid: string, isTest: boolean, regional: boolean): Observable<GetBrandsLogosByMerchantResponse[]>;
110
+ /**
111
+ * Get transfer processors config by merchant
112
+ * @param mid - public merchant id
113
+ * @param testEnv - is test environment
114
+ * @param regional - Define if endpoint used regional URL
115
+ * @param paymentType - optional paymentType query param
116
+ */
117
+ requestTransferConfig(mid: string, testEnv: boolean, regional: boolean, paymentType?: TransferPaymentTypeEnum): Observable<GetTransferConfigResponse>;
108
118
  /**
109
119
  * Send Webpay tokens request to Transbank API
110
120
  */
@@ -2,10 +2,12 @@
2
2
  /**
3
3
  * ITransferService file.
4
4
  */
5
+ import { TransferPaymentTypeEnum } from "./../../lib/infrastructure/TransferPaymentTypeEnum";
5
6
  import { Observable } from "rxjs";
6
7
  import { BankListResponse } from "./../../lib/types/bank_list_response";
8
+ import { GetTransferConfigResponse } from "./../../lib/types/get_transfer_config_response";
7
9
  import { TokenResponse } from "./../../lib/types/remote/token_response";
8
- import { TransferTokenRequest } from "./../../lib/types/remote/transfer_token_request";
10
+ import { TransferTokenRequest } from "./../../lib/types/transfer_token_request";
9
11
  export interface ITransferService {
10
12
  /**
11
13
  * Transfer Token
@@ -22,4 +24,12 @@ export interface ITransferService {
22
24
  * @param regional - Define if endpoint used regional URL
23
25
  */
24
26
  requestBankList(mid: string, isTest: boolean, regional: boolean): Observable<BankListResponse>;
27
+ /**
28
+ * Transfer processors Config
29
+ * @param mid - public merchant id
30
+ * @param isTest - is test environment
31
+ * @param regional - Define if endpoint used regional URL
32
+ * @param paymentType - optional paymentType filter
33
+ */
34
+ getTransferConfig(mid: string, isTest: boolean, regional: boolean, paymentType?: TransferPaymentTypeEnum): Observable<GetTransferConfigResponse>;
25
35
  }
@@ -1,12 +1,14 @@
1
1
  /* tslint:disable:all */
2
+ import { TransferPaymentTypeEnum } from "./../../lib/infrastructure/TransferPaymentTypeEnum";
2
3
  import "reflect-metadata";
3
4
  import { IAntiFraud } from "./../../lib/repository/IAntiFraud";
4
5
  import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
5
6
  import { ITransferService } from "./../../lib/repository/ITransferService";
6
7
  import { Observable } from "rxjs";
7
8
  import { BankListResponse } from "./../../lib/types/bank_list_response";
9
+ import { GetTransferConfigResponse } from "./../../lib/types/get_transfer_config_response";
8
10
  import { TokenResponse } from "./../../lib/types/remote/token_response";
9
- import { TransferTokenRequest } from "./../../lib/types/remote/transfer_token_request";
11
+ import { TransferTokenRequest } from "./../../lib/types/transfer_token_request";
10
12
  /**
11
13
  * Implementation
12
14
  */
@@ -16,4 +18,5 @@ export declare class TransferService implements ITransferService {
16
18
  constructor(gateway: IKushkiGateway, antiFraud: IAntiFraud);
17
19
  requestTransferToken(request: TransferTokenRequest, mid: string, isTest: boolean, regional: boolean): Observable<TokenResponse>;
18
20
  requestBankList(mid: string, isTest: boolean, regional: boolean): Observable<BankListResponse>;
21
+ getTransferConfig(mid: string, isTest: boolean, regional: boolean, paymentType?: TransferPaymentTypeEnum): Observable<GetTransferConfigResponse>;
19
22
  }
@@ -30,15 +30,21 @@ let TransferService = class TransferService {
30
30
  }
31
31
  requestTransferToken(request, mid, isTest, regional) {
32
32
  return this._gateway.requestMerchantSettings(mid, isTest, regional).pipe(operators_1.switchMap((merchant) => {
33
- const client = request.documentNumber !== undefined
33
+ const client = "documentNumber" in request && request.documentNumber !== undefined
34
34
  ? request.documentNumber
35
35
  : new Date().getTime().toString();
36
- return this._antiFraud.createSiftScienceSession(request.bankId, client, mid, isTest, merchant);
36
+ const bank_id = "bankId" in request && request.bankId !== undefined
37
+ ? request.bankId
38
+ : "";
39
+ return this._antiFraud.createSiftScienceSession(bank_id, client, mid, isTest, merchant);
37
40
  }), operators_1.switchMap((siftObject) => this._gateway.requestTransferToken(Object.assign(Object.assign({}, request), siftObject), mid, isTest, regional)));
38
41
  }
39
42
  requestBankList(mid, isTest, regional) {
40
43
  return this._gateway.requestPseBankList(mid, isTest, regional);
41
44
  }
45
+ getTransferConfig(mid, isTest, regional, paymentType) {
46
+ return this._gateway.requestTransferConfig(mid, isTest, regional, paymentType);
47
+ }
42
48
  };
43
49
  TransferService = __decorate([
44
50
  inversify_1.injectable(),
@@ -0,0 +1,46 @@
1
+ /* tslint:disable:all */
2
+ /* tslint:disable:all */
3
+
4
+ /**
5
+ * Transfer processors enabled for the merchant. Use it to let the end user pick a processor and, when available, a product and channel before calling requestTransferToken.
6
+ */
7
+ export interface GetTransferConfigResponse {
8
+ /**
9
+ * Enabled transfer processors. An empty array is a valid response: the merchant has no transfer processor configured.
10
+ */
11
+ processors: {
12
+ /**
13
+ * Processor name as configured in Kushki (e.g. "Bre-B Credibanco Processor"). For multi-processor merchants send it as-is in requestTransferToken as processor.name.
14
+ */
15
+ name: string;
16
+ /**
17
+ * ISO 4217 currency code the processor operates with (e.g. "COP"). Use it as currency in requestTransferToken.
18
+ */
19
+ currency: string;
20
+ /**
21
+ * Payment products the processor offers, each through one or more channels. Absent for legacy processors such as PSE.
22
+ */
23
+ supportedFlows?: {
24
+ /**
25
+ * Product type. "PAYMENT" is a one-time payment, "SUBSCRIPTION" a recurring one; the same values TransferPaymentTypeEnum accepts as getTransferConfig filter.
26
+ */
27
+ paymentType: "PAYMENT" | "SUBSCRIPTION";
28
+ /**
29
+ * Channels offering the product (e.g. "QR", "PUSH", "DEEPLINK"). For a "PAYMENT" product, send the chosen value as processor.channel in requestTransferToken.
30
+ */
31
+ channels: string[];
32
+ /**
33
+ * Human readable product name meant to be displayed to the end user.
34
+ */
35
+ name: string;
36
+ /**
37
+ * Optional longer text describing the product, meant to be displayed to the end user.
38
+ */
39
+ description?: string;
40
+ /**
41
+ * Available periodicities (e.g. "monthly"). Only for "SUBSCRIPTION" products.
42
+ */
43
+ periodicities?: string[];
44
+ }[];
45
+ }[];
46
+ }
@@ -8,7 +8,8 @@ export type TransferTokenRequest =
8
8
  | BrazilianTokenRequest
9
9
  | CostaRicaTokenRequest
10
10
  | PeruvianTokenRequest
11
- | EcuadorTokenRequest;
11
+ | EcuadorTokenRequest
12
+ | MultiProcessorTokenRequest;
12
13
  export type CallbackUrl = string;
13
14
  export type UserType = "0" | "1";
14
15
  export type UserId = string | null;
@@ -130,3 +131,18 @@ export interface EcuadorTokenRequest {
130
131
  savePaymentData?: boolean;
131
132
  [k: string]: any;
132
133
  }
134
+ /**
135
+ * Transfer token request for merchants with multiple processors. processor.name and processor.channel come from getTransferConfig (processors[].name and a channel of a PAYMENT product) and are forwarded as-is. Extra fields a processor needs go in the body or inside processor; the backend validates them.
136
+ */
137
+ export interface MultiProcessorTokenRequest {
138
+ amount: Amount;
139
+ currency: string;
140
+ userId?: UserId;
141
+ sessionId?: SessionId;
142
+ processor: {
143
+ name: string;
144
+ channel?: string;
145
+ [k: string]: any;
146
+ };
147
+ [k: string]: any;
148
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kushki/js",
3
- "version": "1.40.5",
3
+ "version": "1.41.0-alpha",
4
4
  "description": "kushki-js",
5
5
  "main": "lib/lib.js",
6
6
  "types": "lib/lib.d.ts",
@@ -1,5 +0,0 @@
1
- /* tslint:disable:all */
2
- /**
3
- * Environment file
4
- */
5
- export declare const environment: {};
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.environment = void 0;
4
- /**
5
- * Environment file
6
- */
7
- /* tslint:disable:all */
8
- // The file contents for the current environment will overwrite these during build.
9
- // The build system defaults to the dev environment which uses `environment.ts`, but if you do
10
- // `ng build --env=prod` then `environment.prod.ts` will be used instead.
11
- exports.environment = {};