@yosle/tropipayjs 0.1.6 → 0.1.7
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/LICENSE +9 -9
- package/README.md +126 -115
- package/docs/README.MD +3 -3
- package/docs/images/intellisense-vs-code.png +0 -0
- package/globals.d.ts +73 -73
- package/index.d.ts +113 -107
- package/index.js +223 -212
- package/interfaces/countries/index.d.ts +1 -0
- package/interfaces/index.d.ts +2 -0
- package/interfaces/paymentlink/index.d.ts +36 -36
- package/package.json +41 -41
- package/rollup.config.js +22 -22
- package/src/globals.d.ts +73 -73
- package/src/index.ts +239 -229
- package/src/interfaces/countries/index.js +1 -1
- package/src/interfaces/countries/index.ts +3 -0
- package/src/interfaces/index.js +1 -1
- package/src/interfaces/index.ts +4 -0
- package/src/interfaces/paymentlink/index.d.ts +36 -36
- package/src/interfaces/paymentlink/index.js +2 -2
- package/src/interfaces/paymentlink/index.ts +39 -39
- package/src/interfaces/paymentlink.js +1 -1
- package/tsconfig.json +94 -94
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,115 +1,126 @@
|
|
|
1
|
-
TropipayJS - Typescript/Javascript SDK for Tropipay Payments API
|
|
2
|
-
===========
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
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).
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# Table of Contents
|
|
13
|
-
- [TropipayJS - Typescript/Javascript SDK for Tropipay Payments API](#tropipayjs---typescriptjavascript-sdk-for-tropipay-payments-api)
|
|
14
|
-
- [Table of Contents](#table-of-contents)
|
|
15
|
-
- [About the project](#about-the-project)
|
|
16
|
-
- [Getting started](#getting-started)
|
|
17
|
-
- [Setting up your app credentials](#setting-up-your-app-credentials)
|
|
18
|
-
- [Usage](#usage)
|
|
19
|
-
- [CommonJS](#commonjs)
|
|
20
|
-
- [ES6](#es6)
|
|
21
|
-
- [Initialize the Tropipay class](#initialize-the-tropipay-class)
|
|
22
|
-
- [Generating a Payment Link](#generating-a-payment-link)
|
|
23
|
-
- [Contributing](#contributing)
|
|
24
|
-
- [License](#license)
|
|
25
|
-
## About the project
|
|
26
|
-
This library is a community effort still under development so use caution if you're planing to use it in production. Tropipay may make some changes on the API Specification in the future. Use the [test environment](https://tropipay-dev.herokuapp.com) to make sure everything is working as expected.
|
|
27
|
-
# Getting started
|
|
28
|
-
You can use npm or yarn to install this package:
|
|
29
|
-
|
|
30
|
-
```npm install @yosle/tropipayjs```
|
|
31
|
-
|
|
32
|
-
or
|
|
33
|
-
|
|
34
|
-
```yarn add @yosle/tropipayjs```
|
|
35
|
-
|
|
36
|
-
## Setting up your app credentials
|
|
37
|
-
|
|
38
|
-
 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
|
|
42
|
-
|
|
43
|
-
## Usage
|
|
44
|
-
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.
|
|
45
|
-
|
|
46
|
-
### CommonJS
|
|
47
|
-
```javascript
|
|
48
|
-
const { Tropipay } = require('@yosle/tropipayjs')
|
|
49
|
-
```
|
|
50
|
-
### ES6
|
|
51
|
-
```javascript
|
|
52
|
-
import { Tropipay } from '@yosle/tropipayjs'
|
|
53
|
-
```
|
|
54
|
-
### Initialize the Tropipay class
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
1
|
+
TropipayJS - Typescript/Javascript SDK for Tropipay Payments API
|
|
2
|
+
===========
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
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).
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Table of Contents
|
|
13
|
+
- [TropipayJS - Typescript/Javascript SDK for Tropipay Payments API](#tropipayjs---typescriptjavascript-sdk-for-tropipay-payments-api)
|
|
14
|
+
- [Table of Contents](#table-of-contents)
|
|
15
|
+
- [About the project](#about-the-project)
|
|
16
|
+
- [Getting started](#getting-started)
|
|
17
|
+
- [Setting up your app credentials](#setting-up-your-app-credentials)
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [CommonJS](#commonjs)
|
|
20
|
+
- [ES6](#es6)
|
|
21
|
+
- [Initialize the Tropipay class](#initialize-the-tropipay-class)
|
|
22
|
+
- [Generating a Payment Link](#generating-a-payment-link)
|
|
23
|
+
- [Contributing](#contributing)
|
|
24
|
+
- [License](#license)
|
|
25
|
+
## About the project
|
|
26
|
+
This library is a community effort still under development so use caution if you're planing to use it in production. Tropipay may make some changes on the API Specification in the future. Use the [test environment](https://tropipay-dev.herokuapp.com) to make sure everything is working as expected.
|
|
27
|
+
# Getting started
|
|
28
|
+
You can use npm or yarn to install this package:
|
|
29
|
+
|
|
30
|
+
```npm install @yosle/tropipayjs```
|
|
31
|
+
|
|
32
|
+
or
|
|
33
|
+
|
|
34
|
+
```yarn add @yosle/tropipayjs```
|
|
35
|
+
|
|
36
|
+
## Setting up your app credentials
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
### CommonJS
|
|
47
|
+
```javascript
|
|
48
|
+
const { Tropipay } = require('@yosle/tropipayjs')
|
|
49
|
+
```
|
|
50
|
+
### ES6
|
|
51
|
+
```javascript
|
|
52
|
+
import { Tropipay } from '@yosle/tropipayjs'
|
|
53
|
+
```
|
|
54
|
+
### Initialize the Tropipay class
|
|
55
|
+
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`.
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
// test environment server
|
|
59
|
+
const tpp = new Tropipay("yourclientidhere",
|
|
60
|
+
"yourclientsecrethere")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
To use your live credentials (real account) you must explicity set serverMode to `Production`.
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
//real account credentials
|
|
67
|
+
const tpp = new Tropipay("yourclientidhere",
|
|
68
|
+
"yourclientsecrethere",'Production')
|
|
69
|
+
```
|
|
70
|
+
### Generating a Payment Link
|
|
71
|
+
```javascript
|
|
72
|
+
/*
|
|
73
|
+
* Example Payload
|
|
74
|
+
*/
|
|
75
|
+
const payload = await tpp.createPayLink({
|
|
76
|
+
reference: "my-paylink-1",
|
|
77
|
+
concept: "Bicycle",
|
|
78
|
+
favorite: "true",
|
|
79
|
+
amount: 3000,
|
|
80
|
+
currency: "EUR",
|
|
81
|
+
description: "Two wheels",
|
|
82
|
+
singleUse: "true",
|
|
83
|
+
reasonId: 4,
|
|
84
|
+
expirationDays: 1,
|
|
85
|
+
lang: "es",
|
|
86
|
+
urlSuccess: "https://webhook.site/680826a5-199e-4455-babc-f47b7f26ee7e",
|
|
87
|
+
urlFailed: "https://webhook.site/680826a5-199e-4455-babc-f47b7f26ee7e",
|
|
88
|
+
urlNotification: "https://webhook.site/680826a5-199e-4455-babc-f47b7f26ee7e",
|
|
89
|
+
serviceDate: "2021-08-20",
|
|
90
|
+
client: {
|
|
91
|
+
name: "John",
|
|
92
|
+
lastName: "McClane",
|
|
93
|
+
address: "Ave. Guadí 232, Barcelona, Barcelona",
|
|
94
|
+
phone: "+34645553333",
|
|
95
|
+
email: "client@email.com",
|
|
96
|
+
countryId: 1,
|
|
97
|
+
termsAndConditions: "true"
|
|
98
|
+
},
|
|
99
|
+
directPayment: "true"
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// Use inside an async function
|
|
103
|
+
const paylink = await tpp.createPayLink(payload)
|
|
104
|
+
console.log(paylink.shortUrl)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
For more examples, please refer to the [Documentation](https://github.com/yosle/tropipayjs/blob/master/docs/)
|
|
108
|
+
|
|
109
|
+
# Contributing
|
|
110
|
+
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!
|
|
111
|
+
|
|
112
|
+
1. Fork the Project
|
|
113
|
+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
|
114
|
+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature`)
|
|
115
|
+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
|
116
|
+
5. Open a Pull Request
|
|
117
|
+
|
|
118
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
119
|
+
|
|
120
|
+
You can also make a small [donation to the author](https://tppay.me/l94qaa3h) of the library.
|
|
121
|
+
# License
|
|
122
|
+
Distributed under the MIT License. See `LICENSE.txt` for more information.
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
package/docs/README.MD
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Documentation
|
|
2
|
-
=============
|
|
3
|
-
|
|
1
|
+
Documentation
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
4
|
This will be added eventually.
|
|
Binary file
|
package/globals.d.ts
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
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[]
|
|
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
74
|
}
|
package/index.d.ts
CHANGED
|
@@ -1,107 +1,113 @@
|
|
|
1
|
-
import { Axios } from 'axios';
|
|
2
|
-
|
|
3
|
-
interface PaymentLinkPayload {
|
|
4
|
-
reference: string;
|
|
5
|
-
concept: string;
|
|
6
|
-
favorite: boolean;
|
|
7
|
-
amount: number;
|
|
8
|
-
currency: string;
|
|
9
|
-
description: string;
|
|
10
|
-
singleUse: boolean;
|
|
11
|
-
reasonId: number;
|
|
12
|
-
expirationDays: number;
|
|
13
|
-
lang: string;
|
|
14
|
-
urlSuccess: string;
|
|
15
|
-
urlFailed: string;
|
|
16
|
-
urlNotification: string;
|
|
17
|
-
serviceDate: string;
|
|
18
|
-
client: {
|
|
19
|
-
name: string;
|
|
20
|
-
lastName: string;
|
|
21
|
-
address: string;
|
|
22
|
-
phone: string;
|
|
23
|
-
email: string;
|
|
24
|
-
countryId: number;
|
|
25
|
-
termsAndConditions: boolean;
|
|
26
|
-
};
|
|
27
|
-
directPayment: boolean;
|
|
28
|
-
paymentMethods?: string[];
|
|
29
|
-
}
|
|
30
|
-
interface PaymentLink extends PaymentLinkPayload {
|
|
31
|
-
expirationDate: string;
|
|
32
|
-
hasClient: boolean;
|
|
33
|
-
updatedAt: string;
|
|
34
|
-
createdAt: string;
|
|
35
|
-
qrImage: string;
|
|
36
|
-
shortUrl: string;
|
|
37
|
-
paymentUrl: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Tropipayjs is a Typescript/Javascript library for the Tropipay API.
|
|
42
|
-
*
|
|
43
|
-
* @author Yosleivy Baez Acosta
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
declare type ServerMode = 'Development' | 'Production';
|
|
48
|
-
declare class Tropipay {
|
|
49
|
-
readonly clientId: string;
|
|
50
|
-
readonly clientSecret: string;
|
|
51
|
-
protected request: Axios;
|
|
52
|
-
protected accessToken: string | undefined;
|
|
53
|
-
protected refreshToken: string | undefined;
|
|
54
|
-
protected serverMode: ServerMode;
|
|
55
|
-
constructor(client_id: string, client_secret: string, server_mode?: ServerMode);
|
|
56
|
-
login(): Promise<LoginResponse>;
|
|
57
|
-
/**
|
|
58
|
-
* Create a paymentLink with the specified options.
|
|
59
|
-
* @param payload PaymentLinkPayload Object.
|
|
60
|
-
* @returns Promise<PaymentLink> or throws an Exception.
|
|
61
|
-
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
|
|
62
|
-
*/
|
|
63
|
-
createPayLink(payload: PaymentLinkPayload): Promise<PaymentLink>;
|
|
64
|
-
/**
|
|
65
|
-
* Get all deposits in this account.
|
|
66
|
-
* @returns A Promise of an Array of AccountDeposits or throws an Exception
|
|
67
|
-
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6OTgyOTQ1Mg-get-deposit-accounts-list
|
|
68
|
-
*/
|
|
69
|
-
getDepositAccounts(): Promise<AccountDeposits[] | Error>;
|
|
70
|
-
/**
|
|
71
|
-
* Get the list of all supported countries by Tropipay.
|
|
72
|
-
* @returns Array of Countries Data
|
|
73
|
-
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list
|
|
74
|
-
*/
|
|
75
|
-
countries(): Promise<Country[]>;
|
|
76
|
-
/**
|
|
77
|
-
* Get the list of all detination countries supported by Tropipay.
|
|
78
|
-
* Obtaining the list of valid countries to send funds to. Useful
|
|
79
|
-
* when adding new beneficiaries to some user.
|
|
80
|
-
*
|
|
81
|
-
* @returns Array of Country Objects
|
|
82
|
-
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries
|
|
83
|
-
*/
|
|
84
|
-
destinations(): Promise<Country[]>;
|
|
85
|
-
/**
|
|
86
|
-
* Get list of all the favorites accounts. This endpoint is not documented
|
|
87
|
-
* in the official Tropipay documentation.
|
|
88
|
-
* @returns
|
|
89
|
-
*/
|
|
90
|
-
favorites(): Promise<any>;
|
|
91
|
-
/**
|
|
92
|
-
* List all account movements. You can optionaly specify
|
|
93
|
-
* offset and limit params for pagination.
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
movements(offset?: number, limit?: number): Promise<any>;
|
|
97
|
-
/**
|
|
98
|
-
* Return profile data for this account.
|
|
99
|
-
* @returns
|
|
100
|
-
*/
|
|
101
|
-
profile(): Promise<any>;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
import { Axios } from 'axios';
|
|
2
|
+
|
|
3
|
+
interface PaymentLinkPayload {
|
|
4
|
+
reference: string;
|
|
5
|
+
concept: string;
|
|
6
|
+
favorite: boolean;
|
|
7
|
+
amount: number;
|
|
8
|
+
currency: string;
|
|
9
|
+
description: string;
|
|
10
|
+
singleUse: boolean;
|
|
11
|
+
reasonId: number;
|
|
12
|
+
expirationDays: number;
|
|
13
|
+
lang: string;
|
|
14
|
+
urlSuccess: string;
|
|
15
|
+
urlFailed: string;
|
|
16
|
+
urlNotification: string;
|
|
17
|
+
serviceDate: string;
|
|
18
|
+
client: {
|
|
19
|
+
name: string;
|
|
20
|
+
lastName: string;
|
|
21
|
+
address: string;
|
|
22
|
+
phone: string;
|
|
23
|
+
email: string;
|
|
24
|
+
countryId: number;
|
|
25
|
+
termsAndConditions: boolean;
|
|
26
|
+
};
|
|
27
|
+
directPayment: boolean;
|
|
28
|
+
paymentMethods?: string[];
|
|
29
|
+
}
|
|
30
|
+
interface PaymentLink extends PaymentLinkPayload {
|
|
31
|
+
expirationDate: string;
|
|
32
|
+
hasClient: boolean;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
qrImage: string;
|
|
36
|
+
shortUrl: string;
|
|
37
|
+
paymentUrl: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Tropipayjs is a Typescript/Javascript library for the Tropipay API.
|
|
42
|
+
*
|
|
43
|
+
* @author Yosleivy Baez Acosta
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
declare type ServerMode = 'Development' | 'Production';
|
|
48
|
+
declare class Tropipay {
|
|
49
|
+
readonly clientId: string;
|
|
50
|
+
readonly clientSecret: string;
|
|
51
|
+
protected request: Axios;
|
|
52
|
+
protected accessToken: string | undefined;
|
|
53
|
+
protected refreshToken: string | undefined;
|
|
54
|
+
protected serverMode: ServerMode;
|
|
55
|
+
constructor(client_id: string, client_secret: string, server_mode?: ServerMode);
|
|
56
|
+
login(): Promise<LoginResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Create a paymentLink with the specified options.
|
|
59
|
+
* @param payload PaymentLinkPayload Object.
|
|
60
|
+
* @returns Promise<PaymentLink> or throws an Exception.
|
|
61
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
|
|
62
|
+
*/
|
|
63
|
+
createPayLink(payload: PaymentLinkPayload): Promise<PaymentLink>;
|
|
64
|
+
/**
|
|
65
|
+
* Get all deposits in this account.
|
|
66
|
+
* @returns A Promise of an Array of AccountDeposits or throws an Exception
|
|
67
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6OTgyOTQ1Mg-get-deposit-accounts-list
|
|
68
|
+
*/
|
|
69
|
+
getDepositAccounts(): Promise<AccountDeposits[] | Error>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the list of all supported countries by Tropipay.
|
|
72
|
+
* @returns Array of Countries Data
|
|
73
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list
|
|
74
|
+
*/
|
|
75
|
+
countries(): Promise<Country[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Get the list of all detination countries supported by Tropipay.
|
|
78
|
+
* Obtaining the list of valid countries to send funds to. Useful
|
|
79
|
+
* when adding new beneficiaries to some user.
|
|
80
|
+
*
|
|
81
|
+
* @returns Array of Country Objects
|
|
82
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries
|
|
83
|
+
*/
|
|
84
|
+
destinations(): Promise<Country[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Get list of all the favorites accounts. This endpoint is not documented
|
|
87
|
+
* in the official Tropipay documentation.
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
favorites(): Promise<any>;
|
|
91
|
+
/**
|
|
92
|
+
* List all account movements. You can optionaly specify
|
|
93
|
+
* offset and limit params for pagination.
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
movements(offset?: number, limit?: number): Promise<any>;
|
|
97
|
+
/**
|
|
98
|
+
* Return profile data for this account.
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
profile(): Promise<any>;
|
|
102
|
+
/**
|
|
103
|
+
* Obtain current Tropipay conversion rate. For example USD to EUR
|
|
104
|
+
* targetCurrency must be 'EUR'
|
|
105
|
+
* @param originCurrency Target currency code supported by Tropipay.
|
|
106
|
+
* @param targetCurrency Must be 'EUR'? (not documented by Tropipay)
|
|
107
|
+
* @returns Conversion rate (number)
|
|
108
|
+
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/85163f6f28b23-get-rate
|
|
109
|
+
*/
|
|
110
|
+
rates(originCurrency: string, targetCurrency?: string): Promise<number | Error>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { Tropipay };
|