@yosle/tropipayjs 0.1.9 → 0.1.11
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/.nvmrc +1 -0
- package/LICENSE +9 -9
- package/README.md +154 -138
- package/api/TropipayAPI.d.ts +93 -0
- package/config/TropipayConfig.d.ts +2 -0
- package/constants/TropipayConstants.d.ts +1 -0
- package/docs/index.MD +18 -18
- package/globals.d.ts +75 -75
- package/hooks/TropipayHooks.d.ts +38 -0
- package/index.d.ts +177 -25
- package/index.js +241 -53
- package/interfaces/index.d.ts +159 -2
- package/interfaces/paymentlink/index.d.ts +56 -5
- package/package.json +43 -43
- package/rollup.config.js +24 -23
- package/src/api/TropipayAPI.ts +317 -0
- package/src/config/TropipayConfig.ts +2 -0
- package/src/constants/TropipayConstants.ts +1 -0
- package/src/hooks/TropipayHooks.ts +153 -0
- package/src/index.ts +19 -299
- package/src/interfaces/index.js +1 -1
- package/src/interfaces/index.ts +193 -4
- package/src/interfaces/mediation/index.ts +22 -22
- package/src/interfaces/paymentlink/index.d.ts +36 -36
- package/src/interfaces/paymentlink/index.js +2 -2
- package/src/interfaces/paymentlink/index.ts +91 -40
- package/src/utils/TropipayUtils.ts +42 -0
- package/tsconfig.json +95 -95
- package/utils/TropipayUtils.d.ts +17 -0
- package/src/globals.d.ts +0 -74
- package/src/interfaces/countries/index.d.ts +0 -0
- package/src/interfaces/countries/index.js +0 -2
- package/src/interfaces/countries/index.ts +0 -3
- package/src/interfaces/index.d.ts +0 -0
- package/src/interfaces/paymentlink.js +0 -1
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v18.16.1
|
package/LICENSE
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Yosleivy Baez Acosta.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
6
|
-
furnished to do so, subject to the following conditions:
|
|
7
|
-
|
|
8
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Yosleivy Baez Acosta.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
6
|
+
furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
10
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,138 +1,154 @@
|
|
|
1
|
-
TropipayJS - Typescript/Javascript SDK for Tropipay Payments API
|
|
2
|
-
===========
|
|
3
|
-
|
|
4
|
-

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
TropiPay is an electronic wallet that allows you to execute the most common financial operations of the day to day. This is SDK for Typescript and Javacript that helps you build integrations with the Tropipay platform in an easier way. Can save you a lot of time and effort implementing all the API features. You can use this library with CommonJS system (node + express) or ES6 module system (NextJS).
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Table of Contents
|
|
14
|
+
|
|
15
|
+
- [TropipayJS - Typescript/Javascript SDK for Tropipay Payments API](#tropipayjs---typescriptjavascript-sdk-for-tropipay-payments-api)
|
|
16
|
+
- [Table of Contents](#table-of-contents)
|
|
17
|
+
- [About the project](#about-the-project)
|
|
18
|
+
- [Getting started](#getting-started)
|
|
19
|
+
- [Setting up your app credentials](#setting-up-your-app-credentials)
|
|
20
|
+
- [Usage](#usage)
|
|
21
|
+
- [CommonJS](#commonjs)
|
|
22
|
+
- [ES6](#es6)
|
|
23
|
+
- [Initialize the Tropipay class](#initialize-the-tropipay-class)
|
|
24
|
+
- [Generating a Payment Link](#generating-a-payment-link)
|
|
25
|
+
- [Contributing](#contributing)
|
|
26
|
+
- [License](#license)
|
|
27
|
+
|
|
28
|
+
## About the project
|
|
29
|
+
|
|
30
|
+
This library is a community effort. Tropipay may make some changes on the API specification. Use the [test environment](https://tropipay-dev.herokuapp.com) to make sure everything is working as expected.
|
|
31
|
+
|
|
32
|
+
**Note:** This library is provided as-is and serves as a client for the Tropipay API. While every effort has been made to ensure the accuracy and reliability of the library, Tropipay is solely responsible for maintaining and updating the API documentation.
|
|
33
|
+
|
|
34
|
+
The library is intended to simplify the integration process with Tropipay's services, but it is essential to consult the official documentation to ensure that you are using the API correctly and taking into account any recent changes or updates made by Tropipay.
|
|
35
|
+
|
|
36
|
+
# Getting started
|
|
37
|
+
|
|
38
|
+
You can use npm or yarn to install this package:
|
|
39
|
+
|
|
40
|
+
```npm install @yosle/tropipayjs```
|
|
41
|
+
|
|
42
|
+
or
|
|
43
|
+
|
|
44
|
+
```yarn add @yosle/tropipayjs```
|
|
45
|
+
|
|
46
|
+
## Setting up your app credentials
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
In order to use the Tropipay API you'll need a client ID and a client secret. Sign up with your [Tropipay](www.tropipay.com) account, go to the App Menu->Applications and credentials. You'll be asked to enter a confirmation code (use 123456 in the test enviroment). _Make sure you test everything in the [test environment](https://tropipay-dev.herokuapp.com) first before using your real account._ Create an app and configure the client id an client secret for the app.
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
The Tropipay instance, allows you to access all the method available in the API. This Object is meant to be used *only in server side*. Do not use the Tropipay object on the client side (browser). This would expose your app credentials (the client secret of your account). You can create an endpoint at your back-end using express and consume it in your front-end, or use SSR if you're using NextJS.
|
|
56
|
+
|
|
57
|
+
### CommonJS
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
const { Tropipay } = require('@yosle/tropipayjs')
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### ES6
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
import { Tropipay } from '@yosle/tropipayjs'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Initialize the Tropipay class
|
|
70
|
+
|
|
71
|
+
You can instantiate the Tropipay class passing the client Id ,client secret and optionally the serverMode parameter, if no serverMode is provided, `Development` will be used as default. Make sure you use the [test environment](https://tropipay-dev.herokuapp.com) credentials when serverMode is on `Development`.
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
// test environment server tropipay-dev.herokuapp.com
|
|
75
|
+
const config = {
|
|
76
|
+
clientId: process.env.TROPIPAY_CLIENT_ID,
|
|
77
|
+
clientSecret: process.env.TROPIPAY_CLIENT_SECRET
|
|
78
|
+
serverMode: 'Development' // it will be used as default if omited
|
|
79
|
+
}
|
|
80
|
+
const tpp = new Tropipay(config)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
To use your live credentials (real account) you must explicity set serverMode to `Production`.
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
//real account credentials
|
|
87
|
+
const config = {
|
|
88
|
+
clientId: process.env.TROPIPAY_CLIENT_ID,
|
|
89
|
+
clientSecret: process.env.TROPIPAY_CLIENT_SECRET,
|
|
90
|
+
serverMode: 'Production' //live account
|
|
91
|
+
}
|
|
92
|
+
const tpp = new Tropipay(config)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Generating a Payment Link
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
/*
|
|
99
|
+
* Example Payload
|
|
100
|
+
*/
|
|
101
|
+
const payload = {
|
|
102
|
+
reference: "my-paylink-1",
|
|
103
|
+
concept: "Bicycle",
|
|
104
|
+
favorite: "true",
|
|
105
|
+
amount: 3000,
|
|
106
|
+
currency: "EUR",
|
|
107
|
+
description: "Two wheels",
|
|
108
|
+
singleUse: "true",
|
|
109
|
+
reasonId: 4,
|
|
110
|
+
expirationDays: 1,
|
|
111
|
+
lang: "es",
|
|
112
|
+
urlSuccess: "https://webhook.site/680826a5-199e-4455-babc-f47b7f26ee7e",
|
|
113
|
+
urlFailed: "https://webhook.site/680826a5-199e-4455-babc-f47b7f26ee7e",
|
|
114
|
+
urlNotification: "https://webhook.site/680826a5-199e-4455-babc-f47b7f26ee7e",
|
|
115
|
+
serviceDate: "2021-08-20",
|
|
116
|
+
client: {
|
|
117
|
+
name: "John",
|
|
118
|
+
lastName: "McClane",
|
|
119
|
+
address: "Ave. Guadí 232, Barcelona, Barcelona",
|
|
120
|
+
phone: "+34645553333",
|
|
121
|
+
email: "client@email.com",
|
|
122
|
+
countryId: 1,
|
|
123
|
+
termsAndConditions: "true"
|
|
124
|
+
},
|
|
125
|
+
directPayment: "true"
|
|
126
|
+
}
|
|
127
|
+
// Use inside an async function
|
|
128
|
+
const paylink = await tpp.createPaymentCard(payload);
|
|
129
|
+
console.log(paylink.shortUrl);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
For more examples, please refer to the [Documentation](https://github.com/yosle/tropipayjs/blob/master/docs/)
|
|
133
|
+
|
|
134
|
+
# Contributing
|
|
135
|
+
|
|
136
|
+
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
|
|
137
|
+
|
|
138
|
+
1. Fork the Project
|
|
139
|
+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
|
140
|
+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature`)
|
|
141
|
+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
|
142
|
+
5. Open a Pull Request
|
|
143
|
+
|
|
144
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
145
|
+
|
|
146
|
+
You can also make a small [donation to the author](https://tppay.me/l94qaa3h) of the library.
|
|
147
|
+
|
|
148
|
+
# License
|
|
149
|
+
|
|
150
|
+
Distributed under the MIT License. See `LICENSE.txt` for more information.
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tropipayjs is a Typescript/Javascript library for the Tropipay API.
|
|
3
|
+
*
|
|
4
|
+
* @author Yosleivy Baez Acosta
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
import { Axios } from "axios";
|
|
8
|
+
import { TropipayConfig, AccountBalance, Country, PaymentLinkPayload, PaymentLink, mediationPaymentCardConfig, LoginResponse, AccountDeposits } from "../interfaces";
|
|
9
|
+
type ServerMode = "Development" | "Production";
|
|
10
|
+
import { TropipayHooks } from "../hooks/TropipayHooks";
|
|
11
|
+
export declare class Tropipay {
|
|
12
|
+
readonly clientId: string;
|
|
13
|
+
readonly clientSecret: string;
|
|
14
|
+
request: Axios;
|
|
15
|
+
static accessToken: string | undefined;
|
|
16
|
+
static refreshToken: string | undefined;
|
|
17
|
+
serverMode: ServerMode;
|
|
18
|
+
hooks: TropipayHooks;
|
|
19
|
+
constructor(config: TropipayConfig);
|
|
20
|
+
login(): Promise<LoginResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Create a paymentLink with the specified options.
|
|
23
|
+
* @param payload PaymentLinkPayload Object.
|
|
24
|
+
* @returns Promise<PaymentLink> or throws an Exception.
|
|
25
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
|
|
26
|
+
*/
|
|
27
|
+
createPaymentCard(payload: PaymentLinkPayload): Promise<PaymentLink>;
|
|
28
|
+
/**
|
|
29
|
+
* Get all deposits in this account.
|
|
30
|
+
* @returns A Promise of an Array of AccountDeposits or throws an Exception
|
|
31
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6OTgyOTQ1Mg-get-deposit-accounts-list
|
|
32
|
+
*/
|
|
33
|
+
getDepositAccounts(): Promise<AccountDeposits[] | Error>;
|
|
34
|
+
/**
|
|
35
|
+
* Get the list of all supported countries by Tropipay.
|
|
36
|
+
* @returns Array of Countries Data
|
|
37
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list
|
|
38
|
+
*/
|
|
39
|
+
countries(): Promise<Country[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Get user balance
|
|
42
|
+
* @returns balance Object { balance: number, pendingIn: number, pendingOut: number }
|
|
43
|
+
*/
|
|
44
|
+
getBalance(): Promise<AccountBalance>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the list of all detination countries supported by Tropipay.
|
|
47
|
+
* Obtaining the list of valid countries to send funds to. Useful
|
|
48
|
+
* when adding new beneficiaries to some user.
|
|
49
|
+
*
|
|
50
|
+
* @returns Array of Country Objects
|
|
51
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries
|
|
52
|
+
*/
|
|
53
|
+
destinations(): Promise<Country[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Get list of all the favorites payment links.
|
|
56
|
+
* @returns Array of account Object or throws an error
|
|
57
|
+
*/
|
|
58
|
+
favorites(): Promise<any>;
|
|
59
|
+
/**
|
|
60
|
+
* List all account movements. You can optionaly specify
|
|
61
|
+
* offset and limit params for pagination.
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
movements(offset?: number, limit?: number): Promise<any>;
|
|
65
|
+
/**
|
|
66
|
+
* Return profile data for current Tropipay account.
|
|
67
|
+
* @returns account object
|
|
68
|
+
*/
|
|
69
|
+
profile(): Promise<any>;
|
|
70
|
+
/**
|
|
71
|
+
* Obtain current Tropipay conversion rate. For example USD to EUR
|
|
72
|
+
* targetCurrency must be 'EUR'
|
|
73
|
+
* @param originCurrency Target currency code supported by Tropipay.
|
|
74
|
+
* @param targetCurrency Must be 'EUR'? (not documented by Tropipay)
|
|
75
|
+
* @returns Conversion rate (number)
|
|
76
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/85163f6f28b23-get-rate
|
|
77
|
+
*/
|
|
78
|
+
rates(originCurrency: string, targetCurrency?: string): Promise<number | Error>;
|
|
79
|
+
/**
|
|
80
|
+
* (ONLY in Bussiness Accounts)
|
|
81
|
+
* An escrow payment link. This allows a payment to be made to persons
|
|
82
|
+
* belonging or not to the TropiPay platform with the particularity
|
|
83
|
+
* that the payment will be held in custody or retained until it is
|
|
84
|
+
* released with the approval of the payer.
|
|
85
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
|
|
86
|
+
* @param config Payload with the payment details
|
|
87
|
+
*/
|
|
88
|
+
createMediationPaymentCard(config: mediationPaymentCardConfig): Promise<PaymentLink>;
|
|
89
|
+
}
|
|
90
|
+
export declare class ClientSideUtils {
|
|
91
|
+
constructor(tropipayInstance: Tropipay);
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ServerMode = "Development" | "Production";
|
package/docs/index.MD
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# Tropipayjs
|
|
2
|
-
|
|
3
|
-
Tropipayjs is a TypeScript/JavaScript library for the Tropipay API.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Installation](#installation)
|
|
8
|
-
- [Usage](#usage)
|
|
9
|
-
- [API Reference](#api-reference)
|
|
10
|
-
- [Contributing](#contributing)
|
|
11
|
-
- [License](#license)
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
To use Tropipayjs in your project, you need to install it via npm. Run the following command:
|
|
16
|
-
|
|
17
|
-
```npm install tropipayjs```
|
|
18
|
-
or
|
|
1
|
+
# Tropipayjs
|
|
2
|
+
|
|
3
|
+
Tropipayjs is a TypeScript/JavaScript library for the Tropipay API.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [API Reference](#api-reference)
|
|
10
|
+
- [Contributing](#contributing)
|
|
11
|
+
- [License](#license)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
To use Tropipayjs in your project, you need to install it via npm. Run the following command:
|
|
16
|
+
|
|
17
|
+
```npm install tropipayjs```
|
|
18
|
+
or
|
|
19
19
|
```yarn add tropipayjs```
|
package/globals.d.ts
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
type LoginResponse = {
|
|
2
|
-
access_token: string,
|
|
3
|
-
refresh_token: string
|
|
4
|
-
token_type: "Bearer",
|
|
5
|
-
expires_in: number,
|
|
6
|
-
scope: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
type LoginError = {
|
|
10
|
-
error: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type Country = {
|
|
14
|
-
id: number,
|
|
15
|
-
name: string,
|
|
16
|
-
sepaZone: boolean,
|
|
17
|
-
state: number,
|
|
18
|
-
slug: string,
|
|
19
|
-
slugn: number,
|
|
20
|
-
callingCode: number,
|
|
21
|
-
isDestination: boolean,
|
|
22
|
-
isRisky: boolean,
|
|
23
|
-
currentCurrency: string | null,
|
|
24
|
-
createdAt: string,
|
|
25
|
-
updatedAt: string,
|
|
26
|
-
isFavorite: boolean,
|
|
27
|
-
position: any
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type Deposit = {
|
|
32
|
-
id: number,
|
|
33
|
-
accountNumber: string,
|
|
34
|
-
alias: string,
|
|
35
|
-
swift: string,
|
|
36
|
-
type: number,
|
|
37
|
-
country: number | null,
|
|
38
|
-
firstName: string,
|
|
39
|
-
default: null,
|
|
40
|
-
state: number,
|
|
41
|
-
userId: string,
|
|
42
|
-
countryDestinationId: number,
|
|
43
|
-
lastName: string,
|
|
44
|
-
documentNumber: number,
|
|
45
|
-
userRelationTypeId: number,
|
|
46
|
-
city: string,
|
|
47
|
-
postalCode: string,
|
|
48
|
-
address: string,
|
|
49
|
-
phone: string,
|
|
50
|
-
checked: boolean,
|
|
51
|
-
province: string,
|
|
52
|
-
beneficiaryType: number,
|
|
53
|
-
relatedUserId: null | string,
|
|
54
|
-
currency: string,
|
|
55
|
-
correspondent?: any,
|
|
56
|
-
location: any,
|
|
57
|
-
office: any,
|
|
58
|
-
officeValue: any,
|
|
59
|
-
paymentType: number,
|
|
60
|
-
paymentEntityBeneficiaryId: number,
|
|
61
|
-
paymentEntityAccountId: number,
|
|
62
|
-
verified: any,
|
|
63
|
-
paymentEntityInfo: any,
|
|
64
|
-
documentTypeId: any,
|
|
65
|
-
documentExpirationDate: Date,
|
|
66
|
-
createdAt: Date<string>,
|
|
67
|
-
updatedAt: Date<string>,
|
|
68
|
-
countryDestination: Country
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
type AccountDeposits = {
|
|
72
|
-
count: number,
|
|
73
|
-
rows: Deposit[]
|
|
74
|
-
}
|
|
75
|
-
|
|
1
|
+
type LoginResponse = {
|
|
2
|
+
access_token: string,
|
|
3
|
+
refresh_token: string
|
|
4
|
+
token_type: "Bearer",
|
|
5
|
+
expires_in: number,
|
|
6
|
+
scope: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type LoginError = {
|
|
10
|
+
error: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Country = {
|
|
14
|
+
id: number,
|
|
15
|
+
name: string,
|
|
16
|
+
sepaZone: boolean,
|
|
17
|
+
state: number,
|
|
18
|
+
slug: string,
|
|
19
|
+
slugn: number,
|
|
20
|
+
callingCode: number,
|
|
21
|
+
isDestination: boolean,
|
|
22
|
+
isRisky: boolean,
|
|
23
|
+
currentCurrency: string | null,
|
|
24
|
+
createdAt: string,
|
|
25
|
+
updatedAt: string,
|
|
26
|
+
isFavorite: boolean,
|
|
27
|
+
position: any
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type Deposit = {
|
|
32
|
+
id: number,
|
|
33
|
+
accountNumber: string,
|
|
34
|
+
alias: string,
|
|
35
|
+
swift: string,
|
|
36
|
+
type: number,
|
|
37
|
+
country: number | null,
|
|
38
|
+
firstName: string,
|
|
39
|
+
default: null,
|
|
40
|
+
state: number,
|
|
41
|
+
userId: string,
|
|
42
|
+
countryDestinationId: number,
|
|
43
|
+
lastName: string,
|
|
44
|
+
documentNumber: number,
|
|
45
|
+
userRelationTypeId: number,
|
|
46
|
+
city: string,
|
|
47
|
+
postalCode: string,
|
|
48
|
+
address: string,
|
|
49
|
+
phone: string,
|
|
50
|
+
checked: boolean,
|
|
51
|
+
province: string,
|
|
52
|
+
beneficiaryType: number,
|
|
53
|
+
relatedUserId: null | string,
|
|
54
|
+
currency: string,
|
|
55
|
+
correspondent?: any,
|
|
56
|
+
location: any,
|
|
57
|
+
office: any,
|
|
58
|
+
officeValue: any,
|
|
59
|
+
paymentType: number,
|
|
60
|
+
paymentEntityBeneficiaryId: number,
|
|
61
|
+
paymentEntityAccountId: number,
|
|
62
|
+
verified: any,
|
|
63
|
+
paymentEntityInfo: any,
|
|
64
|
+
documentTypeId: any,
|
|
65
|
+
documentExpirationDate: Date,
|
|
66
|
+
createdAt: Date<string>,
|
|
67
|
+
updatedAt: Date<string>,
|
|
68
|
+
countryDestination: Country
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type AccountDeposits = {
|
|
72
|
+
count: number,
|
|
73
|
+
rows: Deposit[]
|
|
74
|
+
}
|
|
75
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { HookEventType, UserHookSubscribed } from "../interfaces";
|
|
2
|
+
import { Tropipay } from "../api/TropipayAPI";
|
|
3
|
+
export declare class TropipayHooks {
|
|
4
|
+
private tropipay;
|
|
5
|
+
constructor(tropipayInstance: Tropipay);
|
|
6
|
+
/**
|
|
7
|
+
* Subscribe a new hook
|
|
8
|
+
* @param event String that represents the name of the event,
|
|
9
|
+
* you must select from the list of available events, otherwise
|
|
10
|
+
* it will not produce an error but it will not be executed.
|
|
11
|
+
* For get full list of available events see endpoint
|
|
12
|
+
* GET /api/v2/hook/events.
|
|
13
|
+
* @param target String representing the type of event supported.
|
|
14
|
+
* It is currently available: 'web' (allows to receive information in a url),
|
|
15
|
+
* 'email' (allows to receive information in an email address).
|
|
16
|
+
* @param value if the selected 'target' is email the value would be an
|
|
17
|
+
* email address, likewise if the selected 'target' is 'web' the expected
|
|
18
|
+
* value corresponds to a url that receives information through the
|
|
19
|
+
* HTTP POST method.
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
subscribe({ eventType, target, value, }: {
|
|
23
|
+
eventType: HookEventType;
|
|
24
|
+
target: "email" | "web";
|
|
25
|
+
value: string;
|
|
26
|
+
}): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Get the sucbcribed hook info by his event type.
|
|
29
|
+
* If no event type is passed, it will return
|
|
30
|
+
* all subscribed hooks or empty Array if none exist.
|
|
31
|
+
* @param eventType or no params for retrieving all hooks
|
|
32
|
+
* @returns All subscribed hooks or empty Array if none exist.
|
|
33
|
+
*/
|
|
34
|
+
list(eventType?: HookEventType): Promise<UserHookSubscribed[]>;
|
|
35
|
+
update(eventType: string, target: "web" | "email", value: string): Promise<any>;
|
|
36
|
+
delete(eventType: HookEventType, target: string): Promise<any>;
|
|
37
|
+
events(): Promise<any>;
|
|
38
|
+
}
|