@yosle/tropipayjs 0.1.5 → 0.1.6

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 ADDED
@@ -0,0 +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
+
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,22 +1,29 @@
1
- TropipayJS -Typescript/Javascript SDK for Tropipay Payments API
1
+ TropipayJS - Typescript/Javascript SDK for Tropipay Payments API
2
2
  ===========
3
+ ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white)
3
4
  ![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)
4
5
  ![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E)
5
6
  ![Next JS](https://img.shields.io/badge/Next-black?style=for-the-badge&logo=next.js&logoColor=white)
6
- ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white)
7
+ ![RollupJS](https://img.shields.io/badge/RollupJS-ef3335?style=for-the-badge&logo=rollup.js&logoColor=white)
7
8
 
8
- TropiPay is an electronic wallet that allows you to execute the most common financial operations of the day to day. This is an 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 (like node + express) or ES6 module system (NextJS).
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).
9
10
 
10
- ## Project status
11
- This library is still under development so using it in the live (real account) isn't recommended yet.
12
11
 
13
12
  # Table of Contents
14
- * [Getting started](#getting-started)
15
- * [Setting up your credentials](#setting-up-your-app-credentials)
16
- * [Documentation](#documentation)
17
- * [Examples](#examples)
18
- * [Contribute and Help](#contributing-and-help)
19
-
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.
20
27
  # Getting started
21
28
  You can use npm or yarn to install this package:
22
29
 
@@ -27,11 +34,13 @@ or
27
34
  ```yarn add @yosle/tropipayjs```
28
35
 
29
36
  ## Setting up your app credentials
30
- ![alt](/docs/images/app-credentials-menu.png)
31
- ![alt](/docs/images/confirmation-code-screen.png)
37
+
38
+ ![alt]([/docs/images/app-credentials-menu.png](https://github.com/yosle/tropipayjs/blob/master/docs/images/app-credentials-menu.png))
39
+ ![alt]([/docs/images/confirmation-code-screen.png](https://github.com/yosle/tropipayjs/blob/master/docs/images/confirmation-code-screen.png))
40
+
32
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 enviroment](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.
33
42
 
34
- ## How to use
43
+ ## Usage
35
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.
36
45
 
37
46
  ### CommonJS
@@ -47,22 +56,60 @@ import { Tropipay } from '@yosle/tropipayjs'
47
56
  const tpp = new Tropipay("yourclientidhere",
48
57
  "yourclientsecrethere")
49
58
  ```
50
- ## Generating a Payment Link
59
+ ### Generating a Payment Link
51
60
  ```javascript
61
+ /*
62
+ * Example Payload
63
+ */
64
+ const payload = await tpp.createPayLink({
65
+ reference: "my-paylink-1",
66
+ concept: "Bicycle",
67
+ favorite: "true",
68
+ amount: 3000,
69
+ currency: "EUR",
70
+ description: "Two wheels",
71
+ singleUse: "true",
72
+ reasonId: 4,
73
+ expirationDays: 1,
74
+ lang: "es",
75
+ urlSuccess: "https://webhook.site/680826a5-199e-4455-babc-f47b7f26ee7e",
76
+ urlFailed: "https://webhook.site/680826a5-199e-4455-babc-f47b7f26ee7e",
77
+ urlNotification: "https://webhook.site/680826a5-199e-4455-babc-f47b7f26ee7e",
78
+ serviceDate: "2021-08-20",
79
+ client: {
80
+ name: "John",
81
+ lastName: "McClane",
82
+ address: "Ave. Guadí 232, Barcelona, Barcelona",
83
+ phone: "+34645553333",
84
+ email: "client@email.com",
85
+ countryId: 1,
86
+ termsAndConditions: "true"
87
+ },
88
+ directPayment: "true"
89
+ })
90
+
91
+ // Use inside an async function
52
92
  const paylink = await tpp.createPayLink(payload)
93
+ console.log(paylink.shortUrl)
53
94
  ```
54
95
 
55
- # Documentation
56
- Examples using express + nodejs and NextJS will be added soon.
96
+ For more examples, please refer to the [Documentation](https://github.com/yosle/tropipayjs/blob/master/docs/)
57
97
 
58
98
  # Contributing
59
- Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
99
+ 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!
100
+
101
+ 1. Fork the Project
102
+ 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
103
+ 3. Commit your Changes (`git commit -m 'Add some AmazingFeature`)
104
+ 4. Push to the Branch (`git push origin feature/AmazingFeature`)
105
+ 5. Open a Pull Request
106
+
107
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
60
108
 
61
- Please make sure to update tests as appropriate.
109
+ You can also make a small [donation to the author](https://tppay.me/l94qaa3h) of the library.
110
+ # License
111
+ Distributed under the MIT License. See `LICENSE.txt` for more information.
62
112
 
63
- You can also make a small [donation to the author](https://tppay.me/l94qaa3h).
64
- ## License
65
- [MIT License](https://choosealicense.com/licenses/mit/)
66
113
 
67
114
 
68
115
 
package/docs/README.MD ADDED
@@ -0,0 +1,4 @@
1
+ Documentation
2
+ =============
3
+
4
+ This will be added eventually.
package/index.d.ts CHANGED
@@ -38,8 +38,8 @@ interface PaymentLink extends PaymentLinkPayload {
38
38
  }
39
39
 
40
40
  /**
41
- * Tropipayjs is a Typescript/Javascript library for the Tropipay API. CommonJs and
42
- * ES6 modules are supported.
41
+ * Tropipayjs is a Typescript/Javascript library for the Tropipay API.
42
+ *
43
43
  * @author Yosleivy Baez Acosta
44
44
  *
45
45
  */
@@ -99,7 +99,7 @@ declare class Tropipay {
99
99
  * @returns
100
100
  */
101
101
  profile(): Promise<any>;
102
- getRates(payload?: {
102
+ rates(payload?: {
103
103
  currencyFrom: string;
104
104
  }): Promise<any>;
105
105
  }
package/index.js CHANGED
@@ -9,8 +9,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
9
9
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
10
10
 
11
11
  /**
12
- * Tropipayjs is a Typescript/Javascript library for the Tropipay API. CommonJs and
13
- * ES6 modules are supported.
12
+ * Tropipayjs is a Typescript/Javascript library for the Tropipay API.
13
+ *
14
14
  * @author Yosleivy Baez Acosta
15
15
  *
16
16
  */
@@ -42,7 +42,7 @@ class Tropipay {
42
42
  client_id: this.clientId,
43
43
  client_secret: this.clientSecret,
44
44
  grant_type: "client_credentials",
45
- scope: "ALLOW_GET_PROFILE_DATA ALLOW_PAYMENT_IN ALLOW_EXTERNAL_CHARGE KYC3_FULL_ALLOW ALLOW_PAYMENT_OUT ALLOW_MARKET_PURCHASES ALLOW_GET_BALANCE ALLOW_GET_MOVEMENT_LIST ALLOW_GET_CREDENTIAL "
45
+ scope: "ALLOW_GET_PROFILE_DATA ALLOW_PAYMENT_IN ALLOW_EXTERNAL_CHARGE KYC3_FULL_ALLOW ALLOW_PAYMENT_OUT ALLOW_MARKET_PURCHASES ALLOW_GET_BALANCE ALLOW_GET_MOVEMENT_LIST ALLOW_GET_CREDENTIAL"
46
46
  }, {
47
47
  // headers: {
48
48
  // 'Content-Type': 'application/json',
@@ -55,7 +55,6 @@ class Tropipay {
55
55
  }
56
56
  catch (error) {
57
57
  if (axios__default["default"].isAxiosError(error)) {
58
- // 👇️ error: AxiosError<any, any>
59
58
  throw new Error("Conection error: " + error.message);
60
59
  }
61
60
  throw new Error("Could not obtain the access token from credentials ");
@@ -82,7 +81,7 @@ class Tropipay {
82
81
  return paylink.data;
83
82
  }
84
83
  catch (error) {
85
- throw new Error(`Could not obtain the access tokemn with the given credentials.`);
84
+ throw new Error(`Could not obtain the access token with the given credentials.`);
86
85
  }
87
86
  }
88
87
  /**
@@ -189,7 +188,7 @@ class Tropipay {
189
188
  throw new Error(`Could not retrieve movements list ${error}`);
190
189
  }
191
190
  }
192
- async getRates(payload = { currencyFrom: "EUR" }) {
191
+ async rates(payload = { currencyFrom: "EUR" }) {
193
192
  console.log(payload);
194
193
  if (!this.accessToken) {
195
194
  await this.login();
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@yosle/tropipayjs",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Javascript / Typescript SDK for the Tropipay API",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "_clear": "rimraf build/compiled/*",
8
+ "_clear": "rimraf src/dist/*",
9
9
  "_tsc": "tsc",
10
10
  "_make-bundle": "rollup --config",
11
11
  "build": "run-s _clear _tsc _make-bundle"
@@ -0,0 +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[]
74
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Tropipayjs is a Typescript/Javascript library for the Tropipay API. CommonJs and
3
- * ES6 modules are supported.
2
+ * Tropipayjs is a Typescript/Javascript library for the Tropipay API.
3
+ *
4
4
  * @author Yosleivy Baez Acosta
5
5
  *
6
6
  */
@@ -48,7 +48,7 @@ export class Tropipay {
48
48
  client_id: this.clientId,
49
49
  client_secret: this.clientSecret,
50
50
  grant_type: "client_credentials",
51
- scope: "ALLOW_GET_PROFILE_DATA ALLOW_PAYMENT_IN ALLOW_EXTERNAL_CHARGE KYC3_FULL_ALLOW ALLOW_PAYMENT_OUT ALLOW_MARKET_PURCHASES ALLOW_GET_BALANCE ALLOW_GET_MOVEMENT_LIST ALLOW_GET_CREDENTIAL "
51
+ scope: "ALLOW_GET_PROFILE_DATA ALLOW_PAYMENT_IN ALLOW_EXTERNAL_CHARGE KYC3_FULL_ALLOW ALLOW_PAYMENT_OUT ALLOW_MARKET_PURCHASES ALLOW_GET_BALANCE ALLOW_GET_MOVEMENT_LIST ALLOW_GET_CREDENTIAL"
52
52
  }, {
53
53
  // headers: {
54
54
  // 'Content-Type': 'application/json',
@@ -61,9 +61,8 @@ export class Tropipay {
61
61
  return data
62
62
  } catch (error) {
63
63
  if (axios.isAxiosError(error)) {
64
- // 👇️ error: AxiosError<any, any>
65
64
  throw new Error("Conection error: " + error.message);
66
- }
65
+ }
67
66
  throw new Error("Could not obtain the access token from credentials ");
68
67
 
69
68
  }
@@ -89,7 +88,7 @@ export class Tropipay {
89
88
  })
90
89
  return paylink.data as PaymentLink
91
90
  } catch (error) {
92
- throw new Error(`Could not obtain the access tokemn with the given credentials.`);
91
+ throw new Error(`Could not obtain the access token with the given credentials.`);
93
92
 
94
93
  }
95
94
  }
@@ -203,7 +202,7 @@ export class Tropipay {
203
202
  }
204
203
  }
205
204
 
206
- async getRates(payload = {currencyFrom: "EUR"}) {
205
+ async rates(payload = {currencyFrom: "EUR"}) {
207
206
  console.log(payload)
208
207
  if (!this.accessToken) {
209
208
  await this.login()
File without changes
File without changes
File without changes
@@ -0,0 +1,36 @@
1
+ export interface PaymentLinkPayload {
2
+ reference: string;
3
+ concept: string;
4
+ favorite: boolean;
5
+ amount: number;
6
+ currency: string;
7
+ description: string;
8
+ singleUse: boolean;
9
+ reasonId: number;
10
+ expirationDays: number;
11
+ lang: string;
12
+ urlSuccess: string;
13
+ urlFailed: string;
14
+ urlNotification: string;
15
+ serviceDate: string;
16
+ client: {
17
+ name: string;
18
+ lastName: string;
19
+ address: string;
20
+ phone: string;
21
+ email: string;
22
+ countryId: number;
23
+ termsAndConditions: boolean;
24
+ };
25
+ directPayment: boolean;
26
+ paymentMethods?: string[];
27
+ }
28
+ export interface PaymentLink extends PaymentLinkPayload {
29
+ expirationDate: string;
30
+ hasClient: boolean;
31
+ updatedAt: string;
32
+ createdAt: string;
33
+ qrImage: string;
34
+ shortUrl: string;
35
+ paymentUrl: string;
36
+ }
File without changes
package/tsconfig.json CHANGED
@@ -23,7 +23,7 @@
23
23
  // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
24
24
  /* Modules */
25
25
  "module": "esnext", /* Specify what module code is generated. */
26
- // "rootDir": "./", /* Specify the root folder within your source files. */
26
+ "rootDir": "./src", /* Specify the root folder within your source files. */
27
27
  "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
28
28
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
29
29
  // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
@@ -44,7 +44,7 @@
44
44
  // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
45
45
  "sourceMap": true, /* Create source map files for emitted JavaScript files. */
46
46
  // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
47
- "outDir": "dist/", /* Specify an output folder for all emitted files. */
47
+ "outDir": "./dist", /* Specify an output folder for all emitted files. */
48
48
  "removeComments": false, /* Disable emitting comments. */
49
49
  // "noEmit": true, /* Disable emitting files from a compilation. */
50
50
  // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */