@finverse/sdk-typescript 0.0.21 → 0.0.22
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 +132 -2
- package/dist/api.d.ts +21 -21
- package/dist/api.js +16 -16
- package/dist/test/paymentInstruction.spec.d.ts +1 -0
- package/dist/test/paymentInstruction.spec.js +58 -0
- package/dist/test/responses/paymentInstruction.d.ts +3 -0
- package/dist/test/responses/paymentInstruction.js +30 -0
- package/package.json +1 -1
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
|
@@ -2063,7 +2063,7 @@ export interface PaymentInstruction {
|
|
|
2063
2063
|
*/
|
|
2064
2064
|
login_identity_id?: string;
|
|
2065
2065
|
/**
|
|
2066
|
-
* Type of payment
|
|
2066
|
+
* Type of payment that was created, please check Documentation on which payment type is supported in each institution
|
|
2067
2067
|
* @type {string}
|
|
2068
2068
|
* @memberof PaymentInstruction
|
|
2069
2069
|
*/
|
|
@@ -2540,7 +2540,7 @@ export interface Transaction {
|
|
|
2540
2540
|
*/
|
|
2541
2541
|
export declare const CustomerApiAxiosParamCreator: (configuration?: Configuration) => {
|
|
2542
2542
|
/**
|
|
2543
|
-
* Create a new payment instruction to be used when linking to perform
|
|
2543
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
2544
2544
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
2545
2545
|
* @param {*} [options] Override http request option.
|
|
2546
2546
|
* @throws {RequiredError}
|
|
@@ -2575,7 +2575,7 @@ export declare const CustomerApiAxiosParamCreator: (configuration?: Configuratio
|
|
|
2575
2575
|
*/
|
|
2576
2576
|
getLoginIdentityHistory: (loginIdentityId: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
2577
2577
|
/**
|
|
2578
|
-
* Get payment instructions
|
|
2578
|
+
* Get payment instructions by payment_instruction_id
|
|
2579
2579
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
2580
2580
|
* @param {*} [options] Override http request option.
|
|
2581
2581
|
* @throws {RequiredError}
|
|
@@ -2605,7 +2605,7 @@ export declare const CustomerApiAxiosParamCreator: (configuration?: Configuratio
|
|
|
2605
2605
|
*/
|
|
2606
2606
|
export declare const CustomerApiFp: (configuration?: Configuration) => {
|
|
2607
2607
|
/**
|
|
2608
|
-
* Create a new payment instruction to be used when linking to perform
|
|
2608
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
2609
2609
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
2610
2610
|
* @param {*} [options] Override http request option.
|
|
2611
2611
|
* @throws {RequiredError}
|
|
@@ -2640,7 +2640,7 @@ export declare const CustomerApiFp: (configuration?: Configuration) => {
|
|
|
2640
2640
|
*/
|
|
2641
2641
|
getLoginIdentityHistory(loginIdentityId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetLoginIdentityHistoryResponse>>;
|
|
2642
2642
|
/**
|
|
2643
|
-
* Get payment instructions
|
|
2643
|
+
* Get payment instructions by payment_instruction_id
|
|
2644
2644
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
2645
2645
|
* @param {*} [options] Override http request option.
|
|
2646
2646
|
* @throws {RequiredError}
|
|
@@ -2670,7 +2670,7 @@ export declare const CustomerApiFp: (configuration?: Configuration) => {
|
|
|
2670
2670
|
*/
|
|
2671
2671
|
export declare const CustomerApiFactory: (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) => {
|
|
2672
2672
|
/**
|
|
2673
|
-
* Create a new payment instruction to be used when linking to perform
|
|
2673
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
2674
2674
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
2675
2675
|
* @param {*} [options] Override http request option.
|
|
2676
2676
|
* @throws {RequiredError}
|
|
@@ -2705,7 +2705,7 @@ export declare const CustomerApiFactory: (configuration?: Configuration, basePat
|
|
|
2705
2705
|
*/
|
|
2706
2706
|
getLoginIdentityHistory(loginIdentityId: string, options?: any): AxiosPromise<GetLoginIdentityHistoryResponse>;
|
|
2707
2707
|
/**
|
|
2708
|
-
* Get payment instructions
|
|
2708
|
+
* Get payment instructions by payment_instruction_id
|
|
2709
2709
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
2710
2710
|
* @param {*} [options] Override http request option.
|
|
2711
2711
|
* @throws {RequiredError}
|
|
@@ -2736,7 +2736,7 @@ export declare const CustomerApiFactory: (configuration?: Configuration, basePat
|
|
|
2736
2736
|
*/
|
|
2737
2737
|
export interface CustomerApiInterface {
|
|
2738
2738
|
/**
|
|
2739
|
-
* Create a new payment instruction to be used when linking to perform
|
|
2739
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
2740
2740
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
2741
2741
|
* @param {*} [options] Override http request option.
|
|
2742
2742
|
* @throws {RequiredError}
|
|
@@ -2776,7 +2776,7 @@ export interface CustomerApiInterface {
|
|
|
2776
2776
|
*/
|
|
2777
2777
|
getLoginIdentityHistory(loginIdentityId: string, options?: AxiosRequestConfig): AxiosPromise<GetLoginIdentityHistoryResponse>;
|
|
2778
2778
|
/**
|
|
2779
|
-
* Get payment instructions
|
|
2779
|
+
* Get payment instructions by payment_instruction_id
|
|
2780
2780
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
2781
2781
|
* @param {*} [options] Override http request option.
|
|
2782
2782
|
* @throws {RequiredError}
|
|
@@ -2811,7 +2811,7 @@ export interface CustomerApiInterface {
|
|
|
2811
2811
|
*/
|
|
2812
2812
|
export declare class CustomerApi extends BaseAPI implements CustomerApiInterface {
|
|
2813
2813
|
/**
|
|
2814
|
-
* Create a new payment instruction to be used when linking to perform
|
|
2814
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
2815
2815
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
2816
2816
|
* @param {*} [options] Override http request option.
|
|
2817
2817
|
* @throws {RequiredError}
|
|
@@ -2851,7 +2851,7 @@ export declare class CustomerApi extends BaseAPI implements CustomerApiInterface
|
|
|
2851
2851
|
*/
|
|
2852
2852
|
getLoginIdentityHistory(loginIdentityId: string, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetLoginIdentityHistoryResponse>>;
|
|
2853
2853
|
/**
|
|
2854
|
-
* Get payment instructions
|
|
2854
|
+
* Get payment instructions by payment_instruction_id
|
|
2855
2855
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
2856
2856
|
* @param {*} [options] Override http request option.
|
|
2857
2857
|
* @throws {RequiredError}
|
|
@@ -3695,14 +3695,14 @@ export declare class LoginIdentityApi extends BaseAPI implements LoginIdentityAp
|
|
|
3695
3695
|
*/
|
|
3696
3696
|
export declare const PaymentApiAxiosParamCreator: (configuration?: Configuration) => {
|
|
3697
3697
|
/**
|
|
3698
|
-
* Create a new payment instruction to be used when linking to perform
|
|
3698
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
3699
3699
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
3700
3700
|
* @param {*} [options] Override http request option.
|
|
3701
3701
|
* @throws {RequiredError}
|
|
3702
3702
|
*/
|
|
3703
3703
|
createPaymentInstruction: (paymentInstruction: CustomerPaymentInstruction, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
3704
3704
|
/**
|
|
3705
|
-
* Get payment instructions
|
|
3705
|
+
* Get payment instructions by payment_instruction_id
|
|
3706
3706
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
3707
3707
|
* @param {*} [options] Override http request option.
|
|
3708
3708
|
* @throws {RequiredError}
|
|
@@ -3715,14 +3715,14 @@ export declare const PaymentApiAxiosParamCreator: (configuration?: Configuration
|
|
|
3715
3715
|
*/
|
|
3716
3716
|
export declare const PaymentApiFp: (configuration?: Configuration) => {
|
|
3717
3717
|
/**
|
|
3718
|
-
* Create a new payment instruction to be used when linking to perform
|
|
3718
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
3719
3719
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
3720
3720
|
* @param {*} [options] Override http request option.
|
|
3721
3721
|
* @throws {RequiredError}
|
|
3722
3722
|
*/
|
|
3723
3723
|
createPaymentInstruction(paymentInstruction: CustomerPaymentInstruction, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CreatePaymentInstructionResponse>>;
|
|
3724
3724
|
/**
|
|
3725
|
-
* Get payment instructions
|
|
3725
|
+
* Get payment instructions by payment_instruction_id
|
|
3726
3726
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
3727
3727
|
* @param {*} [options] Override http request option.
|
|
3728
3728
|
* @throws {RequiredError}
|
|
@@ -3735,14 +3735,14 @@ export declare const PaymentApiFp: (configuration?: Configuration) => {
|
|
|
3735
3735
|
*/
|
|
3736
3736
|
export declare const PaymentApiFactory: (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) => {
|
|
3737
3737
|
/**
|
|
3738
|
-
* Create a new payment instruction to be used when linking to perform
|
|
3738
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
3739
3739
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
3740
3740
|
* @param {*} [options] Override http request option.
|
|
3741
3741
|
* @throws {RequiredError}
|
|
3742
3742
|
*/
|
|
3743
3743
|
createPaymentInstruction(paymentInstruction: CustomerPaymentInstruction, options?: any): AxiosPromise<CreatePaymentInstructionResponse>;
|
|
3744
3744
|
/**
|
|
3745
|
-
* Get payment instructions
|
|
3745
|
+
* Get payment instructions by payment_instruction_id
|
|
3746
3746
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
3747
3747
|
* @param {*} [options] Override http request option.
|
|
3748
3748
|
* @throws {RequiredError}
|
|
@@ -3756,7 +3756,7 @@ export declare const PaymentApiFactory: (configuration?: Configuration, basePath
|
|
|
3756
3756
|
*/
|
|
3757
3757
|
export interface PaymentApiInterface {
|
|
3758
3758
|
/**
|
|
3759
|
-
* Create a new payment instruction to be used when linking to perform
|
|
3759
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
3760
3760
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
3761
3761
|
* @param {*} [options] Override http request option.
|
|
3762
3762
|
* @throws {RequiredError}
|
|
@@ -3764,7 +3764,7 @@ export interface PaymentApiInterface {
|
|
|
3764
3764
|
*/
|
|
3765
3765
|
createPaymentInstruction(paymentInstruction: CustomerPaymentInstruction, options?: AxiosRequestConfig): AxiosPromise<CreatePaymentInstructionResponse>;
|
|
3766
3766
|
/**
|
|
3767
|
-
* Get payment instructions
|
|
3767
|
+
* Get payment instructions by payment_instruction_id
|
|
3768
3768
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
3769
3769
|
* @param {*} [options] Override http request option.
|
|
3770
3770
|
* @throws {RequiredError}
|
|
@@ -3780,7 +3780,7 @@ export interface PaymentApiInterface {
|
|
|
3780
3780
|
*/
|
|
3781
3781
|
export declare class PaymentApi extends BaseAPI implements PaymentApiInterface {
|
|
3782
3782
|
/**
|
|
3783
|
-
* Create a new payment instruction to be used when linking to perform
|
|
3783
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
3784
3784
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
3785
3785
|
* @param {*} [options] Override http request option.
|
|
3786
3786
|
* @throws {RequiredError}
|
|
@@ -3788,7 +3788,7 @@ export declare class PaymentApi extends BaseAPI implements PaymentApiInterface {
|
|
|
3788
3788
|
*/
|
|
3789
3789
|
createPaymentInstruction(paymentInstruction: CustomerPaymentInstruction, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreatePaymentInstructionResponse>>;
|
|
3790
3790
|
/**
|
|
3791
|
-
* Get payment instructions
|
|
3791
|
+
* Get payment instructions by payment_instruction_id
|
|
3792
3792
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
3793
3793
|
* @param {*} [options] Override http request option.
|
|
3794
3794
|
* @throws {RequiredError}
|
package/dist/api.js
CHANGED
|
@@ -47,7 +47,7 @@ exports.PaymentInstructionTypeEnum = {
|
|
|
47
47
|
exports.CustomerApiAxiosParamCreator = function (configuration) {
|
|
48
48
|
return {
|
|
49
49
|
/**
|
|
50
|
-
* Create a new payment instruction to be used when linking to perform
|
|
50
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
51
51
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
52
52
|
* @param {*} [options] Override http request option.
|
|
53
53
|
* @throws {RequiredError}
|
|
@@ -201,7 +201,7 @@ exports.CustomerApiAxiosParamCreator = function (configuration) {
|
|
|
201
201
|
};
|
|
202
202
|
}),
|
|
203
203
|
/**
|
|
204
|
-
* Get payment instructions
|
|
204
|
+
* Get payment instructions by payment_instruction_id
|
|
205
205
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
206
206
|
* @param {*} [options] Override http request option.
|
|
207
207
|
* @throws {RequiredError}
|
|
@@ -315,7 +315,7 @@ exports.CustomerApiFp = function (configuration) {
|
|
|
315
315
|
const localVarAxiosParamCreator = exports.CustomerApiAxiosParamCreator(configuration);
|
|
316
316
|
return {
|
|
317
317
|
/**
|
|
318
|
-
* Create a new payment instruction to be used when linking to perform
|
|
318
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
319
319
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
320
320
|
* @param {*} [options] Override http request option.
|
|
321
321
|
* @throws {RequiredError}
|
|
@@ -375,7 +375,7 @@ exports.CustomerApiFp = function (configuration) {
|
|
|
375
375
|
});
|
|
376
376
|
},
|
|
377
377
|
/**
|
|
378
|
-
* Get payment instructions
|
|
378
|
+
* Get payment instructions by payment_instruction_id
|
|
379
379
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
380
380
|
* @param {*} [options] Override http request option.
|
|
381
381
|
* @throws {RequiredError}
|
|
@@ -423,7 +423,7 @@ exports.CustomerApiFactory = function (configuration, basePath, axios) {
|
|
|
423
423
|
const localVarFp = exports.CustomerApiFp(configuration);
|
|
424
424
|
return {
|
|
425
425
|
/**
|
|
426
|
-
* Create a new payment instruction to be used when linking to perform
|
|
426
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
427
427
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
428
428
|
* @param {*} [options] Override http request option.
|
|
429
429
|
* @throws {RequiredError}
|
|
@@ -470,7 +470,7 @@ exports.CustomerApiFactory = function (configuration, basePath, axios) {
|
|
|
470
470
|
return localVarFp.getLoginIdentityHistory(loginIdentityId, options).then((request) => request(axios, basePath));
|
|
471
471
|
},
|
|
472
472
|
/**
|
|
473
|
-
* Get payment instructions
|
|
473
|
+
* Get payment instructions by payment_instruction_id
|
|
474
474
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
475
475
|
* @param {*} [options] Override http request option.
|
|
476
476
|
* @throws {RequiredError}
|
|
@@ -513,7 +513,7 @@ exports.CustomerApiFactory = function (configuration, basePath, axios) {
|
|
|
513
513
|
*/
|
|
514
514
|
class CustomerApi extends base_1.BaseAPI {
|
|
515
515
|
/**
|
|
516
|
-
* Create a new payment instruction to be used when linking to perform
|
|
516
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
517
517
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
518
518
|
* @param {*} [options] Override http request option.
|
|
519
519
|
* @throws {RequiredError}
|
|
@@ -573,7 +573,7 @@ class CustomerApi extends base_1.BaseAPI {
|
|
|
573
573
|
.then((request) => request(this.axios, this.basePath));
|
|
574
574
|
}
|
|
575
575
|
/**
|
|
576
|
-
* Get payment instructions
|
|
576
|
+
* Get payment instructions by payment_instruction_id
|
|
577
577
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
578
578
|
* @param {*} [options] Override http request option.
|
|
579
579
|
* @throws {RequiredError}
|
|
@@ -1993,7 +1993,7 @@ exports.LoginIdentityApi = LoginIdentityApi;
|
|
|
1993
1993
|
exports.PaymentApiAxiosParamCreator = function (configuration) {
|
|
1994
1994
|
return {
|
|
1995
1995
|
/**
|
|
1996
|
-
* Create a new payment instruction to be used when linking to perform
|
|
1996
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
1997
1997
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
1998
1998
|
* @param {*} [options] Override http request option.
|
|
1999
1999
|
* @throws {RequiredError}
|
|
@@ -2025,7 +2025,7 @@ exports.PaymentApiAxiosParamCreator = function (configuration) {
|
|
|
2025
2025
|
};
|
|
2026
2026
|
}),
|
|
2027
2027
|
/**
|
|
2028
|
-
* Get payment instructions
|
|
2028
|
+
* Get payment instructions by payment_instruction_id
|
|
2029
2029
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
2030
2030
|
* @param {*} [options] Override http request option.
|
|
2031
2031
|
* @throws {RequiredError}
|
|
@@ -2064,7 +2064,7 @@ exports.PaymentApiFp = function (configuration) {
|
|
|
2064
2064
|
const localVarAxiosParamCreator = exports.PaymentApiAxiosParamCreator(configuration);
|
|
2065
2065
|
return {
|
|
2066
2066
|
/**
|
|
2067
|
-
* Create a new payment instruction to be used when linking to perform
|
|
2067
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
2068
2068
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
2069
2069
|
* @param {*} [options] Override http request option.
|
|
2070
2070
|
* @throws {RequiredError}
|
|
@@ -2076,7 +2076,7 @@ exports.PaymentApiFp = function (configuration) {
|
|
|
2076
2076
|
});
|
|
2077
2077
|
},
|
|
2078
2078
|
/**
|
|
2079
|
-
* Get payment instructions
|
|
2079
|
+
* Get payment instructions by payment_instruction_id
|
|
2080
2080
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
2081
2081
|
* @param {*} [options] Override http request option.
|
|
2082
2082
|
* @throws {RequiredError}
|
|
@@ -2097,7 +2097,7 @@ exports.PaymentApiFactory = function (configuration, basePath, axios) {
|
|
|
2097
2097
|
const localVarFp = exports.PaymentApiFp(configuration);
|
|
2098
2098
|
return {
|
|
2099
2099
|
/**
|
|
2100
|
-
* Create a new payment instruction to be used when linking to perform
|
|
2100
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
2101
2101
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
2102
2102
|
* @param {*} [options] Override http request option.
|
|
2103
2103
|
* @throws {RequiredError}
|
|
@@ -2108,7 +2108,7 @@ exports.PaymentApiFactory = function (configuration, basePath, axios) {
|
|
|
2108
2108
|
.then((request) => request(axios, basePath));
|
|
2109
2109
|
},
|
|
2110
2110
|
/**
|
|
2111
|
-
* Get payment instructions
|
|
2111
|
+
* Get payment instructions by payment_instruction_id
|
|
2112
2112
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
2113
2113
|
* @param {*} [options] Override http request option.
|
|
2114
2114
|
* @throws {RequiredError}
|
|
@@ -2128,7 +2128,7 @@ exports.PaymentApiFactory = function (configuration, basePath, axios) {
|
|
|
2128
2128
|
*/
|
|
2129
2129
|
class PaymentApi extends base_1.BaseAPI {
|
|
2130
2130
|
/**
|
|
2131
|
-
* Create a new payment instruction to be used when linking to perform
|
|
2131
|
+
* Create a new payment instruction to be used when linking to perform new payment
|
|
2132
2132
|
* @param {CustomerPaymentInstruction} paymentInstruction Request body for starting a new Link
|
|
2133
2133
|
* @param {*} [options] Override http request option.
|
|
2134
2134
|
* @throws {RequiredError}
|
|
@@ -2140,7 +2140,7 @@ class PaymentApi extends base_1.BaseAPI {
|
|
|
2140
2140
|
.then((request) => request(this.axios, this.basePath));
|
|
2141
2141
|
}
|
|
2142
2142
|
/**
|
|
2143
|
-
* Get payment instructions
|
|
2143
|
+
* Get payment instructions by payment_instruction_id
|
|
2144
2144
|
* @param {string} paymentInstructionId The id of a payment instruction
|
|
2145
2145
|
* @param {*} [options] Override http request option.
|
|
2146
2146
|
* @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,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;
|