New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@yosle/tropipayjs

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yosle/tropipayjs - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

docs/images/app-credentials-menu.png

47

index.d.ts

@@ -41,5 +41,5 @@ import { Axios } from 'axios';

/**
* Tropipayjs is a wrapper for the Tropipay API. It was made in
* typescript but you can use Javascript.
* @author Yosleivy baez Acosta
* Tropipayjs is a Typescript/Javascript library for the Tropipay API. CommonJs and
* ES6 modules are supported.
* @author Yosleivy Baez Acosta
*

@@ -50,14 +50,14 @@ */

declare class Tropipay {
readonly client_id: string;
readonly client_secret: string;
request: Axios;
access_token: string | undefined;
refresh_token: string | undefined;
server_mode: ServerMode;
readonly clientId: string;
readonly clientSecret: string;
protected request: Axios;
protected accessToken: string | undefined;
protected refreshToken: string | undefined;
protected serverMode: ServerMode;
constructor(client_id: string, client_secret: string, server_mode?: ServerMode);
login(): Promise<LoginResponse>;
/**
* Create a paymentLink width the specifued payload
* @param payload Object of PaymentLinkPayload type with paylink payload
* @returns Promise<PaymentLink> or Error
* Create a paymentLink with the specified options.
* @param payload PaymentLinkPayload Object.
* @returns Promise<PaymentLink> or throws an Exception.
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge

@@ -74,15 +74,24 @@ */

* Get the list of all supported countries by Tropipay.
* @returns Array of Countries
* @see
* @returns Array of Countries Data
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list
*/
countries(): Promise<Country[] | Error>;
countries(): Promise<Country[]>;
/**
* Get list of all the favorites accounts.
* Get the list of all detination countries supported by Tropipay.
* Obtaining the list of valid countries to send funds to. Useful
* when adding new beneficiaries to some user.
*
* @returns Array of Country Objects
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries
*/
destinations(): Promise<Country[]>;
/**
* Get list of all the favorites accounts. This endpoint is not documented
* in the official Tropipay documentation.
* @returns
* @see
*/
favorites(): Promise<any>;
/**
* List all movements in current account. You can optionaly specify
* offset and limit params for pagination.
* List all account movements. You can optionaly specify
* offset and limit params for pagination.
* @returns

@@ -89,0 +98,0 @@ */

@@ -12,20 +12,20 @@ 'use strict';

/**
* Tropipayjs is a wrapper for the Tropipay API. It was made in
* typescript but you can use Javascript.
* @author Yosleivy baez Acosta
* Tropipayjs is a Typescript/Javascript library for the Tropipay API. CommonJs and
* ES6 modules are supported.
* @author Yosleivy Baez Acosta
*
*/
class Tropipay {
client_id;
client_secret;
clientId;
clientSecret;
request;
access_token;
refresh_token;
server_mode;
accessToken;
refreshToken;
serverMode;
constructor(client_id, client_secret, server_mode = 'Development') {
this.client_id = client_id;
this.client_secret = client_secret;
this.server_mode = server_mode;
this.clientId = client_id;
this.clientSecret = client_secret;
this.serverMode = server_mode;
this.request = axios__default["default"].create({
baseURL: this.server_mode === 'Production'
baseURL: this.serverMode === 'Production'
? 'https://www.tropipay.com'

@@ -36,3 +36,3 @@ : 'https://tropipay-dev.herokuapp.com',

Accept: 'application/json',
Authorization: `Bearer ${this.access_token}`,
Authorization: `Bearer ${this.accessToken}`,
}

@@ -44,4 +44,4 @@ });

const { data } = await this.request.post('/api/v2/access/token', {
client_id: this.client_id,
client_secret: this.client_secret,
client_id: this.clientId,
client_secret: this.clientSecret,
grant_type: "client_credentials",

@@ -55,4 +55,4 @@ 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 "

});
this.access_token = data.access_token;
this.refresh_token = data.refresh_token;
this.accessToken = data.access_token;
this.refreshToken = data.refresh_token;
return data;

@@ -69,9 +69,9 @@ }

/**
* Create a paymentLink width the specifued payload
* @param payload Object of PaymentLinkPayload type with paylink payload
* @returns Promise<PaymentLink> or Error
* Create a paymentLink with the specified options.
* @param payload PaymentLinkPayload Object.
* @returns Promise<PaymentLink> or throws an Exception.
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
*/
async createPayLink(payload) {
if (!this.access_token) {
if (!this.accessToken) {
await this.login();

@@ -83,3 +83,3 @@ }

// 'Content-Type': 'application/json',
Authorization: `Bearer ${this.access_token}`,
Authorization: `Bearer ${this.accessToken}`,
// Accept: 'application/json'

@@ -91,3 +91,3 @@ }

catch (error) {
throw new Error(`Error tryng to get the access token`);
throw new Error(`Could not obtain the access tokemn with the given credentials.`);
}

@@ -101,3 +101,3 @@ }

async getDepositAccounts() {
if (!this.access_token) {
if (!this.accessToken) {
await this.login();

@@ -115,11 +115,8 @@ }

* Get the list of all supported countries by Tropipay.
* @returns Array of Countries
* @see
* @returns Array of Countries Data
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list
*/
async countries() {
if (!this.access_token) {
await this.login();
}
try {
const countries = await this.request.get('/api/countries');
const countries = await this.request.get('/api/v2/countries');
return countries.data;

@@ -132,25 +129,43 @@ }

/**
* Get list of all the favorites accounts.
* Get the list of all detination countries supported by Tropipay.
* Obtaining the list of valid countries to send funds to. Useful
* when adding new beneficiaries to some user.
*
* @returns Array of Country Objects
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries
*/
async destinations() {
try {
const countries = await this.request.get('/api/v2/countries/destinations');
return countries.data;
}
catch (error) {
throw new Error(`Could not retrieve the destination countries list`);
}
}
/**
* Get list of all the favorites accounts. This endpoint is not documented
* in the official Tropipay documentation.
* @returns
* @see
*/
async favorites() {
if (!this.access_token) {
if (!this.accessToken) {
await this.login();
}
try {
const favorites = await this.request.get('/api/v2/paymentcards/favorites');
return favorites.data;
const favoritesList = await this.request.get('/api/v2/paymentcards/favorites');
console.log(favoritesList);
return favoritesList.data;
}
catch (error) {
throw new Error(`Could not retrieve favorites list`);
throw new Error(`Could not retrieve favorites list ${error}`);
}
}
/**
* List all movements in current account. You can optionaly specify
* offset and limit params for pagination.
* List all account movements. You can optionaly specify
* offset and limit params for pagination.
* @returns
*/
async movements(offset = 0, limit = 10) {
if (!this.access_token) {
if (!this.accessToken) {
await this.login();

@@ -163,3 +178,3 @@ }

Accept: 'application/json',
Authorization: `Bearer ${this.access_token}`,
Authorization: `Bearer ${this.accessToken}`,
} });

@@ -177,3 +192,3 @@ return movements.data;

async profile() {
if (!this.access_token) {
if (!this.accessToken) {
await this.login();

@@ -191,3 +206,3 @@ }

console.log(payload);
if (!this.access_token) {
if (!this.accessToken) {
await this.login();

@@ -200,3 +215,3 @@ }

Accept: 'application/json',
Authorization: `Bearer ${this.access_token}`,
Authorization: `Bearer ${this.accessToken}`,
} });

@@ -203,0 +218,0 @@ return rates.data;

/**
* Tropipayjs is a wrapper for the Tropipay API. It was made in
* typescript but you can use Javascript.
* @author Yosleivy baez Acosta
* Tropipayjs is a Typescript/Javascript library for the Tropipay API. CommonJs and
* ES6 modules are supported.
* @author Yosleivy Baez Acosta
*

@@ -16,8 +16,8 @@ */

export class Tropipay {
readonly client_id: string;
readonly client_secret: string;
public request: Axios;
public access_token: string | undefined;
public refresh_token: string | undefined;
public server_mode: ServerMode;
readonly clientId: string;
readonly clientSecret: string;
protected request: Axios;
protected accessToken: string | undefined;
protected refreshToken: string | undefined;
protected serverMode: ServerMode;

@@ -28,8 +28,8 @@ constructor(

server_mode: ServerMode = 'Development') {
this.client_id = client_id;
this.client_secret = client_secret
this.server_mode = server_mode
this.clientId = client_id;
this.clientSecret = client_secret
this.serverMode = server_mode
this.request = axios.create({
baseURL: this.server_mode === 'Production'
baseURL: this.serverMode === 'Production'
? 'https://www.tropipay.com'

@@ -40,3 +40,3 @@ : 'https://tropipay-dev.herokuapp.com',

Accept: 'application/json',
Authorization: `Bearer ${this.access_token}`,
Authorization: `Bearer ${this.accessToken}`,

@@ -51,4 +51,4 @@ }

const { data } = await this.request.post<LoginResponse>('/api/v2/access/token', {
client_id: this.client_id,
client_secret: this.client_secret,
client_id: this.clientId,
client_secret: this.clientSecret,
grant_type: "client_credentials",

@@ -63,4 +63,4 @@ 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 "

this.access_token = data.access_token
this.refresh_token = data.refresh_token
this.accessToken = data.access_token
this.refreshToken = data.refresh_token
return data

@@ -78,9 +78,9 @@ } catch (error) {

/**
* Create a paymentLink width the specifued payload
* @param payload Object of PaymentLinkPayload type with paylink payload
* @returns Promise<PaymentLink> or Error
* Create a paymentLink with the specified options.
* @param payload PaymentLinkPayload Object.
* @returns Promise<PaymentLink> or throws an Exception.
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
*/
async createPayLink(payload: PaymentLinkPayload): Promise<PaymentLink> {
if (!this.access_token) {
if (!this.accessToken) {
await this.login()

@@ -92,3 +92,3 @@ }

// 'Content-Type': 'application/json',
Authorization: `Bearer ${this.access_token}`,
Authorization: `Bearer ${this.accessToken}`,
// Accept: 'application/json'

@@ -99,3 +99,3 @@ }

} catch (error) {
throw new Error(`Error tryng to get the access token`);
throw new Error(`Could not obtain the access tokemn with the given credentials.`);

@@ -111,3 +111,3 @@ }

async getDepositAccounts(): Promise<AccountDeposits[] | Error>{
if (!this.access_token) {
if (!this.accessToken) {
await this.login()

@@ -125,12 +125,10 @@ }

* Get the list of all supported countries by Tropipay.
* @returns Array of Countries
* @see
* @returns Array of Countries Data
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list
*/
async countries(): Promise<Country[] | Error>{
if (!this.access_token) {
await this.login()
}
async countries(): Promise<Country[] > {
try {
const countries = await this.request.get('/api/countries')
return countries.data
const countries = await this.request.get('/api/v2/countries')
return countries.data
} catch (error) {

@@ -141,16 +139,35 @@ throw new Error(`Could not retrieve the countries list`);

/**
* Get list of all the favorites accounts.
* Get the list of all detination countries supported by Tropipay.
* Obtaining the list of valid countries to send funds to. Useful
* when adding new beneficiaries to some user.
*
* @returns Array of Country Objects
* @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries
*/
async destinations(): Promise<Country[]> {
try {
const countries = await this.request.get('/api/v2/countries/destinations')
return countries.data
} catch (error) {
throw new Error(`Could not retrieve the destination countries list`);
}
}
/**
* Get list of all the favorites accounts. This endpoint is not documented
* in the official Tropipay documentation.
* @returns
* @see
*/
async favorites(){
if (!this.access_token) {
if (!this.accessToken) {
await this.login()
}
try {
const favorites = await this.request.get('/api/v2/paymentcards/favorites')
return favorites.data
} catch (error) {
throw new Error(`Could not retrieve favorites list`);
const favoritesList = await this.request.get('/api/v2/paymentcards/favorites')
console.log(favoritesList)
return favoritesList.data
} catch (error) {
throw new Error(`Could not retrieve favorites list ${error}`);
}

@@ -160,8 +177,8 @@ }

/**
* List all movements in current account. You can optionaly specify
* offset and limit params for pagination.
* List all account movements. You can optionaly specify
* offset and limit params for pagination.
* @returns
*/
async movements(offset = 0 , limit = 10){
if (!this.access_token) {
if (!this.accessToken) {
await this.login()

@@ -175,3 +192,3 @@ }

Accept: 'application/json',
Authorization: `Bearer ${this.access_token}`,
Authorization: `Bearer ${this.accessToken}`,

@@ -191,3 +208,3 @@ } })

async profile(){
if (!this.access_token) {
if (!this.accessToken) {
await this.login()

@@ -205,3 +222,3 @@ }

console.log(payload)
if (!this.access_token) {
if (!this.accessToken) {
await this.login()

@@ -214,3 +231,3 @@ }

Accept: 'application/json',
Authorization: `Bearer ${this.access_token}`,
Authorization: `Bearer ${this.accessToken}`,

@@ -217,0 +234,0 @@ } })

{
"name": "@yosle/tropipayjs",
"version": "0.1.4",
"version": "0.1.5",
"description": "Javascript / Typescript SDK for the Tropipay API",

@@ -37,3 +37,7 @@ "main": "index.js",

"run-s": "^0.0.0"
},
"funding": {
"type": "individual",
"url": "https://tppay.me/l94qaa3h"
}
}

@@ -1,28 +0,68 @@

TropipayJS - A typed SDK for Tropipay Payments API
TropipayJS -Typescript/Javascript SDK for Tropipay Payments API
===========
![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)
![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E)
![Next JS](https://img.shields.io/badge/Next-black?style=for-the-badge&logo=next.js&logoColor=white)
![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white)
TropiPay is an electronic wallet that allows you to execute the most common financial operations of the day to day. This is a SDK for Typescript and Javacript that helps you build integrations with the Tropipay platform in a easier way. Can save you a lot of time and effort implementing all the API features. You can use this library with your prefered framework like Express or Nextjs.
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).
# Instalation
## Project status
This library is still under development so using it in the live (real account) isn't recommended yet.
# Table of Contents
* [Getting started](#getting-started)
* [Setting up your credentials](#setting-up-your-app-credentials)
* [Documentation](#documentation)
* [Examples](#examples)
* [Contribute and Help](#contributing-and-help)
# Getting started
You can use npm or yarn to install this package:
`npm install tropipayjs` or
`yarn add tropipayjs`
```npm install @yosle/tropipayjs```
# How to use
or
```yarn add @yosle/tropipayjs```
## Setting up your app credentials
![alt](/docs/images/app-credentials-menu.png)
![alt](/docs/images/confirmation-code-screen.png)
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.
## How to use
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.
## Setting up your credentials
In order to use the Tropipay API you need to signup in a live (production) or the test enviroment. Create an app and configure the client id an client secret for the app.
### CommonJS
```javascript
const { Tropipay } = require('@yosle/tropipayjs')
```
### ES6
```javascript
import { Tropipay } from '@yosle/tropipayjs'
```
### Initialize the Tropipay class
```javascript
const tpp = new Tropipay("yourclientidhere",
"yourclientsecrethere")
```
## Generating a Payment Link
```javascript
const paylink = await tpp.createPayLink(payload)
```
# Examples
# Documentation
Examples using express + nodejs and NextJS will be added soon.
# Using Typescript
# Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
# Contributing and Help
Having problems? want to contribute? join our community slack.
Please make sure to update tests as appropriate.
You can also make a small [donation to the author](https://tppay.me/l94qaa3h).
## License
[MIT License](https://choosealicense.com/licenses/mit/)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc