@finverse/sdk-typescript 0.0.21 → 0.0.24

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/README.md CHANGED
@@ -6,8 +6,7 @@ This SDK enables a basic end-to-end backend integration with the Finverse API, i
6
6
  npm install @finverse/sdk-typescript
7
7
  ```
8
8
 
9
-
10
- ## Getting started
9
+ ## Getting started (Linking flow)
11
10
 
12
11
  ### 1. Authenticate with Finverse API: Obtain Customer Access Token
13
12
  ```typescript
@@ -162,3 +161,134 @@ const statementId = statements.data.statements[0].id;
162
161
  // Can download statement from here
163
162
  const satementLink = await new LoginIdentityApi(configuration).getStatementLink(statementId);
164
163
  ```
164
+
165
+ ## Getting started (Payment flow)
166
+
167
+ ### 1. Authenticate with Finverse API: Obtain Customer Access Token
168
+ ```typescript
169
+ // Obtain these from https://dashboard.finverse.com
170
+ const apiHost = "https://api.sandbox.finverse.net"
171
+ const clientId = process.env.FINVERSE_CLIENTID
172
+ const clientSecret = process.env.FINVERSE_SECRET
173
+ const redirectUri = process.env.REDIRECT_URI
174
+
175
+ const configuration = new Configuration({ basePath: apiHost });
176
+ // Obtain customer access token
177
+ const customerTokenResp = await new PublicApi(configuration).generateCustomerAccessToken({
178
+ client_id: clientId,
179
+ client_secret: clientSecret,
180
+ grant_type: 'client_credentials',
181
+ });
182
+
183
+ const customerAccessToken = customerTokenResp.access_token
184
+ ```
185
+
186
+ ### 2. Create payment instruction
187
+ ```typescript
188
+ const configuration = new Configuration({ basePath: config.apiHost, accessToken: customerToken.access_token });
189
+ const paymentInstruction: CustomerPaymentInstruction = {
190
+ type: "DEBIT_AUTHORIZATION",
191
+ user_id: "customer_user1",
192
+ frequency: "MONTHLY",
193
+ start_date: "2022-04-01",
194
+ end_date: "2022-12-01",
195
+ amount: 1000,
196
+ currency: "PHP",
197
+ recipient_name: "HOMECREDIT",
198
+ recipient_account_id: "Recipient Account Id",
199
+ sender_name: "Sender Name",
200
+ sender_account_id: "LOAN102345",
201
+ remarks: "HOME CREDIT REPAYMENT"
202
+ };
203
+ const createPaymentInstructionResponse = await new CustomerApi(configuration).createPaymentInstruction(paymentInstruction);
204
+
205
+ // createPaymentInstructionResponse.data.payment_instruction_id can be used to retrieve the status
206
+ ```
207
+
208
+ ### 3. Link with payment instruction: Obtain Link Token and Link URL to launch Finverse Link UI
209
+ ```typescript
210
+ // generate a link token
211
+
212
+ // reference back to your system userId, finverse does not use this
213
+ const userId = "someUserId"
214
+ // this will be sent in the redirectUri callback, can be used to identify the state
215
+ const state = "someUniqueState"
216
+ const configuration = new Configuration({
217
+ basePath: apiHost,
218
+ accessToken: customerToken.access_token
219
+ });
220
+ const linkTokenResp = await new CustomerApi(configuration).generateLinkToken({
221
+ ClientId: clientId,
222
+ UserId: userId,
223
+ RedirectUri: redirectUri,
224
+ State: state,
225
+ ResponseMode: "form_post",
226
+ ResponseType: "code",
227
+ GrantType: "client_credentials",
228
+ PaymentInstructionId: createPaymentInstructionResponse.data.payment_instruction_id,
229
+ ProductsRequested: "PAYMENTS",
230
+ });
231
+
232
+ // The linkUrl can be used to initiate Finverse Link
233
+ console.log("linkUrl: " + linkTokenResp.link_url)
234
+ ```
235
+
236
+ ### 4. Finalize linking: Exchange code for Login Identity Access Token
237
+ ```typescript
238
+ // when Finverse Link UI is successful, obtain the code from Finverse Link
239
+ // exchange it for a Login Identity Access Token
240
+ const code = "obtainAfterLink"
241
+ const configuration = new Configuration({
242
+ basePath: apiHost,
243
+ accessToken: customerToken.access_token
244
+ });
245
+ const loginIdentityTokenResp = await new LinkApi(configuration).token(
246
+ "authorization_code",
247
+ code,
248
+ clientId,
249
+ redirectURI,
250
+ );
251
+
252
+ // The loginIdentityToken can be used to retrieve data
253
+ const loginIdentityToken = loginIdentityTokenResp.access_token
254
+ ```
255
+
256
+ ### 5. Poll loginIdentityStatus until ready
257
+ Alternatively you can use webhook to receive LoginIdentity event.
258
+
259
+ ```typescript
260
+ enum FinalStatus {
261
+ ERROR = 'ERROR',
262
+ DATA_RETRIEVAL_PARTIALLY_SUCCESSFUL = 'DATA_RETRIEVAL_PARTIALLY_SUCCESSFUL',
263
+ DATA_RETRIEVAL_COMPLETE = 'DATA_RETRIEVAL_COMPLETE',
264
+ }
265
+
266
+ const configuration = new Configuration({
267
+ basePath: apiHost,
268
+ accessToken: loginIdentityToken.access_token
269
+ });
270
+ let loginIdentity: AxiosResponse<GetLoginIdentityByIdResponse>;
271
+
272
+ // Poll until loginIdentityStatus is ready
273
+ for (let i = 0; i < 20; i++) {
274
+ loginIdentity = await new LoginIdentityApi(configuration).getLoginIdentity();
275
+ const loginIdentityStatus = loginIdentity.data.login_identity.status;
276
+ if (
277
+ loginIdentityStatus === FinalStatus.ERROR ||
278
+ loginIdentityStatus === FinalStatus.DATA_RETRIEVAL_COMPLETE ||
279
+ loginIdentityStatus === FinalStatus.DATA_RETRIEVAL_PARTIALLY_SUCCESSFUL
280
+ ) { break; }
281
+
282
+ await new Promise((resolve) => setTimeout(resolve, 3000));
283
+ }
284
+
285
+ console.log("login identity: " + loginIdentityResp.login_identity)
286
+ ```
287
+
288
+ ### 6. Get payment instruction status
289
+ ```typescript
290
+ const configuration = new Configuration({ basePath: config.apiHost, accessToken: customerToken.access_token });
291
+ const getPaymentInstructionResponse = await new CustomerApi(configuration).getPaymentInstruction(createPaymentInstructionResponse.data.payment_instruction_id);
292
+
293
+ console.log("paymentInstruction status: " + getPaymentInstructionResponse.data.payment_instruction.status);
294
+ ```
package/dist/api.d.ts CHANGED
@@ -1162,13 +1162,13 @@ export interface IncomeEstimate {
1162
1162
  * @type {number}
1163
1163
  * @memberof IncomeEstimate
1164
1164
  */
1165
- amount?: number;
1165
+ amount: number;
1166
1166
  /**
1167
1167
  * Currency
1168
1168
  * @type {string}
1169
1169
  * @memberof IncomeEstimate
1170
1170
  */
1171
- currency?: string;
1171
+ currency: string;
1172
1172
  }
1173
1173
  /**
1174
1174
  *
@@ -1181,19 +1181,19 @@ export interface IncomeResponse {
1181
1181
  * @type {Array<SingleSourceIncome>}
1182
1182
  * @memberof IncomeResponse
1183
1183
  */
1184
- income?: Array<SingleSourceIncome>;
1184
+ income: Array<SingleSourceIncome>;
1185
1185
  /**
1186
1186
  *
1187
1187
  * @type {LoginIdentityShort}
1188
1188
  * @memberof IncomeResponse
1189
1189
  */
1190
- login_identity?: LoginIdentityShort;
1190
+ login_identity: LoginIdentityShort;
1191
1191
  /**
1192
1192
  *
1193
1193
  * @type {InstitutionShort}
1194
1194
  * @memberof IncomeResponse
1195
1195
  */
1196
- institution?: InstitutionShort;
1196
+ institution: InstitutionShort;
1197
1197
  }
1198
1198
  /**
1199
1199
  *
@@ -1206,7 +1206,7 @@ export interface IncomeStream {
1206
1206
  * @type {string}
1207
1207
  * @memberof IncomeStream
1208
1208
  */
1209
- account_id?: string;
1209
+ account_id: string;
1210
1210
  /**
1211
1211
  *
1212
1212
  * @type {IncomeEstimate}
@@ -1218,13 +1218,13 @@ export interface IncomeStream {
1218
1218
  * @type {number}
1219
1219
  * @memberof IncomeStream
1220
1220
  */
1221
- transaction_count?: number;
1221
+ transaction_count: number;
1222
1222
  /**
1223
1223
  *
1224
1224
  * @type {Array<MonthlyIncomeEstimate>}
1225
1225
  * @memberof IncomeStream
1226
1226
  */
1227
- monthly_history?: Array<MonthlyIncomeEstimate>;
1227
+ monthly_history: Array<MonthlyIncomeEstimate>;
1228
1228
  }
1229
1229
  /**
1230
1230
  *
@@ -1243,13 +1243,13 @@ export interface IncomeTotal {
1243
1243
  * @type {number}
1244
1244
  * @memberof IncomeTotal
1245
1245
  */
1246
- transaction_count?: number;
1246
+ transaction_count: number;
1247
1247
  /**
1248
1248
  *
1249
1249
  * @type {Array<MonthlyIncomeEstimate>}
1250
1250
  * @memberof IncomeTotal
1251
1251
  */
1252
- monthly_history?: Array<MonthlyIncomeEstimate>;
1252
+ monthly_history: Array<MonthlyIncomeEstimate>;
1253
1253
  }
1254
1254
  /**
1255
1255
  *
@@ -1561,6 +1561,12 @@ export interface LinkTokenRequest {
1561
1561
  * @memberof LinkTokenRequest
1562
1562
  */
1563
1563
  payment_instruction_id?: string;
1564
+ /**
1565
+ * Controls the behavior of the automatic data refresh checkbox
1566
+ * @type {string}
1567
+ * @memberof LinkTokenRequest
1568
+ */
1569
+ automatic_data_refresh?: LinkTokenRequestAutomaticDataRefreshEnum;
1564
1570
  }
1565
1571
  export declare const LinkTokenRequestUiModeEnum: {
1566
1572
  readonly Iframe: "iframe";
@@ -1568,6 +1574,12 @@ export declare const LinkTokenRequestUiModeEnum: {
1568
1574
  readonly AutoRedirect: "auto_redirect";
1569
1575
  };
1570
1576
  export declare type LinkTokenRequestUiModeEnum = typeof LinkTokenRequestUiModeEnum[keyof typeof LinkTokenRequestUiModeEnum];
1577
+ export declare const LinkTokenRequestAutomaticDataRefreshEnum: {
1578
+ readonly On: "ON";
1579
+ readonly Off: "OFF";
1580
+ readonly ForcedOn: "FORCED_ON";
1581
+ };
1582
+ export declare type LinkTokenRequestAutomaticDataRefreshEnum = typeof LinkTokenRequestAutomaticDataRefreshEnum[keyof typeof LinkTokenRequestAutomaticDataRefreshEnum];
1571
1583
  /**
1572
1584
  *
1573
1585
  * @export
@@ -1968,19 +1980,19 @@ export interface MonthlyIncomeEstimate {
1968
1980
  * @type {IncomeEstimate}
1969
1981
  * @memberof MonthlyIncomeEstimate
1970
1982
  */
1971
- estimated_income?: IncomeEstimate;
1983
+ estimated_income: IncomeEstimate;
1972
1984
  /**
1973
1985
  * The numeric month
1974
1986
  * @type {number}
1975
1987
  * @memberof MonthlyIncomeEstimate
1976
1988
  */
1977
- month?: number;
1989
+ month: number;
1978
1990
  /**
1979
1991
  * The year
1980
1992
  * @type {number}
1981
1993
  * @memberof MonthlyIncomeEstimate
1982
1994
  */
1983
- year?: number;
1995
+ year: number;
1984
1996
  }
1985
1997
  /**
1986
1998
  *
@@ -2063,7 +2075,7 @@ export interface PaymentInstruction {
2063
2075
  */
2064
2076
  login_identity_id?: string;
2065
2077
  /**
2066
- * Type of payment is being created, please check Documentation on which payment type is supported in each institution
2078
+ * Type of payment that was created, please check Documentation on which payment type is supported in each institution
2067
2079
  * @type {string}
2068
2080
  * @memberof PaymentInstruction
2069
2081
  */
@@ -2299,25 +2311,25 @@ export interface SingleSourceIncome {
2299
2311
  * @type {Array<IncomeStream>}
2300
2312
  * @memberof SingleSourceIncome
2301
2313
  */
2302
- income_streams?: Array<IncomeStream>;
2314
+ income_streams: Array<IncomeStream>;
2303
2315
  /**
2304
2316
  *
2305
2317
  * @type {IncomeTotal}
2306
2318
  * @memberof SingleSourceIncome
2307
2319
  */
2308
- income_total?: IncomeTotal;
2320
+ income_total: IncomeTotal;
2309
2321
  /**
2310
2322
  * Where the income estimate was sourced from
2311
2323
  * @type {string}
2312
2324
  * @memberof SingleSourceIncome
2313
2325
  */
2314
- source?: string;
2326
+ source: string;
2315
2327
  /**
2316
2328
  * Unknown
2317
2329
  * @type {string}
2318
2330
  * @memberof SingleSourceIncome
2319
2331
  */
2320
- source_id?: string;
2332
+ source_id: string;
2321
2333
  }
2322
2334
  /**
2323
2335
  *
@@ -2540,7 +2552,7 @@ export interface Transaction {
2540
2552
  */
2541
2553
  export declare const CustomerApiAxiosParamCreator: (configuration?: Configuration) => {
2542
2554
  /**
2543
- * Create a new payment instruction to be used when linking to perform debit authorization
2555
+ * Create a new payment instruction to be used when linking to perform new payment
2544
2556
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
2545
2557
  * @param {*} [options] Override http request option.
2546
2558
  * @throws {RequiredError}
@@ -2575,7 +2587,7 @@ export declare const CustomerApiAxiosParamCreator: (configuration?: Configuratio
2575
2587
  */
2576
2588
  getLoginIdentityHistory: (loginIdentityId: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
2577
2589
  /**
2578
- * Get payment instructions to be used when linking to perform debit authorization by id
2590
+ * Get payment instructions by payment_instruction_id
2579
2591
  * @param {string} paymentInstructionId The id of a payment instruction
2580
2592
  * @param {*} [options] Override http request option.
2581
2593
  * @throws {RequiredError}
@@ -2605,7 +2617,7 @@ export declare const CustomerApiAxiosParamCreator: (configuration?: Configuratio
2605
2617
  */
2606
2618
  export declare const CustomerApiFp: (configuration?: Configuration) => {
2607
2619
  /**
2608
- * Create a new payment instruction to be used when linking to perform debit authorization
2620
+ * Create a new payment instruction to be used when linking to perform new payment
2609
2621
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
2610
2622
  * @param {*} [options] Override http request option.
2611
2623
  * @throws {RequiredError}
@@ -2640,7 +2652,7 @@ export declare const CustomerApiFp: (configuration?: Configuration) => {
2640
2652
  */
2641
2653
  getLoginIdentityHistory(loginIdentityId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetLoginIdentityHistoryResponse>>;
2642
2654
  /**
2643
- * Get payment instructions to be used when linking to perform debit authorization by id
2655
+ * Get payment instructions by payment_instruction_id
2644
2656
  * @param {string} paymentInstructionId The id of a payment instruction
2645
2657
  * @param {*} [options] Override http request option.
2646
2658
  * @throws {RequiredError}
@@ -2670,7 +2682,7 @@ export declare const CustomerApiFp: (configuration?: Configuration) => {
2670
2682
  */
2671
2683
  export declare const CustomerApiFactory: (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) => {
2672
2684
  /**
2673
- * Create a new payment instruction to be used when linking to perform debit authorization
2685
+ * Create a new payment instruction to be used when linking to perform new payment
2674
2686
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
2675
2687
  * @param {*} [options] Override http request option.
2676
2688
  * @throws {RequiredError}
@@ -2705,7 +2717,7 @@ export declare const CustomerApiFactory: (configuration?: Configuration, basePat
2705
2717
  */
2706
2718
  getLoginIdentityHistory(loginIdentityId: string, options?: any): AxiosPromise<GetLoginIdentityHistoryResponse>;
2707
2719
  /**
2708
- * Get payment instructions to be used when linking to perform debit authorization by id
2720
+ * Get payment instructions by payment_instruction_id
2709
2721
  * @param {string} paymentInstructionId The id of a payment instruction
2710
2722
  * @param {*} [options] Override http request option.
2711
2723
  * @throws {RequiredError}
@@ -2736,7 +2748,7 @@ export declare const CustomerApiFactory: (configuration?: Configuration, basePat
2736
2748
  */
2737
2749
  export interface CustomerApiInterface {
2738
2750
  /**
2739
- * Create a new payment instruction to be used when linking to perform debit authorization
2751
+ * Create a new payment instruction to be used when linking to perform new payment
2740
2752
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
2741
2753
  * @param {*} [options] Override http request option.
2742
2754
  * @throws {RequiredError}
@@ -2776,7 +2788,7 @@ export interface CustomerApiInterface {
2776
2788
  */
2777
2789
  getLoginIdentityHistory(loginIdentityId: string, options?: AxiosRequestConfig): AxiosPromise<GetLoginIdentityHistoryResponse>;
2778
2790
  /**
2779
- * Get payment instructions to be used when linking to perform debit authorization by id
2791
+ * Get payment instructions by payment_instruction_id
2780
2792
  * @param {string} paymentInstructionId The id of a payment instruction
2781
2793
  * @param {*} [options] Override http request option.
2782
2794
  * @throws {RequiredError}
@@ -2811,7 +2823,7 @@ export interface CustomerApiInterface {
2811
2823
  */
2812
2824
  export declare class CustomerApi extends BaseAPI implements CustomerApiInterface {
2813
2825
  /**
2814
- * Create a new payment instruction to be used when linking to perform debit authorization
2826
+ * Create a new payment instruction to be used when linking to perform new payment
2815
2827
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
2816
2828
  * @param {*} [options] Override http request option.
2817
2829
  * @throws {RequiredError}
@@ -2851,7 +2863,7 @@ export declare class CustomerApi extends BaseAPI implements CustomerApiInterface
2851
2863
  */
2852
2864
  getLoginIdentityHistory(loginIdentityId: string, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetLoginIdentityHistoryResponse>>;
2853
2865
  /**
2854
- * Get payment instructions to be used when linking to perform debit authorization by id
2866
+ * Get payment instructions by payment_instruction_id
2855
2867
  * @param {string} paymentInstructionId The id of a payment instruction
2856
2868
  * @param {*} [options] Override http request option.
2857
2869
  * @throws {RequiredError}
@@ -3695,14 +3707,14 @@ export declare class LoginIdentityApi extends BaseAPI implements LoginIdentityAp
3695
3707
  */
3696
3708
  export declare const PaymentApiAxiosParamCreator: (configuration?: Configuration) => {
3697
3709
  /**
3698
- * Create a new payment instruction to be used when linking to perform debit authorization
3710
+ * Create a new payment instruction to be used when linking to perform new payment
3699
3711
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
3700
3712
  * @param {*} [options] Override http request option.
3701
3713
  * @throws {RequiredError}
3702
3714
  */
3703
3715
  createPaymentInstruction: (paymentInstruction: CustomerPaymentInstruction, options?: AxiosRequestConfig) => Promise<RequestArgs>;
3704
3716
  /**
3705
- * Get payment instructions to be used when linking to perform debit authorization by id
3717
+ * Get payment instructions by payment_instruction_id
3706
3718
  * @param {string} paymentInstructionId The id of a payment instruction
3707
3719
  * @param {*} [options] Override http request option.
3708
3720
  * @throws {RequiredError}
@@ -3715,14 +3727,14 @@ export declare const PaymentApiAxiosParamCreator: (configuration?: Configuration
3715
3727
  */
3716
3728
  export declare const PaymentApiFp: (configuration?: Configuration) => {
3717
3729
  /**
3718
- * Create a new payment instruction to be used when linking to perform debit authorization
3730
+ * Create a new payment instruction to be used when linking to perform new payment
3719
3731
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
3720
3732
  * @param {*} [options] Override http request option.
3721
3733
  * @throws {RequiredError}
3722
3734
  */
3723
3735
  createPaymentInstruction(paymentInstruction: CustomerPaymentInstruction, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CreatePaymentInstructionResponse>>;
3724
3736
  /**
3725
- * Get payment instructions to be used when linking to perform debit authorization by id
3737
+ * Get payment instructions by payment_instruction_id
3726
3738
  * @param {string} paymentInstructionId The id of a payment instruction
3727
3739
  * @param {*} [options] Override http request option.
3728
3740
  * @throws {RequiredError}
@@ -3735,14 +3747,14 @@ export declare const PaymentApiFp: (configuration?: Configuration) => {
3735
3747
  */
3736
3748
  export declare const PaymentApiFactory: (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) => {
3737
3749
  /**
3738
- * Create a new payment instruction to be used when linking to perform debit authorization
3750
+ * Create a new payment instruction to be used when linking to perform new payment
3739
3751
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
3740
3752
  * @param {*} [options] Override http request option.
3741
3753
  * @throws {RequiredError}
3742
3754
  */
3743
3755
  createPaymentInstruction(paymentInstruction: CustomerPaymentInstruction, options?: any): AxiosPromise<CreatePaymentInstructionResponse>;
3744
3756
  /**
3745
- * Get payment instructions to be used when linking to perform debit authorization by id
3757
+ * Get payment instructions by payment_instruction_id
3746
3758
  * @param {string} paymentInstructionId The id of a payment instruction
3747
3759
  * @param {*} [options] Override http request option.
3748
3760
  * @throws {RequiredError}
@@ -3756,7 +3768,7 @@ export declare const PaymentApiFactory: (configuration?: Configuration, basePath
3756
3768
  */
3757
3769
  export interface PaymentApiInterface {
3758
3770
  /**
3759
- * Create a new payment instruction to be used when linking to perform debit authorization
3771
+ * Create a new payment instruction to be used when linking to perform new payment
3760
3772
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
3761
3773
  * @param {*} [options] Override http request option.
3762
3774
  * @throws {RequiredError}
@@ -3764,7 +3776,7 @@ export interface PaymentApiInterface {
3764
3776
  */
3765
3777
  createPaymentInstruction(paymentInstruction: CustomerPaymentInstruction, options?: AxiosRequestConfig): AxiosPromise<CreatePaymentInstructionResponse>;
3766
3778
  /**
3767
- * Get payment instructions to be used when linking to perform debit authorization by id
3779
+ * Get payment instructions by payment_instruction_id
3768
3780
  * @param {string} paymentInstructionId The id of a payment instruction
3769
3781
  * @param {*} [options] Override http request option.
3770
3782
  * @throws {RequiredError}
@@ -3780,7 +3792,7 @@ export interface PaymentApiInterface {
3780
3792
  */
3781
3793
  export declare class PaymentApi extends BaseAPI implements PaymentApiInterface {
3782
3794
  /**
3783
- * Create a new payment instruction to be used when linking to perform debit authorization
3795
+ * Create a new payment instruction to be used when linking to perform new payment
3784
3796
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
3785
3797
  * @param {*} [options] Override http request option.
3786
3798
  * @throws {RequiredError}
@@ -3788,7 +3800,7 @@ export declare class PaymentApi extends BaseAPI implements PaymentApiInterface {
3788
3800
  */
3789
3801
  createPaymentInstruction(paymentInstruction: CustomerPaymentInstruction, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreatePaymentInstructionResponse>>;
3790
3802
  /**
3791
- * Get payment instructions to be used when linking to perform debit authorization by id
3803
+ * Get payment instructions by payment_instruction_id
3792
3804
  * @param {string} paymentInstructionId The id of a payment instruction
3793
3805
  * @param {*} [options] Override http request option.
3794
3806
  * @throws {RequiredError}
package/dist/api.js CHANGED
@@ -22,7 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  });
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.PublicApi = exports.PublicApiFactory = exports.PublicApiFp = exports.PublicApiAxiosParamCreator = exports.PaymentApi = exports.PaymentApiFactory = exports.PaymentApiFp = exports.PaymentApiAxiosParamCreator = exports.LoginIdentityApi = exports.LoginIdentityApiFactory = exports.LoginIdentityApiFp = exports.LoginIdentityApiAxiosParamCreator = exports.LinkApi = exports.LinkApiFactory = exports.LinkApiFp = exports.LinkApiAxiosParamCreator = exports.CustomerApi = exports.CustomerApiFactory = exports.CustomerApiFp = exports.CustomerApiAxiosParamCreator = exports.PaymentInstructionTypeEnum = exports.LinkTokenRequestUiModeEnum = exports.CustomerPaymentInstructionTypeEnum = void 0;
25
+ exports.PublicApi = exports.PublicApiFactory = exports.PublicApiFp = exports.PublicApiAxiosParamCreator = exports.PaymentApi = exports.PaymentApiFactory = exports.PaymentApiFp = exports.PaymentApiAxiosParamCreator = exports.LoginIdentityApi = exports.LoginIdentityApiFactory = exports.LoginIdentityApiFp = exports.LoginIdentityApiAxiosParamCreator = exports.LinkApi = exports.LinkApiFactory = exports.LinkApiFp = exports.LinkApiAxiosParamCreator = exports.CustomerApi = exports.CustomerApiFactory = exports.CustomerApiFp = exports.CustomerApiAxiosParamCreator = exports.PaymentInstructionTypeEnum = exports.LinkTokenRequestAutomaticDataRefreshEnum = exports.LinkTokenRequestUiModeEnum = exports.CustomerPaymentInstructionTypeEnum = void 0;
26
26
  const axios_1 = require("axios");
27
27
  // Some imports not used depending on template conditions
28
28
  // @ts-ignore
@@ -37,6 +37,11 @@ exports.LinkTokenRequestUiModeEnum = {
37
37
  Redirect: 'redirect',
38
38
  AutoRedirect: 'auto_redirect',
39
39
  };
40
+ exports.LinkTokenRequestAutomaticDataRefreshEnum = {
41
+ On: 'ON',
42
+ Off: 'OFF',
43
+ ForcedOn: 'FORCED_ON',
44
+ };
40
45
  exports.PaymentInstructionTypeEnum = {
41
46
  DebitAuthorization: 'DEBIT_AUTHORIZATION',
42
47
  };
@@ -47,7 +52,7 @@ exports.PaymentInstructionTypeEnum = {
47
52
  exports.CustomerApiAxiosParamCreator = function (configuration) {
48
53
  return {
49
54
  /**
50
- * Create a new payment instruction to be used when linking to perform debit authorization
55
+ * Create a new payment instruction to be used when linking to perform new payment
51
56
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
52
57
  * @param {*} [options] Override http request option.
53
58
  * @throws {RequiredError}
@@ -201,7 +206,7 @@ exports.CustomerApiAxiosParamCreator = function (configuration) {
201
206
  };
202
207
  }),
203
208
  /**
204
- * Get payment instructions to be used when linking to perform debit authorization by id
209
+ * Get payment instructions by payment_instruction_id
205
210
  * @param {string} paymentInstructionId The id of a payment instruction
206
211
  * @param {*} [options] Override http request option.
207
212
  * @throws {RequiredError}
@@ -315,7 +320,7 @@ exports.CustomerApiFp = function (configuration) {
315
320
  const localVarAxiosParamCreator = exports.CustomerApiAxiosParamCreator(configuration);
316
321
  return {
317
322
  /**
318
- * Create a new payment instruction to be used when linking to perform debit authorization
323
+ * Create a new payment instruction to be used when linking to perform new payment
319
324
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
320
325
  * @param {*} [options] Override http request option.
321
326
  * @throws {RequiredError}
@@ -375,7 +380,7 @@ exports.CustomerApiFp = function (configuration) {
375
380
  });
376
381
  },
377
382
  /**
378
- * Get payment instructions to be used when linking to perform debit authorization by id
383
+ * Get payment instructions by payment_instruction_id
379
384
  * @param {string} paymentInstructionId The id of a payment instruction
380
385
  * @param {*} [options] Override http request option.
381
386
  * @throws {RequiredError}
@@ -423,7 +428,7 @@ exports.CustomerApiFactory = function (configuration, basePath, axios) {
423
428
  const localVarFp = exports.CustomerApiFp(configuration);
424
429
  return {
425
430
  /**
426
- * Create a new payment instruction to be used when linking to perform debit authorization
431
+ * Create a new payment instruction to be used when linking to perform new payment
427
432
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
428
433
  * @param {*} [options] Override http request option.
429
434
  * @throws {RequiredError}
@@ -470,7 +475,7 @@ exports.CustomerApiFactory = function (configuration, basePath, axios) {
470
475
  return localVarFp.getLoginIdentityHistory(loginIdentityId, options).then((request) => request(axios, basePath));
471
476
  },
472
477
  /**
473
- * Get payment instructions to be used when linking to perform debit authorization by id
478
+ * Get payment instructions by payment_instruction_id
474
479
  * @param {string} paymentInstructionId The id of a payment instruction
475
480
  * @param {*} [options] Override http request option.
476
481
  * @throws {RequiredError}
@@ -513,7 +518,7 @@ exports.CustomerApiFactory = function (configuration, basePath, axios) {
513
518
  */
514
519
  class CustomerApi extends base_1.BaseAPI {
515
520
  /**
516
- * Create a new payment instruction to be used when linking to perform debit authorization
521
+ * Create a new payment instruction to be used when linking to perform new payment
517
522
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
518
523
  * @param {*} [options] Override http request option.
519
524
  * @throws {RequiredError}
@@ -573,7 +578,7 @@ class CustomerApi extends base_1.BaseAPI {
573
578
  .then((request) => request(this.axios, this.basePath));
574
579
  }
575
580
  /**
576
- * Get payment instructions to be used when linking to perform debit authorization by id
581
+ * Get payment instructions by payment_instruction_id
577
582
  * @param {string} paymentInstructionId The id of a payment instruction
578
583
  * @param {*} [options] Override http request option.
579
584
  * @throws {RequiredError}
@@ -1993,7 +1998,7 @@ exports.LoginIdentityApi = LoginIdentityApi;
1993
1998
  exports.PaymentApiAxiosParamCreator = function (configuration) {
1994
1999
  return {
1995
2000
  /**
1996
- * Create a new payment instruction to be used when linking to perform debit authorization
2001
+ * Create a new payment instruction to be used when linking to perform new payment
1997
2002
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
1998
2003
  * @param {*} [options] Override http request option.
1999
2004
  * @throws {RequiredError}
@@ -2025,7 +2030,7 @@ exports.PaymentApiAxiosParamCreator = function (configuration) {
2025
2030
  };
2026
2031
  }),
2027
2032
  /**
2028
- * Get payment instructions to be used when linking to perform debit authorization by id
2033
+ * Get payment instructions by payment_instruction_id
2029
2034
  * @param {string} paymentInstructionId The id of a payment instruction
2030
2035
  * @param {*} [options] Override http request option.
2031
2036
  * @throws {RequiredError}
@@ -2064,7 +2069,7 @@ exports.PaymentApiFp = function (configuration) {
2064
2069
  const localVarAxiosParamCreator = exports.PaymentApiAxiosParamCreator(configuration);
2065
2070
  return {
2066
2071
  /**
2067
- * Create a new payment instruction to be used when linking to perform debit authorization
2072
+ * Create a new payment instruction to be used when linking to perform new payment
2068
2073
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
2069
2074
  * @param {*} [options] Override http request option.
2070
2075
  * @throws {RequiredError}
@@ -2076,7 +2081,7 @@ exports.PaymentApiFp = function (configuration) {
2076
2081
  });
2077
2082
  },
2078
2083
  /**
2079
- * Get payment instructions to be used when linking to perform debit authorization by id
2084
+ * Get payment instructions by payment_instruction_id
2080
2085
  * @param {string} paymentInstructionId The id of a payment instruction
2081
2086
  * @param {*} [options] Override http request option.
2082
2087
  * @throws {RequiredError}
@@ -2097,7 +2102,7 @@ exports.PaymentApiFactory = function (configuration, basePath, axios) {
2097
2102
  const localVarFp = exports.PaymentApiFp(configuration);
2098
2103
  return {
2099
2104
  /**
2100
- * Create a new payment instruction to be used when linking to perform debit authorization
2105
+ * Create a new payment instruction to be used when linking to perform new payment
2101
2106
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
2102
2107
  * @param {*} [options] Override http request option.
2103
2108
  * @throws {RequiredError}
@@ -2108,7 +2113,7 @@ exports.PaymentApiFactory = function (configuration, basePath, axios) {
2108
2113
  .then((request) => request(axios, basePath));
2109
2114
  },
2110
2115
  /**
2111
- * Get payment instructions to be used when linking to perform debit authorization by id
2116
+ * Get payment instructions by payment_instruction_id
2112
2117
  * @param {string} paymentInstructionId The id of a payment instruction
2113
2118
  * @param {*} [options] Override http request option.
2114
2119
  * @throws {RequiredError}
@@ -2128,7 +2133,7 @@ exports.PaymentApiFactory = function (configuration, basePath, axios) {
2128
2133
  */
2129
2134
  class PaymentApi extends base_1.BaseAPI {
2130
2135
  /**
2131
- * Create a new payment instruction to be used when linking to perform debit authorization
2136
+ * Create a new payment instruction to be used when linking to perform new payment
2132
2137
  * @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
2133
2138
  * @param {*} [options] Override http request option.
2134
2139
  * @throws {RequiredError}
@@ -2140,7 +2145,7 @@ class PaymentApi extends base_1.BaseAPI {
2140
2145
  .then((request) => request(this.axios, this.basePath));
2141
2146
  }
2142
2147
  /**
2143
- * Get payment instructions to be used when linking to perform debit authorization by id
2148
+ * Get payment instructions by payment_instruction_id
2144
2149
  * @param {string} paymentInstructionId The id of a payment instruction
2145
2150
  * @param {*} [options] Override http request option.
2146
2151
  * @throws {RequiredError}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const axios_mock_adapter_1 = require("axios-mock-adapter");
13
+ const axios_1 = require("axios");
14
+ const config_1 = require("./config");
15
+ const __1 = require("..");
16
+ const api_1 = require("../api");
17
+ const customerToken_1 = require("./responses/customerToken");
18
+ const paymentInstruction_1 = require("./responses/paymentInstruction");
19
+ const chai_1 = require("chai");
20
+ describe('PaymentInstruction', function () {
21
+ let mock;
22
+ before(() => {
23
+ mock = new axios_mock_adapter_1.default(axios_1.default);
24
+ });
25
+ it('Create paymentInstruction', function () {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ mock.onPost(`${config_1.config.apiHost}/payments/instruction`).reply(200, paymentInstruction_1.createPaymentInstruction());
28
+ const configuration = new __1.Configuration({ basePath: config_1.config.apiHost, accessToken: customerToken_1.customerToken.access_token });
29
+ const paymentInstruction = {
30
+ type: "DEBIT_AUTHORIZATION",
31
+ user_id: "customer_user1",
32
+ frequency: "MONTHLY",
33
+ start_date: "2022-04-01",
34
+ end_date: "2022-12-01",
35
+ amount: 1000,
36
+ currency: "PHP",
37
+ recipient_name: "HOMECREDIT",
38
+ recipient_account_id: "Recipient Account Id",
39
+ sender_name: "Sender Name",
40
+ sender_account_id: "LOAN102345",
41
+ remarks: "HOME CREDIT REPAYMENT"
42
+ };
43
+ const createPaymentInstructionResponse = yield new api_1.CustomerApi(configuration).createPaymentInstruction(paymentInstruction);
44
+ chai_1.expect(createPaymentInstructionResponse.data.payment_instruction_id).to.be.ok;
45
+ });
46
+ });
47
+ it('Get paymentInstruction', function () {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ mock.onGet(`${config_1.config.apiHost}/payments/instruction/stub_payment_instruction_id`).reply(200, paymentInstruction_1.getPaymentInstruction());
50
+ const configuration = new __1.Configuration({ basePath: config_1.config.apiHost, accessToken: customerToken_1.customerToken.access_token });
51
+ const getPaymentInstructionResponse = yield new api_1.CustomerApi(configuration).getPaymentInstruction("stub_payment_instruction_id");
52
+ chai_1.expect(getPaymentInstructionResponse.data.payment_instruction).to.be.ok;
53
+ });
54
+ });
55
+ after(() => {
56
+ mock.restore();
57
+ });
58
+ });
@@ -0,0 +1,3 @@
1
+ import { GetPaymentInstructionsResponse, CreatePaymentInstructionResponse } from '../../api';
2
+ export declare function createPaymentInstruction(): CreatePaymentInstructionResponse;
3
+ export declare function getPaymentInstruction(): GetPaymentInstructionsResponse;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPaymentInstruction = exports.createPaymentInstruction = void 0;
4
+ function createPaymentInstruction() {
5
+ return {
6
+ payment_instruction_id: "01FYRK0Q1DVFTJRG50J5QT424Y",
7
+ };
8
+ }
9
+ exports.createPaymentInstruction = createPaymentInstruction;
10
+ function getPaymentInstruction() {
11
+ return {
12
+ payment_instruction: {
13
+ amount: 1000,
14
+ currency: "PHP",
15
+ end_date: "2022-12-01",
16
+ frequency: "MONTHLY",
17
+ info: {},
18
+ recipient_account_id: "HOMECREDIT",
19
+ recipient_name: "HOMECREDIT",
20
+ reference_id: "01G0KD6Z8P06W4536X4BHEQYAX",
21
+ remarks: "HOME CREDIT REPAYMENT",
22
+ sender_account_id: "LOAN102345",
23
+ sender_name: "Sender Name",
24
+ start_date: "2022-04-01",
25
+ status: "SUBMITTED",
26
+ type: "DEBIT_AUTHORIZATION",
27
+ }
28
+ };
29
+ }
30
+ exports.getPaymentInstruction = getPaymentInstruction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finverse/sdk-typescript",
3
- "version": "0.0.21",
3
+ "version": "0.0.24",
4
4
  "description": "OpenAPI client for @finverse/sdk-typescript",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "keywords": [
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/chai": "^4.3.1",
25
- "@types/mocha": "^9.1.0",
25
+ "@types/mocha": "^9.1.1",
26
26
  "@types/node": "^12.11.5",
27
27
  "axios-mock-adapter": "^1.20.0",
28
28
  "chai": "^4.3.6",